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

Add speedrate parameter for insert() / eject() functions in wiregrid_actuator #574

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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: 6 additions & 1 deletion docs/agents/wiregrid_actuator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ The main functions are ``insert()`` and ``eject()``.
In the both of the functions, after the inserting/ejecting, the stopper locks the actuators again.
However, the motor power is not turned ON or OFF during the both functions.

The parameter details are here:
- speedrate: Actuator speed rate [0.0, 5.0] (default: 0.2)
DO NOT use speedrate > 1.0 if el != 90 deg!!
BrianJKoopman marked this conversation as resolved.
Show resolved Hide resolved

**Test Functions**
- check_limitswitch(): Check ON/OFF of the limit switches
- check_stopper(): Check ON/OFF (lock/unlock) of the stoppers
Expand All @@ -98,7 +102,8 @@ In the test mode, you can choose the moving distance [mm] and speed rate.
The parameter details are here:

- distance: Actuator moving distance [mm] (default: 10)
- speedrate: Actuator speed rate [0.0, 1.0] (default: 0.2)
- speedrate: Actuator speed rate [0.0, 5.0] (default: 0.2)
DO NOT use speedrate > 1.0 if el != 90 deg!!


Hardware Configurations
Expand Down
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