OTDeck: model slots as resource holders and render them in the visualizer#1131
Merged
Conversation
OTDeck: model slots as resource holders, inset onto the plate cornerOTDeck: model slots as resource holders and render them in the visualizer
rickwierenga
reviewed
Jul 2, 2026
rickwierenga
reviewed
Jul 2, 2026
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>
f4b5b22 to
77338f8
Compare
Member
|
this has conflicts but otherwise good to merge |
# Conflicts: # pylabrobot/visualizer/lib.js
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Models the OT-2 deck's 12 slots as
ResourceHolderchildren 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