Skip to content

Commit

Permalink
fix(api): Home pipette used correct gantry load settings (#12742)
Browse files Browse the repository at this point in the history
  • Loading branch information
andySigler authored May 19, 2023
1 parent f7a29a3 commit 5884a41
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
28 changes: 17 additions & 11 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,13 @@ async def move(
self._handle_motor_status_response(positions)

def _build_home_pipettes_runner(
self, axes: Sequence[OT3Axis]
self,
axes: Sequence[OT3Axis],
gantry_load: GantryLoad,
) -> Optional[MoveGroupRunner]:
speed_settings = (
self._configuration.motion_settings.max_speed_discontinuity.low_throughput
)
speed_settings = self._configuration.motion_settings.max_speed_discontinuity[
gantry_load
]

distances_pipette = {
ax: -1 * self.axis_bounds[ax][1] - self.axis_bounds[ax][0]
Expand All @@ -566,11 +568,13 @@ def _build_home_pipettes_runner(
return None

def _build_home_gantry_z_runner(
self, axes: Sequence[OT3Axis]
self,
axes: Sequence[OT3Axis],
gantry_load: GantryLoad,
) -> Optional[MoveGroupRunner]:
speed_settings = (
self._configuration.motion_settings.max_speed_discontinuity.low_throughput
)
speed_settings = self._configuration.motion_settings.max_speed_discontinuity[
gantry_load
]

distances_gantry = {
ax: -1 * self.axis_bounds[ax][1] - self.axis_bounds[ax][0]
Expand Down Expand Up @@ -614,7 +618,9 @@ def _build_home_gantry_z_runner(
return None

@requires_update
async def home(self, axes: Sequence[OT3Axis]) -> OT3AxisMap[float]:
async def home(
self, axes: Sequence[OT3Axis], gantry_load: GantryLoad
) -> OT3AxisMap[float]:
"""Home each axis passed in, and reset the positions to 0.
Args:
Expand All @@ -631,8 +637,8 @@ async def home(self, axes: Sequence[OT3Axis]) -> OT3AxisMap[float]:
return {}

maybe_runners = (
self._build_home_gantry_z_runner(checked_axes),
self._build_home_pipettes_runner(checked_axes),
self._build_home_gantry_z_runner(checked_axes, gantry_load),
self._build_home_pipettes_runner(checked_axes, gantry_load),
)
coros = [
runner.run(can_messenger=self._messenger)
Expand Down
4 changes: 3 additions & 1 deletion api/src/opentrons/hardware_control/backends/ot3simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ async def move(
self._encoder_position.update(final_positions)

@ensure_yield
async def home(self, axes: Optional[List[OT3Axis]] = None) -> OT3AxisMap[float]:
async def home(
self, axes: Sequence[OT3Axis], gantry_load: GantryLoad
) -> OT3AxisMap[float]:
"""Home axes.
Args:
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,10 +1201,10 @@ async def _retrieve_home_position() -> Tuple[
moves[0],
MoveStopCondition.none,
)
await self._backend.home([axis])
await self._backend.home([axis], self.gantry_load)
else:
# both stepper and encoder positions are invalid, must home
await self._backend.home([axis])
await self._backend.home([axis], self.gantry_load)

async def _home(self, axes: Sequence[OT3Axis]) -> None:
"""Home one axis at a time."""
Expand All @@ -1214,7 +1214,7 @@ async def _home(self, axes: Sequence[OT3Axis]) -> None:
if axis == OT3Axis.G:
await self.home_gripper_jaw()
elif axis == OT3Axis.Q:
await self._backend.home([axis])
await self._backend.home([axis], self.gantry_load)
else:
await self._home_axis(axis)
except ZeroLengthMoveError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ async def test_home_execute(
assert not controller._motor_status

commanded_homes = set(axes)
await controller.home(axes)
await controller.home(axes, GantryLoad.LOW_THROUGHPUT)
all_calls = list(chain([args[0][0] for args in mock_move_group_run.call_args_list]))
for command in all_calls:
for group in command._move_groups:
Expand All @@ -277,7 +277,7 @@ async def test_home_prioritize_mount(
# nothing has been homed
assert not controller._motor_status

await controller.home(axes)
await controller.home(axes, GantryLoad.LOW_THROUGHPUT)
has_xy = len({OT3Axis.X, OT3Axis.Y} & set(axes)) > 0
has_mount = len(set(OT3Axis.mount_axes()) & set(axes)) > 0
run = mock_move_group_run.call_args_list[0][0][0]._move_groups
Expand All @@ -302,7 +302,7 @@ async def test_home_build_runners(
mock_move_group_run.side_effect = move_group_run_side_effect(controller, axes)
assert not controller._motor_status

await controller.home(axes)
await controller.home(axes, GantryLoad.LOW_THROUGHPUT)
has_pipette = len(set(OT3Axis.pipette_axes()) & set(axes)) > 0
has_gantry = len(set(OT3Axis.gantry_axes()) & set(axes)) > 0

Expand Down Expand Up @@ -348,7 +348,7 @@ async def test_home_only_present_devices(

# nothing has been homed
assert not controller._motor_status
await controller.home(axes)
await controller.home(axes, GantryLoad.LOW_THROUGHPUT)

for call in mock_move_group_run.call_args_list:
# pull the bound-self argument that is the runner instance out of
Expand Down Expand Up @@ -845,7 +845,7 @@ async def test_update_required_flag(
controller._initialized = True
controller._check_updates = True
with pytest.raises(FirmwareUpdateRequired):
await controller.home(axes)
await controller.home(axes, GantryLoad.LOW_THROUGHPUT)


async def test_update_required_bypass_firmware_update(controller: OT3Controller):
Expand Down
8 changes: 5 additions & 3 deletions api/tests/opentrons/hardware_control/test_moves.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
SourceType,
CalibrationStatus,
)
from opentrons.config.types import GantryLoad
from opentrons.hardware_control.types import (
Axis,
CriticalPoint,
Expand Down Expand Up @@ -87,8 +88,8 @@ async def test_home(ot3_hardware, mock_home):
with mock.patch("opentrons.hardware_control.ot3api.deck_from_machine") as dfm_mock:
dfm_mock.return_value = {OT3Axis.X: 20}
await ot3_hardware._home([OT3Axis.X])

mock_home.assert_called_once_with([OT3Axis.X])
assert ot3_hardware.gantry_load == GantryLoad.LOW_THROUGHPUT
mock_home.assert_called_once_with([OT3Axis.X], GantryLoad.LOW_THROUGHPUT)
assert dfm_mock.call_count == 2
dfm_mock.assert_called_with(
mock_home.return_value,
Expand All @@ -106,7 +107,8 @@ async def test_home_unmet(ot3_hardware, mock_home):
mock_home.side_effect = MoveConditionNotMet()
with pytest.raises(MoveConditionNotMet):
await ot3_hardware.home([OT3Axis.X])
mock_home.assert_called_once_with([OT3Axis.X])
assert ot3_hardware.gantry_load == GantryLoad.LOW_THROUGHPUT
mock_home.assert_called_once_with([OT3Axis.X], GantryLoad.LOW_THROUGHPUT)
assert ot3_hardware._current_position == {}


Expand Down

0 comments on commit 5884a41

Please sign in to comment.