Simplify saving the serving-area slot where the cup was placed#261
Merged
Nicolas Palpacuer (NickPPC) merged 3 commits intoJul 21, 2026
Merged
Conversation
Return the 0-based slot from placeHeldInServingArea (and through placeFullCupOnShelf / serveIcedCoffee) and set it on the order in the serving step, instead of re-deriving it from servingAreaSlotCounter in a separate deliveryPickupPosition helper. The slot is known exactly at placement, so this drops the helper and its extra geometry lookup. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Comment on lines
+230
to
+239
| // discardSlot adapts a placement function that reports its serving slot to the | ||
| // plain action signature — a standalone action has no order to attach the slot | ||
| // to, so it's dropped (only the brew cycle keeps it, for delivery pickup_position). | ||
| func discardSlot(fn func(ctx, cancelCtx context.Context) (int, error)) func(ctx, cancelCtx context.Context) error { | ||
| return func(ctx, cancelCtx context.Context) error { | ||
| _, err := fn(ctx, cancelCtx) | ||
| return err | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Suggested change
| // discardSlot adapts a placement function that reports its serving slot to the | |
| // plain action signature — a standalone action has no order to attach the slot | |
| // to, so it's dropped (only the brew cycle keeps it, for delivery pickup_position). | |
| func discardSlot(fn func(ctx, cancelCtx context.Context) (int, error)) func(ctx, cancelCtx context.Context) error { | |
| return func(ctx, cancelCtx context.Context) error { | |
| _, err := fn(ctx, cancelCtx) | |
| return err | |
| } | |
| } |
We will not be adding this it is too confusing. We can inline it for the relevant actions
| func (s *beanjaminCoffee) serveIcedCoffee(ctx, cancelCtx context.Context) (int, error) { | ||
| if s.gripper == nil { | ||
| return fmt.Errorf("serve_iced_coffee: no gripper configured") | ||
| return 0, fmt.Errorf("serve_iced_coffee: no gripper configured") |
There was a problem hiding this comment.
Suggested change
| return 0, fmt.Errorf("serve_iced_coffee: no gripper configured") | |
| return -1, fmt.Errorf("serve_iced_coffee: no gripper configured") |
We should use invalid values on error
| "brew_coffee": s.brewCoffee, | ||
| "set_cup_for_coffee": s.setCupForCoffee, | ||
| "give_full_cup_to_customer": s.placeFullCupOnShelf, | ||
| "give_full_cup_to_customer": discardSlot(s.placeFullCupOnShelf), |
There was a problem hiding this comment.
Suggested change
| "give_full_cup_to_customer": discardSlot(s.placeFullCupOnShelf), | |
| "give_full_cup_to_customer": func(ctx, cancelCtx context.Context) error{ | |
| _, err := discardSlot(s.placeFullCupOnShelf) | |
| return err | |
| } |
- Drop the discardSlot helper; the three placement actions (give_full_cup_to_customer, place_held, serve_iced_coffee) inline a closure that calls the placement function and returns only the error. - Return -1 (an invalid slot) instead of 0 on the error paths of placeHeldInServingArea, placeFullCupOnShelf, and serveIcedCoffee. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Nicolas Palpacuer (NickPPC)
approved these changes
Jul 17, 2026
Nicolas Palpacuer (NickPPC)
merged commit Jul 21, 2026
324b12a
into
viamrobotics:main
4 checks passed
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.
Return the slot from placeHeldInServingArea (and through placeFullCupOnShelf / serveIcedCoffee) and set it on the order in the serving step, instead of re-deriving it from servingAreaSlotCounter in a separate deliveryPickupPosition helper. The slot is known exactly at placement.