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
linter stuff cleanup
  • Loading branch information
caila-marashaj committed Jul 26, 2023
commit bdea049f1379f6060766301d50c4aaa1e56eeda9
3 changes: 2 additions & 1 deletion api/src/opentrons/hardware_control/backends/ot3simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,11 @@ async def tip_action(
axes: Sequence[Axis],
distance: float = 33,
speed: float = -5.5,
acceleration: float = 0,
tip_action: str = "drop",
) -> None:
_ = create_tip_action_group(
axes, distance, speed, cast(PipetteAction, tip_action)
axes, distance, speed, acceleration, cast(PipetteAction, tip_action)
)

def _attached_to_mount(
Expand Down
7 changes: 3 additions & 4 deletions api/src/opentrons/hardware_control/backends/ot3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,16 @@ def get_system_constraints(
) -> "SystemConstraints[OT3Axis]":
conf_by_pip = config.by_gantry_load(gantry_load)
constraints = {}
axis_kind = [
axis_kind_list = [
OT3AxisKind.P,
OT3AxisKind.X,
OT3AxisKind.Y,
OT3AxisKind.Z,
OT3AxisKind.Z_G,
]
if gantry_load == GantryLoad.HIGH_THROUGHPUT:
axis_kind.append(OT3AxisKind.Q)
for axis_kind in axis_kind:
axis_kind_list.append(OT3AxisKind.Q)
for axis_kind in axis_kind_list:
for axis in OT3Axis.of_kind(axis_kind):
constraints[axis] = AxisConstraints.build(
conf_by_pip["acceleration"][axis_kind],
Expand All @@ -246,7 +246,6 @@ def get_system_constraints(
conf_by_pip["default_max_speed"][axis_kind],
)


return constraints


Expand Down
29 changes: 10 additions & 19 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,6 @@ async def _force_pick_up_tip(
)
await self._move(target_up)

async def get_gear_position(self):
return await self._backend.gear_motor_position_estimation()

async def _motor_pick_up_tip(
self, mount: OT3Mount, pipette_spec: TipMotorPickUpTipSpec
) -> None:
Expand All @@ -1682,33 +1679,27 @@ async def _motor_pick_up_tip(
await self._move(target_down)
# perform pick up tip

# gear_origin_dict = {OT3Axis.Q: 0}
gear_motor_origin = await self._backend.gear_motor_position_estimation()
gear_origin_dict = {
OT3Axis.Q: gear_motor_origin[0]
}
gear_origin_dict = {OT3Axis.Q: gear_motor_origin[0]}
gear_motor_target = pipette_spec.pick_up_distance + pipette_spec.home_buffer
gear_target_dict = {OT3Axis.Q: gear_motor_target}
moves = self._build_moves(gear_origin_dict, gear_target_dict)
blocks = moves[0][0].blocks

for block in blocks:
Copy link
Contributor

Choose a reason for hiding this comment

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

we should pass moves into the backend tip action

print(f"block speed = {block.initial_speed}")
print(f"block acceleration = {block.acceleration}")
await self._backend.tip_action(
[OT3Axis.of_main_tool_actuator(mount)],
block.distance,
block.initial_speed,
block.acceleration,
"clamp",
[OT3Axis.of_main_tool_actuator(mount)],
float(block.distance),
float(block.initial_speed),
float(block.acceleration),
"clamp",
)
# back clamps off the adapter posts
print(f"pipette spec speed = {pipette_spec.speed}")
await self._backend.tip_action(
[Axis.of_main_tool_actuator(mount)],
pipette_spec.pick_up_distance + pipette_spec.home_buffer,
(pipette_spec.speed - 1),
0,
[OT3Axis.of_main_tool_actuator(mount)],
float(pipette_spec.pick_up_distance + pipette_spec.home_buffer),
float(pipette_spec.speed),
float(0),
"home",
)

Expand Down
7 changes: 3 additions & 4 deletions api/src/opentrons/hardware_control/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class OT3AxisKind(enum.Enum):
#: Plunger axis (of the left and right pipettes)
Z_G = 4
#: Gripper Z axis
Q = 5
Q = 6
#: High-throughput tip grabbing axis
OTHER = 5
#: The internal axes of high throughput pipettes, for instance
Expand Down Expand Up @@ -152,7 +152,7 @@ def to_kind(cls, axis: "Axis") -> OT3AxisKind:
cls.Z_L: OT3AxisKind.Z,
cls.Z_R: OT3AxisKind.Z,
cls.Z_G: OT3AxisKind.Z_G,
cls.Q: OT3AxisKind.OTHER,
cls.Q: OT3AxisKind.Q,
cls.G: OT3AxisKind.OTHER,
}
return kind_map[axis]
Expand All @@ -166,8 +166,7 @@ def of_kind(cls, kind: OT3AxisKind) -> List["Axis"]:
OT3AxisKind.Z: [cls.Z_L, cls.Z_R],
OT3AxisKind.Z_G: [cls.Z_G],
OT3AxisKind.Q: [cls.Q],
OT3AxisKind.OTHER: [cls.Q],
# OT3AxisKind.OTHER: [cls.G],
OT3AxisKind.OTHER: [cls.Q, cls.G],
}
return kind_map[kind]

Expand Down
1 change: 0 additions & 1 deletion api/tests/opentrons/hardware_control/test_ot3_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,6 @@ async def test_save_instrument_offset(
)



async def test_pick_up_tip_full_tiprack(
ot3_hardware: ThreadManager[OT3API],
mock_instrument_handlers: Tuple[Mock],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,18 @@ class UpdateMotorPositionEstimationResponse(BaseMessage): # noqa: D101


@dataclass
class UpdateGearMotorPositionEstimationRequest(EmptyPayloadMessage): # noqa D101
class UpdateGearMotorPositionEstimationRequest(EmptyPayloadMessage): # noqa: D101
caila-marashaj marked this conversation as resolved.
Show resolved Hide resolved
message_id: Literal[
MessageId.update_gear_motor_position_estimation_request
] = MessageId.update_gear_motor_position_estimation_request


@dataclass
class UpdateGearMotorPositionEstimationResponse(BaseMessage): # noqa D101
class UpdateGearMotorPositionEstimationResponse(BaseMessage): # noqa: D101
payload: payloads.GearMotorPositionResponse
payload_type: Type[payloads.GearMotorPositionResponse] = payloads.GearMotorPositionResponse
payload_type: Type[
payloads.GearMotorPositionResponse
] = payloads.GearMotorPositionResponse
message_id: Literal[
MessageId.update_gear_motor_position_estimation_response
] = MessageId.update_gear_motor_position_estimation_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ class MoveCompletedPayload(MoveGroupResponsePayload):

@dataclass(eq=False)
class GearMotorPositionResponse(EmptyPayload):
"""Read Gear Motor Position Estimation."""

current_position: utils.UInt32Field
Copy link
Contributor

Choose a reason for hiding this comment

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

We can still have position flags here imo, it would just be related to boot-up only.




@dataclass(eq=False)
class MotorPositionResponse(EmptyPayload):
"""Read Encoder Position."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,20 @@ async def update_gear_motor_position_estimation(
"""

def _listener_filter(arbitration_id: ArbitrationId) -> bool:
return (NodeId(arbitration_id.parts.originating_node_id) in {NodeId.pipette_left}) and (
return (
NodeId(arbitration_id.parts.originating_node_id) in {NodeId.pipette_left}
) and (
MessageId(arbitration_id.parts.message_id)
== UpdateGearMotorPositionEstimationResponse.message_id
)

data = []

# for node in nodes:
with WaitableCallback(can_messenger, _listener_filter) as reader:
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use MultipleMessagesWaitableCallback. See get_motor_position above. It will make the code much cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

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

Bump on this comment.

await can_messenger.send(
node_id=NodeId.pipette_left,
message=UpdateGearMotorPositionEstimationRequest(),
)
print(f"SENT GEAR MOTOR ESTIMATION REQUEST")
try:
for i in range(2):
response = await asyncio.wait_for(
Expand Down Expand Up @@ -215,7 +215,6 @@ async def _parser_update_gear_motor_position_response(
reader: WaitableCallback, expected: NodeId
) -> Tuple[float, bool]:
async for response, arb_id in reader:
print(f"\nGOT RESPONSE {response}\n")
assert isinstance(response, UpdateGearMotorPositionEstimationResponse)
node = NodeId(arb_id.parts.originating_node_id)
if node == expected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ def __init__(
"""
self._move_groups = move_groups
self._start_at_index = start_at_index
# self._ignore_stalls = ignore_stalls
self._ignore_stalls = True
self._ignore_stalls = ignore_stalls
self._is_prepped: bool = False

@staticmethod
Expand Down Expand Up @@ -328,12 +327,12 @@ def _get_tip_action_motor_message(
acceleration=Int32Field(
int(
(
step.acceleration_mm_sec_sq
* 1000.0
/ interrupts_per_sec
/ interrupts_per_sec
step.acceleration_mm_sec_sq
* 1000.0
/ interrupts_per_sec
/ interrupts_per_sec
)
* (2 ** 31)
* (2**31)
)
),
action=PipetteTipActionTypeField(step.action),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ async def run_gear_motors(args: argparse.Namespace) -> None:
{
pipette_node: MoveGroupTipActionStep(
velocity_mm_sec=float64(5.5),
acceleration_mm_sec_sq=float64(0),
duration_sec=float64(2.5),
stop_condition=MoveStopCondition.none,
action=PipetteTipActionType.clamp,
Expand All @@ -140,6 +141,7 @@ async def run_gear_motors(args: argparse.Namespace) -> None:
{
pipette_node: MoveGroupTipActionStep(
velocity_mm_sec=float64(-5.0),
acceleration_mm_sec_sq=float64(0),
duration_sec=float64(6),
stop_condition=MoveStopCondition.limit_switch,
action=PipetteTipActionType.home,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async def run(args: argparse.Namespace) -> None:
{
pipette_node: MoveGroupTipActionStep(
velocity_mm_sec=float64(5.5),
acceleration_mm_sec_sq=float64(0),
duration_sec=float64(2.5),
stop_condition=MoveStopCondition.none,
action=PipetteTipActionType.clamp,
Expand All @@ -86,6 +87,7 @@ async def run(args: argparse.Namespace) -> None:
{
pipette_node: MoveGroupTipActionStep(
velocity_mm_sec=float64(-5.5),
acceleration_mm_sec_sq=float64(0),
duration_sec=float64(6),
stop_condition=MoveStopCondition.limit_switch,
action=PipetteTipActionType.home,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def move_group_tip_action() -> MoveGroups:
{
NodeId.pipette_left: MoveGroupTipActionStep(
velocity_mm_sec=float64(2),
acceleration_mm_sec_sq=float64(0),
duration_sec=float64(1),
action=PipetteTipActionType.clamp,
stop_condition=MoveStopCondition.none,
Expand Down