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

feat(robot-server): Expose tip status in instruments #13160

Merged
merged 4 commits into from
Jul 27, 2023

Conversation

Laura-Danielle
Copy link
Contributor

@Laura-Danielle Laura-Danielle commented Jul 25, 2023

Overview

We are now exposing the tip presence status (which is only valid on the Flex) through the /instruments endpoint. Closes RSS-291

Test Plan

  • Test on Flex, make sure the instruments endpoint returns updated data for the tip presence. You can test this on a single/multi by pushed the ejector flag up. (This feature is NOT yet implemented on the 96 channel and so the data there cannot be trusted).

Changelog

  • Add a PipetteStateDict in the hardware controller. This is currently only used in the ot3api, but we can (and should) definitely expand on this state in the future
  • Add a separate get_instrument_state function in the ot3api.py which gets the current state of the tip ejector. Unfortunately we currently have to ask for the state each time this function is called because we currently don't have a state store for the hardware controller as it relates to specific hardware components (such as sensors).

Review requests

Does it look OK for now? Anything you want me to add and/or take away?

Risk assessment

Low. New feature add.

@Laura-Danielle Laura-Danielle requested review from a team and b-cooper and removed request for a team July 25, 2023 13:23
@Laura-Danielle Laura-Danielle requested a review from a team as a code owner July 25, 2023 13:23
@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Merging #13160 (a8c9ba7) into edge (76eece6) will not change coverage.
Report is 11 commits behind head on edge.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             edge   #13160   +/-   ##
=======================================
  Coverage   72.11%   72.11%           
=======================================
  Files        1531     1531           
  Lines       50773    50773           
  Branches     3144     3144           
=======================================
  Hits        36614    36614           
  Misses      13650    13650           
  Partials      509      509           
Flag Coverage Δ
g-code-testing 96.44% <ø> (ø)

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

Files Changed Coverage Δ
...entrons/hardware_control/backends/ot3controller.py 69.27% <ø> (ø)
...pentrons/hardware_control/backends/ot3simulator.py 86.88% <ø> (ø)
api/src/opentrons/hardware_control/dev_types.py 100.00% <ø> (ø)
api/src/opentrons/hardware_control/ot3api.py 79.66% <ø> (ø)

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Looks good to me, and tested on a Flex!

class PipetteState(BaseModel):
"""State from an attached pipette."""

tip_detected: bool = Field(
Copy link
Contributor

Choose a reason for hiding this comment

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

🐫-case for HTTP-facing field names.

Suggested change
tip_detected: bool = Field(
tipDetected: bool = Field(

@@ -217,6 +226,7 @@ def rehearse_instrument_retrievals() -> None:
last_modified=None,
),
),
state=PipetteState(tip_detected=True),
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
state=PipetteState(tip_detected=True),
state=PipetteState(tipDetected=True),

@@ -237,6 +247,7 @@ def rehearse_instrument_retrievals() -> None:
last_modified=None,
),
),
state=PipetteState(tip_detected=False),
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
state=PipetteState(tip_detected=False),
state=PipetteState(tipDetected=False),

Comment on lines 84 to 100
class PipetteState(BaseModel):
"""State from an attached pipette."""

tip_detected: bool = Field(
None,
description="Physical state of the tip photointerrupter on the Flex. Null for OT-2",
)


class Pipette(_GenericInstrument[PipetteModel, PipetteData]):
"""Attached pipette info & configuration."""

instrumentType: Literal["pipette"] = "pipette"
instrumentName: PipetteName
instrumentModel: PipetteModel
data: PipetteData
state: Optional[PipetteState]
Copy link
Contributor

Choose a reason for hiding this comment

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

Confirmed in-person with @sanni-t:

Instead of what's written now, where tipDetected is inside data.state:

{
  "data": {
    "instrumentType": "pipette",
    "data": {
      "calibratedOffset": { /* ... */ }
      // ..
    }
    "state": {
        "tipDetected": true
    }
    // ...
  },
  "meta": { /* ... */ }
}

We'd like data.state to not exist, and tipDetected to be directly inside the existing data.data, like this:

{
  "data": {
    "instrumentType": "pipette",
    "data": {
      "calibratedOffset": { /* ... */ }
      "tipDetected": true
      // ...
    }
    // ...
  },
  "meta": { /* ... */ }
}

This is consistent with a gripper's jawState, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just because it's consistent doesn't mean we should stick with what we've previously done. IMO jawState should also go into a similarly named state component of the body returned from /instruments -- though obviously let's not address that till post launch. I've already got sign off on this from JS devs.

tipDetected is in fact active state about the pipette whereas things listed in data can be considered "stored" state (albeit it can change from time to time but no where near as frequently as data).

@Laura-Danielle Laura-Danielle merged commit 54a1275 into edge Jul 27, 2023
25 checks passed
@Laura-Danielle Laura-Danielle deleted the RSS-291-expose-tip-status-instruments branch July 27, 2023 19:01
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.

4 participants