-
Notifications
You must be signed in to change notification settings - Fork 179
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(api, robot-server, shared-data): add FlexStacker module to the hardware controller and robot server. #17187
Changes from 5 commits
a2cf1e3
d26ee40
be1a278
5865baa
2cf4b16
ce2b674
f1b0e69
18bdd62
83b5b7d
a6703e2
dc016e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from .abstract import AbstractStackerDriver | ||
from .abstract import AbstractFlexStackerDriver | ||
from .driver import FlexStackerDriver | ||
from .simulator import SimulatingDriver | ||
|
||
__all__ = [ | ||
"AbstractStackerDriver", | ||
"AbstractFlexStackerDriver", | ||
"FlexStackerDriver", | ||
"SimulatingDriver", | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from enum import Enum | ||
from dataclasses import dataclass, fields | ||
from typing import List | ||
from typing import List, Dict | ||
|
||
from opentrons.drivers.command_builder import CommandBuilder | ||
|
||
|
@@ -45,6 +45,14 @@ class StackerInfo: | |
hw: HardwareRevision | ||
sn: str | ||
|
||
def to_dict(self) -> Dict[str, str]: | ||
"""Build command.""" | ||
return { | ||
"serial": self.sn, | ||
"version": self.fw, | ||
"model": self.hw.value, | ||
} | ||
|
||
|
||
class StackerAxis(Enum): | ||
"""Stacker Axis.""" | ||
|
@@ -90,11 +98,11 @@ def distance(self, distance: float) -> float: | |
class LimitSwitchStatus: | ||
"""Stacker Limit Switch Statuses.""" | ||
|
||
XE: bool | ||
XR: bool | ||
ZE: bool | ||
ZR: bool | ||
LR: bool | ||
XE: bool = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The GCode that we use to get the limit switch statuses always return results for all axes. What are the reasoning behind having setting default values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes it easier to build the obj for testing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the data constraints should match real life, IMO, and not have defaults. if it's annoying to build for tests, we can make a helper function in the test file that does it. |
||
XR: bool = False | ||
ZE: bool = False | ||
ZR: bool = False | ||
LR: bool = False | ||
|
||
@classmethod | ||
def get_fields(cls) -> List[str]: | ||
|
@@ -116,8 +124,8 @@ def get(self, axis: StackerAxis, direction: Direction) -> bool: | |
class PlatformStatus: | ||
"""Stacker Platform Statuses.""" | ||
|
||
E: bool | ||
R: bool | ||
E: bool = False | ||
R: bool = False | ||
|
||
@classmethod | ||
def get_fields(cls) -> List[str]: | ||
|
@@ -128,6 +136,58 @@ def get(self, direction: Direction) -> bool: | |
"""Get platform status.""" | ||
return self.E if direction == Direction.EXTENT else self.R | ||
|
||
def to_dict(self) -> Dict[str, bool]: | ||
"""Dict of the data.""" | ||
return { | ||
"extent": self.E, | ||
"retract": self.R, | ||
} | ||
|
||
|
||
class PlatformState(Enum): | ||
UNKNOWN = "unknown" | ||
EXTENDED = "extended" | ||
RETRACTED = "retracted" | ||
|
||
@classmethod | ||
def from_status(cls, status: PlatformStatus) -> "PlatformState": | ||
"""Get the state from the platform status.""" | ||
if status.E and not status.R: | ||
return PlatformState.EXTENDED | ||
if status.R and not status.E: | ||
return PlatformState.RETRACTED | ||
return PlatformState.UNKNOWN | ||
|
||
|
||
class StackerAxisState(Enum): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice - I was actually planning on this exact logic of this in FW. So we can send a GCode querying the axis state, and it will return one of these strings. |
||
UNKNOWN = "unknown" | ||
EXTENDED = "extended" | ||
RETRACTED = "retracted" | ||
|
||
@classmethod | ||
def from_status( | ||
cls, status: LimitSwitchStatus, axis: StackerAxis | ||
) -> "StackerAxisState": | ||
"""Get the axis state from the limit switch status.""" | ||
match axis: | ||
case StackerAxis.X: | ||
if status.XE and not status.XR: | ||
return StackerAxisState.EXTENDED | ||
if status.XR and not status.XE: | ||
return StackerAxisState.RETRACTED | ||
case StackerAxis.Z: | ||
if status.ZE and not status.ZR: | ||
return StackerAxisState.EXTENDED | ||
if status.ZR and not status.ZE: | ||
return StackerAxisState.RETRACTED | ||
case StackerAxis.L: | ||
return ( | ||
StackerAxisState.EXTENDED | ||
if status.LR | ||
else StackerAxisState.RETRACTED | ||
) | ||
return StackerAxisState.UNKNOWN | ||
|
||
|
||
@dataclass | ||
class MoveParams: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we call this
prep_for_update()
or something that's more like what other modules use?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enter_programming_mode
is the lower-level driver function called by the module's higher-levelprep_for_update
function, which adheres to the rest of the modules.