Skip to content

Commit

Permalink
fix(hardware): minimum movement displacement of 0.05mm (#13052)
Browse files Browse the repository at this point in the history
* Displacement must be at least 0.05mm to move an axis

* need an approx

---------

Co-authored-by: Seth Foster <[email protected]>
  • Loading branch information
fsinapi and sfoster1 authored Jul 6, 2023
1 parent 37609fd commit bbffb4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/tests/opentrons/hardware_control/test_ot3_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ async def test_find_edge(
# all other moves should only move in the search axis
for call in checked_calls:
assert call[0][0] == OT3Mount.RIGHT
assert _other_axis_val(call[0][1], search_axis) == _other_axis_val(
Point(0, 0, 0), search_axis
assert _other_axis_val(call[0][1], search_axis) == pytest.approx(
_other_axis_val(Point(0, 0, 0), search_axis)
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

FLOAT_THRESHOLD = 0.001 # TODO: re-evaluate this value based on system limitations

MINIMUM_DISPLACEMENT = 0.05


class MoveConditionNotMet(ValueError):
"""Error raised if a move does not meet its stop condition before finishing."""
Expand All @@ -47,6 +49,10 @@ def get_unit_vector(
initial_vectorized = vectorize({k: np.float64(v) for k, v in initial.items()})
target_vectorized = vectorize({k: np.float64(v) for k, v in target.items()})
displacement: "NDArray[np.float64]" = target_vectorized - initial_vectorized
# minimum distance of 0.05mm
for i in range(len(displacement)):
if abs(displacement[i]) < MINIMUM_DISPLACEMENT:
displacement[i] = 0
distance = np.linalg.norm(displacement) # type: ignore[no-untyped-call]
if not distance or np.array_equal(initial_vectorized, target_vectorized):
raise ZeroLengthMoveError(initial, target)
Expand Down

0 comments on commit bbffb4a

Please sign in to comment.