Skip to content

Commit

Permalink
Merge pull request #55 from AllenNeuralDynamics/dev/acceleration
Browse files Browse the repository at this point in the history
acceleration commands
  • Loading branch information
adamkglaser authored Nov 28, 2023
2 parents 1751e3e + 5e50f8e commit a51c2d0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/tigerasi/device_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Cmds(Enum):
PZINFO = "PZINFO" # [card address]PZINFO
Z2B = "Z2B" # Z2B Y? |or| Z2B Y=1 to set the axis id.
INFO = "INFO" # INFO [axis]
ACCEL = "AC"


class ErrorCodes(Enum):
Expand Down
35 changes: 34 additions & 1 deletion src/tigerasi/tiger_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
STEPS_PER_UM = 10.0 # multiplication constant to convert micrometers to steps.
MM_SCALE = 4
DEG_SCALE = 3
MS_SCALE = 0
DEFAULT_SPEED_PERCENT = 67.0
DEFAULT_SPEED_MM_PER_SEC = 7.68 * 67.0
REPLY_WAIT_TIME_S = 0.020 # minimum time to wait for a reply after having
Expand Down Expand Up @@ -412,7 +413,6 @@ def set_speed(self, wait: bool = True, **axes: float):
axes = {x: round(v, MM_SCALE) for x, v in axes.items()}
self._set_cmd_args_and_kwds(Cmds.SPEED, **axes, wait=wait)

# TODO: needs testing.
@axis_check()
def get_speed(self, *axes: str):
"""return the speed from the specified axis in [mm/s] or all axes if
Expand All @@ -428,6 +428,39 @@ def get_speed(self, *axes: str):
"""
return self._get_axis_value(Cmds.SPEED, *axes)

@axis_check('wait')
def set_acceleration(self, **axes: float):
"""Set one or more axis accelerations to a value in [ms].
Implements `ACCEL <https://www.asiimaging.com/docs/products/serial_commands#commandaccel_ac>`_ command.
:param axes: one or more axes specified by name where the value is
the acceleration in [ms].
:param wait: wait until the reply has been received.
.. code-block:: python
box.set_acceleration(x=100, y=70)
"""
# Round axes values in ms to 0 decimal places.
axes = {x: round(v, MS_SCALE) for x, v in axes.items()}
self._set_cmd_args_and_kwds(Cmds.ACCEL, **axes)

@axis_check()
def get_acceleration(self, *axes: str):
"""return the acceleration from the specified axis in [ms] or all axes if
none are specified.
:param axes: one or more lettered axes (case insensitive).
:return: speed of requested axes in dict form (upper case).
.. code-block:: python
box.get_acceleration('x', 'z') # returns: {'X': 100, 'Y': 70}
"""
return self._get_axis_value(Cmds.ACCEL, *axes)

@axis_check()
def bind_axis_to_joystick_input(self, **axes: JoystickInput):
"""Map a tiger axis to a joystick input. Implements
Expand Down

0 comments on commit a51c2d0

Please sign in to comment.