Skip to content

Commit

Permalink
add speedrate parameter in insert/eject() in wiregrid_actuator
Browse files Browse the repository at this point in the history
  • Loading branch information
sadachi5 committed Nov 16, 2023
1 parent 93ccdf7 commit 89f4aa4
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions socs/agents/wiregrid_actuator/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,23 @@ def _eject(self, main_distance=920, main_speedrate=1.0):
##################
# Return: status(True or False), message

@ocs_agent.param('speedrate', default=1.0, type=float,
check=lambda x: 0.0 < x <= 5.0)
def insert(self, session, params=None):
"""insert()
**Task** - Insert the wire-grid into the forebaffle interface above the
SAT.
Parameters:
speedrate (float): Actuator speed rate [0.0, 5.0] (default: 1.0)
DO NOT use speedrate > 1.0 if el != 90 deg!!
"""
# Get parameters
speedrate = params.get('speedrate')
self.log.info('insert(): set speed rate = {}'
.format(speedrate))

with self.lock.acquire_timeout(timeout=3, job='insert') as acquired:
if not acquired:
self.log.warn(
Expand All @@ -293,22 +303,32 @@ def insert(self, session, params=None):
# Wait for a second before moving
time.sleep(1)
# Moving commands
ret, msg = self._insert(920, 1.0)
ret, msg = self._insert(920, speedrate)
if not ret:
msg = 'insert(): '\
'ERROR!: Failed insert() in _insert(850,1.0) | {}'\
.format(msg)
'ERROR!: Failed insert() in _insert(920,{}) | {}'\
.format(speedrate, msg)
self.log.error(msg)
return False, msg
return True, 'insert(): Successfully finish!'

@ocs_agent.param('speedrate', default=1.0, type=float,
check=lambda x: 0.0 < x <= 5.0)
def eject(self, session, params=None):
"""eject()
**Task** - Eject the wire-grid from the forebaffle interface above the
SAT.
Parameters:
speedrate (float): Actuator speed rate [0.0, 5.0] (default: 1.0)
DO NOT use speedrate > 1.0 if el != 90 deg!!
"""
# Get parameters
speedrate = params.get('speedrate')
self.log.info('eject(): set speed rate = {}'
.format(speedrate))

with self.lock.acquire_timeout(timeout=3, job='eject') as acquired:
if not acquired:
self.log.warn(
Expand All @@ -319,10 +339,10 @@ def eject(self, session, params=None):
# Wait for a second before moving
time.sleep(1)
# Moving commands
ret, msg = self._eject(920, 1.0)
ret, msg = self._eject(920, speedrate)
if not ret:
msg = 'eject(): ERROR!: Failed in _eject(850,1.0) | {}'\
.format(msg)
msg = 'eject(): ERROR!: Failed in _eject(920,{}) | {}'\
.format(speedrate, msg)
self.log.error(msg)
return False, msg
return True, 'eject(): Successfully finish!'
Expand Down Expand Up @@ -451,7 +471,7 @@ def eject_homing(self, session, params=None):

@ocs_agent.param('distance', default=10., type=float)
@ocs_agent.param('speedrate', default=0.2, type=float,
check=lambda x: 0.0 < x <= 1.0)
check=lambda x: 0.0 < x <= 5.0)
def insert_test(self, session, params):
"""insert_test(distance=10, speedrate=0.1)
Expand All @@ -460,7 +480,8 @@ def insert_test(self, session, params):
Parameters:
distance (float): Actuator moving distance [mm] (default: 10)
speedrate (float): Actuator speed rate [0.0, 1.0] (default: 0.2)
speedrate (float): Actuator speed rate [0.0, 5.0] (default: 0.2)
DO NOT use speedrate > 1.0 if el != 90 deg!!
"""
# Get parameters
distance = params.get('distance')
Expand Down Expand Up @@ -502,16 +523,17 @@ def insert_test(self, session, params):

@ocs_agent.param('distance', default=10., type=float)
@ocs_agent.param('speedrate', default=0.2, type=float,
check=lambda x: 0.0 < x <= 1.0)
check=lambda x: 0.0 < x <= 5.0)
def eject_test(self, session, params):
"""eject_test(distance=10, speedrate=0.1)
**Task** - Eject slowly the wire-grid from the forebaffle interface
above the SAT with a small distance.
Parameters:
distance: Actuator moving distance [mm] (default: 10)
speedrate: Actuator speed rate [0.0, 1.0] (default: 0.2)
distance (float): Actuator moving distance [mm] (default: 10)
speedrate (float): Actuator speed rate [0.0, 5.0] (default: 0.2)
DO NOT use speedrate > 1.0 if el != 90 deg!!
"""
# Get parameters
distance = params.get('distance', 10)
Expand Down

0 comments on commit 89f4aa4

Please sign in to comment.