DetourPathRecovery was the one recovery behavior that mattered for the onCancelRequested() fix in recovery_core (commit 254c7fc): it calls SBPLDetourPlanner::makePlan() synchronously from update(), which runs on the control thread — cancel arriving mid-search had nothing to preempt it with, and the control loop itself would stall for the remainder of allocated_time. - Moves the search to a per-attempt worker thread (startWorker/workerBody/ planInto/finishAttempt/waitWorker/joinWorker/requestWorkerStop); update() only polls. - onCancelRequested() (new override): preempts via robot_nav_core::Preemptable if the inner planner supports it (see Test/sbpl_lattice_planner), then waits up to cancel_join_timeout (0.2 s) and joins — cancel now actually blocks until the worker is gone, not just until a flag is set. - onStart() joins a stale worker from a previous attempt before starting a new one; destructor joins too. - async_planning param (default true) so tests can force the old synchronous path when they need deterministic single-thread timing. - Uses RECOVERY_CORE_EXPORT_BEHAVIOR for the ABI version symbol. - test/plugins/test_line_planner.cpp: added plan_delay (simulate a slow search) and made it Preemptable, exported as TestSlowPlanner, to drive the new worker-thread cancel tests. Depends on recovery_core commit 254c7fc (onCancelRequested hook + ABI macro) and Test/sbpl_lattice_planner commit 7456e99 (Preemptable pattern this follows). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
125 lines
5.1 KiB
YAML
125 lines
5.1 KiB
YAML
# Config CHỈ dành cho unit test của sbpl_recovery — được nạp qua PNKX_NAV_CORE_CONFIG_DIR do chính
|
|
# binary test đặt. KHÔNG phải config runtime.
|
|
#
|
|
# `lock_costmap: false` và `costmap_frame_override` là test seam: costmap trong test là placeholder
|
|
# không dereference được (không dựng nổi Costmap2DROBOT trong unit test — cần tf3 + cây config đầy
|
|
# đủ). Production không bao giờ đặt hai khoá này.
|
|
|
|
recovery:
|
|
behaviors:
|
|
- {name: detour, type: DetourPathRecovery}
|
|
- {name: detour_flaky, type: DetourPathRecovery}
|
|
- {name: detour_dead, type: DetourPathRecovery}
|
|
- {name: detour_map, type: DetourPathRecovery}
|
|
- {name: detour_narrow, type: DetourPathRecovery}
|
|
- {name: detour_alias, type: DetourPathRecovery}
|
|
- {name: detour_async, type: DetourPathRecovery}
|
|
- {name: detour_slow, type: DetourPathRecovery}
|
|
|
|
detour:
|
|
planner_name: TestLinePlanner
|
|
planning_distance: 1.0 # [m]
|
|
sample_step: 0.5 # [m]
|
|
attempts_per_run: 3
|
|
lock_costmap: false
|
|
costmap_frame_override: odom
|
|
async_planning: false # planner giả tức thì — giữ đường đồng bộ để test đếm tick như cũ
|
|
|
|
detour_flaky:
|
|
planner_name: TestFlakyPlanner # hai ứng viên đầu bị "chắn", ứng viên ba mới thông
|
|
planning_distance: 1.0
|
|
sample_step: 0.5
|
|
attempts_per_run: 3
|
|
lock_costmap: false
|
|
costmap_frame_override: odom
|
|
async_planning: false # planner giả tức thì — giữ đường đồng bộ để test đếm tick như cũ
|
|
|
|
detour_dead:
|
|
planner_name: TestDeadPlanner # không ứng viên nào thông -> behavior phải kFailed
|
|
planning_distance: 1.0
|
|
sample_step: 0.5
|
|
attempts_per_run: 3
|
|
lock_costmap: false
|
|
costmap_frame_override: odom
|
|
async_planning: false # planner giả tức thì — giữ đường đồng bộ để test đếm tick như cũ
|
|
|
|
detour_map:
|
|
planner_name: TestLinePlanner # plan ở frame map, costmap ở odom -> ép đường quy đổi TF
|
|
planning_distance: 1.0
|
|
sample_step: 0.5
|
|
attempts_per_run: 3
|
|
lock_costmap: false
|
|
costmap_frame_override: odom
|
|
async_planning: false # planner giả tức thì — giữ đường đồng bộ để test đếm tick như cũ
|
|
|
|
# Tên instance KHÁC symbol: đọc param từ `DetourOnlyTuning`, nạp .so theo alias `TestLinePlanner`.
|
|
# Đây là đường mà cấu hình runtime dùng để cho detour một instance SBPL riêng (allocated_time
|
|
# ngắn) trong khi `libsbpl_lattice_planner` chỉ export đúng một symbol.
|
|
detour_alias:
|
|
planner_name: DetourOnlyTuning
|
|
planner_symbol: TestLinePlanner
|
|
planning_distance: 1.0
|
|
sample_step: 0.5
|
|
attempts_per_run: 3
|
|
lock_costmap: false
|
|
costmap_frame_override: odom
|
|
async_planning: false # planner giả tức thì — giữ đường đồng bộ để test đếm tick như cũ
|
|
# Đường bất đồng bộ (mặc định production): planner giả ngủ 0.3 s, có Preemptable.
|
|
detour_async:
|
|
planner_name: TestSlowPlanner
|
|
planning_distance: 1.0
|
|
sample_step: 0.5
|
|
attempts_per_run: 3
|
|
lock_costmap: false
|
|
costmap_frame_override: odom
|
|
cancel_join_timeout: 0.5 # [s]
|
|
# Cùng planner; instance riêng để test cancel giữa chừng không dính bộ đếm của instance trên.
|
|
detour_slow:
|
|
planner_name: TestSlowPlanner
|
|
planning_distance: 1.0
|
|
sample_step: 0.5
|
|
attempts_per_run: 3
|
|
lock_costmap: false
|
|
costmap_frame_override: odom
|
|
cancel_join_timeout: 0.5 # [s]
|
|
|
|
detour_narrow:
|
|
planner_name: TestOffsetPlanner # planner giả luôn vẽ đường vòng lệch 1.0 m khỏi tuyến
|
|
planning_distance: 1.0
|
|
sample_step: 0.5
|
|
attempts_per_run: 3
|
|
max_deviation: 0.2 # [m] chặt hơn độ lệch của planner -> mọi ứng viên bị loại
|
|
lock_costmap: false
|
|
costmap_frame_override: odom
|
|
async_planning: false # planner giả tức thì — giữ đường đồng bộ để test đếm tick như cũ
|
|
|
|
# Bảng symbol -> thư viện cho Boost.DLL. Ba symbol planner cùng một .so; param của planner đọc theo
|
|
# namespace mang tên symbol.
|
|
TestLinePlanner:
|
|
library_path: libsbpl_recovery_test_line_planner
|
|
|
|
TestFlakyPlanner:
|
|
library_path: libsbpl_recovery_test_line_planner
|
|
fail_first_attempts: 2
|
|
|
|
TestDeadPlanner:
|
|
library_path: libsbpl_recovery_test_line_planner
|
|
fail_first_attempts: 1000
|
|
|
|
TestSlowPlanner:
|
|
library_path: libsbpl_recovery_test_line_planner
|
|
plan_delay: 0.3 # [s] một lượt "search" giả
|
|
|
|
# Luôn vẽ đường vòng lệch 1.0 m khỏi đoạn thẳng start->goal: dùng để kiểm guard max_deviation.
|
|
TestOffsetPlanner:
|
|
library_path: libsbpl_recovery_test_line_planner
|
|
lateral_offset: 1.0
|
|
|
|
# Namespace param THUẦN — cố ý KHÔNG có library_path: nó không phải symbol, việc nạp .so đi theo
|
|
# `planner_symbol`. Tham số khác hẳn bản mặc định để test chứng minh param được đọc từ đây.
|
|
DetourOnlyTuning:
|
|
points: 9
|
|
|
|
DetourPathRecovery:
|
|
library_path: libsbpl_recovery
|