Skip to content

Commit

Permalink
fix(hardware): correct duration calculation from the change in z-rais…
Browse files Browse the repository at this point in the history
…e post LLD success (#17434)

…as still raising too far out of the well

<!--
Thanks for taking the time to open a Pull Request (PR)! Please make sure
you've read the "Opening Pull Requests" section of our Contributing
Guide:


https://github.com/Opentrons/opentrons/blob/edge/CONTRIBUTING.md#opening-pull-requests

GitHub provides robust markdown to format your PR. Links, diagrams,
pictures, and videos along with text formatting make it possible to
create a rich and informative PR. For more information on GitHub
markdown, see:


https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

To ensure your code is reviewed quickly and thoroughly, please fill out
the sections below to the best of your ability!
-->

# Overview

We had updated the distance that the z raises after an LLD success but
did not update the duration calculation so the z was still raising too
far out of the liquid.

<!--
Describe your PR at a high level. State acceptance criteria and how this
PR fits into other work. Link issues, PRs, and other relevant resources.
-->

## Test Plan and Hands on Testing

<!--
Describe your testing of the PR. Emphasize testing not reflected in the
code. Attach protocols, logs, screenshots and any other assets that
support your testing.
-->

## Changelog

<!--
List changes introduced by this PR considering future developers and the
end user. Give careful thought and clear documentation to breaking
changes.
-->

## Review requests

<!--
- What do you need from reviewers to feel confident this PR is ready to
merge?
- Ask questions.
-->

## Risk assessment

<!--
- Indicate the level of attention this PR needs.
- Provide context to guide reviewers.
- Discuss trade-offs, coupling, and side effects.
- Look for the possibility, even if you think it's small, that your
change may affect some other part of the system.
- For instance, changing return tip behavior may also change the
behavior of labware calibration.
- How do your unit tests and on hands on testing mitigate this PR's
risks and the risk of future regressions?
- Especially in high risk PRs, explain how you know your testing is
enough.
-->
  • Loading branch information
ryanthecoder authored and TamarZanzouri committed Feb 11, 2025
1 parent 1bc27f2 commit 42a0492
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ async def liquid_probe(
distance={head_node: float64(z_offset_for_plunger_prep)},
velocity={head_node: float64(-1 * mount_speed)},
acceleration={},
duration=float64(max_z_distance / mount_speed),
duration=float64(z_offset_for_plunger_prep / mount_speed),
present_nodes=[head_node],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ReadFromSensorResponse,
Acknowledgement,
BindSensorOutputRequest,
AddLinearMoveRequest,
)
from opentrons_hardware.firmware_bindings.messages import MessageDefinition
from opentrons_hardware.firmware_bindings.messages.payloads import (
Expand Down Expand Up @@ -49,6 +50,7 @@
SensorThresholdMode,
SensorOutputBinding,
)
from opentrons_hardware.hardware_control.constants import interrupts_per_sec
from opentrons_hardware.sensors.scheduler import SensorScheduler
from opentrons_hardware.sensors.sensor_driver import SensorDriver
from opentrons_hardware.sensors.types import SensorDataType
Expand Down Expand Up @@ -214,6 +216,11 @@ def get_responder() -> Iterator[
yield check_third_move

responder_getter = get_responder()
z_offset_for_plunger_prep = 2.0
mount_speed = 10.0
expected_raise_duration = (
interrupts_per_sec * z_offset_for_plunger_prep / mount_speed
)

def move_responder(
node_id: NodeId, message: MessageDefinition
Expand All @@ -223,6 +230,12 @@ def move_responder(
responder = next(responder_getter)
return responder(node_id, message)
else:
if isinstance(message, AddLinearMoveRequest):
if message.payload.velocity_mm.value < 0:
# value < 0 means the raise z move
assert message.payload.duration.value == expected_raise_duration
velocity = int(-1 * mount_speed / interrupts_per_sec * 2**31)
assert message.payload.velocity_mm.value == velocity
return []

message_send_loopback.add_responder(move_responder)
Expand All @@ -232,12 +245,12 @@ def move_responder(
tool=target_node,
head_node=motor_node,
max_p_distance=70,
mount_speed=10,
mount_speed=mount_speed,
plunger_speed=8,
threshold_pascals=threshold_pascals,
plunger_impulse_time=0.2,
num_baseline_reads=20,
z_offset_for_plunger_prep=2.0,
z_offset_for_plunger_prep=z_offset_for_plunger_prep,
sensor_id=SensorId.S0,
)
assert position[motor_node].positions_only()[0] == 14
Expand Down

0 comments on commit 42a0492

Please sign in to comment.