Orchestration And Coordination

orchestration_and_coordination.py

Order queue + state gateway for a fleet of sushi-waiter robots

This node owns a persistent FIFO of customer orders (YAML on disk) and serves as the single gateway where each robot asks:

> “Given my current controller state, what do I do next?”

It exposes two services per robot namespace:

  • /{robot}/robot_state_decision – FSM step (state → action).

  • /{robot}/robot_state_decision_add – append a freshly verified order.

Interfaces (strongly-typed, stateful)

Kind

Name

ROS type

Notes

Service

/{robot}/robot_state_decision

tiago1/robotstatedecision

Request → state_input: str Response ← state_output, order, success

Service

/{robot}/robot_state_decision_add

tiago1/send_order

Push order (id_client, list_of_orders) into queue

Orchestration System Integration KPIs

Metric

Target

Task assignment latency (call to /robot_state_decision → response)

≤ 100 ms

Throughput (orders assigned per second)

≥ 20 orders/s

Conflict rate (duplicate table assignments)

< 1 %

Persistent storage

tiago_data.yaml (beside this script) keeps the queue:

orders:
  - id_client: 7
    food_list: [sushi, pasta]
  - id_client: 9
    food_list: [ramen]

File is re-loaded and re-saved on every service call → multiple nodes or manual edits always stay in sync.

Decision rules

  1. Queue empty → state_output="Wait" , success=False

  2. Queue non-empty and robot in Free or Wait → pop order, return it with state_output="Busy" , success=True

  3. Otherwise echo incoming state with success=False

class orchestration_and_coordination.BusyState[source]

Bases: State

Robot reports it has finished → flip back to Free.

handle(context, req)[source]
class orchestration_and_coordination.FreeState[source]

Bases: State

Idle → try to grab the next order, else go to Wait.

handle(context, req)[source]
class orchestration_and_coordination.State[source]

Bases: object

Abstract FSM state; subclasses must implement handle().

handle(context, req: tiago1.srv.robotstatedecisionRequest) tiago1.srv.robotstatedecisionResponse[source]
class orchestration_and_coordination.WaitState[source]

Bases: State

Waiting for an order; become Busy if one appears.

handle(context, req)[source]
class orchestration_and_coordination.orchestration_and_coordination[source]

Bases: object

Persistent order queue + multi-robot FSM helper.

yaml_path

Path to tiago_data.yaml.

Type:

str

robot_states

Per-robot FSM state objects.

Type:

dict[str, State]

data

In-memory YAML contents (orders list).

Type:

dict

handle_request(req: tiago1.srv.robotstatedecisionRequest)[source]

Dispatch to the current FSM state.

handle_request_new_order(req: tiago1.srv.send_order.Request) tiago1.srv.send_orderResponse[source]

Append new order from verifier into YAML queue.

load_data()[source]

Load order queue from disk (create file if absent).

obtain_order()[source]

Pop and return oldest order or None if queue empty.

save_data()[source]

Flush :pyattr:`data` back to YAML.

set_state(robot_id: str, state: State)[source]

Update FSM for robot_id.