Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update on the treatment of logfile and log directory for the wiregrid kikusui agent #615

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/agents/wiregrid_kikusui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ An example docker-compose configuration::
- INSTANCE_ID=wgkikusui
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
- "<local directory to record log file>:/data/wg-data"
- "<local directory to record log file>:/data/wg-data/action"

- Since the agent within the container needs to communicate with hardware on the
host network you must use ``network_mode: "host"`` in your compose file.
- To control the wire-grid rotation accurately,
the agent uses the output of the ``Wiregrid Encoder Agent``.
Therefore, mounting the volume of the ``ocs-wgencoder-agent`` is necessary.
the agent uses the OCS output of the ``Wiregrid Encoder Agent``.
- For the ``calibration_wg()`` function and debug mode (assigned by ``--debug`` option),
a directory path to log files should be assigned in the ``volumes`` section
(``/data/wg-data`` is the default path in the docker).
(``/data/wg-data/action`` is the path in the docker).


Description
Expand Down
19 changes: 9 additions & 10 deletions socs/agents/wiregrid_kikusui/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(self, agent, kikusui_ip, kikusui_port,
self.encoder_agent = encoder_agent
self.debug = debug

self.position_path = '/data/wg-data/position.log'
self.debug_log_path = '/data/wg-data/action/'

self.open_trial = 10
Expand Down Expand Up @@ -387,16 +386,12 @@ def get_angle(self, session, params=None):
return True, \
'Get wire-grid rotation angle = {} deg'.format(angle)

@ocs_agent.param('storepath', default='/data/wg-data/action/', type=str)
def calibrate_wg(self, session, params):
"""calibrate_wg(storepath='/data/wg-data/action/')
def calibrate_wg(self, session, params=None):
"""calibrate_wg()

**Task** - Run rotation-motor calibration for wire-grid.

Parameters:
storepath (str): Path for log file.
"""
storepath = params.get('storepath')

with self.lock.acquire_timeout(timeout=5, job='calibrate_wg')\
as acquired:
Expand All @@ -406,7 +401,7 @@ def calibrate_wg(self, session, params):
.format(self.lock.job))
return False, 'Could not acquire lock'

logfile = openlog(storepath)
logfile = openlog(self.debug_log_path)

cycle = 1
for i in range(11):
Expand Down Expand Up @@ -468,14 +463,18 @@ def stepwise_rotation(self, session, params=None):
self.feedback_time = params.get(
'feedback_time', [0.181, 0.221, 0.251, 0.281, 0.301])

logfile = openlog(self.debug_log_path)
if self.debug:
logfile = openlog(self.debug_log_path)
else:
logfile = None

for i in range(int(self.num_laps * 16.)):
self._move_next(
logfile, self.feedback_steps, self.feedback_time)
time.sleep(self.stopped_time)

logfile.close()
if self.debug:
logfile.close()

return True, 'Step-wise rotation finished'

Expand Down