-
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.
Merge branch 'edge' into chore_update-pydantic-v2
- Loading branch information
Showing
162 changed files
with
6,794 additions
and
1,824 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
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 |
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
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
Oops, something went wrong.