Skip to content

Commit e738ebe

Browse files
committed
fix rounding error
1 parent f8f9312 commit e738ebe

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

api/src/opentrons/hardware_control/ot3api.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from dataclasses import replace
66
import logging
77
from collections import OrderedDict
8+
from math import isclose
89
from typing import (
910
AsyncIterator,
1011
cast,
@@ -2709,7 +2710,11 @@ async def liquid_probe(
27092710
error: Optional[PipetteLiquidNotFoundError] = None
27102711
pos = await self.gantry_position(checked_mount, refresh=True)
27112712
# probe_start_pos.z + z_distance of pass - pos.z should be < max_z_dist
2712-
while (probe_start_pos.z - pos.z) < max_z_dist:
2713+
# due to rounding errors this can get caught in an infinite loop when the distance is almost equal
2714+
# so we check to see if they're within 0.01 which is 1/5th the minimum movement distance from move_utils.py
2715+
while (probe_start_pos.z - pos.z) < max_z_dist and not isclose(
2716+
(probe_start_pos.z - pos.z), max_z_dist, rel_tol=0.01
2717+
):
27132718
# safe distance so we don't accidentally aspirate liquid if we're already close to liquid
27142719
safe_plunger_pos = top_types.Point(
27152720
pos.x, pos.y, pos.z + probe_safe_reset_mm
@@ -2749,9 +2754,9 @@ async def liquid_probe(
27492754
except PipetteLiquidNotFoundError as lnfe:
27502755
error = lnfe
27512756
pos = await self.gantry_position(checked_mount, refresh=True)
2752-
#await self.move_to(checked_mount, probe_start_pos + top_types.Point(z=2))
2753-
#await self.prepare_for_aspirate(checked_mount)
2754-
#await self.move_to(checked_mount, probe_start_pos)
2757+
# await self.move_to(checked_mount, probe_start_pos + top_types.Point(z=2))
2758+
# await self.prepare_for_aspirate(checked_mount)
2759+
# await self.move_to(checked_mount, probe_start_pos)
27552760
if error is not None:
27562761
# if we never found liquid raise an error
27572762
raise error

0 commit comments

Comments
 (0)