4 Commits

Author SHA1 Message Date
4d3cc01d15 docs: sua duong dan SBPL_RECOVERY_AUDIT.md sau khi don sang Test/docs/sbpl_recovery/ 2026-09-22 15:31:06 +07:00
ea79686eef feat: run detour planning on a worker thread so cancel doesn't block the control loop
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>
2026-09-12 22:06:50 +07:00
8f9326be04 feat: bỏ mô hình detour, lập lại CẢ ĐƯỜNG tới đích chặng
Behavior cũ quét plan tìm một ĐIỂM NỐI rồi vá đoạn vòng vào tuyến cũ. Bốn điều
kiện xếp chồng làm nó sinh đường khép kín (audit trên /tmp/crowd2.log mission
cuối): điểm nối bị ràng buộc phải nằm trên tuyến cũ, mprim cũ định giá xoay tại
chỗ đắt gấp 5 lần cung nên SBPL luôn vẽ vòng, và mỗi lượt vá lại ăn mòn tuyến
(rejoin 106/305 -> 130/289 -> 132/273) nên robot không bao giờ về tuyến.

Giờ nó làm đúng việc của global planner nhưng chạy trong recovery: makePlan từ
pose hiện tại tới plan_.back() trên lưới đã chọn, trả NGUYÊN đường vừa lập.
Đo trên sim: nhanh hơn 5 lần và thẳng (arc/chord 1.01-1.04, winding +9 độ,
self_cross 0) so với bản vá đoạn (1.05-1.98).

Gỡ theo: buildCandidates / classifyPose / classifyOn / classifyMergedPoint /
inLocalView / ScanStats / candidates_, và bốn khoá config chỉ phục vụ việc chọn
điểm nối (planning_distance, sample_step, rejoin_clearance,
max_rejoin_distance). Số lượt vẫn chặn bằng attempts_per_run.

Test: bỏ 9 ca về ứng viên điểm nối, viết lại 2, sửa 2, thêm 2 — 17/17 xanh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rayqed51UoUzE7QDRmM9K
2026-09-04 19:34:45 +07:00
72435b76fd first commit 2026-08-09 18:48:16 +07:00