Skip to content

Commit

Permalink
configure trash on decks (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickwierenga authored Jan 3, 2025
1 parent b4ff02c commit b0da084
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- put_direction -> drop_direction
- `location` parameter of `assign_child_resource` is not optional (https://github.com/PyLabRobot/pylabrobot/pull/336)
- `Resource.get_absolute_location` raises `NoLocationError` instead of `AssertionError` when absolute location is not defined (https://github.com/PyLabRobot/pylabrobot/pull/338)
- `no_trash` and `no_teaching_rack` were renamed to `with_trash` and `with_teaching_rack` to avoid double negatives (https://github.com/PyLabRobot/pylabrobot/pull/347)

### Added

Expand Down Expand Up @@ -143,6 +144,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- `hotel_high_speed=False`
- `use_unsafe_hotel: bool = False`
- `iswap_collision_control_level: int = 0`
- `with_trash96` on `HamiltonSTARDeck` so there is more fine grained control (https://github.com/PyLabRobot/pylabrobot/pull/347)

### Deprecated

Expand Down
41 changes: 35 additions & 6 deletions pylabrobot/resources/hamilton/hamilton_decks.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def serialize(self) -> dict:
return {
**super().serialize(),
"num_rails": self.num_rails,
"no_trash": True, # data encoded as child. (not very pretty to have this key though...)
"with_trash": False, # data encoded as child. (not very pretty to have this key though...)
"with_trash96": False,
}

def _check_safe_z_height(self, resource: Resource):
Expand Down Expand Up @@ -356,8 +357,11 @@ def __init__(
name="deck",
category: str = "deck",
origin: Coordinate = Coordinate.zero(),
no_trash: bool = False,
no_teaching_rack: bool = False,
with_trash: bool = True,
with_trash96: bool = True,
with_teaching_rack: bool = True,
no_trash: Optional[bool] = None,
no_teaching_rack: Optional[bool] = None,
) -> None:
"""Create a new STAR(let) deck of the given size."""

Expand All @@ -371,8 +375,15 @@ def __init__(
origin=origin,
)

if no_trash is not None:
raise NotImplementedError("no_trash is deprecated. Use with_trash=False instead.")
if no_teaching_rack is not None:
raise NotImplementedError(
"no_teaching_rack is deprecated. Use with_teaching_rack=False instead."
)

# assign trash area
if not no_trash:
if with_trash:
trash_x = (
size_x - 560
) # only tested on STARLet, assume STAR is same distance from right max..
Expand All @@ -382,14 +393,16 @@ def __init__(
location=Coordinate(x=trash_x, y=190.6, z=137.1),
) # z I am not sure about

self._trash96: Optional[Trash] = None
if with_trash96:
# got this location from a .lay file, but will probably need to be adjusted by the user.
self._trash96 = Trash("trash_core96", size_x=82.6, size_y=122.4, size_z=0) # size of tiprack
self.assign_child_resource(
resource=self._trash96,
location=Coordinate(x=-232.1, y=110.3, z=189.0),
) # 165.0 -> 189.0

if not no_teaching_rack:
if with_teaching_rack:
teaching_carrier = Resource(name="teaching_carrier", size_x=30, size_y=445.2, size_z=100)
tip_spots = [
TipSpot(
Expand Down Expand Up @@ -423,19 +436,26 @@ def __init__(
def serialize(self) -> dict:
return {
**super().serialize(),
"no_teaching_rack": True, # data encoded as child. (not very pretty to have this key though...)
"with_teaching_rack": False, # data encoded as child. (not very pretty to have this key though...)
}

def rails_to_location(self, rails: int) -> Coordinate:
x = 100.0 + (rails - 1) * _RAILS_WIDTH
return Coordinate(x=x, y=63, z=100)

def get_trash_area96(self) -> Trash:
if self._trash96 is None:
raise RuntimeError(
"Trash area for 96-well plates was not created. Initialize with `with_trash96=True`."
)
return self._trash96


def STARLetDeck(
origin: Coordinate = Coordinate.zero(),
with_trash: bool = True,
with_trash96: bool = True,
with_teaching_rack: bool = True,
) -> HamiltonSTARDeck:
"""Create a new STARLet deck.
Expand All @@ -448,11 +468,17 @@ def STARLetDeck(
size_y=STARLET_SIZE_Y,
size_z=STARLET_SIZE_Z,
origin=origin,
with_trash=with_trash,
with_trash96=with_trash96,
with_teaching_rack=with_teaching_rack,
)


def STARDeck(
origin: Coordinate = Coordinate.zero(),
with_trash: bool = True,
with_trash96: bool = True,
with_teaching_rack: bool = True,
) -> HamiltonSTARDeck:
"""Create a new STAR deck.
Expand All @@ -465,4 +491,7 @@ def STARDeck(
size_y=STAR_SIZE_Y,
size_z=STAR_SIZE_Z,
origin=origin,
with_trash=with_trash,
with_trash96=with_trash96,
with_teaching_rack=with_teaching_rack,
)
4 changes: 2 additions & 2 deletions pylabrobot/resources/hamilton/vantage_decks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(
name="deck",
category: str = "deck",
origin: Coordinate = Coordinate.zero(),
no_trash: bool = False,
with_trash: bool = True,
) -> None:
"""Create a new Vantage deck of the given size.
Expand All @@ -41,7 +41,7 @@ def __init__(
)
self.size = 1.3

if not no_trash:
if with_trash:
trash_x = size_x - 480 # works with vantage 1.3 (480) (used to be 460)

# an experimentally informed guess.
Expand Down
4 changes: 2 additions & 2 deletions pylabrobot/resources/opentrons/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(
size_y: float = 565.2,
size_z: float = 900,
origin: Coordinate = Coordinate(0, 0, 0),
no_trash: bool = False,
with_trash: bool = True,
name: str = "deck",
):
# size_z is probably wrong
Expand All @@ -40,7 +40,7 @@ def __init__(
Coordinate(x=265.0, y=271.5, z=0.0),
]

if not no_trash:
if with_trash:
self._assign_trash()

def _assign_trash(self):
Expand Down
5 changes: 3 additions & 2 deletions pylabrobot/visualizer/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ class HamiltonSTARDeck extends Deck {
...super.serialize(),
...{
num_rails: this.num_rails,
no_trash: true,
with_trash: false,
with_trash96: false,
},
};
}
Expand Down Expand Up @@ -547,7 +548,7 @@ class OTDeck extends Deck {
return {
...super.serialize(),
...{
no_trash: true,
with_trash: false,
},
};
}
Expand Down

0 comments on commit b0da084

Please sign in to comment.