Skip to content

OTDeck: model slots as resource holders and render them in the visualizer#1131

Merged
BioCam merged 7 commits into
PyLabRobot:mainfrom
BioCam:ot2-deck-slot-holders
Jul 7, 2026
Merged

OTDeck: model slots as resource holders and render them in the visualizer#1131
BioCam merged 7 commits into
PyLabRobot:mainfrom
BioCam:ot2-deck-slot-holders

Conversation

@BioCam

@BioCam BioCam commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Models the OT-2 deck's 12 slots as ResourceHolder children inset onto the deck plate corner, and updates the visualizer to draw those holders.

Modelling each slot as a holder gives it a real location and a single child (its labware), so placement, serialization, and slot lookup all go through the holder instead of ad-hoc deck math. The visualizer then renders each slot from its holder - an occupied slot shows its labware, an empty one shows the slot number on top - and finds the deck by type (instanceof Deck) rather than a hardcoded name.

Foundation of the OT-2 series; depends on nothing else in it.

🤖 Generated with Claude Code

@BioCam BioCam changed the title OTDeck: model slots as resource holders, inset onto the plate corner OTDeck: model slots as resource holders and render them in the visualizer Jun 30, 2026
Comment thread pylabrobot/visualizer/lib.js Outdated
Comment thread pylabrobot/visualizer/lib.js Outdated
BioCam and others added 6 commits July 2, 2026 23:56
Model the 12 slots as ResourceHolder children (one per slot) so the deck geometry has
a single source of truth that serializes and renders like the rest of PLR, instead of
a bare coordinate list paralleled by hardcoded grids elsewhere.

Re-base the slots onto the deck plate corner (the Opentrons cornerOffsetFromOrigin of
115.65, 68.03), so they sit correctly inside the plate rather than flush in the
front-left. Set size_z to 0 to match the flat reference surface, and size slot 12's
holder to the fixed-trash footprint (172.86 x 165.86 x 82) since the trash overhangs a
standard slot. Default deck name is now ot2_deck.

`OpentronsOT2Backend`: convert deck-frame coordinates to the robot frame before issuing
moves, which cancels the inset so real hardware moves are unchanged; and walk
holder->deck for the slot lookup now that labware sits in a holder. Deserializing a deck
saved before slots were holders now errors loudly rather than misplacing labware.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
assign_child_resource replaced the existing slot holder via list.index(existing), but `existing`
is typed Resource (not ResourceHolder), which mypy rejected. Find it by identity with an enumerate
loop instead; behaviour is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…so mypy passes

The serialize/deserialize test indexed loaded.slots[6]/[3] (typed Resource | None) directly for
.name and get_slot; bind them and assert non-None first. Behaviour unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Now that OTDeck's slots are ResourceHolder children, draw them from the serialized
resource tree like any other holder instead of a hardcoded slot grid. Drop the deck
`location` override that double-counted the plate-corner offset (labware was rendering
and measuring one slot-offset too far). Slot-number labels are inset to match the
holders and drawn on top of empty slots only, so labware in an occupied slot is shown
instead of being covered.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Trash renderer and the drag-snapping helpers looked up `resources["deck"]`,
assuming the deck is named "deck". Renaming the OT-2 deck to ot2_deck left that lookup
undefined, so `Trash.drawMainShape` read `undefined.constructor` and crashed the whole
render (blank canvas and empty tree).

Add a `getDeck()` helper that finds the deck by `instanceof Deck` and route all three
call sites through it, so the visualizer is robust to any deck name. The Trash stays
hidden whenever a deck is present, as before.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@BioCam BioCam force-pushed the ot2-deck-slot-holders branch from f4b5b22 to 77338f8 Compare July 2, 2026 23:04
@rickwierenga

Copy link
Copy Markdown
Member

this has conflicts but otherwise good to merge

@BioCam BioCam merged commit 243d594 into PyLabRobot:main Jul 7, 2026
21 checks passed
@BioCam BioCam deleted the ot2-deck-slot-holders branch July 7, 2026 09:04
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.

2 participants