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
modify tip action, debugging code still in there
  • Loading branch information
caila-marashaj committed Jul 26, 2023
commit c3e044a5d5fdb744459297e1ec03581786f25002
3 changes: 1 addition & 2 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
create_gripper_jaw_home_group,
create_gripper_jaw_hold_group,
create_tip_action_group,
create_tip_action_home_group,
PipetteAction,
motor_nodes,
LIMIT_SWITCH_OVERTRAVEL_DISTANCE,
Expand Down Expand Up @@ -83,7 +82,7 @@
from opentrons_hardware.hardware_control.motor_position_status import (
get_motor_position,
update_motor_position_estimation,
# update_gear_motor_position_estimation,
update_gear_motor_position_estimation,
)
from opentrons_hardware.hardware_control.limit_switches import get_limit_switches
from opentrons_hardware.hardware_control.tip_presence import get_tip_ejector_state
Expand Down
79 changes: 39 additions & 40 deletions api/src/opentrons/hardware_control/backends/ot3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,9 @@ def create_move_group(
moves: List[Move[Axis]],
present_nodes: Iterable[NodeId],
stop_condition: MoveStopCondition,
tip_action_type: Optional[PipetteTipActionType] = None,
) -> Tuple[MoveGroup, Dict[NodeId, float]]:
pos = _convert_to_node_id_dict(origin)
move_group: MoveGroup = []
if tip_action_type is not None:
tip_action_step = PipetteTipActionType[tip_action_type]
else:
tip_action_step = None
for move in moves:
unit_vector = move.unit_vector
for block in move.blocks:
Expand All @@ -361,7 +356,6 @@ def create_move_group(
duration=block.time,
present_nodes=present_nodes,
stop_condition=stop_condition,
tip_action_step=tip_action_step,
)
for ax in pos.keys():
pos[ax] += node_id_distances.get(ax, 0)
Expand Down Expand Up @@ -404,43 +398,48 @@ def create_tip_action_home_group(
return [home_group, backoff_group]


def create_fast_tip_action_group(
axes: Sequence[OT3Axis],
move: Move,
action: str = "clamp",
def create_tip_action_group(
moves: List[Move[OT3Axis]],
present_nodes: Iterable[NodeId],
action: PipetteTipActionType,
accelerate_during_move: bool = True,
) -> MoveGroup:
current_nodes = [axis_to_node(ax) for ax in axes]
tip_action_group = []
for block in move.blocks:
if block.initial_speed == 0:
continue
step = create_tip_action_step(
velocity={node_id: np.float64(block.initial_speed) for node_id in current_nodes},
distance={node_id: np.float64(block.distance) for node_id in current_nodes},
acceleration={node_id: np.float64(block.acceleration) for node_id in current_nodes},
present_nodes=current_nodes,
action=PipetteTipActionType[action],
)
tip_action_group.append(step)
return tip_action_group
move_group: MoveGroup = []
for move in moves:
unit_vector = move.unit_vector
for block in move.blocks:
velocities = unit_vector_multiplication(unit_vector, block.initial_speed)
if accelerate_during_move:
accelerations = unit_vector_multiplication(unit_vector, block.acceleration)
else:
accelerations = {OT3Axis.Q: 0}
step = create_tip_action_step(
velocity=_convert_to_node_id_dict(velocities),
acceleration=_convert_to_node_id_dict(accelerations),
duration=block.time,
present_nodes=present_nodes,
action=PipetteTipActionType[action],
)
move_group.append(step)
return move_group


def create_tip_action_group(
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],
)
return [step]
# def create_tip_action_group(
# 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],
# )
# return [step]


def create_gripper_jaw_grip_group(
Expand Down
47 changes: 32 additions & 15 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,22 @@ async def _home(self, axes: Sequence[Axis]) -> None:
await self._cache_current_position()
await self._cache_encoder_position()

async def home_gear_motors(self, accelerate_during_move: bool = False) -> None:
if accelerate_during_move:
current_pos = await self._backend.gear_motor_position_estimation()
if current_pos == 0:
return
print(f"got current gear position = {current_pos}")
current_pos_dict = {OT3Axis.Q: current_pos[0]}
# current_pos_dict = {OT3Axis.Q: 5}
# breakpoint()
else:
current_pos_dict = {OT3Axis.Q: 50}
home_target = {OT3Axis.Q: 0}
home_moves = self._build_moves(current_pos_dict, home_target)
await self._backend.tip_action(home_moves[0], "home", accelerate_during_move)


@ExecutionManagerProvider.wait_for_running
async def home(self, axes: Optional[List[Axis]] = None) -> None:
"""
Expand All @@ -1276,7 +1292,8 @@ async def home(self, axes: Optional[List[Axis]] = None) -> None:
else:
checked_axes = [ax for ax in Axis if ax != Axis.Q]
if self.gantry_load == GantryLoad.HIGH_THROUGHPUT:
checked_axes.append(Axis.Q)
# checked_axes.append(OT3Axis.Q)
await self.home_gear_motors()
self._log.info(f"Homing {axes}")

home_seq = [
Expand Down Expand Up @@ -1688,7 +1705,7 @@ async def _motor_pick_up_tip(
gear_target_dict = {OT3Axis.Q: gear_motor_target}
clamp_moves = self._build_moves(gear_origin_dict, gear_target_dict)

await self._backend.fast_tip_action(gear_origin_dict, clamp_moves[0], "clamp")
await self._backend.tip_action(clamp_moves[0], "clamp")

# else:
# await self._backend.tip_action(
Expand All @@ -1700,22 +1717,22 @@ async def _motor_pick_up_tip(
# )

gear_motor_position = {OT3Axis.Q: self._backend.gear_motor_position}
# print(f"gear motor pos = {gear_motor_position}")
home_target = {OT3Axis.Q: 5}
print(f"gear motor pos = {gear_motor_position}")
home_target = {OT3Axis.Q: 0}
# print(f"passing in gear motor position = {gear_motor_position}")
home_moves = self._build_moves(gear_motor_position, home_target)
# print(f"home moves = {home_moves[0]}")
await self._backend.fast_tip_action(gear_motor_position, home_moves[0], "clamp")
print(f"done almost homing at {time.time()}")

await self._backend.tip_action(
[OT3Axis.of_main_tool_actuator(mount)],
# float(pipette_spec.pick_up_distance + pipette_spec.home_buffer),
float(5.5),
float(pipette_spec.speed - 1),
float(0),
"home",
)
await self._backend.tip_action(home_moves[0], "home")
# print(f"done almost homing at {time.time()}")

# await self._backend.tip_action(
# [OT3Axis.of_main_tool_actuator(mount)],
# # float(pipette_spec.pick_up_distance + pipette_spec.home_buffer),
# float(5.5),
# float(pipette_spec.speed - 1),
# float(0),
# "home",
# )

async def pick_up_tip(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def serialize(self) -> bytes:
"""
string = self._get_format_string()
vals = [x.value for x in astuple(self)]
# breakpoint()
try:
return struct.pack(string, *vals)
except struct.error as e:
Expand Down
50 changes: 17 additions & 33 deletions hardware/opentrons_hardware/hardware_control/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class MoveGroupSingleAxisStep:
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
velocity_mm_sec: np.float64
action: PipetteTipActionType
stop_condition: MoveStopCondition
acceleration_mm_sec_sq: np.float64


@dataclass(frozen=True)
Expand Down Expand Up @@ -107,7 +107,6 @@ def create_step(
duration: np.float64,
present_nodes: Iterable[NodeId],
stop_condition: MoveStopCondition = MoveStopCondition.none,
tip_action_step: Optional[PipetteTipActionType] = None,
) -> MoveGroupStep:
"""Create a move from a block.

Expand All @@ -126,28 +125,16 @@ def create_step(
# adds a MoveGroupSingleGripperStep
ordered_nodes = list([n for n in present_nodes if n != NodeId.gripper_g])
step: MoveGroupStep = {}
if tip_action_step is not None:

step[NodeId.pipette_left] = MoveGroupTipActionStep(
for axis_node in ordered_nodes:
step[axis_node] = MoveGroupSingleAxisStep(
distance_mm=distance.get(axis_node, np.float64(0)),
acceleration_mm_sec_sq=acceleration.get(axis_node, np.float64(0)),
velocity_mm_sec=velocity.get(axis_node, np.float64(0)),
duration_sec=duration,
velocity_mm_sec=velocity.get(NodeId.pipette_left, np.float64(0)),
action=tip_action_step,
stop_condition=stop_condition,
acceleration_mm_sec_sq=acceleration.get(NodeId.pipette_left, np.float64(0)),
move_type=MoveType.get_move_type(stop_condition),
)
return step

else:
for axis_node in ordered_nodes:
step[axis_node] = MoveGroupSingleAxisStep(
distance_mm=distance.get(axis_node, np.float64(0)),
acceleration_mm_sec_sq=acceleration.get(axis_node, np.float64(0)),
velocity_mm_sec=velocity.get(axis_node, np.float64(0)),
duration_sec=duration,
stop_condition=stop_condition,
move_type=MoveType.get_move_type(stop_condition),
)
return step
return step


def create_backoff_step(velocity: Dict[NodeId, np.float64]) -> MoveGroupStep:
Expand Down Expand Up @@ -198,27 +185,24 @@ 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],
duration: np.float64,
present_nodes: Iterable[NodeId],
action: PipetteTipActionType,
) -> MoveGroupStep:
"""Creates a step for tip handling actions that require motor movement."""
if action == PipetteTipActionType.home:
stop_condition = MoveStopCondition.limit_switch
else:
stop_condition = MoveStopCondition.none
step: MoveGroupStep = {}
stop_condition = (
caila-marashaj marked this conversation as resolved.
Show resolved Hide resolved
MoveStopCondition.limit_switch
if action == PipetteTipActionType.home
else MoveStopCondition.none
)
for axis_node in present_nodes:
step[axis_node] = MoveGroupTipActionStep(
duration_sec=abs(distance[axis_node] / velocity[axis_node]),
velocity_mm_sec=velocity[axis_node],
duration_sec=duration,
velocity_mm_sec=velocity.get(axis_node, np.float64(0)),
action=action,
stop_condition=stop_condition,
acceleration_mm_sec_sq=acceleration[axis_node],
acceleration_mm_sec_sq=acceleration.get(axis_node, np.float64(0)),
)
# breakpoint()
return step


Expand Down
Loading