Skip to content

Commit

Permalink
fixups from rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Nov 1, 2024
1 parent b91630b commit 2959b4b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class MoveAxesRelativeResult(DestinationRobotPositionResult):


class MoveAxesRelativeImplementation(
AbstractCommandImpl[
MoveAxesRelativeParams, SuccessData[MoveAxesRelativeResult, None]
]
AbstractCommandImpl[MoveAxesRelativeParams, SuccessData[MoveAxesRelativeResult]]
):
"""MoveAxesRelative command implementation."""

Expand All @@ -59,7 +57,7 @@ def __init__(

async def execute(
self, params: MoveAxesRelativeParams
) -> SuccessData[MoveAxesRelativeResult, None]:
) -> SuccessData[MoveAxesRelativeResult]:
# TODO (lc 08-16-2024) implement `move_axes` for OT 2 hardware controller
# and then we can remove this validation.
ensure_ot3_hardware(self._hardware_api)
Expand All @@ -69,7 +67,6 @@ async def execute(
)
return SuccessData(
public=MoveAxesRelativeResult(position=current_position),
private=None,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MoveAxesToResult(DestinationRobotPositionResult):


class MoveAxesToImplementation(
AbstractCommandImpl[MoveAxesToParams, SuccessData[MoveAxesToResult, None]]
AbstractCommandImpl[MoveAxesToParams, SuccessData[MoveAxesToResult]]
):
"""MoveAxesTo command implementation."""

Expand All @@ -58,9 +58,7 @@ def __init__(
self._gantry_mover = gantry_mover
self._hardware_api = hardware_api

async def execute(
self, params: MoveAxesToParams
) -> SuccessData[MoveAxesToResult, None]:
async def execute(self, params: MoveAxesToParams) -> SuccessData[MoveAxesToResult]:
# TODO (lc 08-16-2024) implement `move_axes` for OT 2 hardware controller
# and then we can remove this validation.
ensure_ot3_hardware(self._hardware_api)
Expand All @@ -71,7 +69,6 @@ async def execute(
)
return SuccessData(
public=MoveAxesToResult(position=current_position),
private=None,
)


Expand Down
5 changes: 2 additions & 3 deletions api/src/opentrons/protocol_engine/commands/robot/move_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MoveToResult(DestinationPositionResult):


class MoveToImplementation(
AbstractCommandImpl[MoveToParams, SuccessData[MoveToResult, None]]
AbstractCommandImpl[MoveToParams, SuccessData[MoveToResult]]
):
"""MoveTo command implementation."""

Expand All @@ -59,13 +59,12 @@ def __init__(
) -> None:
self._movement = movement

async def execute(self, params: MoveToParams) -> SuccessData[MoveToResult, None]:
async def execute(self, params: MoveToParams) -> SuccessData[MoveToResult]:
x, y, z = await self._movement.move_mount_to(
mount=params.mount, destination=params.destination, speed=params.speed
)
return SuccessData(
public=MoveToResult(position=DeckPoint(x=x, y=y, z=z)),
private=None,
)


Expand Down
19 changes: 13 additions & 6 deletions api/src/opentrons/protocol_engine/execution/gantry_mover.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ def _critical_point_for(
else:
return self._hardware_api.critical_point_for(mount)

def _get_gantry_offsets_for_robot_type(self) -> Tuple[Point, Point, Optional[Point]]:
def _get_gantry_offsets_for_robot_type(
self,
) -> Tuple[Point, Point, Optional[Point]]:
if isinstance(self._hardware_api.config, OT3Config):
return (
Point(*self._hardware_api.config.left_mount_offset),
Expand Down Expand Up @@ -334,7 +336,11 @@ async def move_axes(
f"The absolute position is: {pos_hw} and hw pos map is {pos_hw}."
)
log.info(f"The calculated move {pos_hw} and {mount}")
left_offset, right_offset, gripper_offset = self._get_gantry_offsets_for_robot_type()
(
left_offset,
right_offset,
gripper_offset,
) = self._get_gantry_offsets_for_robot_type()
absolute_pos = target_axis_map_from_absolute(
mount,
pos_hw,
Expand Down Expand Up @@ -530,10 +536,11 @@ def get_max_travel_z_from_mount(self, mount: MountType) -> float:
)
else:
instrument_height = VIRTUAL_MAX_OT3_HEIGHT
tip_length = (
self._state_view.tips.get_tip_length(pipette.id) if pipette else 0.0
)

if pipette:
tip = self._state_view.pipettes.get_attached_tip(pipette_id=pipette.id)
tip_length = tip.length if tip is not None else 0.0
else:
tip_length = 0.0
return instrument_height - tip_length

async def move_axes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,5 @@ async def test_move_axes_to_implementation(
assert result == SuccessData(
public=MoveAxesRelativeResult(
position={MotorAxis.X: 10, MotorAxis.Y: 10, MotorAxis.EXTENSION_Z: 20}
),
private=None,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ async def test_move_axes_to_implementation(
assert result == SuccessData(
public=MoveAxesToResult(
position={MotorAxis.X: 10, MotorAxis.Y: 10, MotorAxis.EXTENSION_Z: 20}
),
private=None,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,5 @@ async def test_move_to_implementation(
result = await subject.execute(params=params)

assert result == SuccessData(
public=MoveToResult(position=DeckPoint(x=4.44, y=5.55, z=6.66)),
private=None,
public=MoveToResult(position=DeckPoint(x=4.44, y=5.55, z=6.66))
)
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,21 @@ async def test_home_z(
],
],
)
@pytest.mark.ot3_only
async def test_move_axes(
decoy: Decoy,
ot3_hardware_api: OT3API,
hardware_subject: HardwareGantryMover,
mock_state_view: StateView,
axis_map: Dict[MotorAxis, float],
critical_point: Optional[Dict[MotorAxis, float]],
expected_mount: Mount,
relative_move: bool,
call_to_hw: "OrderedDict[HardwareAxis, float]",
final_position: Dict[HardwareAxis, float],
) -> None:
subject = HardwareGantryMover(
state_view=mock_state_view, hardware_api=ot3_hardware_api
)
curr_pos = {
HardwareAxis.X: 10.0,
HardwareAxis.Y: 15.0,
Expand Down Expand Up @@ -561,13 +565,13 @@ def _current_position(mount: Mount, refresh: bool) -> Dict[HardwareAxis, float]:
Point(1, 1, 1)
)

pos = await hardware_subject.move_axes(axis_map, critical_point, 100, relative_move)
pos = await subject.move_axes(axis_map, critical_point, 100, relative_move)
decoy.verify(
await ot3_hardware_api.move_axes(position=call_to_hw, speed=100),
times=1,
)
assert pos == {
hardware_subject._hardware_axis_to_motor_axis(ax): pos
subject._hardware_axis_to_motor_axis(ax): pos
for ax, pos in final_position.items()
}

Expand Down

0 comments on commit 2959b4b

Please sign in to comment.