Skip to content

Simplify saving the serving-area slot where the cup was placed#261

Merged
Nicolas Palpacuer (NickPPC) merged 3 commits into
viamrobotics:mainfrom
yao-stuy:delivery-pickup-slot
Jul 21, 2026
Merged

Simplify saving the serving-area slot where the cup was placed#261
Nicolas Palpacuer (NickPPC) merged 3 commits into
viamrobotics:mainfrom
yao-stuy:delivery-pickup-slot

Conversation

@yao-stuy

Copy link
Copy Markdown
Member

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.

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 thread coffee/espresso.go Outdated
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
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread coffee/iced.go Outdated
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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread coffee/espresso.go Outdated
"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),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@NickPPC
Nicolas Palpacuer (NickPPC) merged commit 324b12a into viamrobotics:main Jul 21, 2026
4 checks passed
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