From ae63384841fccc061742c571693bf7f39a21fa04 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Thu, 17 Sep 2020 15:00:12 -0400 Subject: [PATCH] refactor(api): check high bounds in jog, swallow errors 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 --- api/src/opentrons/api/calibration.py | 9 +++++++-- api/tests/opentrons/api/test_calibration.py | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api/src/opentrons/api/calibration.py b/api/src/opentrons/api/calibration.py index 5394018c091..77b94b8b227 100755 --- a/api/src/opentrons/api/calibration.py +++ b/api/src/opentrons/api/calibration.py @@ -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 @@ -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, diff --git a/api/tests/opentrons/api/test_calibration.py b/api/tests/opentrons/api/test_calibration.py index c0bd455412e..fe0559cbd25 100755 --- a/api/tests/opentrons/api/test_calibration.py +++ b/api/tests/opentrons/api/test_calibration.py @@ -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') @@ -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