- recovery_resume: while an allowed stationary behavior (detour_path)
runs, probe the local planner; its command never reaches the arbiter;
after N moving cycles cancel the recovery and resume the current plan,
capped per leg
- host the env_monitor_core IntrusionDetector (EnvContext, footprint)
- runtime config: recovery_resume keys, priest_fallback keys, evade
max_tf_gap / view_loss_timeout, SBPL detour options, env_monitor tuning
- CostmapEnvironment::sampleScans: raw LaserScan + fixed-frame poses for detectors
that need scans (EnvNeeds.scans); recovery deps carry SensorReader for EvadeRecovery
- EnvMonitor brake now blocks only VelocitySource::kController; a latched kContact
brake no longer zeroes the evade back-up command in RECOVERING (sim 27/11 14:21)
- test: LatchedBrakeDoesNotZeroTheRecoveryVelocity
- config/runtime: env_monitor, recovery_behaviors, priest_mpcc, lane_route,
global costmap plugin keys in progress
Not built or tested yet.
EnvMonitor and its detectors now live in env_monitor_core. NavigationRuntime owns
the monitor; StateMachine runs each detector's own route (step or sequence,
lock or abort on exhaustion) with a cursor per detector. RecoveryRunner accepts
named routes for detectors outside the six built-in triggers.
A failed primary global planner on a docking, go_straight or rotate request no longer swaps to backup_global_planner. It goes straight to the planning_failed recovery route and aborts. Only the position profile may use the backup planner. Update STATE_MACHINE.md and add test NonPositionPlannerFailureSkipsBackup.
- Comment trong include/move_base2 (config, control_loop, core/env_monitor, core/grid_analysis,
io/env_logger, ports/environment_port), src/control_loop.cpp và test/walking_skeleton_test.cpp:
đường dẫn ENV_MONITOR_PLAN.md đổi từ Test/ sang Test/docs/move_base2/. Không đổi dòng code nào.
- docs/PLAN_LIFECYCLE_CANCEL_PAUSE_RESUME.md: xoá, bản plan đã nằm ở Test/docs/move_base2/.
- config/runtime/priest_local_planner_params.yaml: num_obs_proj 90 -> 200 (số vật cản gần nhất
đưa vào phép chiếu ADMM), giữ theo quyết định của người dùng.
- navigation_server: them addRouteGraph(topic, RouteGraph), day vao sensor_store cung namespace
addStaticMap; consumer (SBPLLatticePlanner) tu doi chieu map_hash.
- PlannerRunner: them setSensorReader()/attachSensors() - trao SensorReader cho global planner
nao ke thua robot_sensor_ports::SensorConsumer, goi TRUOC initialize() (dynamic_cast, giong co
che ControllerRunner dang dung).
- sensor_store_params.yaml: khai topic /route_graph (data_type RouteGraph, capacity 1).
- sbpl_global_params.yaml (config/runtime): dong bo schema initial_epsilon/final_epsilon/
eps_step/repair_time/return_first_solution + khoi voronoi_corridor (xem pnkx_nav_core
c52cbe5, Test/sbpl_lattice_planner cho code doc cac khoa nay).
- launch: them arg launch_prefix (vd "stdbuf -oL" - robot::log_* dung printf khong flush, qua
`| tee` bi block-buffer 8 KB lam log dung o dong cu du node con chay); them
route_graph_maps_dir/route_graph_topic cho amr_node doc file voronoi.json theo map dang kich hoat.
- docs: xoa PLAN_LIFECYCLE_CANCEL_PAUSE_RESUME.md (don sang Test/docs/move_base2/), sua duong dan
ENV_MONITOR_PLAN.md trong comment cac header EnvMonitor lien quan.
NavigationServer::emergency() phan anh ngay tren thread goi (getTwist
tra 0, getFeedback bao EMERGENCY) truoc khi ham tra ve, du control
thread dang block trong plugin nao; don dep that (planner/recovery/
action/mission layer) chay o chu ky ke cua control thread. State
NavigationState::kEmergency la state GIU, khong terminal: pause/resume/
cancel/goal moi deu bi bo qua, chi clearEmergency() moi thoat, ve
kIdle.
MissionLayer: emergency() -> drain hang doi, goi cancel toi navigation
dung 1 lan, chuyen MissionState::EMERGENCY; clearEmergency() ve
CLEAR_EMERGENCY, khong tu chay lai gi, cho order ke tiep.
Test moi cho ca 2 lop (navigation_server_test, mission_layer_test,
state_machine_test, walking_skeleton_test) phu: force-zero-truoc-cycle,
tu choi moveTo/instantActions khi dang chot, huy goal con pending, mo
chot roi nhan goal moi.
Root cause (from a C++ host log, 2026-09-11): cancel during PLANNING only set
a discard flag on the planner thread, which ran to allocated_time before
CANCELLED could be reported; a queued next mission landed on a still-busy
planner and timed out too. Same class of bug existed for pause, recovery, and
implicitly for a legitimate ABORTED read while a component was still
unwinding. Full audit, decisions, and phased design in
docs/PLAN_LIFECYCLE_CANCEL_PAUSE_RESUME.md; old-vs-new behaviour per state in
docs/LIFECYCLE_BEHAVIOUR_MATRIX.md.
Runtime quiescence, not just "command sent":
- kPausing (new state) mirrors kCancelling: PAUSED/CANCELLED is only entered
once planner and recovery are idle, the action reports terminal, and the
robot is stopped per odometry (robot_stopped, stopped_measured_linear/
angular_eps) — not merely "the command we sent was zero". settle_timeout
bounds the wait; exceeding it still finishes but logs an ungated error
naming which component was still busy, so a plugin that doesn't honour
cancel/pause is visible instead of silently swallowed.
- PlannerRunner::running_planner_ (new): the instance the planner thread is
actually inside makePlan() with, tracked separately from active_ — active_
can already point at a different instance after swapPlanner() while the
old attempt is still running. cancelPlan(), swapPlanner() (when a job is
running_ or only pending_ and not yet picked up), and the destructor all
preempt through this pointer now; the old code preempted through active_
and could silently preempt the wrong (idle) instance after a profile swap.
- ComponentStatusBoard + per-component ComponentPhase (idle/busy/stopping/
paused/hung), read by PlannerRunner, RecoveryRunner, ActionRunner and
ControlLoop instead of ad hoc bools — this is what makes "did everything
actually stop" answerable at all, and what the new Watchdog thread reads
to flag a component busy-without-progress as hung (logged once at the
edge) without the control loop needing to detect its own stall.
- Resume: PLANNING replans from the current pose. CONTROLLING re-issues
setPlan() with the plan already in hand (decided: setPlan again, not a
fresh plan) — the local planner needs nothing else since it already runs
once per control cycle; a fresh plan on resume was considered and
rejected as unnecessary work for a plan that's still valid.
- Command-to-zero on cancel/pause stays immediate (no deceleration ramp) —
existing VelocityArbiter behaviour, left as is per a scoped decision.
Depends on: Test/sbpl (bd89924), pnkx_nav_core (2b0993b, robot_nav_core::
Preemptable + component_status_probe.h), Test/sbpl_lattice_planner (7456e99),
Test/recovery_core (254c7fc, onCancelRequested + ABI guard), Test/
sbpl_recovery (ea79686, worker-thread cancel), Test/action_core (669c3f7,
pause/resume + kCancelled), Test/dock_pattern_action (cc1ea74).
Verified: 13 gtest binaries / 528 tests, 0 failures. Runtime on the dev
machine (Gazebo + real ROS host + VDA5050 over MQTT), 6 scenarios — cancel
during PLANNING, pause/resume during PLANNING and CONTROLLING (incl.
submit-while-still-winding-down), pause-then-cancel during PLANNING and
CONTROLLING: no ABORTED/RECOVERING in any run, preempt lands within
hundredths of a millisecond of entering CANCELLING/PAUSING, PAUSED/CANCELLED
only reported once the robot is actually stopped per odometry. Full numbers
in the plan doc section 6.
Excluded from this commit (pre-existing, unrelated):
config/runtime/recovery_behaviors_params.yaml (allocated_time 1.0->2.0,
SBPLDetourPlanner tuning predating this work).
Not yet done (see plan doc "Trạng thái"): config tuning (phase 0, pending
per a scoping decision); runtime scenarios for cancel mid-detour and a 30 s
pause mid-action; commit to rb_ws is a separate step, not done here.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Mission layer giờ LUÔN chạy: mọi VDA5050 Order đi qua `mission_adapters` — cắt
thành chặng tại mỗi node có action, chỉ phần `released` được chạy,
`orderUpdateId` nối tiếp, `mission_timeout` làm lưới cuối. Đường lùi "order đi
thẳng xuống như một goal" không còn được chọn bằng config; nó chỉ còn là hành vi
tự động khi layer không nạp được nguồn nào, và vẫn kèm log cảnh báo.
`mission_namespace` rỗng giờ bị validate CHẶN — trước đây tắt layer là khỏi cần
namespace, giờ rỗng nghĩa là boot với một layer không đọc được nguồn nào.
Marker của profile docking thành TUỲ CHỌN: docking chạy bằng goal_frame đã quy
về pose tuyệt đối và local planner không đọc `maker_name`, nên
`PNKXDockingLocalPlanner` legacy — lý do duy nhất của công tắc — không còn được
dùng. Request có marker vẫn được validate và bind như cũ, chỉ bỏ nhánh từ chối
request không marker.
Bỏ theo: hai trường config, bốn chỗ đọc/describe/validate, hai khối YAML runtime
và hai dòng trong test config. Test: xoá RejectsDockingRequestWithoutMarker (trái
hợp đồng mới) và DisabledMissionLayerDoesNotNeedANamespace; đổi
MissionLayerIsEnabledByDefault -> MissionNamespaceHasADefault,
RejectsEnabledMissionLayerWithoutNamespace -> RejectsAnEmptyMissionNamespace.
Verify: catkin_make --pkg move_base2 rc=0; ctest -R move_base2 17/17.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rayqed51UoUzE7QDRmM9K
ControlLoop truyền `output.recovery_trigger == kCollision` vào onRecoveryFinished ở cycle tick, mà
StateMachineOutput::recovery_trigger chỉ được điền ở cycle khởi động recovery (và khi trừ ngân sách);
cycle tick là mặc định kPlanningFailed nên from_contact luôn false. Run 6/9 16:30 (đám đông): người
đứng 7 cm trước mũi → 4 cờ collision cùng chỗ → route cạn → ABORT, JSONL contact_standdown = 0.
- ControlLoop::running_recovery_trigger_ ghi ở start_recovery, dùng ở tick kết thúc.
- FakeRecoveryPort::setSucceedWithPath; test walking skeleton
DetourFromContactThatDidNotMoveTheRobotArmsTheStandDown (cờ → detour có path → chạm lại tại chỗ
→ không RECOVERING thứ hai trong 1,5 s, lệnh về controller).
Test: walking_skeleton 58/58, env_monitor 47/47, các bộ khác pass. Sim 18:07 và 20:26 không hồi quy
(chưa có ca cờ collision thứ hai để kiểm sống).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xXjFjr2DQ6rhmhHSW4fk4
Xoá hạ tầng giám sát cũ đã tắt từ 5/9 (path_monitor/enabled: false), −2947 dòng:
- ControlLoop: PathMonitorConfig, updatePathMonitor / updateProgressMonitor / applyCollisionGuard /
planIsBlocked / resetPathMonitor / rebuildPlanArcLength, toàn bộ member bốn phép đo, luật "plan
mới bẩn thì giữ plan cũ" trong collectPlannerResult. Bốn cổng StateMachineInput giữ nguyên
(off_path không còn nguồn, đặt false).
- ports/path_check_port.h, CostmapPathCheck trong NavigationRuntime.
- plan_inspector: bỏ checkPlan / checkMotion / PlanBlockResult / MotionCheckParams /
MotionBlockResult; giữ planarTransform, nearestIndex, trackedNearestIndex, crossTrackError.
- Config: readPathMonitor, MoveBase2Config::path_monitor, validate; xoá
config/runtime/path_monitor_params.yaml; comment YAML/state_machine đổi sang tên verdict EnvMonitor.
- Test: FakePathCheckPort, 30 test WalkingSkeletonPathMonitor/CollisionGuard, 13 test
PlanInspectorCheck/Motion, 2 test validate thân guard.
P0(b): ControlLoop::step() gọi EnvironmentPort::refresh() một lần đầu cycle (không phụ thuộc
env_monitor/enabled); ControllerRunner::setSnapshotRefreshedByLoop(true) làm ba refreshSnapshot()
trong runner thành no-op — monitor và controller đọc cùng một lưới, một bản copy mỗi cycle.
Test: env_monitor 43, grid_analysis 33, plan_inspector 11, walking_skeleton 57, config_validation 32,
scenario 12, state_machine 100, navigation_server 56, controller_runner 28, velocity_arbiter 29,
planner_runner 31 — pass.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xXjFjr2DQ6rhmhHSW4fk4
Bộ giám sát mới trong ControlLoop (core/env_monitor, core/grid_analysis, ports/environment_port,
io/env_logger), thay bốn phép đo của PathMonitor (code cũ còn, tắt bằng path_monitor/enabled: false):
- kContact: dò tiếp xúc dọc quỹ đạo local planner (thay cung v/omega), bao tốc độ sqrt(2a(d - margin))
có dư, phanh chỉ khi vượt bao, cờ collision khi kề mũi tĩnh 1 s; cổng xoay tại chỗ theo lệnh
controller muốn; hysteresis + xác nhận khi nhả; đứng ra sau detour không dịch robot (nhường
controller); giữ phanh khi route khoá thì báo no valid command để controller_patience leo thang.
- kStall: cost_to_go = geodesic tới điểm thoát 2 m dọc plan + phần plan còn lại, index plan bám cửa
sổ, bộ lọc lật liên thông; cờ no_progress chỉ khi cổng dịch chuyển thực mở (robot không đi được
đâu trong 12 s dù lệnh >= 1,5 m) — thay ngân sách replan cho stall.
- kUnreachable: liên thông tới điểm thoát, đang ở action log.
- EnvLogger ghi JSONL mỗi tick nặng; config/runtime/env_monitor_params.yaml đủ khoá, comment tiếng
Việt; ControllerPort::measuredVelocity; FakeEnvironmentPort cho test.
Sim 5–6/9: hết churn detour, khe 1,25 m đi qua 0,5 m/s, lượt 6/9 10:15 2 detour/142 s không oan.
Test: grid_analysis 31, env_monitor 43, plan_inspector 37, walking_skeleton 87, các bộ khác pass.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xXjFjr2DQ6rhmhHSW4fk4
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