-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): allow ungrip gripper labware while door is open (#16394)
# Overview closes [EXEC-734](https://opentrons.atlassian.net/browse/EXEC-734). add ungrip command and allow queuing it and executing it while door is open. ## Test Plan and Hands on Testing 1. upload a protocol that will enter ER mode. 2. open door. 3. issue an ungrip command: ``` { "data": { "commandType": "unsafe/ungripLabware", "intent": "fixit", "params": { } } } ``` 4. make sure the gripper opens its jaw. tested with dev server and the command succeeded but still need to test with an actual gripper (@SyntaxColoring thank you Max) ## Changelog 1. added an ungrip command `unsafe/ungripLabware` 2. added logic for queuing while the door is open. 3. added logic for allowing to execute while door is open. ## Review requests 1. gripper command makes sense? 2. logic changes make sense? ## Risk assessment medium. added a new command but need to make sure nothing has changed with the door saftey. [EXEC-734]: https://opentrons.atlassian.net/browse/EXEC-734?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Max Marrone <[email protected]>
- Loading branch information
1 parent
56cd361
commit 7badfee
Showing
9 changed files
with
312 additions
and
6 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
73 changes: 73 additions & 0 deletions
73
api/src/opentrons/protocol_engine/commands/unsafe/unsafe_ungrip_labware.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,73 @@ | ||
"""Ungrip labware payload, result, and implementaiton.""" | ||
|
||
from __future__ import annotations | ||
from opentrons.protocol_engine.errors.exceptions import GripperNotAttachedError | ||
from pydantic import BaseModel | ||
from typing import Optional, Type | ||
from typing_extensions import Literal | ||
|
||
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 | ||
|
||
|
||
UnsafeUngripLabwareCommandType = Literal["unsafe/ungripLabware"] | ||
|
||
|
||
class UnsafeUngripLabwareParams(BaseModel): | ||
"""Payload required for an UngripLabware command.""" | ||
|
||
|
||
class UnsafeUngripLabwareResult(BaseModel): | ||
"""Result data from the execution of an UngripLabware command.""" | ||
|
||
|
||
class UnsafeUngripLabwareImplementation( | ||
AbstractCommandImpl[ | ||
UnsafeUngripLabwareParams, | ||
SuccessData[UnsafeUngripLabwareResult, None], | ||
] | ||
): | ||
"""Ungrip labware command implementation.""" | ||
|
||
def __init__( | ||
self, | ||
hardware_api: HardwareControlAPI, | ||
**kwargs: object, | ||
) -> None: | ||
self._hardware_api = hardware_api | ||
|
||
async def execute( | ||
self, params: UnsafeUngripLabwareParams | ||
) -> SuccessData[UnsafeUngripLabwareResult, None]: | ||
"""Ungrip Labware.""" | ||
ot3_hardware_api = ensure_ot3_hardware(self._hardware_api) | ||
if not ot3_hardware_api.has_gripper(): | ||
raise GripperNotAttachedError("No gripper found to perform ungrip.") | ||
await ot3_hardware_api.ungrip() | ||
return SuccessData(public=UnsafeUngripLabwareResult(), private=None) | ||
|
||
|
||
class UnsafeUngripLabware( | ||
BaseCommand[UnsafeUngripLabwareParams, UnsafeUngripLabwareResult, ErrorOccurrence] | ||
): | ||
"""UnsafeUngripLabware command model.""" | ||
|
||
commandType: UnsafeUngripLabwareCommandType = "unsafe/ungripLabware" | ||
params: UnsafeUngripLabwareParams | ||
result: Optional[UnsafeUngripLabwareResult] | ||
|
||
_ImplementationCls: Type[ | ||
UnsafeUngripLabwareImplementation | ||
] = UnsafeUngripLabwareImplementation | ||
|
||
|
||
class UnsafeUngripLabwareCreate(BaseCommandCreate[UnsafeUngripLabwareParams]): | ||
"""UnsafeEngageAxes command request model.""" | ||
|
||
commandType: UnsafeUngripLabwareCommandType = "unsafe/ungripLabware" | ||
params: UnsafeUngripLabwareParams | ||
|
||
_CommandCls: Type[UnsafeUngripLabware] = UnsafeUngripLabware |
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
40 changes: 40 additions & 0 deletions
40
api/tests/opentrons/protocol_engine/commands/unsafe/test_ungrip_labware.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,40 @@ | ||
"""Test update-position-estimator commands.""" | ||
from decoy import Decoy | ||
|
||
from opentrons.protocol_engine.commands.unsafe.unsafe_ungrip_labware import ( | ||
UnsafeUngripLabwareParams, | ||
UnsafeUngripLabwareResult, | ||
UnsafeUngripLabwareImplementation, | ||
) | ||
from opentrons.protocol_engine.commands.command import SuccessData | ||
from opentrons.protocol_engine.errors.exceptions import GripperNotAttachedError | ||
from opentrons.hardware_control import OT3HardwareControlAPI | ||
import pytest | ||
|
||
|
||
async def test_ungrip_labware_implementation( | ||
decoy: Decoy, ot3_hardware_api: OT3HardwareControlAPI | ||
) -> None: | ||
"""Test UngripLabware command execution.""" | ||
subject = UnsafeUngripLabwareImplementation(hardware_api=ot3_hardware_api) | ||
|
||
decoy.when(ot3_hardware_api.has_gripper()).then_return(True) | ||
|
||
result = await subject.execute(params=UnsafeUngripLabwareParams()) | ||
|
||
assert result == SuccessData(public=UnsafeUngripLabwareResult(), private=None) | ||
|
||
decoy.verify( | ||
await ot3_hardware_api.ungrip(), | ||
) | ||
|
||
|
||
async def test_ungrip_labware_implementation_raises_no_gripper_attached( | ||
decoy: Decoy, ot3_hardware_api: OT3HardwareControlAPI | ||
) -> None: | ||
"""Test UngripLabware command execution.""" | ||
subject = UnsafeUngripLabwareImplementation(hardware_api=ot3_hardware_api) | ||
|
||
decoy.when(ot3_hardware_api.has_gripper()).then_return(False) | ||
with pytest.raises(GripperNotAttachedError): | ||
await subject.execute(params=UnsafeUngripLabwareParams()) |
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
Oops, something went wrong.