Skip to content

Commit

Permalink
use actual trash height for deck conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
jbleon95 committed Feb 28, 2024
1 parent 0f9874a commit 89a1f43
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
5 changes: 2 additions & 3 deletions api/src/opentrons/motion_planning/deck_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class TrashBin:
"""A non-labware trash bin (loaded via api level 2.16 and above)."""

name_for_errors: str
highest_z: float


@dataclass
Expand Down Expand Up @@ -138,9 +139,7 @@ def is_allowed(self, item: DeckItem) -> bool:
elif isinstance(item, _Module):
return item.highest_z_including_labware < self.max_height
elif isinstance(item, TrashBin):
# Since this is a restriction for OT-2 only and OT-2 trashes exceeded the height limit, always return False
# TODO(jbl 2024-01-16) Include trash height and use that for check for more robustness
return False
return item.highest_z < self.max_height


class _NoModule(NamedTuple):
Expand Down
7 changes: 6 additions & 1 deletion api/src/opentrons/protocol_api/_disposal_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# 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"


Expand Down Expand Up @@ -92,6 +93,10 @@ def __init__(
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."""
Expand Down Expand Up @@ -142,7 +147,7 @@ def height(self) -> float:
This is intended for Opentrons internal use only and is not a guaranteed API.
"""
return self._engine_client.state.addressable_areas.get_fixture_height(
_TRASH_BIN_CUTOUT_FIXTURE
self._cutout_fixture_name
)


Expand Down
4 changes: 3 additions & 1 deletion api/src/opentrons/protocol_api/core/engine/deck_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ def _map_disposal_location(
if isinstance(disposal_location, TrashBin):
return (
disposal_location.location,
wrapped_deck_conflict.TrashBin(name_for_errors="trash bin"),
wrapped_deck_conflict.TrashBin(
name_for_errors="trash bin", highest_z=disposal_location.height
),
)
else:
return None
Expand Down
4 changes: 2 additions & 2 deletions api/tests/opentrons/motion_planning/test_deck_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_flex_trash_bin_blocks_thermocycler() -> None:
highest_z_including_labware=123,
is_semi_configuration=False,
)
trash = deck_conflict.TrashBin(name_for_errors="some_trash_bin")
trash = deck_conflict.TrashBin(name_for_errors="some_trash_bin", highest_z=1.23)

with pytest.raises(
deck_conflict.DeckConflictError,
Expand Down Expand Up @@ -539,7 +539,7 @@ def test_heater_shaker_restrictions_trash_bin_addressable_area() -> None:
heater_shaker = deck_conflict.HeaterShakerModule(
highest_z_including_labware=123, name_for_errors="some_heater_shaker"
)
trash = deck_conflict.TrashBin(name_for_errors="some_trash_bin")
trash = deck_conflict.TrashBin(name_for_errors="some_trash_bin", highest_z=456)

with pytest.raises(
deck_conflict.DeckConflictError,
Expand Down
16 changes: 13 additions & 3 deletions api/tests/opentrons/protocol_api/core/engine/test_deck_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
from opentrons.motion_planning.adjacent_slots_getters import _MixedTypeSlots
from opentrons.protocols.api_support.types import APIVersion
from opentrons.protocol_api import MAX_SUPPORTED_VERSION
from opentrons.protocol_api._disposal_locations import TrashBin, WasteChute
from opentrons.protocol_api._disposal_locations import (
TrashBin,
WasteChute,
_TRASH_BIN_CUTOUT_FIXTURE,
)
from opentrons.protocol_api.labware import Labware
from opentrons.protocol_api.core.engine import deck_conflict
from opentrons.protocol_engine import (
Expand Down Expand Up @@ -347,6 +351,12 @@ def test_maps_trash_bins(
"""It should correctly map disposal locations."""
mock_trash_lw = decoy.mock(cls=Labware)

decoy.when(
mock_sync_client.state.addressable_areas.get_fixture_height(
_TRASH_BIN_CUTOUT_FIXTURE
)
).then_return(1.23)

deck_conflict.check(
engine_state=mock_state_view,
existing_labware_ids=[],
Expand All @@ -372,11 +382,11 @@ def test_maps_trash_bins(
wrapped_deck_conflict.check(
existing_items={
DeckSlotName.SLOT_B1: wrapped_deck_conflict.TrashBin(
name_for_errors="trash bin",
name_for_errors="trash bin", highest_z=1.23
)
},
new_item=wrapped_deck_conflict.TrashBin(
name_for_errors="trash bin",
name_for_errors="trash bin", highest_z=1.23
),
new_location=DeckSlotName.SLOT_A1,
robot_type=mock_state_view.config.robot_type,
Expand Down

0 comments on commit 89a1f43

Please sign in to comment.