Files
move_base2/test/config/move_base2_params.yaml
duongtd d10c240395 Feed per-marker docking parameters to the global planner
A docking global planner has no way to learn which marker the leg is for:
BaseGlobalPlanner::initialize() takes only the plugin name and the costmap,
and the plugin builds its own NodeHandle to read parameters. The only channel
left is the parameter tree, so copy the marker's keys into the planner's
namespace before the instance is built - the same shape as
Costmap2DROBOT::copyParentParameters() pouring parameters into each layer.

PlannerPort::bindDockingMarker() is called at the request gate, right before
swapPlanner(), because swapPlanner is where the instance is built and reads
its parameters. Copying afterwards would be a no-op: initialize() runs once.

- The destination is whatever global_planner the profile names, so a marker
  bound to a planner other than DockPlanner writes into that planner's
  namespace. Only DockPlanner reads footprint_dock today; the config
  documents that the value is inert elsewhere.
- The namespace is verified after construction. robot::NodeHandle silently
  falls back to its parent when a namespace does not resolve, so a mistyped
  marker would otherwise read footprint from ROOT - the robot footprint -
  and use it as the dock's size.
- The cached instance is rebuilt when the marker changes, and swapPlanner no
  longer short-circuits on an unchanged planner name, otherwise the second
  dock would run with the first dock's geometry. Rebuilds are skipped when
  the same marker is bound again.
- The replaced instance is retired rather than destroyed: the planner thread
  captures the active pointer and releases the mutex before calling into the
  plugin, so destroying it from the control thread is a use-after-free.

Add eight PlannerRunner tests. The test plugin now exports its initialize()
count and the footprint it read, which is the only way to observe from
outside that the rebuild actually happened.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-12 21:53:12 +07:00

299 lines
11 KiB
YAML

# Config CHỈ dùng cho test của gói. Bản runtime nằm ở `pnkx_nav_core/config/` (C2).
#
# Chạy test kèm: PNKX_NAV_CORE_CONFIG_DIR=src/AMR_T800/Test/move_base2/test/config
# --- Tham số runtime, dùng cho config_validation_test ----------------------------------------
move_base2:
docking_requires_marker: false
controller_frequency: 20.0 # [Hz]
planner_frequency: 0.0 # [Hz] 0 = chỉ lập plan khi cần
planner_timeout: 5.0 # [s]
planner_patience: 5.0 # [s]
controller_patience: 15.0 # [s]
oscillation_timeout: 0.0 # [s] 0 = tắt
oscillation_distance: 0.5 # [m]
action_patience: 0.0 # [s] 0 = tắt; lưới cuối, không phải cơ chế timeout chính
max_planning_retries: -1 # < 0 = không giới hạn
recovery_behavior_enabled: true
max_vel_x: 0.5 # [m/s] tiến
min_vel_x: -0.2 # [m/s] lùi, ÂM
max_vel_theta: 1.0 # [rad/s]
acc_lim_x: 1.0 # [m/s^2]
acc_lim_theta: 2.0 # [rad/s^2]
global_frame: map
robot_base_frame: base_link
sensors:
laser_sor_enabled: true # lọc outlier laser TRƯỚC khi vào costmap
laser_sor_mean_k: 8 # [điểm] số láng giềng gần nhất dùng để ước lượng
laser_sor_stddev_mul: 1.5 # [-] ngưỡng = mean + hệ_số * stddev
recovery_namespace: recovery
action_namespace: actions
mission_namespace: mission_adapters
backup_global_planner: TestBackupGlobalPlanner
position:
base_global_planner: TestGlobalPlanner
base_local_planner: TestLocalPlanner
docking:
base_global_planner: TestDockPlanner
base_local_planner: TestLocalPlanner
docking_marker_profiles:
trolley:
global_planner: TestTrolleyDockPlanner
local_planner: TestTrolleyDockLocalPlanner
# --- Schema runtime root-profile ---------------------------------------------------------------
# Đây là schema dùng bởi move_base_common_params.yaml của move_base2. Không có adapter gen-1.
root_profiles:
controller_frequency: 30.0
planner_frequency: 0.0
planner_patience: 2.0
controller_patience: 0.033333333
max_planning_retries: 0
recovery_behavior_enabled: true
docking_requires_marker: false
backup_global_planner: TestBackupGlobalPlanner
position:
global_planner: TestGlobalPlanner
local_planner: TestLocalPlanner
docking:
global_planner: TestDockPlanner
local_planner: TestLocalPlanner
docking_marker_profiles:
trolley:
global_planner: TestTrolleyDockPlanner
local_planner: TestTrolleyDockLocalPlanner
go_straight:
global_planner: TestStraightPlanner
local_planner: TestStraightLocalPlanner
rotate:
global_planner: TestRotatePlanner
local_planner: TestRotateLocalPlanner
# --- Cấu hình sai, dùng cho test đường lỗi -----------------------------------------------------
move_base2_bad_frequency:
controller_frequency: 0.0 # phải bị từ chối
move_base2_bad_frames:
controller_frequency: 20.0
global_frame: base_link # trùng robot_base_frame -> pose robot luôn là gốc toạ độ
robot_base_frame: base_link
position:
base_local_planner: TestLocalPlanner
move_base2_no_planner:
controller_frequency: 20.0 # không profile nào có base_local_planner
move_base2_bad_sensors:
controller_frequency: 20.0
position:
base_local_planner: TestLocalPlanner
sensors:
laser_sor_enabled: true
laser_sor_mean_k: 1 # < 2 -> vô nghĩa, phải bị từ chối
# --- Recovery behavior cho recovery_runner_test ------------------------------------------------
#
# Chỉ khai behavior họ kNone: họ velocity cần Costmap2DROBOT thật (TF + chuỗi layer) nên được kiểm
# ở tầng tích hợp, không kiểm bằng fake ở đây.
recovery:
behaviors:
- {name: wait_short, type: WaitRecovery}
- {name: wait_long, type: WaitRecovery}
routes:
planning_failed: [wait_short]
controlling_failed: [wait_long, wait_short]
oscillation: [wait_long]
# Lặp behavior trong một route là HỢP LỆ (2026-08-05): mỗi lần xuất hiện là một lượt thử —
# ngân sách cho vòng "thử — chờ — nhích lại gần — thử lại" của giám sát tuyến.
path_blocked: [wait_short, wait_long, wait_short]
wait_short:
wait_duration: 1.0 # [s]
wait_long:
wait_duration: 5.0 # [s]
timeout: 3.0 # [s] cố ý NGẮN HƠN wait_duration -> lượt này luôn kết thúc bằng timeout
recovery_empty:
behaviors: []
recovery_missing_library:
behaviors:
- {name: ghost, type: GhostRecovery}
# Mô phỏng config được commit trước plugin DetourPathRecovery. `configure()` báo partial failure,
# nhưng configureRoutes() phải bỏ detour_path thay vì đưa index không tồn tại sang StateMachine.
recovery_missing_detour:
behaviors:
- {name: wait_short, type: WaitRecovery}
- {name: detour_path, type: DetourPathRecovery}
routes:
planning_failed: [wait_short]
controlling_failed: [detour_path, wait_short]
oscillation: [detour_path, wait_short]
# --- Recovery THẬT cho kịch bản có vật cản (RecoveryScenarioDriver) ----------------------------
#
# Namespace riêng, KHÔNG dùng chung với `recovery` ở trên: hai bộ test hỏi hai câu khác nhau. Bộ kia
# kiểm chỗ nối RecoveryPort <-> recovery_core bằng behavior họ kNone; bộ này kiểm hành vi an toàn
# THẬT của BackUpRecovery trên lưới có vật cản.
recovery_scenario:
behaviors:
- {name: back_up, type: BackUpRecovery}
back_up:
backup_distance: 0.50 # [m] quãng lùi mong muốn
backup_distance_max: 1.0 # [m] trần cứng
linear_speed: 0.15 # [m/s] độ lớn; dấu âm do plugin đặt (lùi)
acc_lim_x: 1.0 # [m/s^2]
timeout: 15.0 # [s]
WaitRecovery:
library_path: librecovery_core_wait_recovery
BackUpRecovery:
library_path: librecovery_core_back_up_recovery
# GhostRecovery cố ý KHÔNG khai library_path.
# --- Action handler cho action_runner_test -----------------------------------------------------
actions:
handlers:
- {name: noop, type: NoopActionHandler}
noop:
action_types: [wait, pick, drop]
duration: 2.0 # [s]
timeout: 10.0 # [s] tầng 1 — trách nhiệm của chính handler
actions_slow:
handlers:
- {name: noop, type: NoopActionHandler}
noop:
action_types: [wait]
hang: true # mô phỏng thiết bị không bao giờ trả lời
timeout: 3.0 # [s] handler tự cắt, không chờ state machine
actions_hang_forever:
handlers:
- {name: noop, type: NoopActionHandler}
noop:
action_types: [wait]
hang: true
timeout: 0.0 # tắt timeout + treo = chạy vĩnh viễn -> phải bị chặn lúc configure
actions_bad:
handlers:
- {name: noop, type: NoopActionHandler}
noop:
action_types: [wait]
duration: 10.0 # [s]
timeout: 5.0 # [s] <= duration -> action LUÔN hỏng; phải bị chặn lúc configure
actions_empty:
handlers: []
actions_missing_library:
handlers:
- {name: ghost, type: GhostActionHandler}
NoopActionHandler:
library_path: libaction_core_noop_action_handler
# --- Profile marker docking ở ROOT, cho PlannerRunner::bindDockingMarker ------------------------
#
# Ở runtime bảng này nằm tại ROOT (maker_sources.yaml) và `PlannerRunner` đọc nó qua NodeHandle gốc,
# khác với bản lồng trong `move_base2:`/`root_profiles:` ở trên — bản đó là đầu vào của
# MoveBase2Config, dùng cho config_validation_test. Hai bản cố ý tách nhau: chúng kiểm hai đường đọc
# khác nhau của cùng một khái niệm.
docking_marker_profiles:
dock_a:
global_planner: TestPlannerOk
local_planner: TestControllerOk
footprint_dock: [[0.5, -0.4], [0.5, 0.4], [-0.5, 0.4], [-0.5, -0.4]] # [m]
dock_b:
global_planner: TestPlannerOk
local_planner: TestControllerOk
footprint_dock: [[0.2, -0.15], [0.2, 0.15], [-0.2, 0.15], [-0.2, -0.15]] # [m], nhỏ hơn dock_a
# Có profile nhưng KHÔNG khai footprint_dock: bindDockingMarker phải chấp nhận và không đánh dấu
# phải dựng lại instance.
dock_no_footprint:
global_planner: TestPlannerOk
local_planner: TestControllerOk
# --- Global planner giả cho planner_runner_test -------------------------------------------------
#
# Bốn alias cùng nằm trong một thư viện; mỗi alias là một hành vi mà PlannerRunner phải xử lý đúng.
TestPlannerOk:
library_path: libmove_base2_test_global_planner
TestPlannerEmptyPlan:
library_path: libmove_base2_test_global_planner
TestPlannerThrowing:
library_path: libmove_base2_test_global_planner
TestPlannerInitFails:
library_path: libmove_base2_test_global_planner
# TestPlannerMissingLibrary cố ý KHÔNG khai library_path.
# GhostActionHandler cố ý KHÔNG khai library_path.
# --- Local planner giả cho controller_runner_test ------------------------------------------------
TestControllerOk:
library_path: libmove_base2_test_local_planner
TestControllerSecondary:
library_path: libmove_base2_test_local_planner
TestControllerNoCommand:
library_path: libmove_base2_test_local_planner
TestControllerNaN:
library_path: libmove_base2_test_local_planner
TestControllerThrowing:
library_path: libmove_base2_test_local_planner
TestControllerRefusesLimits:
library_path: libmove_base2_test_local_planner
TestControllerMarkerProbe:
library_path: libmove_base2_test_local_planner
TestControllerFootprintProbe:
library_path: libmove_base2_test_local_planner
# Danh sách marker cho test đường docking (setDockingMarker) — format chuỗi cách nhau bằng space,
# đúng như maker_sources.yaml production.
maker_sources: dock_a dock_b
# TestControllerMissing cố ý KHÔNG khai library_path.
# --- Schema gen-1 (move_base_common_params.yaml) cho test đường legacy --------------------------
legacy_move_base:
controller_frequency: 20.0 # [Hz]
planner_frequency: 0.0 # [Hz]
planner_patience: 0.0 # gen-1: "fail -> recovery NGAY", KHÔNG phải "tắt"
controller_patience: 15.0 # [s]
oscillation_timeout: 0.0 # [s]
oscillation_distance: 0.5 # [m]
max_planning_retries: 0
recovery_behavior_enabled: true
base_global_planner: SBPLLatticePlanner
base_local_planner: LocalPlannerAdapter # phải bị BỎ QUA có log
position_planner_name: HybridLocalPlanner
docking_planner_name: DockLocalPlanner
# Global planner riêng của profile nằm trong namespace mang tên chính planner đó.
DockLocalPlanner:
base_global_planner: DockPlanner