-
Notifications
You must be signed in to change notification settings - Fork 178
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): allow custom user offsets for deck configured trash bins and waste chute #14560
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5720db3
initial draft of trash/waste chute offset
jbleon95 0dbf280
move trash loading more to core
jbleon95 434b4b4
make engine based append internal only
jbleon95 4f5930a
move disposal locations to new singular file
jbleon95 5fd4a9f
inject engine client into disposal locations
jbleon95 2506328
height property and more/updated doc strings
jbleon95 1db7176
refactor adding disposal addressable area to engine
jbleon95 6904ac0
more unit test coverage
jbleon95 0ee1995
only alternate tip drop location if supplying not trash automatically
jbleon95 0f9874a
include api version in trash objects
jbleon95 89a1f43
use actual trash height for deck conflict
jbleon95 55f8058
Merge branch 'edge' of https://github.com/Opentrons/opentrons into di…
jbleon95 acdd0c7
more unit tests
jbleon95 76c80dc
docstrings for top() methods
ecormany 627bf5e
publish TrashBin and WasteChute public members
ecormany cbb7fb8
make disposal_locations public and not public stuff inside private
jbleon95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing_extensions import Protocol as TypingProtocol | ||
|
||
from opentrons.types import DeckSlotName | ||
from opentrons.protocols.api_support.types import APIVersion | ||
from opentrons.protocol_engine.clients import SyncClient | ||
|
||
|
||
# TODO(jbl 2024-02-26) these are hardcoded here since there is a 1 to many relationship going from | ||
# addressable area names to cutout fixture ids. Currently for trash and waste chute this would not be | ||
# an issue (trash has only one fixture that provides it, all waste chute fixtures are the same height). | ||
# The ultimate fix for this is a multiple pass analysis, so for now these are being hardcoded to avoid | ||
# writing cumbersome guessing logic for area name -> fixture name while still providing a direct link to | ||
# the numbers in shared data. | ||
_TRASH_BIN_CUTOUT_FIXTURE = "trashBinAdapter" | ||
_TRASH_BIN_OT2_CUTOUT_FIXTURE = "fixedTrashSlot" | ||
_WASTE_CHUTE_CUTOUT_FIXTURE = "wasteChuteRightAdapterCovered" | ||
|
||
|
||
@dataclass(frozen=True) | ||
class DisposalOffset: | ||
x: float | ||
y: float | ||
z: float | ||
|
||
|
||
class DisposalLocation(TypingProtocol): | ||
"""Abstract class for disposal location.""" | ||
|
||
def top(self, x: float = 0, y: float = 0, z: float = 0) -> DisposalLocation: | ||
"""Returns a disposal location with a user set offset.""" | ||
... | ||
|
||
@property | ||
def offset(self) -> DisposalOffset: | ||
"""Offset of the disposal location. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
... | ||
|
||
@property | ||
def location(self) -> DeckSlotName: | ||
"""Location of the disposal location. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
... | ||
|
||
@property | ||
def area_name(self) -> str: | ||
"""Addressable area name of the disposal location. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
... | ||
|
||
@property | ||
def height(self) -> float: | ||
"""Height of the disposal location. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
... | ||
|
||
|
||
class TrashBin(DisposalLocation): | ||
"""Represents a Flex or OT-2 trash bin. | ||
|
||
See :py:meth:`.ProtocolContext.load_trash_bin`. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
location: DeckSlotName, | ||
addressable_area_name: str, | ||
engine_client: SyncClient, | ||
api_version: APIVersion, | ||
offset: DisposalOffset = DisposalOffset(x=0, y=0, z=0), | ||
) -> None: | ||
self._location = location | ||
self._addressable_area_name = addressable_area_name | ||
self._offset = offset | ||
self._api_version = api_version | ||
self._engine_client = engine_client | ||
if self._engine_client.state.config.robot_type == "OT-2 Standard": | ||
self._cutout_fixture_name = _TRASH_BIN_OT2_CUTOUT_FIXTURE | ||
else: | ||
self._cutout_fixture_name = _TRASH_BIN_CUTOUT_FIXTURE | ||
|
||
def top(self, x: float = 0, y: float = 0, z: float = 0) -> TrashBin: | ||
"""Returns a trash bin with a user set offset.""" | ||
return TrashBin( | ||
location=self._location, | ||
addressable_area_name=self._addressable_area_name, | ||
engine_client=self._engine_client, | ||
api_version=self._api_version, | ||
offset=DisposalOffset(x=x, y=y, z=z), | ||
) | ||
|
||
@property | ||
def offset(self) -> DisposalOffset: | ||
"""Current offset of the trash bin.. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
return self._offset | ||
|
||
@property | ||
def location(self) -> DeckSlotName: | ||
"""Location of the trash bin. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
return self._location | ||
|
||
@property | ||
def area_name(self) -> str: | ||
"""Addressable area name of the trash bin. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
return self._addressable_area_name | ||
|
||
@property | ||
def height(self) -> float: | ||
"""Height of the trash bin. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
return self._engine_client.state.addressable_areas.get_fixture_height( | ||
self._cutout_fixture_name | ||
) | ||
|
||
|
||
class WasteChute(DisposalLocation): | ||
"""Represents a Flex waste chute. | ||
|
||
See :py:meth:`.ProtocolContext.load_waste_chute`. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
engine_client: SyncClient, | ||
api_version: APIVersion, | ||
offset: DisposalOffset = DisposalOffset(x=0, y=0, z=0), | ||
) -> None: | ||
self._engine_client = engine_client | ||
self._api_version = api_version | ||
self._offset = offset | ||
|
||
def top(self, x: float = 0, y: float = 0, z: float = 0) -> WasteChute: | ||
"""Returns a waste chute with a user set offset.""" | ||
return WasteChute( | ||
engine_client=self._engine_client, | ||
api_version=self._api_version, | ||
offset=DisposalOffset(x=x, y=y, z=z), | ||
) | ||
|
||
@property | ||
def offset(self) -> DisposalOffset: | ||
"""Current offset of the waste chute. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
return self._offset | ||
|
||
@property | ||
def location(self) -> DeckSlotName: | ||
"""Location of the waste chute. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
return DeckSlotName.SLOT_D3 | ||
|
||
@property | ||
def area_name(self) -> str: | ||
"""Addressable area name of the waste chute. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
# TODO(jbl 2024-02-06) this is hardcoded here and should be removed when a multiple pass analysis exists | ||
# | ||
# We want to tell Protocol Engine that there's a waste chute in the waste chute location when it's loaded, | ||
# so analysis can prevent the user from doing anything that would collide with it. At the same time, we | ||
# do not want to create a false negative when it comes to addressable area conflict. We therefore use the | ||
# addressable area `1ChannelWasteChute` because every waste chute cutout fixture provides it and it will | ||
# provide the engine with the information it needs. | ||
return "1ChannelWasteChute" | ||
|
||
@property | ||
def height(self) -> float: | ||
"""Height of the waste chute. | ||
|
||
:meta private: | ||
|
||
This is intended for Opentrons internal use only and is not a guaranteed API. | ||
""" | ||
return self._engine_client.state.addressable_areas.get_fixture_height( | ||
_WASTE_CHUTE_CUTOUT_FIXTURE | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can we change this name? maybe disposale_location?