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 27 commits
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
2 changes: 1 addition & 1 deletion api/src/opentrons/config/defaults_ot3.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
OT3AxisKind.Z: 35,
OT3AxisKind.P: 15,
OT3AxisKind.Z_G: 50,
OT3AxisKind.Q: 5.5,
OT3AxisKind.Q: 10,
},
low_throughput={
OT3AxisKind.X: 350,
Expand Down
66 changes: 44 additions & 22 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
create_gripper_jaw_home_group,
create_gripper_jaw_hold_group,
create_tip_action_group,
create_tip_action_home_group,
PipetteAction,
create_gear_motor_home_group,
motor_nodes,
LIMIT_SWITCH_OVERTRAVEL_DISTANCE,
map_pipette_type_to_sensor_id,
Expand Down Expand Up @@ -259,6 +258,7 @@ def __init__(
self._estop_detector: Optional[EstopDetector] = None
self._estop_state_machine = EstopStateMachine(detector=None)
self._position = self._get_home_position()
self._gear_motor_position: Dict[NodeId, float] = {}
self._encoder_position = self._get_home_position()
self._motor_status = {}
self._check_updates = check_updates
Expand Down Expand Up @@ -330,6 +330,10 @@ def _build_system_hardware(
usb_messenger=usb_messenger,
)

@property
def gear_motor_position(self) -> Dict[NodeId, float]:
return self._gear_motor_position

def _motor_nodes(self) -> Set[NodeId]:
"""Get a list of the motor controller nodes of all attached and ok devices."""
return motor_nodes(self._subsystem_manager.targets)
Expand Down Expand Up @@ -593,42 +597,60 @@ async def home(
]
async with self._monitor_overpressure(moving_pipettes):
positions = await asyncio.gather(*coros)
# TODO(CM): default gear motor homing routine to have some acceleration
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[
distance=self.axis_bounds[Axis.Q][1] - self.axis_bounds[Axis.Q][0],
velocity=self._configuration.motion_settings.max_speed_discontinuity.high_throughput[
Axis.to_kind(Axis.Q)
],
tip_action="home",
)
for position in positions:
self._handle_motor_status_response(position)
return axis_convert(self._position, 0.0)

def _filter_move_group(self, move_group: MoveGroup) -> MoveGroup:
new_group: MoveGroup = []
for step in move_group:
new_group.append(
{
node: axis_step
for node, axis_step in step.items()
if node in self._motor_nodes()
}
)
return new_group

async def tip_action(
caila-marashaj marked this conversation as resolved.
Show resolved Hide resolved
self,
axes: Sequence[Axis],
distance: float,
speed: float,
moves: Optional[List[Move[Axis]]] = None,
caila-marashaj marked this conversation as resolved.
Show resolved Hide resolved
distance: Optional[float] = None,
velocity: Optional[float] = None,
tip_action: str = "home",
back_off: Optional[bool] = False,
) -> None:
if tip_action == "home":
speed = speed * -1
runner = MoveGroupRunner(
move_groups=create_tip_action_home_group(axes, distance, speed)
move_group = []
# make sure either moves or distance and velocity is not None
assert any([moves, distance and velocity])
caila-marashaj marked this conversation as resolved.
Show resolved Hide resolved
if moves is not None:
move_group = create_tip_action_group(
moves, [NodeId.pipette_left], tip_action
)
else:
runner = MoveGroupRunner(
move_groups=[
create_tip_action_group(
axes, distance, speed, cast(PipetteAction, tip_action)
)
]
elif distance is not None and velocity is not None:
move_group = create_gear_motor_home_group(
float(distance), float(velocity), back_off
)

runner = MoveGroupRunner(
move_groups=[move_group],
ignore_stalls=True if not ff.stall_detection_enabled() else False,
)
positions = await runner.run(can_messenger=self._messenger)
for axis, point in positions.items():
self._position.update({axis: point[0]})
self._encoder_position.update({axis: point[1]})
if NodeId.pipette_left in positions:
caila-marashaj marked this conversation as resolved.
Show resolved Hide resolved
self._gear_motor_position = {
NodeId.pipette_left: positions[NodeId.pipette_left][0]
}

@requires_update
async def gripper_grip_jaw(
Expand Down
22 changes: 12 additions & 10 deletions api/src/opentrons/hardware_control/backends/ot3simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
create_gripper_jaw_hold_group,
create_gripper_jaw_grip_group,
create_gripper_jaw_home_group,
create_tip_action_group,
PipetteAction,
NODEID_SUBSYSTEM,
motor_nodes,
target_to_subsystem,
Expand Down Expand Up @@ -139,6 +137,7 @@ def __init__(
self._initialized = False
self._lights = {"button": False, "rails": False}
self._estop_state_machine = EstopStateMachine(detector=None)
self._gear_motor_position: Dict[NodeId, float] = {}

def _sanitize_attached_instrument(
mount: OT3Mount, passed_ai: Optional[Dict[str, Optional[str]]] = None
Expand Down Expand Up @@ -203,6 +202,10 @@ def initialized(self, value: bool) -> None:
def eeprom_data(self) -> EEPROMData:
return EEPROMData()

@property
def gear_motor_position(self) -> Dict[NodeId, float]:
return self._gear_motor_position

@property
def board_revision(self) -> BoardRevision:
"""Get the board revision"""
Expand Down Expand Up @@ -372,17 +375,15 @@ async def get_tip_present(self, mount: OT3Mount, tip_state: TipStateType) -> Non
"""Get the state of the tip ejector flag for a given mount."""
pass

@ensure_yield
async def tip_action(
self,
axes: Sequence[Axis],
distance: float = 33,
speed: float = -5.5,
tip_action: str = "drop",
moves: Optional[List[Move[Axis]]] = None,
distance: Optional[float] = None,
velocity: Optional[float] = None,
tip_action: str = "home",
back_off: Optional[bool] = False,
) -> None:
_ = create_tip_action_group(
axes, distance, speed, cast(PipetteAction, tip_action)
)
pass

def _attached_to_mount(
self, mount: OT3Mount, expected_instr: Optional[PipetteName]
Expand Down Expand Up @@ -528,6 +529,7 @@ def axis_bounds(self) -> OT3AxisMap[Tuple[float, float]]:
Axis.Y: phony_bounds,
Axis.X: phony_bounds,
Axis.Z_G: phony_bounds,
Axis.Q: phony_bounds,
}

@property
Expand Down
80 changes: 49 additions & 31 deletions api/src/opentrons/hardware_control/backends/ot3utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Shared utilities for ot3 hardware control."""
from typing import Dict, Iterable, List, Set, Tuple, TypeVar, Sequence, cast
from typing import Dict, Iterable, List, Set, Tuple, TypeVar, cast, Sequence, Optional
from typing_extensions import Literal
from logging import getLogger
from opentrons.config.defaults_ot3 import DEFAULT_CALIBRATION_AXIS_MAX_SPEED
Expand Down Expand Up @@ -228,13 +228,16 @@ def get_system_constraints(
) -> "SystemConstraints[Axis]":
conf_by_pip = config.by_gantry_load(gantry_load)
constraints = {}
for axis_kind in [
axis_kind_list = [
OT3AxisKind.P,
OT3AxisKind.X,
OT3AxisKind.Y,
OT3AxisKind.Z,
OT3AxisKind.Z_G,
]:
]
if gantry_load == GantryLoad.HIGH_THROUGHPUT:
axis_kind_list.append(OT3AxisKind.Q)
for axis_kind in axis_kind_list:
for axis in Axis.of_kind(axis_kind):
constraints[axis] = AxisConstraints.build(
conf_by_pip["acceleration"][axis_kind],
Expand Down Expand Up @@ -373,38 +376,53 @@ def create_home_groups(
return [home_group, backoff_group]


def create_tip_action_home_group(
axes: Sequence[Axis], distance: float, velocity: float
) -> List[MoveGroup]:
current_nodes = [axis_to_node(ax) for ax in axes]
home_group = [
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},
present_nodes=current_nodes,
action=PipetteTipActionType.home,
)
]

backoff_group = [
create_tip_action_backoff_step(
velocity={node_id: np.float64(velocity / 2) for node_id in current_nodes}
)
]
return [home_group, backoff_group]
def create_tip_action_group(
moves: Sequence[Move[Axis]],
present_nodes: Iterable[NodeId],
action: str,
) -> MoveGroup:
move_group: MoveGroup = []
for move in moves:
unit_vector = move.unit_vector
for block in move.blocks:
if block.time < (3.0 / interrupts_per_sec):
continue
velocities = unit_vector_multiplication(unit_vector, block.initial_speed)
accelerations = unit_vector_multiplication(unit_vector, block.acceleration)
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[Axis], distance: float, velocity: float, action: PipetteAction
def create_gear_motor_home_group(
distance: float,
velocity: float,
backoff: Optional[bool] = False,
) -> 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},
present_nodes=current_nodes,
action=PipetteTipActionType[action],
move_group: MoveGroup = []
home_step = create_tip_action_step(
velocity={NodeId.pipette_left: np.float64(-1 * velocity)},
acceleration={NodeId.pipette_left: np.float64(0)},
duration=np.float64(distance / velocity),
present_nodes=[NodeId.pipette_left],
action=PipetteTipActionType.home,
)
return [step]
move_group.append(home_step)

if backoff:
backoff_group = create_tip_action_backoff_step(
velocity={
node_id: np.float64(velocity / 2) for node_id in [NodeId.pipette_left]
}
)
move_group.append(backoff_group)
return move_group


def create_gripper_jaw_grip_group(
Expand Down
Loading
Loading