Skip to content

Commit

Permalink
fix(api): Speed up LLD by reducing the post-success raise. (#17102)
Browse files Browse the repository at this point in the history
<!--
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

Right now if we successfully detect liquid we raise (slowly) the entire
max pass distance. this takes a while, especially on the 96 channel
since it's calculated off the max plunger speed.
This reduces the post-success raise to the "safe plunger prep" distance
which we know is a safe distance from the liquid to prevent unwanted
capillary action or adhesion to the outside of the tip.

<!--
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 Dec 13, 2024
1 parent a7a84df commit 352e4ac
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ async def liquid_probe(
threshold_pascals: float,
plunger_impulse_time: float,
num_baseline_reads: int,
z_offset_for_plunger_prep: float,
probe: InstrumentProbeType = InstrumentProbeType.PRIMARY,
force_both_sensors: bool = False,
response_queue: Optional[PipetteSensorResponseQueue] = None,
Expand Down
2 changes: 2 additions & 0 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,7 @@ async def liquid_probe(
threshold_pascals: float,
plunger_impulse_time: float,
num_baseline_reads: int,
z_offset_for_plunger_prep: float,
probe: InstrumentProbeType = InstrumentProbeType.PRIMARY,
force_both_sensors: bool = False,
response_queue: Optional[PipetteSensorResponseQueue] = None,
Expand Down Expand Up @@ -1535,6 +1536,7 @@ def response_capture(data: Dict[SensorId, List[SensorDataType]]) -> None:
threshold_pascals=threshold_pascals,
plunger_impulse_time=plunger_impulse_time,
num_baseline_reads=num_baseline_reads,
z_offset_for_plunger_prep=z_offset_for_plunger_prep,
sensor_id=sensor_id_for_instrument(probe),
force_both_sensors=force_both_sensors,
emplace_data=response_capture,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ async def liquid_probe(
threshold_pascals: float,
plunger_impulse_time: float,
num_baseline_reads: int,
z_offset_for_plunger_prep: float,
probe: InstrumentProbeType = InstrumentProbeType.PRIMARY,
force_both_sensors: bool = False,
response_queue: Optional[PipetteSensorResponseQueue] = None,
Expand Down
3 changes: 3 additions & 0 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2677,6 +2677,7 @@ async def _liquid_probe_pass(
probe_settings: LiquidProbeSettings,
probe: InstrumentProbeType,
p_travel: float,
z_offset_for_plunger_prep: float,
force_both_sensors: bool = False,
response_queue: Optional[PipetteSensorResponseQueue] = None,
) -> float:
Expand All @@ -2689,6 +2690,7 @@ async def _liquid_probe_pass(
probe_settings.sensor_threshold_pascals,
probe_settings.plunger_impulse_time,
probe_settings.samples_for_baselining,
z_offset_for_plunger_prep,
probe=probe,
force_both_sensors=force_both_sensors,
response_queue=response_queue,
Expand Down Expand Up @@ -2838,6 +2840,7 @@ async def prep_plunger_for_probe_move(
probe_settings,
checked_probe,
plunger_travel_mm + sensor_baseline_plunger_move_mm,
z_offset_for_plunger_prep,
force_both_sensors,
response_queue,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ async def test_liquid_probe(
threshold_pascals=fake_liquid_settings.sensor_threshold_pascals,
plunger_impulse_time=fake_liquid_settings.plunger_impulse_time,
num_baseline_reads=fake_liquid_settings.samples_for_baselining,
z_offset_for_plunger_prep=2.0,
)
except PipetteLiquidNotFoundError:
# the move raises a liquid not found now since we don't call the move group and it doesn't
Expand Down
3 changes: 3 additions & 0 deletions api/tests/opentrons/hardware_control/test_ot3_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ async def test_liquid_probe(
fake_settings_aspirate.sensor_threshold_pascals,
fake_settings_aspirate.plunger_impulse_time,
fake_settings_aspirate.samples_for_baselining,
probe_safe_reset_mm,
probe=InstrumentProbeType.PRIMARY,
force_both_sensors=False,
response_queue=None,
Expand Down Expand Up @@ -1114,6 +1115,7 @@ async def test_multi_liquid_probe(
fake_settings_aspirate.sensor_threshold_pascals,
fake_settings_aspirate.plunger_impulse_time,
fake_settings_aspirate.samples_for_baselining,
2.0,
probe=InstrumentProbeType.PRIMARY,
force_both_sensors=False,
response_queue=None,
Expand Down Expand Up @@ -1149,6 +1151,7 @@ async def _fake_pos_update_and_raise(
threshold_pascals: float,
plunger_impulse_time: float,
num_baseline_reads: int,
z_offset_for_plunger_prep: float,
probe: InstrumentProbeType = InstrumentProbeType.PRIMARY,
force_both_sensors: bool = False,
response_queue: Optional[
Expand Down
4 changes: 3 additions & 1 deletion hardware/opentrons_hardware/hardware_control/tool_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ async def liquid_probe(
threshold_pascals: float,
plunger_impulse_time: float,
num_baseline_reads: int,
z_offset_for_plunger_prep: float,
sensor_id: SensorId = SensorId.S0,
force_both_sensors: bool = False,
emplace_data: Optional[
Expand Down Expand Up @@ -331,8 +332,9 @@ async def liquid_probe(
)
sensor_runner = MoveGroupRunner(move_groups=[[lower_plunger], [sensor_group]])

# Only raise the z a little so we don't do a huge slow travel
raise_z = create_step(
distance={head_node: float64(max_z_distance)},
distance={head_node: float64(z_offset_for_plunger_prep)},
velocity={head_node: float64(-1 * mount_speed)},
acceleration={},
duration=float64(max_z_distance / mount_speed),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def move_responder(
threshold_pascals=threshold_pascals,
plunger_impulse_time=0.2,
num_baseline_reads=20,
z_offset_for_plunger_prep=2.0,
sensor_id=SensorId.S0,
)
assert position[motor_node].positions_only()[0] == 14
Expand Down

0 comments on commit 352e4ac

Please sign in to comment.