Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): retract function should acquire motion lock #14944

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,16 +1655,17 @@ async def retract_axis(self, axis: Axis) -> None:
motor_ok = self._backend.check_motor_status([axis])
encoder_ok = self._backend.check_encoder_status([axis])

if motor_ok and encoder_ok:
# we can move to the home position without checking the limit switch
origin = await self._backend.update_position()
target_pos = {axis: self._backend.home_position()[axis]}
await self._backend.move(origin, target_pos, 400, HWStopCondition.none)
else:
# home the axis
await self._home_axis(axis)
await self._cache_current_position()
await self._cache_encoder_position()
async with self._motion_lock:
if motor_ok and encoder_ok:
# we can move to the home position without checking the limit switch
origin = await self._backend.update_position()
target_pos = {axis: self._backend.home_position()[axis]}
await self._backend.move(origin, target_pos, 400, HWStopCondition.none)
else:
# home the axis
await self._home_axis(axis)
await self._cache_current_position()
await self._cache_encoder_position()

# Gantry/frame (i.e. not pipette) config API
@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def _listener(message: MessageDefinition, arb_id: ArbitrationId) -> None:
)
else:
log.debug("Read motor status terminated, no missing nodes.")
return reported
finally:
can_messenger.remove_listener(_listener)
return reported


async def get_tip_motor_enabled(
Expand Down
Loading