From fe6252c268f51658e5de6e017cf6985e1f1f0e85 Mon Sep 17 00:00:00 2001 From: Ryan Howard Date: Wed, 7 Aug 2024 10:43:35 -0400 Subject: [PATCH] fix(api): made a mistake in math when i removed the isclose check (#15913) # Overview Should have realized it was wrong when I had to change the test ## Test Plan and Hands on Testing ## Changelog ## Review requests ## Risk assessment Co-authored-by: caila-marashaj --- api/src/opentrons/hardware_control/ot3api.py | 7 +++++-- api/tests/opentrons/hardware_control/test_ot3_api.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/src/opentrons/hardware_control/ot3api.py b/api/src/opentrons/hardware_control/ot3api.py index 4f0cf262775..5f9c9840834 100644 --- a/api/src/opentrons/hardware_control/ot3api.py +++ b/api/src/opentrons/hardware_control/ot3api.py @@ -2714,7 +2714,10 @@ async def liquid_probe( error: Optional[PipetteLiquidNotFoundError] = None pos = await self.gantry_position(checked_mount, refresh=True) - while (probe_start_pos.z - pos.z) < max_z_dist: + # probe_start_pos.z + z_distance of pass - pos.z should be < max_z_dist + # due to rounding errors this can get caught in an infinite loop when the distance is almost equal + # so we check to see if they're within 0.01 which is 1/5th the minimum movement distance from move_utils.py + while (probe_start_pos.z - pos.z) < (max_z_dist + 0.01): # safe distance so we don't accidentally aspirate liquid if we're already close to liquid safe_plunger_pos = top_types.Point( pos.x, pos.y, pos.z + probe_safe_reset_mm @@ -2724,7 +2727,7 @@ async def liquid_probe( pos.x, pos.y, pos.z + probe_pass_z_offset_mm ) max_z_time = ( - max_z_dist - (probe_start_pos.z - safe_plunger_pos.z) + max_z_dist - probe_start_pos.z + pass_start_pos.z ) / probe_settings.mount_speed p_travel_required_for_z = max_z_time * probe_settings.plunger_speed p_pass_travel = min(p_travel_required_for_z, p_working_mm) diff --git a/api/tests/opentrons/hardware_control/test_ot3_api.py b/api/tests/opentrons/hardware_control/test_ot3_api.py index 21ab1ad8ef9..190f8841c13 100644 --- a/api/tests/opentrons/hardware_control/test_ot3_api.py +++ b/api/tests/opentrons/hardware_control/test_ot3_api.py @@ -838,7 +838,7 @@ async def test_liquid_probe( mock_move_to_plunger_bottom.call_count == 2 mock_liquid_probe.assert_called_once_with( mount, - 52, + 46, fake_settings_aspirate.mount_speed, (fake_settings_aspirate.plunger_speed * -1), fake_settings_aspirate.sensor_threshold_pascals, @@ -990,7 +990,7 @@ async def _fake_pos_update_and_raise( OT3Mount.LEFT, fake_max_z_dist, fake_settings_aspirate ) # assert that it went through 4 passes and then prepared to aspirate - assert mock_move_to_plunger_bottom.call_count == 5 + assert mock_move_to_plunger_bottom.call_count == 4 @pytest.mark.parametrize(