Skip to content

Commit

Permalink
feat(hardware-testing): enable multi sensor processing in liquid probe (
Browse files Browse the repository at this point in the history
#14883)

<!--
Thanks for taking the time to open a pull request! 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

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

This allows the liquid level detection script to tell the pipette to
buffer the data from both pipettes and fetch them afterwards,
it will now spit out seprate CSVs for each sensor. post processing not
yet updated so the final report just grabs one from each trial, will
implement in EXEC-268

<!--
Use this section to describe your pull-request at a high level. If the
PR addresses any open issues, please tag the issues here.
-->

<!--
Use this section to describe the steps that you took to test your Pull
Request.
If you did not perform any testing provide justification why.

OT-3 Developers: You should default to testing on actual physical
hardware.
Once again, if you did not perform testing against hardware, justify
why.

Note: It can be helpful to write a test plan before doing development

Example Test Plan (HTTP API Change)

- Verified that new optional argument `dance-party` causes the robot to
flash its lights, move the pipettes,
then home.
- Verified that when you omit the `dance-party` option the robot homes
normally
- Added protocol that uses `dance-party` argument to G-Code Testing
Suite
- Ran protocol that did not use `dance-party` argument and everything
was successful
- Added unit tests to validate that changes to pydantic model are
correct

-->

<!--
List out the changes to the code in this PR. Please try your best to
categorize your changes and describe what has changed and why.

Example changelog:
- Fixed app crash when trying to calibrate an illegal pipette
- Added state to API to track pipette usage
- Updated API docs to mention only two pipettes are supported

IMPORTANT: MAKE SURE ANY BREAKING CHANGES ARE PROPERLY COMMUNICATED
-->

<!--
Describe any requests for your reviewers here.
-->

<!--
Carefully go over your pull request and look at the other parts of the
codebase it may affect. 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 in protocol may also change the
behavior of labware calibration.

Identify the other parts of the system your codebase may affect, so that
in addition to your own review and testing, other people who may not
have the system internalized as much as you can focus their attention
and testing there.
-->
  • Loading branch information
ryanthecoder authored and Carlos-fernandez committed Jun 3, 2024
1 parent 3406b70 commit b572bcb
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 33 deletions.
4 changes: 4 additions & 0 deletions api/src/opentrons/config/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,15 @@ class LiquidProbeSettings:
aspirate_while_sensing: bool
auto_zero_sensor: bool
num_baseline_reads: int
<<<<<<< HEAD
<<<<<<< HEAD
data_files: Optional[Dict[InstrumentProbeType, str]]
=======
data_file: Optional[str]
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
data_files: Optional[Dict[InstrumentProbeType, str]]
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))


@dataclass(frozen=True)
Expand Down
4 changes: 4 additions & 0 deletions api/src/opentrons/hardware_control/backends/flex_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,15 @@ async def liquid_probe(
plunger_speed: float,
threshold_pascals: float,
output_format: OutputOptions = OutputOptions.can_bus_only,
<<<<<<< HEAD
<<<<<<< HEAD
data_files: Optional[Dict[InstrumentProbeType, str]] = None,
=======
data_file: Optional[str] = None,
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
data_files: Optional[Dict[InstrumentProbeType, str]] = None,
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
auto_zero_sensor: bool = True,
num_baseline_reads: int = 10,
probe: InstrumentProbeType = InstrumentProbeType.PRIMARY,
Expand Down
14 changes: 14 additions & 0 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,11 +1357,15 @@ async def liquid_probe(
plunger_speed: float,
threshold_pascals: float,
output_option: OutputOptions = OutputOptions.can_bus_only,
<<<<<<< HEAD
<<<<<<< HEAD
data_files: Optional[Dict[InstrumentProbeType, str]] = None,
=======
data_file: Optional[str] = None,
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
data_files: Optional[Dict[InstrumentProbeType, str]] = None,
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
auto_zero_sensor: bool = True,
num_baseline_reads: int = 10,
probe: InstrumentProbeType = InstrumentProbeType.PRIMARY,
Expand All @@ -1383,6 +1387,9 @@ async def liquid_probe(
output_option.value & OutputOptions.can_bus_only.value
)
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
data_files_transposed = (
None
if data_files is None
Expand All @@ -1391,8 +1398,11 @@ async def liquid_probe(
for probe in data_files.keys()
}
)
<<<<<<< HEAD
=======
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
positions = await liquid_probe(
messenger=self._messenger,
tool=tool,
Expand All @@ -1404,11 +1414,15 @@ async def liquid_probe(
csv_output=csv_output,
sync_buffer_output=sync_buffer_output,
can_bus_only_output=can_bus_only_output,
<<<<<<< HEAD
<<<<<<< HEAD
data_files=data_files_transposed,
=======
data_file=data_file,
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
data_files=data_files_transposed,
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
auto_zero_sensor=auto_zero_sensor,
num_baseline_reads=num_baseline_reads,
sensor_id=sensor_id_for_instrument(probe),
Expand Down
4 changes: 4 additions & 0 deletions api/src/opentrons/hardware_control/backends/ot3simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,15 @@ async def liquid_probe(
plunger_speed: float,
threshold_pascals: float,
output_format: OutputOptions = OutputOptions.can_bus_only,
<<<<<<< HEAD
<<<<<<< HEAD
data_files: Optional[Dict[InstrumentProbeType, str]] = None,
=======
data_file: Optional[str] = None,
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
data_files: Optional[Dict[InstrumentProbeType, str]] = None,
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
auto_zero_sensor: bool = True,
num_baseline_reads: int = 10,
probe: InstrumentProbeType = InstrumentProbeType.PRIMARY,
Expand Down
4 changes: 4 additions & 0 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2623,11 +2623,15 @@ async def liquid_probe(
(probe_settings.plunger_speed * plunger_direction),
probe_settings.sensor_threshold_pascals,
probe_settings.output_option,
<<<<<<< HEAD
<<<<<<< HEAD
probe_settings.data_files,
=======
probe_settings.data_file,
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
probe_settings.data_files,
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
probe_settings.auto_zero_sensor,
probe_settings.num_baseline_reads,
probe=probe if probe else InstrumentProbeType.PRIMARY,
Expand Down
4 changes: 4 additions & 0 deletions api/tests/opentrons/hardware_control/test_ot3_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,11 +820,15 @@ async def test_liquid_probe(
(fake_settings_aspirate.plunger_speed * -1),
fake_settings_aspirate.sensor_threshold_pascals,
fake_settings_aspirate.output_option,
<<<<<<< HEAD
<<<<<<< HEAD
fake_settings_aspirate.data_files,
=======
fake_settings_aspirate.data_file,
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
fake_settings_aspirate.data_files,
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
fake_settings_aspirate.auto_zero_sensor,
fake_settings_aspirate.num_baseline_reads,
probe=InstrumentProbeType.PRIMARY,
Expand Down
12 changes: 12 additions & 0 deletions hardware-testing/hardware_testing/liquid_sense/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,19 @@ def run(tip: int, run_args: RunArgs) -> None:
lpc_offset = run_args.dial_indicator.read_stable()
run_args.pipette._retract()

<<<<<<< HEAD
def _get_tip_offset() -> float:
=======
def _get_baseline() -> float:
run_args.pipette.pick_up_tip(tips[0])
del tips[: run_args.pipette_channels]
liquid_height = _jog_to_find_liquid_height(
run_args.ctx, run_args.pipette, test_well
)
target_height = test_well.bottom(liquid_height).point.z

run_args.pipette._retract()
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
tip_offset = 0.0
if run_args.dial_indicator is not None:
run_args.pipette.move_to(dial_well.top())
Expand Down
11 changes: 11 additions & 0 deletions hardware/opentrons_hardware/hardware_control/move_group_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
MoveAckId,
<<<<<<< HEAD
MotorDriverErrorCode,
<<<<<<< HEAD
=======
SensorId,
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
)
from opentrons_hardware.drivers.can_bus.can_messenger import CanMessenger
from opentrons_hardware.firmware_bindings.messages import MessageDefinition
Expand Down Expand Up @@ -314,10 +317,14 @@ def _get_stepper_motor_message(
return HomeRequest(payload=home_payload)
elif step.move_type == MoveType.sensor:
# stop_condition = step.stop_condition.value
<<<<<<< HEAD
<<<<<<< HEAD
assert step.sensor_id is not None
=======
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
assert step.sensor_id is not None
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
stop_condition = MoveStopCondition.sync_line
sensor_move_payload = AddSensorLinearMoveBasePayload(
request_stop_condition=MoveStopConditionField(stop_condition),
Expand All @@ -338,11 +345,15 @@ def _get_stepper_motor_message(
velocity_mm=Int32Field(
int((step.velocity_mm_sec / interrupts_per_sec) * (2**31))
),
<<<<<<< HEAD
<<<<<<< HEAD
sensor_id=SensorIdField(step.sensor_id),
=======
sensor_id=SensorIdField(SensorId.S0),
>>>>>>> 7995d78c39 (refactor(hardware): give options for sensor data output during probe (#14673))
=======
sensor_id=SensorIdField(step.sensor_id),
>>>>>>> b3b65dfc27 (feat(hardware-testing): enable multi sensor processing in liquid probe (#14883))
)
return AddSensorLinearMoveRequest(payload=sensor_move_payload)
else:
Expand Down
Loading

0 comments on commit b572bcb

Please sign in to comment.