-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hardware): add csv file logging capability to capacitive_probe m…
…ethod (#14785) <!-- 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! --> # Overview This PR, along with Opentrons/ot3-firmware#768, adds csv file logging capability to the capacitive_probe ot3api method. This work utilizes the work that adds the same capability to the liquid_probe process. The MoveGroupSingleAxisStep, AddSensorLinearMoveRequest, and SendAccumulatedSensorDataRequest classes were modified to include a sensor_type data field. The capacitive_probe_ot3_tunable script was added for testing. <!-- Use this section to describe your pull-request at a high level. If the PR addresses any open issues, please tag the issues here. --> # Test Plan <!-- 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 --> - [x] Ran script without csv logging and detected saltwater liquid height - [x] Ran script with csv loffing and detected saltwater liquid height # Changelog <!-- 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 --> # Review requests <!-- Describe any requests for your reviewers here. --> # Risk assessment <!-- 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
1 parent
a1921c7
commit b2c6390
Showing
23 changed files
with
442 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,4 +160,5 @@ opentrons-robot-app.tar.gz | |
# asdf versions file | ||
.tool-versions | ||
mock_dir | ||
.npm-cache/ | ||
.eslintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
hardware-testing/hardware_testing/examples/capacitive_probe_ot3_tunable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
"""Capacitive probe OT3.""" | ||
import argparse | ||
import asyncio | ||
|
||
from opentrons.config.types import CapacitivePassSettings, OutputOptions | ||
from opentrons.hardware_control.ot3api import OT3API | ||
from opentrons.hardware_control.types import InstrumentProbeType | ||
|
||
from hardware_testing.opentrons_api import types | ||
from hardware_testing.opentrons_api import helpers_ot3 | ||
|
||
# distance added to the pipette shaft | ||
# when the calibration probe is attached | ||
PROBE_LENGTH = 34.5 | ||
|
||
# the capacitive readings need to be stable <0.1 | ||
# before probing anything | ||
STABLE_CAP_PF = 0.1 | ||
|
||
# capacitance relative threshold in picofarads | ||
CAP_REL_THRESHOLD_PF = 10.0 | ||
|
||
# ideally these values come from either: | ||
# 1) the API config file | ||
# 2) or, found through manually jogging | ||
# The Z is different from the XY probing location | ||
# because the pipette cannot reach the bottom of the | ||
# cutout, so we cannot probe the Z inside the cutout | ||
ASSUMED_Z_LOCATION = types.Point(x=228, y=150, z=80) # C2 slot center | ||
ASSUMED_XY_LOCATION = types.Point(x=228, y=150, z=ASSUMED_Z_LOCATION.z) | ||
|
||
# configure how the probing motion behaves | ||
# capacitive_probe will always automatically do the following: | ||
# 1) move to the "prep" distance away from the assumed location | ||
# 2) set the capacitive threshold | ||
# a) the value is sent over CAN to the pipette's MCU | ||
# b) the pipette will trigger the SYNC line when the threshold is reached | ||
# 3) move along the specified axis, at the specified speed | ||
# a) the max distance probed = prep + max_overrun | ||
# 4) movement will stop when (either/or): | ||
# a) the sensor is triggered | ||
# b) or, the max distance is reached | ||
# 5) move to the "prep" distance away from the assumed location | ||
PROBE_SETTINGS_Z_AXIS = CapacitivePassSettings( | ||
prep_distance_mm=10, | ||
max_overrun_distance_mm=3, | ||
speed_mm_per_s=1, | ||
sensor_threshold_pf=CAP_REL_THRESHOLD_PF, | ||
output_option=OutputOptions.sync_only, | ||
) | ||
PROBE_SETTINGS_Z_AXIS_OUTPUT = CapacitivePassSettings( | ||
prep_distance_mm=10, | ||
max_overrun_distance_mm=3, | ||
speed_mm_per_s=1, | ||
sensor_threshold_pf=CAP_REL_THRESHOLD_PF, | ||
output_option=OutputOptions.sync_buffer_to_csv, | ||
data_files={InstrumentProbeType.PRIMARY: "/data/capacitive_sensor_data.csv"}, | ||
) | ||
|
||
|
||
async def _probe_sequence(api: OT3API, mount: types.OT3Mount, stable: bool) -> float: | ||
z_ax = types.Axis.by_mount(mount) | ||
|
||
print("Align the XY axes above Z probe location...") | ||
home_pos_z = helpers_ot3.get_endstop_position_ot3(api, mount)[z_ax] | ||
await api.move_to(mount, ASSUMED_Z_LOCATION._replace(z=home_pos_z)) | ||
|
||
if stable: | ||
await helpers_ot3.wait_for_stable_capacitance_ot3( | ||
api, mount, threshold_pf=STABLE_CAP_PF, duration=1.0 | ||
) | ||
found_z, _ = await api.capacitive_probe( | ||
mount, z_ax, ASSUMED_Z_LOCATION.z, PROBE_SETTINGS_Z_AXIS | ||
) | ||
print(f"Found deck Z location = {found_z} mm") | ||
return found_z | ||
|
||
|
||
async def _main(is_simulating: bool, cycles: int, stable: bool) -> None: | ||
api = await helpers_ot3.build_async_ot3_hardware_api( | ||
is_simulating=is_simulating, pipette_left="p1000_single_v3.3" | ||
) | ||
mount = types.OT3Mount.LEFT | ||
if not api.hardware_pipettes[mount.to_mount()]: | ||
raise RuntimeError("No pipette attached") | ||
|
||
# add length to the pipette, to account for the attached probe | ||
await api.add_tip(mount, PROBE_LENGTH) | ||
|
||
await helpers_ot3.home_ot3(api) | ||
for c in range(cycles): | ||
print(f"Cycle {c + 1}/{cycles}") | ||
await _probe_sequence(api, mount, stable) | ||
|
||
# move up, "remove" the probe, then disengage the XY motors when done | ||
z_ax = types.Axis.by_mount(mount) | ||
top_z = helpers_ot3.get_endstop_position_ot3(api, mount)[z_ax] | ||
await api.move_to(mount, ASSUMED_XY_LOCATION._replace(z=top_z)) | ||
await api.remove_tip(mount) | ||
await api.disengage_axes([types.Axis.X, types.Axis.Y]) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--simulate", action="store_true") | ||
parser.add_argument("--cycles", type=int, default=1) | ||
parser.add_argument("--stable", type=bool, default=True) | ||
args = parser.parse_args() | ||
asyncio.run(_main(args.simulate, args.cycles, args.stable)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.