Skip to content

Commit

Permalink
Update on the treatment of logfile and log directory for the wiregrid…
Browse files Browse the repository at this point in the history
… kikusui agent (#615)

* update the log file treatment of the wiregrid_kikusui
  • Loading branch information
sadachi5 authored and d-hoshino2626 committed Apr 12, 2024
1 parent c15ca8f commit 9ee6ea0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
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

0 comments on commit 9ee6ea0

Please sign in to comment.