-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app): handle dtwiz after estop (#16168)
# Overview Fixes some issues around estop and drop tip. Specifically, - When you hit the estop, we surface an error and lose positioning - normal for errors like this - but we also turn off the motors, and they need to be turned back on, so add a command to do that and use it in dtwiz - on desktop, the estop takeover wouldn't work if you were anywhere but the top level devices page because of either the react-router update or because of an oversight that was made during the flex launch - the estop takeover is polling, and slowly. we should add notifications at some point but for now we can do some strategic query invalidations and fast polling when the estop is triggered to make it more responsive ## Test Plan and Hands on Testing - run a protocol, stop it with estop, and check that the modal fires; is responsive; and leaves you to a dtwiz, which opertaes correctly - [x] on desktop, viewing the run, while network connected - [x] on desktop, viewing the run, while usb connected - [x] on odd --------- Closes RQA-3103, RQA-3133 Co-authored-by: Seth Foster <[email protected]>
- Loading branch information
1 parent
631eeff
commit 5999238
Showing
16 changed files
with
379 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
api/src/opentrons/protocol_engine/commands/unsafe/unsafe_engage_axes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
"""Update position estimators payload, result, and implementaiton.""" | ||
|
||
from __future__ import annotations | ||
from pydantic import BaseModel, Field | ||
from typing import TYPE_CHECKING, Optional, List, Type | ||
from typing_extensions import Literal | ||
|
||
from ...types import MotorAxis | ||
from ..command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData | ||
from ...errors.error_occurrence import ErrorOccurrence | ||
from ...resources import ensure_ot3_hardware | ||
|
||
from opentrons.hardware_control import HardwareControlAPI | ||
|
||
if TYPE_CHECKING: | ||
from ...execution import GantryMover | ||
|
||
|
||
UnsafeEngageAxesCommandType = Literal["unsafe/engageAxes"] | ||
|
||
|
||
class UnsafeEngageAxesParams(BaseModel): | ||
"""Payload required for an UnsafeEngageAxes command.""" | ||
|
||
axes: List[MotorAxis] = Field(..., description="The axes for which to enable.") | ||
|
||
|
||
class UnsafeEngageAxesResult(BaseModel): | ||
"""Result data from the execution of an UnsafeEngageAxes command.""" | ||
|
||
|
||
class UnsafeEngageAxesImplementation( | ||
AbstractCommandImpl[ | ||
UnsafeEngageAxesParams, | ||
SuccessData[UnsafeEngageAxesResult, None], | ||
] | ||
): | ||
"""Enable axes command implementation.""" | ||
|
||
def __init__( | ||
self, | ||
hardware_api: HardwareControlAPI, | ||
gantry_mover: GantryMover, | ||
**kwargs: object, | ||
) -> None: | ||
self._hardware_api = hardware_api | ||
self._gantry_mover = gantry_mover | ||
|
||
async def execute( | ||
self, params: UnsafeEngageAxesParams | ||
) -> SuccessData[UnsafeEngageAxesResult, None]: | ||
"""Enable exes.""" | ||
ot3_hardware_api = ensure_ot3_hardware(self._hardware_api) | ||
await ot3_hardware_api.engage_axes( | ||
[ | ||
self._gantry_mover.motor_axis_to_hardware_axis(axis) | ||
for axis in params.axes | ||
] | ||
) | ||
return SuccessData(public=UnsafeEngageAxesResult(), private=None) | ||
|
||
|
||
class UnsafeEngageAxes( | ||
BaseCommand[UnsafeEngageAxesParams, UnsafeEngageAxesResult, ErrorOccurrence] | ||
): | ||
"""UnsafeEngageAxes command model.""" | ||
|
||
commandType: UnsafeEngageAxesCommandType = "unsafe/engageAxes" | ||
params: UnsafeEngageAxesParams | ||
result: Optional[UnsafeEngageAxesResult] | ||
|
||
_ImplementationCls: Type[ | ||
UnsafeEngageAxesImplementation | ||
] = UnsafeEngageAxesImplementation | ||
|
||
|
||
class UnsafeEngageAxesCreate(BaseCommandCreate[UnsafeEngageAxesParams]): | ||
"""UnsafeEngageAxes command request model.""" | ||
|
||
commandType: UnsafeEngageAxesCommandType = "unsafe/engageAxes" | ||
params: UnsafeEngageAxesParams | ||
|
||
_CommandCls: Type[UnsafeEngageAxes] = UnsafeEngageAxes |
52 changes: 52 additions & 0 deletions
52
api/tests/opentrons/protocol_engine/commands/unsafe/test_engage_axes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Test update-position-estimator commands.""" | ||
from decoy import Decoy | ||
|
||
from opentrons.protocol_engine.commands.unsafe.unsafe_engage_axes import ( | ||
UnsafeEngageAxesParams, | ||
UnsafeEngageAxesResult, | ||
UnsafeEngageAxesImplementation, | ||
) | ||
from opentrons.protocol_engine.commands.command import SuccessData | ||
from opentrons.protocol_engine.execution import GantryMover | ||
from opentrons.protocol_engine.types import MotorAxis | ||
from opentrons.hardware_control import OT3HardwareControlAPI | ||
from opentrons.hardware_control.types import Axis | ||
|
||
|
||
async def test_engage_axes_implementation( | ||
decoy: Decoy, ot3_hardware_api: OT3HardwareControlAPI, gantry_mover: GantryMover | ||
) -> None: | ||
"""Test EngageAxes command execution.""" | ||
subject = UnsafeEngageAxesImplementation( | ||
hardware_api=ot3_hardware_api, gantry_mover=gantry_mover | ||
) | ||
|
||
data = UnsafeEngageAxesParams( | ||
axes=[MotorAxis.LEFT_Z, MotorAxis.LEFT_PLUNGER, MotorAxis.X, MotorAxis.Y] | ||
) | ||
|
||
decoy.when(gantry_mover.motor_axis_to_hardware_axis(MotorAxis.LEFT_Z)).then_return( | ||
Axis.Z_L | ||
) | ||
decoy.when( | ||
gantry_mover.motor_axis_to_hardware_axis(MotorAxis.LEFT_PLUNGER) | ||
).then_return(Axis.P_L) | ||
decoy.when(gantry_mover.motor_axis_to_hardware_axis(MotorAxis.X)).then_return( | ||
Axis.X | ||
) | ||
decoy.when(gantry_mover.motor_axis_to_hardware_axis(MotorAxis.Y)).then_return( | ||
Axis.Y | ||
) | ||
decoy.when( | ||
await ot3_hardware_api.update_axis_position_estimations( | ||
[Axis.Z_L, Axis.P_L, Axis.X, Axis.Y] | ||
) | ||
).then_return(None) | ||
|
||
result = await subject.execute(data) | ||
|
||
assert result == SuccessData(public=UnsafeEngageAxesResult(), private=None) | ||
|
||
decoy.verify( | ||
await ot3_hardware_api.engage_axes([Axis.Z_L, Axis.P_L, Axis.X, Axis.Y]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.