Commit Graph

5 Commits

Author SHA1 Message Date
f2097380e4 feat: trigger collision riêng, ngân sách recovery theo dịch chuyển, guard đo bằng thời gian/góc
Năm thay đổi của cùng một chiến dịch: robot đứng chết ở góc trụ và giữa đám
đông. Mọi con số dưới đây lấy từ log sim ngày 3-4/9, ghi lại trong
Test/COLLISION_GUARD_LOOP_FIX_PLAN.md.

1) Ngân sách recovery nạp lại theo DỊCH CHUYỂN (state_machine)
   Trước: recovery thành công + nộp path mới thì cursor route reset NGAY. Sim
   4/9: guard chặn tại chỗ -> detour lập lại đúng đường cũ (cost y hệt, 0 ms)
   -> cursor về 0 -> chặn lại sau 2 cycle -> 249 vòng trong 52 s, robot bất
   động, controller_patience không bao giờ tích đủ vì path_blocked chen trước
   mỗi 0.2 s. Giờ chỉ nạp lại khi robot đã đi >= recovery_reset_min_travel
   (0.10 m) kể từ lần nạp trước; chưa đi thì tính như một lần thất bại ->
   route cạn -> mute -> controller_patience -> controlling_failed -> ABORT có
   lý do, ~2 s. Mốc theo origin đo quãng đường (reset cùng lúc với nó), nếu
   không thì 0.18 m sau path mới bị báo "0.00 m" và ABORT oan.

2) Guard loại trừ BASELINE (plan_inspector)
   Câu hỏi đổi từ "thân có đè LETHAL không" thành "lệnh này có đưa THÊM ô
   LETHAL vào thân không". Ô đã nằm dưới thân đệm tại pose hiện tại được gom
   thành baseline (rasterize diện tích ~600 ô, binary_search) và bỏ qua ở các
   mẫu sau. Sim 4/9: người kề hông ở 0.46 m ngang (thân 0.48 + đệm 0.05) làm
   mẫu đầu tiên báo "0.05 m" mãi dù PRIEST lệnh đi thẳng, SBPL (không đệm) bảo
   đi được, robot đứng chết. Trượt song song thì đi được, rẽ vào thì vẫn chặn.

3) Thân robot lấy từ FOOTPRINT COSTMAP
   collision_*_offset = 0 cả ba -> hỏi PathCheckPort::robotBodyExtents() mỗi
   cycle (footprint không đệm, cùng hình với SBPL và PRIEST). Đổi footprint lúc
   chạy là guard đổi theo, không phải chép số vào hai file. Khai tay thì phải
   đủ cả ba, khai lửng là config sai. Không có nguồn nào thì báo lỗi và KHÔNG
   kết luận — dừng mù là biến lỗi cấu hình thành robot chết.

4) "Sắp chạm" đo bằng THỜI GIAN và GÓC, không chỉ mét
   Mét dọc cung không nói lên gì với cung xoay gần tại chỗ: cùng 0.15 m, đi
   thẳng 0.36 m/s là chạm sau 0.4 s, còn xoay bò v 0.04 omega -0.5 (R 0.08 m)
   là quay 107 độ và còn 3.8 s — PRIEST đã thôi xoay sau 30-60 độ để thẳng hàng
   với path. Sim 16:26: 11 lần nổ trong 15 s tại góc trụ, xoay 0.9 rad mất 12 s
   thay vì 2 s. Giờ chỉ dừng khi t_contact <= collision_stop_time HOẶC turn <=
   collision_stop_angle; ngoài đó chỉ kẹp v. Đi thẳng (turn ~ 0) không đổi hành
   vi. Cung cũng không dò quá collision_lookahead_angle.

5) Trigger kCollision RIÊNG cho Phép đo 3
   Trước dùng chung path_blocked. Phép đo 1 nổ ở 3 m nên lập lại đường là đủ;
   Phép đo 3 nổ khi đã sát vật, replan từ đúng pose đó thường trả cùng path
   hoặc không ra nghiệm (start trong vành 253) — muốn thoát phải ĐỔI POSE, tức
   back_up đứng trước detour_path. Route, ngân sách và khoá đều riêng. Ưu tiên
   collision > path_blocked > off_path. Cạn route vẫn là KHOÁ chứ không ABORT
   (contract 2026-08-05e).

Config: tách path_monitor ra file riêng path_monitor_params.yaml, sắp xếp lại
theo bốn phép đo; recovery_behaviors_params.yaml sắp xếp lại theo trigger và
dọn bốn khoá chết của mô hình detour cũ. Khoá mới: recovery_reset_min_travel,
collision_exclude_baseline, collision_stop_time, collision_stop_angle,
collision_lookahead_angle.

Debug (khoá debug/state): dòng "hit at sample K: <edge> edge touches cell
(x, y)" và "body overlaps N LETHAL cell(s) ... letting it move" để phân biệt
"góc thân quét tới" với "người bước tới" khi đọc log mà không có costmap.

Verify: catkin_make --pkg move_base2 rc=0; ctest -R move_base2 15/15
(MotionCheck 16, CollisionGuard 13, RecoveryBudget 6, config 34).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rayqed51UoUzE7QDRmM9K
2026-09-04 19:35:25 +07:00
b102391fb8 Keep raw sensor readings so plugins can reach what the costmap threw away
Sensor data entered this runtime and disappeared into the costmap. At 0.05 m
with inflation the costmap has destroyed ray order and object shape, so a dock
detector fitting lines to find a V plate cannot reconstruct what the laser
saw - two 0.2 m wings on that grid are one blob. A reinforcement-learning
local planner wants the raw scan for the same reason. Neither had a route:
ActionContext held only TF, and LocalPlanner::initialize takes only a costmap.

NavigationServer now owns a SensorStore and feeds it from all five doors,
handing a read-only port to the action registry and to the controller runner.

The store gets the reading BEFORE the filter. Anything that wants filtering
filters upstream; the store does not know a filter exists. With laser SOR on,
the store and the costmap deliberately see different data - one wants outliers
gone, the other wants the true shape - and the comment at addLaserScan now
says so, because the one it replaces claimed the opposite.

remove* mirrors into the store, dropping readings while keeping the topic
declared. A host that has disowned data while the store still serves it means
the two disagree about what the robot can currently see, and max_age only
covers the tail of that.

Reaching a local planner without breaking every other one: widening
LocalPlanner::initialize would break hybrid, mppi, priest, stanley and
deep_mpc at once for the sake of one planner. A planner that wants sensor data
inherits SensorConsumer instead, and ControllerRunner finds out with a
dynamic_cast after loading it, at all three sites that build an instance and
always before initialize(). Planners that do not inherit it cast to null and
nothing happens, so nothing needs rebuilding. That cast crosses a .so boundary
and depends on matching RTTI, which a green build does not prove - hence the
log line, and hence TestControllerSensorProbe, dlopen'd like a real plugin, to
check it actually matches.

sensor_store/report_period prints what the store holds every N seconds, off by
default. Until a consumer exists it is the only way to see whether data
arrives at all, and it is what separates a mistyped topic from a dead sensor -
without it the two look identical. It reads age from the control loop's clock,
not robot::Time::now(), which is the wall clock while a simulated scan is not.

Config is refused at boot, not at first use: an unknown data_type, a short name
two packages share, a duplicate topic, a capacity below 1, a max_age that is
not positive. Declaring no sensor at all is valid and leaves the store empty
and silent - a runtime with no consumer of raw data holds nothing, which is an
answer rather than a reason to refuse to start.

robot_nav_msgs/OccupancyGrid is registered here rather than in
robot_sensor_ports, which ships only its own package's types; pulling
robot_nav_msgs into every translation unit that touches the store would be the
cost of doing otherwise.
2026-08-26 11:35:17 +07:00
701d25f952 optimal & fix file cmake 2026-08-03 22:41:32 +07:00
d8babff20b optimal 2026-07-30 09:24:47 +07:00
4762a3032c first commit 2026-07-29 15:45:16 +07:00