Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hardware): add acceleration to pick up tip for 96 channel #12944

Merged
merged 28 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
95d068b
add acceleration to tip_action
caila-marashaj Jun 15, 2023
b4d4bee
pick up tip move happens, but rumbly
caila-marashaj Jun 21, 2023
bdea049
linter stuff cleanup
caila-marashaj Jun 21, 2023
782a760
fixed position of acceleration in tipaction msg
caila-marashaj Jun 22, 2023
73d26bf
moving but delayed
caila-marashaj Jun 27, 2023
c3e044a
modify tip action, debugging code still in there
caila-marashaj Jun 28, 2023
a85074e
mostly working but returning position too early
caila-marashaj Jun 29, 2023
1952348
need to update tests
caila-marashaj Jul 6, 2023
fa194a3
updated unit test args for tip_action
caila-marashaj Jul 17, 2023
d2e7927
rebase
caila-marashaj Jul 17, 2023
2b20a20
rough final draft
caila-marashaj Jul 18, 2023
8cf3c15
cleanup
caila-marashaj Jul 18, 2023
7e5b7ef
format
caila-marashaj Jul 18, 2023
8ace0ef
remove redundant data check from gear motors
caila-marashaj Jul 18, 2023
155738b
hardware controller changes
caila-marashaj Jul 19, 2023
0aede03
increase backward distances
caila-marashaj Jul 20, 2023
97e12e9
changed helpers_ot3 function
caila-marashaj Jul 21, 2023
1550c9a
format
caila-marashaj Jul 21, 2023
735ebe7
helpers_ot3 function change
caila-marashaj Jul 21, 2023
af1eefa
got rid of copysign call
caila-marashaj Jul 21, 2023
e2280aa
check if speed exists
caila-marashaj Jul 21, 2023
5be4492
add deafult value to axis convert call
caila-marashaj Jul 24, 2023
93ef4ca
update gear motor position handling after move
caila-marashaj Jul 25, 2023
f1a42d1
test fix
caila-marashaj Jul 25, 2023
2b71f07
moved comments
caila-marashaj Jul 26, 2023
57bb955
remove updategearmotorpositionestimation msg
caila-marashaj Jul 26, 2023
e201a43
removed more unneeded code
caila-marashaj Jul 26, 2023
6eb76e6
address change reqs
caila-marashaj Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rough final draft
  • Loading branch information
caila-marashaj committed Jul 26, 2023
commit 2b20a204ce7462de038653c290c25c755778703b
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 @@ -606,13 +606,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 @@ -1717,7 +1717,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 @@ -1382,7 +1382,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 @@ -1408,10 +1408,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 @@ -1435,7 +1435,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 @@ -1447,7 +1447,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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are still receiving multiple responses from the tip action request. We should have a test that captures that.

In fact, we should expand on this test to mimic all the varying responses you can get from a tip action (i.e. if it's an acceleration move, then 3 responses for each motor) or if it's a regular home then just two responses.

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