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 api math bugs #15860

Merged
merged 6 commits into from
Aug 2, 2024
Merged
Changes from 3 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
10 changes: 8 additions & 2 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dataclasses import replace
import logging
from collections import OrderedDict
from math import isclose
from typing import (
AsyncIterator,
cast,
Expand Down Expand Up @@ -2714,7 +2715,12 @@ 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 and not isclose(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
while (probe_start_pos.z - pos.z) < max_z_dist and not isclose(
while (probe_start_pos.z - pos.z) < (max_z_dist + 0.01):

?

(probe_start_pos.z - pos.z), max_z_dist, rel_tol=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
Expand All @@ -2724,7 +2730,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)
Expand Down
Loading