-
Notifications
You must be signed in to change notification settings - Fork 175
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
Changes from 1 commit
95d068b
b4d4bee
bdea049
782a760
73d26bf
c3e044a
a85074e
1952348
fa194a3
d2e7927
2b20a20
8cf3c15
7e5b7ef
8ace0ef
155738b
0aede03
97e12e9
1550c9a
735ebe7
af1eefa
e2280aa
5be4492
93ef4ca
f1a42d1
2b71f07
57bb955
e201a43
6eb76e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ( | ||
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
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