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

fix(api): Lld end z retract position bug #15960

Merged
merged 3 commits into from
Aug 12, 2024
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
15 changes: 12 additions & 3 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,7 @@ async def _liquid_probe_pass(
force_both_sensors: bool = False,
) -> float:
plunger_direction = -1 if probe_settings.aspirate_while_sensing else 1
await self._backend.liquid_probe(
end_z = await self._backend.liquid_probe(
mount,
p_travel,
probe_settings.mount_speed,
Expand All @@ -2641,8 +2641,17 @@ async def _liquid_probe_pass(
probe=probe,
force_both_sensors=force_both_sensors,
)
end_pos = await self.gantry_position(mount, refresh=True)
return end_pos.z
machine_pos = await self._backend.update_position()
machine_pos[Axis.by_mount(mount)] = end_z
deck_end_z = self._deck_from_machine(machine_pos)[Axis.by_mount(mount)]
offset = offset_for_mount(
mount,
top_types.Point(*self._config.left_mount_offset),
top_types.Point(*self._config.right_mount_offset),
top_types.Point(*self._config.gripper_mount_offset),
)
cp = self.critical_point_for(mount, None)
return deck_end_z + offset[2] + cp.z
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: I think offset.z is a little clearer


async def liquid_probe(
self,
Expand Down
23 changes: 3 additions & 20 deletions api/tests/opentrons/hardware_control/test_ot3_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,15 +815,9 @@ async def test_liquid_probe(
with patch.object(
hardware_backend, "liquid_probe", AsyncMock(spec=hardware_backend.liquid_probe)
) as mock_liquid_probe:
return_dict = {
head_node: 140,
NodeId.gantry_x: 0,
NodeId.gantry_y: 0,
pipette_node: 0,
}

# make sure aspirate while sensing reverses direction
mock_liquid_probe.return_value = return_dict
mock_liquid_probe.return_value = 140
fake_settings_aspirate = LiquidProbeSettings(
mount_speed=5,
plunger_speed=20,
Expand All @@ -849,8 +843,6 @@ async def test_liquid_probe(
force_both_sensors=False,
)

return_dict[head_node], return_dict[pipette_node] = 142, 142
mock_liquid_probe.return_value = return_dict
await ot3_hardware.liquid_probe(
mount, fake_max_z_dist, fake_liquid_settings
) # should raise no exceptions
Expand Down Expand Up @@ -903,7 +895,7 @@ async def test_liquid_probe_plunger_moves(
PipetteLiquidNotFoundError,
PipetteLiquidNotFoundError,
PipetteLiquidNotFoundError,
None,
140,
]

fake_max_z_dist = 75.0
Expand Down Expand Up @@ -1056,16 +1048,10 @@ async def test_multi_liquid_probe(
with patch.object(
hardware_backend, "liquid_probe", AsyncMock(spec=hardware_backend.liquid_probe)
) as mock_liquid_probe:
return_dict = {
NodeId.head_l: 140,
NodeId.gantry_x: 0,
NodeId.gantry_y: 0,
NodeId.pipette_left: 0,
}
side_effects = [
PipetteLiquidNotFoundError(),
PipetteLiquidNotFoundError(),
return_dict,
140,
]

# make sure aspirate while sensing reverses direction
Expand Down Expand Up @@ -1103,9 +1089,6 @@ async def test_multi_liquid_probe(
)
assert mock_liquid_probe.call_count == 3

return_dict[NodeId.head_l], return_dict[NodeId.pipette_left] = 142, 142
mock_liquid_probe.return_value = return_dict


async def test_liquid_not_found(
ot3_hardware: ThreadManager[OT3API],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async def run_sync_buffer_to_csv(
),
expected_nodes=[tool],
)
if raise_z is not None and False:
if raise_z is not None:
# if probing is finished, move the head node back up before requesting the data buffer
if positions[head_node].move_ack == MoveCompleteAck.stopped_by_condition:
await raise_z.run(can_messenger=messenger)
Expand Down
Loading