Skip to content

Commit

Permalink
fix rounding error
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Jul 31, 2024
1 parent f8f9312 commit e738ebe
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 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 @@ -2709,7 +2710,11 @@ async def liquid_probe(
error: Optional[PipetteLiquidNotFoundError] = None
pos = await self.gantry_position(checked_mount, refresh=True)
# probe_start_pos.z + z_distance of pass - pos.z should be < max_z_dist
while (probe_start_pos.z - pos.z) < 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(
(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 Down Expand Up @@ -2749,9 +2754,9 @@ async def liquid_probe(
except PipetteLiquidNotFoundError as lnfe:
error = lnfe
pos = await self.gantry_position(checked_mount, refresh=True)
#await self.move_to(checked_mount, probe_start_pos + top_types.Point(z=2))
#await self.prepare_for_aspirate(checked_mount)
#await self.move_to(checked_mount, probe_start_pos)
# await self.move_to(checked_mount, probe_start_pos + top_types.Point(z=2))
# await self.prepare_for_aspirate(checked_mount)
# await self.move_to(checked_mount, probe_start_pos)
if error is not None:
# if we never found liquid raise an error
raise error
Expand Down

0 comments on commit e738ebe

Please sign in to comment.