Reasoning Order Verification

reasoning_order_verification.py

Overview

reasoning_order_verification.py is the natural-language gatekeeper that stands between automatic speech recognition (ASR) and the orchestration layer.

Workflow

  1. ASR sentence arrives on /{robot}/voice_recogn.

  2. The node validates the text:

    • contains the polite fragment “Can I have”

    • mentions at least one item from food_list

  3. If valid → build a structured :pyclass:`tiago1.msg.Voice_rec` order, publish it to the task-manager and push the same order into the shared orchestration queue via the /robot_state_decision_add service.

  4. If invalid → emit an integer error code on the interaction error channel.

Interfaces (strongly-typed, stateless)

Direction

Name

ROS type

Notes

Required

/{robot}/voice_recogn

std_msgs/String

Raw ASR text, e.g. "Can I have sushi please".

Provided

/{robot}/verif_T_manager

tiago1/Voice_rec

Structured, validated order (id + list_of_orders).

Provided

/{robot}/error_from_interaction

std_msgs/Int32

1 → unknown dish  2 → missing “Can I have”.

Service client

/{robot}/robot_state_decision_add

tiago1/send_order

Appends the order to the orchestration FIFO.

Order Verification & Error Handling KPIs

Metric

Target

Verification latency (/voice_recogn/verif_T_manager)

≤ 200 ms

Dish-match recall (valid dishes recognized)

≥ 98 %

Error-handling coverage (mis-orders triggering error code)

≥ 95 %

Validation policy

  • Syntax guard – sentence must include “Can I have”.

  • Menu match – at least one substring from food_list must be present.

  • Multi-dish support – all matches packed into a single order message.

Error codes

1 – no recognised dish

2 – polite fragment missing Both are recoverable; waiter simply prompts the customer to repeat.

class reasoning_order_verification.ReasoningOrderVerification(server_robots: int, food_list: list[str])[source]

Bases: object

Parse spoken orders → validate → publish structured order or error code.

Variables

server_clientrospy.ServiceProxy

Link to /{robot}/robot_state_decision_add (FIFO enqueue).

food_listlist[str]

Canonical dish names; matching is substring-based (case-sensitive).

msgstd_msgs.msg.String | None

Latest ASR sentence waiting to be parsed.

counter_idint

Auto-incremented ticket number for each accepted order.

parse_order()[source]

Validate :pyattr:`self.msg`; publish order or error.

Called once per second from the main loop.

string_callback(msg: std_msgs.msg.String)[source]

Cache latest ASR string for validation in main loop.