Skip to content

Commit

Permalink
rough final draft
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jul 18, 2023
1 parent deed9a0 commit 79384d0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 38 deletions.
14 changes: 7 additions & 7 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,13 @@ async def home(
async with self._monitor_overpressure(moving_pipettes):
positions = await asyncio.gather(*coros)
# if Axis.Q in checked_axes:
# await self.tip_action(
# [Axis.Q],
# self.axis_bounds[Axis.Q][1] - self.axis_bounds[Axis.Q][0],
# self._configuration.motion_settings.max_speed_discontinuity.high_throughput[
# Axis.to_kind(Axis.Q)
# ],
# )
# await self.tip_action(
# [Axis.Q],
# self.axis_bounds[Axis.Q][1] - self.axis_bounds[Axis.Q][0],
# self._configuration.motion_settings.max_speed_discontinuity.high_throughput[
# Axis.to_kind(Axis.Q)
# ],
# )
for position in positions:
self._handle_motor_status_response(position)
return axis_convert(self._position, 0.0)
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ async def _motor_pick_up_tip(
]
gear_origin_dict = {Axis.Q: gear_origin_float}
clamp_move_target = pipette_spec.pick_up_distance
gear_target_dict = {AxisQ: clamp_move_target}
gear_target_dict = {Axis.Q: clamp_move_target}
clamp_moves = self._build_moves(gear_origin_dict, gear_target_dict)
await self._backend.tip_action(moves=clamp_moves[0], tip_action="clamp")

Expand Down
12 changes: 6 additions & 6 deletions api/tests/opentrons/hardware_control/test_ot3_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing_extensions import Literal
from math import copysign
import pytest
from mock import AsyncMock, patch, Mock, call, PropertyMock
from mock import AsyncMock, patch, Mock, PropertyMock
from hypothesis import given, strategies, settings, HealthCheck, assume, example

from opentrons.calibration_storage.types import CalibrationStatus, SourceType
Expand Down Expand Up @@ -1381,7 +1381,7 @@ def _fake_function():
)

def _update_gear_motor_pos(
moves: Optional[List[Move[OT3Axis]]] = None,
moves: Optional[List[Move[Axis]]] = None,
distance: Optional[float] = None,
velocity: Optional[float] = None,
tip_action: str = "home",
Expand All @@ -1407,10 +1407,10 @@ def _update_gear_motor_pos(
# breakpoint()
# first call should be "clamp", moving down
assert tip_action.call_args_list[0][-1]["tip_action"] == "clamp"
assert tip_action.call_args_list[0][-1]["moves"][0].unit_vector == {AxisQ: 1}
assert tip_action.call_args_list[0][-1]["moves"][0].unit_vector == {Axis.Q: 1}
# next call should be "clamp", moving back up
assert tip_action.call_args_list[1][-1]["tip_action"] == "clamp"
assert tip_action.call_args_list[1][-1]["moves"][0].unit_vector == {AxisQ: -1}
assert tip_action.call_args_list[1][-1]["moves"][0].unit_vector == {Axis.Q: -1}
# last call should be "home"
assert tip_action.call_args_list[2][-1]["tip_action"] == "home"
assert len(tip_action.call_args_list) == 3
Expand All @@ -1434,7 +1434,7 @@ def _fake_function():
drop_moves=[
DropTipMove(
target_position=10,
current={AxisP_L: 1.0},
current={Axis.P_L: 1.0},
speed=1,
is_ht_tip_action=True,
)
Expand All @@ -1446,7 +1446,7 @@ def _fake_function():
)

def _update_gear_motor_pos(
moves: Optional[List[Move[OT3Axis]]] = None,
moves: Optional[List[Move[Axis]]] = None,
distance: Optional[float] = None,
velocity: Optional[float] = None,
tip_action: str = "home",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def _parser_update_motor_position_response(
node = NodeId(arb_id.parts.originating_node_id)
if node == expected:
return (
float(response.payload.current_position.value),
float(response.payload.current_position.value) / 1000.0,
float(response.payload.encoder_position.value) / 1000.0,
bool(
response.payload.position_flags.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,10 @@ async def test_home_timeout(
await subject.run(can_messenger=mock_can_messenger)


async def test_tip_action_move_runner_receives_two_responses(
async def test_tip_action_move_runner_receives_response(
mock_can_messenger: AsyncMock, move_group_tip_action: MoveGroups
) -> None:
"""The magic call function should receive two responses for a tip action."""
"""The magic call function should now receive one response for a tip action."""
with patch.object(MoveScheduler, "_handle_move_completed") as mock_move_complete:
subject = MoveScheduler(move_groups=move_group_tip_action)
mock_sender = MockSendMoveCompleter(move_group_tip_action, subject)
Expand All @@ -785,22 +785,12 @@ async def test_tip_action_move_runner_receives_two_responses(
assert isinstance(
mock_move_complete.call_args_list[0][0][0], md.TipActionResponse
)
assert mock_move_complete.call_args_list[0][0][
0
].payload.gear_motor_id == GearMotorIdField(1)

assert isinstance(
mock_move_complete.call_args_list[1][0][0], md.TipActionResponse
)
assert mock_move_complete.call_args_list[1][0][
0
].payload.gear_motor_id == GearMotorIdField(0)


async def test_tip_action_move_runner_position_updated(
mock_can_messenger: AsyncMock, move_group_tip_action: MoveGroups
) -> None:
"""Two responses from a tip action move are properly handled."""
"""Response from a tip action move is properly handled."""
subject = MoveScheduler(move_groups=move_group_tip_action)
mock_sender = MockSendMoveCompleter(move_group_tip_action, subject)
mock_can_messenger.ensure_send.side_effect = mock_sender.mock_ensure_send
Expand All @@ -810,17 +800,17 @@ async def test_tip_action_move_runner_position_updated(
assert completion_message[0][1].payload.current_position_um.value == 2000


async def test_tip_action_move_runner_fail_receives_one_response(
mock_can_messenger: AsyncMock, move_group_tip_action: MoveGroups, caplog: Any
) -> None:
"""Tip action move should fail if one or less responses received."""
subject = MoveScheduler(move_groups=move_group_tip_action)
mock_sender = MockSendMoveCompleter(move_group_tip_action, subject)
mock_can_messenger.ensure_send.side_effect = mock_sender.mock_ensure_send_failure
mock_can_messenger.send.side_effect = mock_sender.mock_send_failure
# async def test_tip_action_move_runner_fail_receives_one_response(
# mock_can_messenger: AsyncMock, move_group_tip_action: MoveGroups, caplog: Any
# ) -> None:
# """Tip action move should fail if one or less responses received."""
# subject = MoveScheduler(move_groups=move_group_tip_action)
# mock_sender = MockSendMoveCompleter(move_group_tip_action, subject)
# mock_can_messenger.ensure_send.side_effect = mock_sender.mock_ensure_send_failure
# mock_can_messenger.send.side_effect = mock_sender.mock_send_failure

with pytest.raises(MotionFailedError):
await subject.run(can_messenger=mock_can_messenger)
# with pytest.raises(MotionFailedError):
# await subject.run(can_messenger=mock_can_messenger)


async def test_multi_group_move(
Expand Down

0 comments on commit 79384d0

Please sign in to comment.