Report why an action failed instead of a bare "action failed"

FrameSamplerActionHandler already builds a precise reason for each way it can
fail: too few samples, detection too scattered, could not publish the output
frame, raw frame never appeared. All four reached the log as the same four
words, because control_loop read the tick, kept only the status, and dropped
the message, while the state machine passed a hard-coded string to finish().

Three field runs in a row could not be diagnosed for that reason: the detector
was healthy, the host confirmed pallet_raw was published and resolvable, and
the only thing navigation said was "action failed".

The handler message now travels through StateMachineInput into the terminal
reason, so it reaches the host feedback as well as the log, and control_loop
logs it directly - as an error when the action fails, as info when it succeeds,
where it carries the sample count worth comparing against the next failure.

StateMachineOutput::reason is a const char* and enter() stores the pointer
rather than copying, so the composed string lives in a StateMachine member.
Building it in a local would return a pointer into destroyed memory - every
other reason in that class is a string literal, so nothing had hit this before.
Two tests cover it: the message reaches the reason, and the reason survives the
StateMachineInput that carried it.

Config in this tree follows the same split as the robot: per-marker dock_anchor
and footprint_dock in maker_sources.yaml, detect handlers separated into
detect_charger and detect_pallet.
This commit is contained in:
2026-08-13 15:01:48 +07:00
parent d10c240395
commit 383a04fe29
11 changed files with 234 additions and 15 deletions

View File

@@ -60,27 +60,27 @@ maker_sources: trolley charger dock_station pallet
docking_marker_profiles:
trolley:
global_planner: DockPlanner
local_planner: HybridLocalPlanner
local_planner: StanleyDockingLocalPlanner
# Goal ở trọng tâm xe trolley (robot chui gầm) → cộng extent tâm→mặt từ footprint_dock.
dock_anchor: center
footprint_dock: [[0.583,-0.48],[0.583,0.48],[-0.583,0.48],[-0.583,-0.48]]
charger:
global_planner: TwoPointsPlanner
local_planner: HybridLocalPlanner
local_planner: StanleyDockingLocalPlanner
# Goal teach ngay tâm mặt trạm sạc. Chỉ có tác dụng nếu đổi sang DockPlanner.
dock_anchor: face
footprint_dock: [[0.583,-0.48],[0.583,0.48],[-0.583,0.48],[-0.583,-0.48]]
dock_station:
global_planner: TwoPointsPlanner
local_planner: HybridLocalPlanner
local_planner: StanleyDockingLocalPlanner
dock_anchor: center
footprint_dock: [[0.583,-0.48],[0.583,0.48],[-0.583,0.48],[-0.583,-0.48]]
pallet:
global_planner: DockPlanner
local_planner: HybridLocalPlanner
local_planner: StanleyDockingLocalPlanner
# Goal teach ở tâm mặt pallet → dock không đóng góp khoảng dừng, footprint_dock bị bỏ qua.
dock_anchor: face
footprint_dock: [[0.9,-0.8],[0.9,0.8],[-0.9,0.8],[-0.9,-0.8]]