Skip to content

Commit

Permalink
create constants for the axis move offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 committed Jan 10, 2025
1 parent 0ebefe4 commit 9bfe92f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions api/src/opentrons/hardware_control/modules/flex_stacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
StackerAxis.L: 23.0,
}

# The offset in mm to subtract from MAX_TRAVEL when moving an axis before we home.
# This lets us use `move_axis` to move fast, leaving the axis OFFSET mm
# from the limit switch. Then we can use `home_axis` to move the axis the rest
# of the way until we trigger the expected limit switch.
OFFSET_SM = 5.0
OFFSET_MD = 10.0
OFFSET_LG = 20.0


class FlexStacker(mod_abc.AbstractModule):
"""Hardware control interface for an attached Flex-Stacker module."""
Expand Down Expand Up @@ -318,28 +326,27 @@ async def dispense_labware(self, labware_height: float) -> bool:
await self._prepare_for_action()

# Move platform along the X then Z axis
await self._move_and_home_axis(StackerAxis.X, Direction.RETRACT, 5)
await self._move_and_home_axis(StackerAxis.Z, Direction.EXTENT, 5)
await self._move_and_home_axis(StackerAxis.X, Direction.RETRACT, OFFSET_SM)
await self._move_and_home_axis(StackerAxis.Z, Direction.EXTENT, OFFSET_SM)

# Transfer
await self.open_latch()
await self.move_axis(StackerAxis.Z, Direction.RETRACT, (labware_height / 2) + 2)
await self.close_latch()

# Move platform along the Z then X axis
await self._move_and_home_axis(
StackerAxis.Z, Direction.RETRACT, (labware_height / 2 + 10)
)
await self._move_and_home_axis(StackerAxis.X, Direction.EXTENT, 5)
offset = (labware_height / 2 + OFFSET_MD)
await self._move_and_home_axis( StackerAxis.Z, Direction.RETRACT, offset)
await self._move_and_home_axis(StackerAxis.X, Direction.EXTENT, OFFSET_SM)
return True

async def store_labware(self, labware_height: float) -> bool:
"""Stores a labware in the stacker."""
await self._prepare_for_action()

# Move X then Z axis
distance = MAX_TRAVEL[StackerAxis.Z] - (labware_height / 2) - 10
await self._move_and_home_axis(StackerAxis.X, Direction.RETRACT, 5)
distance = MAX_TRAVEL[StackerAxis.Z] - (labware_height / 2) - OFFSET_MD
await self._move_and_home_axis(StackerAxis.X, Direction.RETRACT, OFFSET_SM)
await self.move_axis(StackerAxis.Z, Direction.EXTENT, distance)

# Transfer
Expand All @@ -349,8 +356,8 @@ async def store_labware(self, labware_height: float) -> bool:
await self.close_latch()

# Move Z then X axis
await self._move_and_home_axis(StackerAxis.Z, Direction.RETRACT, 20)
await self._move_and_home_axis(StackerAxis.X, Direction.EXTENT, 5)
await self._move_and_home_axis(StackerAxis.Z, Direction.RETRACT, OFFSET_LG)
await self._move_and_home_axis(StackerAxis.X, Direction.EXTENT, OFFSET_SM)
return True

async def _move_and_home_axis(
Expand Down

0 comments on commit 9bfe92f

Please sign in to comment.