Skip to content

Commit

Permalink
refactor(api): check high bounds in jog, swallow errors
Browse files Browse the repository at this point in the history
When we jog during labware calibration, it's possible to trigger hard
limits, most commonly in +z. We should catch and prevent these, since
hard limits mess up the positioning state. But we have no way to
actually display errors during jog actions, so we just swallow the error
at the jog level. So, if you jog too far, the jog just doesn't do
anything.

Closes #6562
  • Loading branch information
sfoster1 committed Sep 17, 2020
1 parent c958d52 commit ae63384
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions api/src/opentrons/api/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from opentrons.types import Point, Mount, Location
from opentrons.protocol_api import labware
from opentrons.hardware_control import CriticalPoint, ThreadedAsyncLock
from opentrons.hardware_control.types import OutOfBoundsMove, MotionChecks

from .models import Container
from .util import robot_is_busy, RobotBusy
Expand Down Expand Up @@ -236,8 +237,12 @@ def jog(self, instrument, distance, axis):
instrument.name, distance, axis))
self._set_state('moving')
if instrument._context:
self._hardware.move_rel(
Mount[inst.mount.upper()], Point(**{axis: distance}))
try:
self._hardware.move_rel(
Mount[inst.mount.upper()], Point(**{axis: distance}),
check_bounds=MotionChecks.HIGH)
except OutOfBoundsMove:
log.exception('Out of bounds jog')
else:
calibration_functions.jog_instrument(
instrument=inst,
Expand Down
3 changes: 2 additions & 1 deletion api/tests/opentrons/api/test_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from opentrons.api import models
from opentrons.types import Point, Location, Mount
from opentrons.hardware_control import CriticalPoint, API
from opentrons.hardware_control.types import MotionChecks

state = partial(state, 'calibration')

Expand Down Expand Up @@ -282,7 +283,7 @@ async def test_jog_api2(main_router, model):
)

expected = [
mock.call(Mount.RIGHT, point)
mock.call(Mount.RIGHT, point, check_bounds=MotionChecks.HIGH)
for point in [Point(x=1), Point(y=2), Point(z=3)]]

assert jog.mock_calls == expected
Expand Down

0 comments on commit ae63384

Please sign in to comment.