Files
move_base2/config/runtime/stanley_local_planner_params.yaml
duongtd 383a04fe29 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.
2026-08-13 15:01:48 +07:00

303 lines
18 KiB
YAML

LocalPlannerAdapter:
library_path: liblocal_planner_adapter
yaw_goal_tolerance: 0.017
xy_goal_tolerance: 0.03
min_approach_linear_velocity: 0.06
StanleyLocalPlanner:
library_path: libstanley_local_planner
# ============================================================================
# PROFILE MO PHONG (move_base2 runtime). Khac profile robot that
# (stanley_local_planner/cfg/...) dung 3 diem:
# steer_zero_offset 0.0 | heading_bias_mode "off" | steer_bias_gain 0.0
# (sim khong co zero servo / IMU anchor -> cac bo bu tat het)
# max_plan_tf_jump_rate 1.5 (dynamic TF sim jitter chu dich, 0.6 gay reset oan)
# ============================================================================
# ================= Robot limits =================
max_vel_x: 0.50 # [m/s] forward, > 0
min_vel_x: -0.25 # [m/s] reverse, < 0
wheel_base: 0.0 # [m] 0 = derive from TF front_axle_frame -> rear_axle_frame
front_axle_frame: "steer_link"
rear_axle_frame: "base_link"
# Two SEPARATE steering limits.
# Path tracking must not use a large angle: forward_vel_ scales with cos(delta) so it
# collapses to speed_base, and vel_steer = v/cos(steer) is guarded to 0 as cos -> 0.
# Pivoting in place uses the full 90 deg the hardware has.
steer_limit_standstill: 1.5708 # [rad] TO BE MEASURED - ceiling at |v| ~ 0
steer_limit_at_max_vel: 0.5000 # [rad] TO BE MEASURED - ceiling at |v| = max_vel_x
align_steer_angle: 1.5708 # [rad] steering while pivoting. Literal number, NOT M_PI/2
min_steer_angle: 0.20 # [rad] threshold for "steering is engaged"
max_steer_rate: 1.00 # [rad/s] measured by [DBG-STEER] 07/08: servo peak 1.08-1.35
# Measured zero offset of the steering channel, ADDED to every command.
# 05/08 log: robot driving straight while the encoder read +0.0373 rad (2.1 deg)
# -> the proportional law paid for it with a standing 5-8 cm cross-track error.
# BRIDGE until the servo encoder zero is calibrated; set back to 0.0 after that.
steer_zero_offset: 0.0 # [rad]
# ================= Goal tolerance =================
xy_goal_tolerance: 0.030 # [m] should match LocalPlannerAdapter
yaw_goal_tolerance: 0.020 # [rad]
goal_sq_dist_tol: 0.05 # [m^2] early exit of the closest-point scan
# ================= Control law (Stanley) =================
path_yaw_mode: "tangent" # tangent | bearing - "bearing" is the old behaviour, kept for rollback
control_gain_e: 2.0 # heading gain (path tangent - robot yaw)
control_gain_d: 1.5 # base cross-track gain
gain_cte_weight: 0.8 # added to k per |cross-track error| [1/m]
gain_heading_weight: 0.5 # added to k per |heading error| [1/rad]
gain_min: 0.5 # lower clamp of k
gain_max: 1.8 # upper clamp of k
soft_min_vel: 0.20 # [m/s] FLOOR of the atan2(k*e, v) denominator. NO ceiling
alpha_gain: 0.0 # steering low-pass [0..1]; 0 = off, max_steer_rate is used instead
curve_gain_e_bonus: 2.0 # added to control_gain_e in curve mode
tangent_window_pts: 3 # points averaged for the tangent when the plan carries no yaw
# Curve tracking rework (08/08): cross-track error is measured at the BASE in both
# directions (front-axle variants manufacture an L^2/2R curve phantom - the robot
# cut INSIDE curves forward and drifted OUTSIDE in reverse); the heading reference
# previews a short distance ahead symmetrically; the curve itself is carried by an
# explicit atan(L*kappa) feedforward. Swept optimum in sim (R=1.5/3.0, both
# directions): max error 0.013-0.016 m vs 0.061/0.129 before.
heading_preview: 0.10 # [m] heading (tangent) reference ahead of the base anchor
curve_feedforward_gain: 1.0 # atan(L*kappa) gain; 0 = OFF (rollback), 1.0 = geometric nominal
# ================= Heading bias (yawR - course, measured +0.030 rad 07/08) =========
# The yaw estimate leads the actual course by a constant that RE-ANCHORS differently
# every session (IMU absolute anchor), so it is learned online from course-over-ground
# instead of configured. A steering offset cannot compensate this: the heading
# REFERENCE is wrong, not the actuator.
heading_bias_mode: "off" # off = disabled
# log = estimate only, [DBG-YAWBIAS] prints the calib number
# apply= subtract the learned bias from the yaw being controlled
# (rollback in the field: switch to "log", no rebuild)
heading_bias_tau: 30.0 # [s] EMA time constant
heading_bias_min_vel: 0.45 # [m/s] below this the course is too noisy to learn from
heading_bias_clamp: 0.05 # [rad] ceiling of the APPLIED correction
heading_bias_min_samples: 60 # [cycles] learned samples required before applying
# ================= Steering bias (integrator, cleans up the residue) =============
# With heading_bias_mode: apply the main disturbance is handled above; the
# integrator only sweeps up what is left. Do NOT run both at full strength.
steer_bias_gain: 0.0 # [rad/(m*s)] SIM: 0 = OFF — plant sim khong co zero servo hay
# heading bias, integrator bat len chi tich nhieu.
# ROBOT THAT: 0.10 khi mode != apply, 0.02 khi mode = apply.
steer_bias_clamp: 0.05 # [rad] anti-windup ceiling
steer_bias_decay: 0.9999 # per-cycle bleed when the integrate conditions do not hold
# (robot that dung 0.9999 de bias song qua cac quang dung 30-60 s)
steer_bias_min_vel: 0.30 # [m/s] below this, do not integrate
steer_bias_max_heading_err: 0.10 # [rad] above this, do not integrate
# ================= Plan window / lookahead =================
max_global_plan_lookahead_dist: 3.0 # [m] window ceiling
min_lookahead: 0.50 # [m] window floor
min_lookahead_near_goal: 0.40 # [m] separate floor near the goal
dyn_lookahead_gain: 2.50 # [m/(m/s)] lookahead = min + gain*|v|
near_goal_freeze_dist: 0.50 # [m] below this: freeze yaw_path, run theta_d only
# Index continuity thresholds, given in METRES and converted to indices with the
# point spacing measured at runtime - the plan resolution is the global planner's
# choice, not a constant.
# The old code used fixed indices (back=3, fwd=15 ~ 0.75 m on a 0.05 m/point plan) and
# therefore never fired: at 1.2 m/s the robot covers 0.04 m = 0.8 index per 33 ms cycle.
# Applied to BOTH closest (window anchor) and target_idx_ (inside the core).
max_advance_dist: 0.20 # [m] forward travel allowed along the plan per cycle
max_back_dist: 0.10 # [m] backward travel allowed along the plan per cycle
# ================= Curvature =================
high_curvature: 0.30 # [1/m] above: shrink lookahead
mid_curvature: 0.20 # [1/m] above: cut the transform window
low_curvature: 0.10 # [1/m] above: enter curve mode
straight_confirm_steps: 110 # consecutive straight cycles before leaving curve mode
# ================= Speed profile =================
speed_base: 0.30 # [m/s] base of the cosine steering profile
curve_max_speed: 0.25 # [m/s] ceiling while curving
min_drive_speed: 0.07 # [m/s] floor while driving
accel_distance: 2.00 # [m] ramp length after leaving a curve
decel_min: 0.05 # [m/s per cycle] deceleration on predicted collision
decel_max: 0.10 # [m/s per cycle]
collision_horizon_factor: 2.0 # multiplies max_vel_x to get the collision check distance
# Braking-distance governor: v <= sqrt(2*a*d_to_stop). The horizon profile alone
# starts braking ~v*horizon out (1.5 m at 1.2 m/s, demanding ~1 m/s^2) — the drive
# cannot follow and the robot overshot 30 cm. The old build was saved by an
# accident (the bearing blow-up tripped the steer gate and cut the drive early).
goal_decel_limit: 0.40 # [m/s^2] TO BE MEASURED — must stay BELOW the drive's real brake.
# Braking starts at v^2/(2a): 1.8 m @ 1.2 m/s, 0.3 m @ 0.5 m/s
min_approach_speed: 0.06 # [m/s] approach floor so the sqrt profile still reaches the goal
# ================= Align / phase =================
heading_eps: 0.020 # [rad] heading error accepted as aligned
steer_eps: 0.020 # [rad] steering error accepted as "servo arrived"
heading_align_tol: 0.050 # [rad] gate for the final straight-line approach (was 0.01 = too tight)
near_goal_dist: 1.00 # [m] below this: enable the final straight mode
steer_realign_off: 0.503 # [rad] above this: CUT drive (0.16*pi)
steer_realign_on: 0.150 # [rad] below this: RESUME drive - must be smaller than _off
steering_active: 0.094 # [rad] above this the steering counts as active (0.03*pi)
segment_transition_threshold: 0.010 # [m]
segment_end_ratio: 0.05 # fraction of the segment left before advancing
xy_reached_gate_factor: 3.0 # multiplies xy_goal_tolerance; a 1-point window may only latch inside this
# ================= TF guard =================
# Measured on the robot: 225 map->odom jumps, max 12.381 m, coinciding with the
# localisation FinishTrajectory(1) 10:41:18 / AddTrajectory(2) 10:41:21. The source is
# outside this package; this is containment, not a cure.
tf_lookup_at_pose_stamp: true # true = look up at pose.header.stamp instead of "latest".
# "latest" returns a different entry each call when the
# buffer holds two map->odom transforms
transform_tolerance: 0.20 # [s] accepted age when looking up by timestamp
max_plan_tf_jump_rate: 1.50 # [m/s] threshold as a RATE, multiplied by the real elapsed time.
# SIM: 1.5 — dynamic TF sim jitter 0.02-0.065 m/chu ky; de 0.6
# thi budget ~0.02 m -> reject don 30/30, reset giua duong
# (log 08/08: 8 reset trong 2 luot lui). ROBOT THAT: 0.60.
max_plan_tf_jump_abs: 1.00 # [m] hard cap of the accepted step: the rate budget grows while
# the transform sits still, and without the cap a multi-metre
# step after a long static stretch would be accepted outright
max_plan_tf_yaw_jump: 0.20 # [rad] rotation threshold - the old code checked translation only
tf_reject_window_cycles: 30 # sliding window; exceeding it means a real relocalisation
tf_reject_ratio: 0.5 # reject fraction inside the window that triggers the reset
# ================= Debug =================
debug_tf: false # nhom log TF (accepted-step, authority, chi tiet reject, fallback).
# SIM: dynamic_tf nhieu chu dich -> tat cho log doc duoc.
# ROBOT THAT: bat lai (true) khi san TF that.
# Reset do reject keo dai van LUON duoc log bat ke cong tac nay.
debug_offset: true # [DBG-OFF] 5 Hz bam path + thong ke max/mean |e| moi luot cua
# (in kem dong DBG-CURVE exit) — soi lech trong duong cong.
debug_level: 2 # 0=off 1=on state change 2=throttled 1 Hz 3=every cycle
# 2 is safe as the operating default: this package throttles with
# its own per-purpose clocks (robot_cpp's log_*_throttle shares ONE
# static timer per function for the whole process, so its throttled
# lines silently eat each other - never rely on it).
# 3 produces >1800 lines/min at 30 Hz - field debugging only
# ==============================================================================
# PROFILE DOCKING (docking_planner_name / docking.local_planner tro vao day).
# CUNG code voi StanleyLocalPlanner (mot factory, hai BOOST_DLL_ALIAS) — chi khac
# config. YAML namespace KHONG ke thua: block nay phai lap lai DU moi key, thieu
# key nao la key do roi ve default trong struct C++, KHONG roi ve block tren.
# Giai thich chi tiet tung tham so: xem block StanleyLocalPlanner o tren.
# Khac biet docking (danh dau # DOCKING:):
# - toc do thap (leg dock ~1.7 m, do chinh xac quan trong hon thoi gian)
# - tolerance chat (xy 0.015 / yaw 0.010 thay vi 0.030 / 0.020)
# ==============================================================================
StanleyDockingLocalPlanner:
library_path: libstanley_local_planner
# ================= Robot limits =================
max_vel_x: 0.30 # [m/s] DOCKING: tran thap — leg dock ngan, uu tien chinh xac
min_vel_x: -0.20 # [m/s] DOCKING: lui cham khi vao pallet
wheel_base: 0.0 # [m] 0 = derive from TF front_axle_frame -> rear_axle_frame
front_axle_frame: "steer_link"
rear_axle_frame: "base_link"
steer_limit_standstill: 1.5708 # [rad]
steer_limit_at_max_vel: 0.5000 # [rad]
align_steer_angle: 1.5708 # [rad]
min_steer_angle: 0.20 # [rad]
max_steer_rate: 1.00 # [rad/s]
steer_zero_offset: 0.0 # [rad] SIM: khong co zero servo
# ================= Goal tolerance =================
xy_goal_tolerance: 0.015 # [m] DOCKING: 0.030 -> 0.015 (log 13/08: dung sat mep 0.024)
yaw_goal_tolerance: 0.010 # [rad] DOCKING: 0.020 -> 0.010 (yaw 0.02 x 1.2 m pallet = 2.4 cm mui cang)
goal_sq_dist_tol: 0.05 # [m^2]
# ================= Control law (Stanley) =================
path_yaw_mode: "tangent"
control_gain_e: 2.0
control_gain_d: 1.5
gain_cte_weight: 0.8
gain_heading_weight: 0.5
gain_min: 0.5
gain_max: 1.8
soft_min_vel: 0.20 # [m/s]
alpha_gain: 0.0
near_goal_heading_gain: 4.0 # DOCKING 13/08: het pivot cuoi — dong not ~0.03 rad heading tren 0.2 m thang chot (yaw-rate ~ v*tan(delta)/L sup o toc bo; gain thuong chi dong 0.005-0.015 rad). Chi an ngoai curve mode. Robot lac duoi cuoi thi giam 3.0.
curve_gain_e_bonus: 0.0 # DOCKING 13/08: 4x heading gain nhan reference lead 0.23 rad dau chang thanh slam full-lock -90, robot xoay tai cho ~2 s truoc khi lan banh. ff da ganh cua; bo bonus de vao cua bang ff + gain 2.0. Neu giua cua e tang lai thi thu 1.0.
tangent_window_pts: 1 # DOCKING 13/08: cua so 3 diem o SAT DAU path lech het ve phia truoc (chord 0..5 = 0.25 m cong) -> reference lead 0.23 thay vi 0.125 rad. Path dock la duong giai tich, 1 chord/5cm du sach. Path rang cua thi tra ve 3.
heading_preview: 0.10 # [m] GIU 0.10. Trial 0.20 (13/08 run C) FAIL: ff doc kappa truoc 0.2 m nen tat som giua cua -> understeer, e max 0.071, th_e o dich 0.097. Combo tot nhat da do: align_to_path_start true + preview 0.10 (run B: max 0.031-0.033, mean 0.012-0.015).
curve_feedforward_gain: 1.0
# ================= Heading bias =================
# DOCKING: OFF co chu dich — leg dock lui + cong + ngan, estimator khong du mau
# de hoc (instance nay KHONG thua huong bias instance position da hoc).
heading_bias_mode: "off"
heading_bias_tau: 30.0 # [s]
heading_bias_min_vel: 0.45 # [m/s]
heading_bias_clamp: 0.05 # [rad]
heading_bias_min_samples: 60 # [cycles]
# ================= Steering bias =================
steer_bias_gain: 0.0 # DOCKING + SIM: OFF (leg qua ngan de tich phan co nghia)
steer_bias_clamp: 0.05 # [rad]
steer_bias_decay: 0.9999
steer_bias_min_vel: 0.30 # [m/s]
steer_bias_max_heading_err: 0.10 # [rad]
# ================= Plan window / lookahead =================
max_global_plan_lookahead_dist: 3.0 # [m]
min_lookahead: 0.50 # [m]
min_lookahead_near_goal: 0.40 # [m]
dyn_lookahead_gain: 2.50 # [m/(m/s)]
near_goal_freeze_dist: 0.50 # [m]
max_advance_dist: 0.20 # [m]
max_back_dist: 0.10 # [m]
# ================= Curvature =================
high_curvature: 0.30 # [1/m]
mid_curvature: 0.20 # [1/m]
low_curvature: 0.10 # [1/m]
straight_confirm_steps: 110
# ================= Speed profile =================
speed_base: 0.20 # [m/s] DOCKING: 0.30 -> 0.20
curve_max_speed: 0.20 # [m/s] DOCKING: cua dock R~1 m, di cham
min_drive_speed: 0.07 # [m/s]
accel_distance: 2.00 # [m]
decel_min: 0.05 # [m/s per cycle]
decel_max: 0.10 # [m/s per cycle]
collision_horizon_factor: 2.0
goal_decel_limit: 0.40 # [m/s^2]
min_approach_speed: 0.05 # [m/s] DOCKING: 0.06 -> 0.05, bo cham vao tolerance chat hon
# ================= Align / phase =================
align_to_path_start: true # DOCKING: pivot ve dung heading POSE DAU path. Da thu false 13/08 (run C, kem preview 0.20): khong bam — giu true.
# khong phai heading reference cua control law (nearest + preview
# 0.10 m, trung binh 3 diem) — tren cua K~1.4 reference do di truoc
# diem dau path ~0.14 rad
align_pivot_toward_curve: true # DOCKING 13/08: pivot do banh ve PHIA cua sap toi (ff pose 0 < -0.30 rad -> -90). Truoc do do +90 roi phai quet 2.6-3.1 rad tai cho ~2.4 s truoc khi lan banh. ROBOT THAT: kiem tra drive nhan lenh -90 truoc khi bat.
heading_eps: 0.010 # [rad] DOCKING: 0.020 -> 0.010. Path dock vao cua K~1.4 ngay
# pose 0; align dung o 0.0185 rad la mang san 1 do lech vao cua
# (sim 13/08: e vot 0.034 m ngay sau align)
steer_eps: 0.020 # [rad]
heading_align_tol: 0.050 # [rad]
near_goal_dist: 1.00 # [m]
steer_realign_off: 0.503 # [rad]
steer_realign_on: 0.080 # [rad] DOCKING: 0.150 -> 0.080. Steer quet 2.6 rad tu pivot sang
# goc cua mat ~2.2 s; tha drive khi con lech 0.111 rad la chay
# voi banh lai chua toi noi — cho settle gan hon roi moi tha
steering_active: 0.094 # [rad]
segment_transition_threshold: 0.010 # [m]
segment_end_ratio: 0.05
xy_reached_gate_factor: 3.0
# ================= TF guard =================
tf_lookup_at_pose_stamp: true
transform_tolerance: 0.20 # [s]
max_plan_tf_jump_rate: 1.50 # [m/s] SIM (robot that: 0.60)
max_plan_tf_jump_abs: 1.00 # [m]
max_plan_tf_yaw_jump: 0.20 # [rad]
tf_reject_window_cycles: 30
tf_reject_ratio: 0.5
# ================= Debug =================
debug_tf: false
debug_offset: true
debug_level: 2