Skip to content
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

Move to start calibration position #11478

Merged
merged 51 commits into from
Oct 26, 2022

Conversation

caila-marashaj
Copy link
Contributor

@caila-marashaj caila-marashaj commented Sep 19, 2022

New command for moving the gantry before and after calibration. Parameter CalibrationSetUpPositions lets the user move either to the middle of the deck for starting to probe, or the front for putting on and taking off the probe attachment. I'm using Deck Slot 2 for the front, and Deck Slot 5 for the middle, can anyone just confirm that these deck slots are the correct ones for those positions?

Note: I have a comment in the files changed section attached to an argument value I wasn't sure about- please take a look!

@caila-marashaj caila-marashaj requested a review from a team as a code owner September 19, 2022 17:46
pipette_id=params.pipetteId,
deck_coordinates=slot_center_deck,
direct=True,
additional_min_travel_z=0,
Copy link
Contributor Author

@caila-marashaj caila-marashaj Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should this parameter additional_min_travel_z be used? I put 0 in there temporarily, but I'm not sure what a reasonable value for this is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an optional param, let's not set it and rely on motion_planning/ to handle any arc movement z minimums -- which is what this is used for. You can check out opentrons/motion_planning/ and protocol_engine/state/motion.py for further info.

@codecov
Copy link

codecov bot commented Sep 19, 2022

Codecov Report

Merging #11478 (5fc8b64) into edge (7825a89) will increase coverage by 1.94%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #11478      +/-   ##
==========================================
+ Coverage   75.01%   76.95%   +1.94%     
==========================================
  Files        2059      679    -1380     
  Lines       57481    11775   -45706     
  Branches     5999     2989    -3010     
==========================================
- Hits        43122     9062   -34060     
+ Misses      12950     1767   -11183     
+ Partials     1409      946     -463     
Flag Coverage Δ
api ?
components ?
g-code-testing ?
hardware ?
hardware-testing ?
labware-library ?
notify-server 88.26% <ø> (ø)
ot3-gravimetric-test ?
protocol-designer ?
react-api-client ?
robot-server ?
shared-data ?
step-generation ?
update-server ?
usb-bridge ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...entrons/protocol_engine/commands/command_unions.py
.../opentrons_hardware/firmware_bindings/constants.py
...bot-server/robot_server/service/session/manager.py
step-generation/src/fixtures/data.ts
app-shell/src/buildroot/index.ts
step-generation/src/utils/orderWells.ts
api/src/opentrons/config/pipette_config.py
...elds/ChangeTipField/getDisabledChangeTipOptions.ts
...defs/tempdeck/set_temp_g_code_functionality_def.py
protocol-designer/src/ui/labware/selectors.ts
... and 1370 more

Copy link
Contributor

@Laura-Danielle Laura-Danielle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a few initial comments. Also, I know we kept changing what the command was actually going to do, but I thought we had landed on making a generalized "move to location" command.

We should probably have this command take in an enum of sorts to specify what location to actual move to i.e.:

  1. probe position
  2. attach/de-attach probe position

We can add in an optional slot param as well and default to center slot for the probe position specifically. Can pair on this if you want.

api/Makefile Outdated
@@ -208,4 +208,4 @@ term:

.PHONY: plot-session
plot-session:
$(python) util/plot_session.py $(plot_type) $(plot_type).pdf
$(python) util/plot_session.py $(plot_type) $(plot_type).pdf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental change here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do:

git checkout origin/edge api/Makefile
git checkout origin/edge api/src/opentrons/protocol_engine/commands/__init__.py

To undo these stray formatting changes.

direct=True,
additional_min_travel_z=0,
)
return CalibrationSetUpPositionResult()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to return a position here, right?

slot_center = self._state_view.labware.get_slot_center_position(
params.slot_name
)
slot_center_deck = DeckPoint(x=slot_center.x, y=slot_center.y, z=slot_center.z)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a safety margin to the z component of the slot_center_deck. I think 3mm is probably OK for now.

pipette_id=params.pipetteId,
deck_coordinates=slot_center_deck,
direct=True,
additional_min_travel_z=0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an optional param, let's not set it and rely on motion_planning/ to handle any arc movement z minimums -- which is what this is used for. You can check out opentrons/motion_planning/ and protocol_engine/state/motion.py for further info.

@@ -226,6 +226,7 @@ def get_slot_position(self, slot: DeckSlotName) -> Point:
def get_slot_center_position(self, slot: DeckSlotName) -> Point:
"""Get the (x, y, z) position of the center of the slot."""
slot_def = self.get_slot_definition(slot)
print("slot def =", slot_def)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidentally left print statement here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still have a print statement here.

from opentrons.protocol_engine.execution import MovementHandler
from opentrons.protocol_engine.state.state import StateView

CalibrationSetUpPositionCommandType = Literal["CalibrationSetUpPosition"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CalibrationSetUpPositionCommandType = Literal["CalibrationSetUpPosition"]
CalibrationSetUpPositionCommandType = Literal["calibrationSetUpPosition"]

Copy link
Contributor

@TamarZanzouri TamarZanzouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! nice job! a few changes but overall looks great! let me know if you need help

@caila-marashaj caila-marashaj requested a review from a team as a code owner September 20, 2022 15:54
api/Makefile Outdated Show resolved Hide resolved
@caila-marashaj caila-marashaj force-pushed the move-to-start-calibration-position branch from a62fee4 to 14c1c0a Compare September 22, 2022 17:16
@caila-marashaj caila-marashaj requested a review from a team as a code owner October 3, 2022 19:18
@caila-marashaj caila-marashaj requested review from a team, brenthagen and ahiuchingau and removed request for a team October 3, 2022 19:18
Copy link
Contributor

@Laura-Danielle Laura-Danielle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good! Let's pair on the last big change which is utilizing the LabwareView class to get the correct coordinates from the deck definition in shared-data.

"""Calibration set up position command parameters."""

slot_name: CalibrationPositions = Field(
CalibrationPositions.probe_position,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this a required parameter Field(..., description=...)

api/Makefile Outdated
@@ -208,4 +208,4 @@ term:

.PHONY: plot-session
plot-session:
$(python) util/plot_session.py $(plot_type) $(plot_type).pdf
$(python) util/plot_session.py $(plot_type) $(plot_type).pdf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

@property
def location(self) -> DeckPoint:
"""Assign location value to CalibrationPositions with a 3mm safety margin."""
if self.value == 5:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the LabwareView class from the protocol engine to get the initial slot coordinates and then apply our own offsets as necessary. LabwareView has the functions get_slot_center_position and get_slot_definition which will be very useful.

We can then be more agnostic about what robot we might be 'moving to'

Copy link
Contributor

@Laura-Danielle Laura-Danielle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more changes that should be made. We also need to test this on a robot before merging.

@@ -175,6 +175,22 @@ async def move_relative(
position=DeckPoint(x=point.x, y=point.y, z=point.z),
)

# async def get_gantry_position(self, pipette_id: str) -> Point:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out function, what was the point of this?

@@ -226,6 +226,7 @@ def get_slot_position(self, slot: DeckSlotName) -> Point:
def get_slot_center_position(self, slot: DeckSlotName) -> Point:
"""Get the (x, y, z) position of the center of the slot."""
slot_def = self.get_slot_definition(slot)
print("slot def =", slot_def)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still have a print statement here.

def offset(self) -> Point:
"""Return offset values for the given position."""
if self.value == 5:
return Point(x=float(10), y=float(0), z=float(3))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these wrapped in floats? Also can we make these DeckPoints instead (see https://github.com/Opentrons/opentrons/pull/11567/files) where we're trying to avoid types from hardware controller or top level types.

pipette_id: str,
position_id: str,
) -> SavedPositionData:
"""Return a SavedPositionData object."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As practice, we generally keep mock functions inside the test themselves if it's only being used by one test.

from opentrons.protocol_engine.types import DeckPoint


probe_position = SavedPositionData(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you move the test functions, you can also move these global variables to be inside the test as well.

Copy link
Contributor

@Laura-Danielle Laura-Danielle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty for your hard work on this! Excited to see it on the robot.

@caila-marashaj caila-marashaj force-pushed the move-to-start-calibration-position branch from a7a5c0c to d72d81c Compare October 26, 2022 16:41
@caila-marashaj caila-marashaj merged commit 790dfbe into edge Oct 26, 2022
@caila-marashaj caila-marashaj deleted the move-to-start-calibration-position branch October 26, 2022 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants