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
Next Next commit
add acceleration to tip_action
  • Loading branch information
caila-marashaj committed Jul 26, 2023
commit 95d068bdf4912c73e1df45d45801574ee7985732
16 changes: 5 additions & 11 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,21 +610,15 @@ async def tip_action(
axes: Sequence[Axis],
distance: float,
speed: float,
acceleration: float = 0,
tip_action: str = "home",
) -> None:
if tip_action == "home":
speed = speed * -1
runner = MoveGroupRunner(
move_groups=create_tip_action_home_group(axes, distance, speed)
)
else:
runner = MoveGroupRunner(
move_groups=[
create_tip_action_group(
axes, distance, speed, cast(PipetteAction, tip_action)
)
]
)
move_group = create_tip_action_group(
axes, distance, speed, acceleration, cast(PipetteAction, tip_action)
)
runner = MoveGroupRunner(move_groups=[move_group])
positions = await runner.run(can_messenger=self._messenger)
for axis, point in positions.items():
self._position.update({axis: point[0]})
Expand Down
20 changes: 16 additions & 4 deletions api/src/opentrons/hardware_control/backends/ot3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def get_current_settings(
config: OT3CurrentSettings,
gantry_load: GantryLoad,
) -> OT3AxisMap[CurrentConfig]:
print(f"CONFIG = {config}")
conf_by_pip = config.by_gantry_load(gantry_load)
print(f"conf_by_pip = {conf_by_pip}")
currents = {}
for axis_kind in conf_by_pip["hold_current"].keys():
for axis in Axis.of_kind(axis_kind):
Expand All @@ -228,20 +230,25 @@ def get_system_constraints(
) -> "SystemConstraints[Axis]":
conf_by_pip = config.by_gantry_load(gantry_load)
constraints = {}
for axis_kind in [
axis_kind = [
OT3AxisKind.P,
OT3AxisKind.X,
OT3AxisKind.Y,
OT3AxisKind.Z,
OT3AxisKind.Z_G,
]:
for axis in Axis.of_kind(axis_kind):
]
if gantry_load == GantryLoad.HIGH_THROUGHPUT:
axis_kind.append(OT3AxisKind.Q)
for axis_kind in axis_kind:
for axis in OT3Axis.of_kind(axis_kind):
constraints[axis] = AxisConstraints.build(
conf_by_pip["acceleration"][axis_kind],
conf_by_pip["max_speed_discontinuity"][axis_kind],
conf_by_pip["direction_change_speed_discontinuity"][axis_kind],
conf_by_pip["default_max_speed"][axis_kind],
)


return constraints


Expand Down Expand Up @@ -395,12 +402,17 @@ def create_tip_action_home_group(


def create_tip_action_group(
axes: Sequence[Axis], distance: float, velocity: float, action: PipetteAction
axes: Sequence[OT3Axis],
distance: float,
velocity: float,
acceleration: float,
action: PipetteAction,
) -> MoveGroup:
current_nodes = [axis_to_node(ax) for ax in axes]
step = create_tip_action_step(
velocity={node_id: np.float64(velocity) for node_id in current_nodes},
distance={node_id: np.float64(distance) for node_id in current_nodes},
acceleration={node_id: np.float64(acceleration) for node_id in current_nodes},
present_nodes=current_nodes,
action=PipetteTipActionType[action],
)
Expand Down
22 changes: 16 additions & 6 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,17 +1678,27 @@ async def _motor_pick_up_tip(
)
await self._move(target_down)
# perform pick up tip
await self._backend.tip_action(
[Axis.of_main_tool_actuator(mount)],
pipette_spec.pick_up_distance,
pipette_spec.speed,
"clamp",
)

gear_origin_dict = {OT3Axis.Q: 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

await self._backend.tip_action(
[OT3Axis.of_main_tool_actuator(mount)],
block.distance,
block.final_speed,
block.acceleration,
"clamp",
)
# back clamps off the adapter posts
await self._backend.tip_action(
[Axis.of_main_tool_actuator(mount)],
pipette_spec.pick_up_distance + pipette_spec.home_buffer,
pipette_spec.speed,
0,
"home",
)

Expand Down
3 changes: 2 additions & 1 deletion api/src/opentrons/hardware_control/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ def of_kind(cls, kind: OT3AxisKind) -> List["Axis"]:
OT3AxisKind.Y: [cls.Y],
OT3AxisKind.Z: [cls.Z_L, cls.Z_R],
OT3AxisKind.Z_G: [cls.Z_G],
OT3AxisKind.OTHER: [cls.Q, cls.G],
OT3AxisKind.Q: [cls.Q],
OT3AxisKind.OTHER: [cls.Q],
}
return kind_map[kind]

Expand Down
2 changes: 2 additions & 0 deletions hardware/opentrons_hardware/firmware_bindings/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class MessageId(int, Enum):
motor_position_response = 0x14
update_motor_position_estimation_request = 0x21
update_motor_position_estimation_response = 0x22
update_gear_motor_position_estimation_request = 0x23
update_gear_motor_position_estimation_response = 0x24

set_motion_constraints = 0x101
get_motion_constraints_request = 0x102
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,22 @@ class UpdateMotorPositionEstimationResponse(BaseMessage): # noqa: D101
] = MessageId.update_motor_position_estimation_response


@dataclass
class UpdateGearMotorPositionEstimationRequest(EmptyPayloadMessage): # noqa D101
message_id: Literal[
MessageId.update_gear_motor_position_estimation_request
] = MessageId.update_gear_motor_position_estimation_request


@dataclass
class UpdateGearMotorPositionEstimationResponse(BaseMessage): # noqa D101
payload: 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


@dataclass
class SetMotionConstraints(BaseMessage): # noqa: D101
payload: payloads.MotionConstraintsPayload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
defs.MotorPositionResponse,
defs.UpdateMotorPositionEstimationRequest,
defs.UpdateMotorPositionEstimationResponse,
defs.UpdateGearMotorPositionEstimationRequest,
defs.UpdateGearMotorPositionEstimationResponse,
defs.SetMotionConstraints,
defs.GetMotionConstraintsRequest,
defs.GetMotionConstraintsResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ class MoveCompletedPayload(MoveGroupResponsePayload):
ack_id: utils.UInt8Field


@dataclass(eq=False)
class GearMotorPositionResponse(EmptyPayload):

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 Expand Up @@ -548,6 +555,7 @@ class TipActionRequestPayload(AddToMoveGroupRequestPayload):
"""A request to perform a tip action."""

velocity: utils.Int32Field
acceleration: utils.Int32Field
action: PipetteTipActionTypeField
request_stop_condition: MoveStopConditionField

Expand Down
3 changes: 3 additions & 0 deletions hardware/opentrons_hardware/hardware_control/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class MoveGroupTipActionStep:
"""A single tip handling action that requires movement in a move group."""

velocity_mm_sec: np.float64
acceleration_mm_sec_sq: np.float64
duration_sec: np.float64
action: PipetteTipActionType
stop_condition: MoveStopCondition
Expand Down Expand Up @@ -186,6 +187,7 @@ def create_tip_action_backoff_step(velocity: Dict[NodeId, np.float64]) -> MoveGr
def create_tip_action_step(
velocity: Dict[NodeId, np.float64],
distance: Dict[NodeId, np.float64],
acceleration: Dict[NodeId, np.float64],
present_nodes: Iterable[NodeId],
action: PipetteTipActionType,
) -> MoveGroupStep:
Expand All @@ -199,6 +201,7 @@ def create_tip_action_step(
for axis_node in present_nodes:
step[axis_node] = MoveGroupTipActionStep(
velocity_mm_sec=velocity[axis_node],
acceleration_mm_sec_sq=acceleration[axis_node],
duration_sec=abs(distance[axis_node] / velocity[axis_node]),
stop_condition=stop_condition,
action=action,
Expand Down
11 changes: 11 additions & 0 deletions hardware/opentrons_hardware/hardware_control/move_group_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,17 @@ def _get_tip_action_motor_message(
velocity=self._convert_velocity(
step.velocity_mm_sec, tip_interrupts_per_sec
),
acceleration=Int32Field(
int(
(
step.acceleration_mm_sec_sq
* 1000.0
/ interrupts_per_sec
/ interrupts_per_sec
)
* (2 ** 31)
)
),
action=PipetteTipActionTypeField(step.action),
request_stop_condition=MoveStopConditionField(step.stop_condition),
)
Expand Down