Skip to content

Commit 430ed52

Browse files
authored
fix(api): we should always call ot3controller.gripper_home_jaw() to home G axis (#12376)
1 parent 38fc810 commit 430ed52

File tree

7 files changed

+28
-33
lines changed

7 files changed

+28
-33
lines changed

api/src/opentrons/config/defaults_ot3.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
DEFAULT_RIGHT_MOUNT_OFFSET: Final[Offset] = (40.5, -60.5, 255.675)
7272
DEFAULT_GRIPPER_MOUNT_OFFSET: Final[Offset] = (84.55, -12.75, 93.85)
7373
DEFAULT_Z_RETRACT_DISTANCE: Final = 2
74-
DEFAULT_GRIPPER_JAW_HOME_DUTY_CYCLE: Final = 25
7574
DEFAULT_SAFE_HOME_DISTANCE: Final = 5
7675

7776
DEFAULT_MAX_SPEEDS: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoad(
@@ -380,9 +379,6 @@ def build_with_defaults(robot_settings: Dict[str, Any]) -> OT3Config:
380379
z_retract_distance=robot_settings.get(
381380
"z_retract_distance", DEFAULT_Z_RETRACT_DISTANCE
382381
),
383-
grip_jaw_home_duty_cycle=robot_settings.get(
384-
"grip_jaw_home_duty_cycle", DEFAULT_GRIPPER_JAW_HOME_DUTY_CYCLE
385-
),
386382
safe_home_distance=robot_settings.get(
387383
"safe_home_distance", DEFAULT_SAFE_HOME_DISTANCE
388384
),

api/src/opentrons/config/types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class OT3Config:
175175
motion_settings: OT3MotionSettings
176176
current_settings: OT3CurrentSettings
177177
z_retract_distance: float
178-
grip_jaw_home_duty_cycle: float
179178
safe_home_distance: float
180179
deck_transform: OT3Transform
181180
carriage_offset: Offset

api/src/opentrons/hardware_control/backends/ot3controller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,9 @@ async def home(self, axes: Sequence[OT3Axis]) -> OT3AxisMap[float]:
608608
A dictionary containing the new positions of each axis
609609
"""
610610
checked_axes = [axis for axis in axes if self._axis_is_present(axis)]
611+
assert (
612+
OT3Axis.G not in checked_axes
613+
), "Please home G axis using gripper_home_jaw()"
611614
if not checked_axes:
612615
return {}
613616

@@ -621,8 +624,6 @@ async def home(self, axes: Sequence[OT3Axis]) -> OT3AxisMap[float]:
621624
if runner
622625
]
623626
positions = await asyncio.gather(*coros)
624-
if OT3Axis.G in checked_axes:
625-
await self.gripper_home_jaw(self._configuration.grip_jaw_home_duty_cycle)
626627
if OT3Axis.Q in checked_axes:
627628
await self.tip_action(
628629
[OT3Axis.Q],

api/src/opentrons/hardware_control/ot3api.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,16 @@ async def home_gripper_jaw(self) -> None:
728728
"""
729729
Home the jaw of the gripper.
730730
"""
731-
gripper = self._gripper_handler.get_gripper()
732-
dc = self._gripper_handler.get_duty_cycle_by_grip_force(
733-
gripper.default_home_force
734-
)
735-
await self._ungrip(duty_cycle=dc)
736-
gripper.state = GripperJawState.HOMED_READY
731+
try:
732+
gripper = self._gripper_handler.get_gripper()
733+
self._log.info("Homing gripper jaw.")
734+
dc = self._gripper_handler.get_duty_cycle_by_grip_force(
735+
gripper.default_home_force
736+
)
737+
await self._ungrip(duty_cycle=dc)
738+
gripper.state = GripperJawState.HOMED_READY
739+
except GripperNotAttachedError:
740+
pass
737741

738742
async def home_plunger(self, mount: Union[top_types.Mount, OT3Mount]) -> None:
739743
"""
@@ -1191,8 +1195,9 @@ async def _home(self, axes: Sequence[OT3Axis]) -> None:
11911195
async with self._motion_lock:
11921196
for axis in axes:
11931197
try:
1194-
# let backend handle homing gripper jaw and pipette plunger
1195-
if axis in [OT3Axis.G, OT3Axis.Q]:
1198+
if axis == OT3Axis.G:
1199+
await self.home_gripper_jaw()
1200+
elif axis == OT3Axis.Q:
11961201
await self._backend.home([axis])
11971202
else:
11981203
await self._home_axis(axis)
@@ -1206,16 +1211,6 @@ async def _home(self, axes: Sequence[OT3Axis]) -> None:
12061211
else:
12071212
await self._cache_current_position()
12081213
await self._cache_encoder_position()
1209-
if axis == OT3Axis.G:
1210-
try:
1211-
self._gripper_handler.set_jaw_state(
1212-
GripperJawState.HOMED_READY
1213-
)
1214-
self._gripper_handler.set_jaw_displacement(
1215-
self._encoder_position[OT3Axis.G]
1216-
)
1217-
except GripperNotAttachedError:
1218-
pass
12191214

12201215
@ExecutionManagerProvider.wait_for_running
12211216
async def home(

api/tests/opentrons/config/ot3_settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
},
111111
"log_level": "NADA",
112112
"z_retract_distance": 10,
113-
"grip_jaw_home_duty_cycle": 25,
114113
"safe_home_distance": 5,
115114
"deck_transform": [[-0.5, 0, 1], [0.1, -2, 4], [0, 0, -1]],
116115
"carriage_offset": (1, 2, 3),

api/tests/opentrons/hardware_control/test_moves.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,18 @@ def mock_home(ot3_hardware):
8484

8585

8686
async def test_home(ot3_hardware, mock_home):
87-
# this is only valid for Axis G, for other axes, check out test_ot3_api.py
8887
with mock.patch("opentrons.hardware_control.ot3api.deck_from_machine") as dfm_mock:
89-
dfm_mock.return_value = {OT3Axis.G: 20}
90-
await ot3_hardware._home([OT3Axis.G])
88+
dfm_mock.return_value = {OT3Axis.X: 20}
89+
await ot3_hardware._home([OT3Axis.X])
9190

92-
mock_home.assert_called_once_with([OT3Axis.G])
91+
mock_home.assert_called_once_with([OT3Axis.X])
9392
assert dfm_mock.call_count == 2
9493
dfm_mock.assert_called_with(
9594
mock_home.return_value,
9695
ot3_hardware._transforms.deck_calibration.attitude,
9796
ot3_hardware._transforms.carriage_offset,
9897
)
99-
assert ot3_hardware._current_position[OT3Axis.G] == 20
98+
assert ot3_hardware._current_position[OT3Axis.X] == 20
10099

101100

102101
async def test_home_unmet(ot3_hardware, mock_home):

api/tests/opentrons/hardware_control/test_ot3_api.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,11 @@ async def test_liquid_probe(
420420
fake_liquid_settings: LiquidProbeSettings,
421421
mock_instrument_handlers: Tuple[Mock],
422422
mock_current_position_ot3: AsyncMock,
423+
mock_ungrip: AsyncMock,
423424
mock_home_plunger: AsyncMock,
424425
) -> None:
426+
mock_ungrip.return_value = None
425427
backend = ot3_hardware.managed_obj._backend
426-
427428
await ot3_hardware.home()
428429
mock_move_to.return_value = None
429430

@@ -490,9 +491,10 @@ async def test_liquid_sensing_errors(
490491
mock_instrument_handlers: Tuple[Mock],
491492
mock_current_position_ot3: AsyncMock,
492493
mock_home_plunger: AsyncMock,
494+
mock_ungrip: AsyncMock,
493495
) -> None:
494496
backend = ot3_hardware.managed_obj._backend
495-
497+
mock_ungrip.return_value = None
496498
await ot3_hardware.home()
497499
mock_move_to.return_value = None
498500

@@ -787,6 +789,8 @@ async def test_gripper_action(
787789
mock_ungrip.assert_called_once()
788790
mock_ungrip.reset_mock()
789791
await ot3_hardware.home([OT3Axis.G])
792+
mock_ungrip.assert_called_once()
793+
mock_ungrip.reset_mock()
790794
await ot3_hardware.grip(5.0)
791795
mock_grip.assert_called_once_with(
792796
gc.duty_cycle_by_force(5.0, gripper_config.grip_force_profile),
@@ -956,7 +960,9 @@ async def test_save_instrument_offset(
956960
async def test_pick_up_tip_full_tiprack(
957961
ot3_hardware: ThreadManager[OT3API],
958962
mock_instrument_handlers: Tuple[Mock],
963+
mock_ungrip: AsyncMock,
959964
) -> None:
965+
mock_ungrip.return_value = None
960966
await ot3_hardware.home()
961967
_, pipette_handler = mock_instrument_handlers
962968
backend = ot3_hardware.managed_obj._backend

0 commit comments

Comments
 (0)