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
pick up tip move happens, but rumbly
  • Loading branch information
caila-marashaj committed Jul 26, 2023
commit b4d4bee81799fa6c547326ab7b1359ab4bca25c6
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 @@ -104,7 +104,7 @@
OT3AxisKind.Z: 150,
OT3AxisKind.P: 30,
OT3AxisKind.Z_G: 150,
OT3AxisKind.Q: 10,
OT3AxisKind.Q: 4,
},
low_throughput={
OT3AxisKind.X: 800,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
from opentrons_hardware.hardware_control.motor_position_status import (
get_motor_position,
update_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
6 changes: 2 additions & 4 deletions api/src/opentrons/hardware_control/backends/ot3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,10 @@ 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):
for axis in OT3Axis.of_kind(axis_kind):
currents[axis] = CurrentConfig(
conf_by_pip["hold_current"][axis_kind],
conf_by_pip["run_current"][axis_kind],
Expand All @@ -227,7 +225,7 @@ def get_current_settings(
def get_system_constraints(
config: OT3MotionSettings,
gantry_load: GantryLoad,
) -> "SystemConstraints[Axis]":
) -> "SystemConstraints[OT3Axis]":
conf_by_pip = config.by_gantry_load(gantry_load)
constraints = {}
axis_kind = [
Expand Down
18 changes: 15 additions & 3 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,9 @@ 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 @@ -1679,25 +1682,32 @@ async def _motor_pick_up_tip(
await self._move(target_down)
# perform pick up tip

gear_origin_dict = {OT3Axis.Q: 0}
# 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_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.final_speed,
block.initial_speed,
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,
(pipette_spec.speed - 1),
0,
"home",
)
Expand Down Expand Up @@ -1776,12 +1786,14 @@ async def drop_tip(
[Axis.of_main_tool_actuator(mount)],
move.target_position,
move.speed,
0,
"clamp",
)
await self._backend.tip_action(
[Axis.of_main_tool_actuator(mount)],
move.target_position + move.home_buffer,
move.speed,
0,
"home",
)
else:
Expand Down
1 change: 1 addition & 0 deletions api/src/opentrons/hardware_control/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def of_kind(cls, kind: OT3AxisKind) -> List["Axis"]:
OT3AxisKind.Z_G: [cls.Z_G],
OT3AxisKind.Q: [cls.Q],
OT3AxisKind.OTHER: [cls.Q],
# OT3AxisKind.OTHER: [cls.G],
}
return kind_map[kind]

Expand Down
1 change: 1 addition & 0 deletions api/tests/opentrons/hardware_control/test_ot3_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ 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 @@ -17,6 +17,8 @@
MotorPositionResponse,
UpdateMotorPositionEstimationRequest,
UpdateMotorPositionEstimationResponse,
UpdateGearMotorPositionEstimationRequest,
UpdateGearMotorPositionEstimationResponse,
)
from opentrons_hardware.firmware_bindings.arbitration_id import ArbitrationId
from opentrons_hardware.firmware_bindings.constants import (
Expand Down Expand Up @@ -159,3 +161,66 @@ def _listener_filter(arbitration_id: ArbitrationId) -> bool:
)

return data


async def update_gear_motor_position_estimation(
can_messenger: CanMessenger, timeout: float = 1.0
) -> Tuple[float, bool]:
"""Updates the estimation of motor position on selected nodes.

Request node to update motor position from its encoder and respond
with updated motor and encoder status.
"""

def _listener_filter(arbitration_id: ArbitrationId) -> bool:
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(
_parser_update_gear_motor_position_response(
reader, NodeId.pipette_left
),
timeout,
)
data.append(response)
# make sure response from both gear motors is the same
assert data[0] == data[1]
print(f"data = {data}")
if not data[0][1] or not data[1][1]:
# If the stepper_ok flag isn't set, that means the node didn't update position.
raise RuntimeError(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should only be checking for a timeout error in this function. We should ensure that the motor position flag is set to not OK if the two gear motor positions don't match though.

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.

f"Failed to update motor position for node: {NodeId.pipette_left}"
)
except asyncio.TimeoutError:
log.warning("Update motor position estimation timed out")
raise StopAsyncIteration

return data[0]


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:
return (
float(response.payload.current_position.value / 1000.0),
bool(MotorPositionFlags.stepper_position_ok.value),
)
raise StopAsyncIteration
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def __init__(
"""
self._move_groups = move_groups
self._start_at_index = start_at_index
self._ignore_stalls = ignore_stalls
# self._ignore_stalls = ignore_stalls
self._ignore_stalls = True
self._is_prepped: bool = False

@staticmethod
Expand Down