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
This commit is contained in:
@@ -159,6 +159,38 @@ void readPathMonitor(robot::NodeHandle& nh, ControlLoopConfig::PathMonitorConfig
|
||||
readDouble(monitor_nh, "max_cross_track", monitor.max_cross_track);
|
||||
readDouble(monitor_nh, "grace_after_new_plan", monitor.grace_after_new_plan);
|
||||
|
||||
// Phép đo 3 (2026-09-03): thân sắp chạm vật cản THẬT trên cung lệnh. Khoá riêng, không dùng chung
|
||||
// tham số nào với hai phép đo trên.
|
||||
readBool(monitor_nh, "collision_enabled", monitor.collision_enabled);
|
||||
readDouble(monitor_nh, "collision_lookahead", monitor.collision_lookahead);
|
||||
monitor_nh.param("collision_max_samples", monitor.collision_max_samples,
|
||||
monitor.collision_max_samples);
|
||||
readDouble(monitor_nh, "collision_stop_distance", monitor.collision_stop_distance);
|
||||
monitor_nh.param("collision_confirm_cycles", monitor.collision_confirm_cycles,
|
||||
monitor.collision_confirm_cycles);
|
||||
monitor_nh.param("collision_cost_threshold", monitor.collision_cost_threshold,
|
||||
monitor.collision_cost_threshold);
|
||||
readDouble(monitor_nh, "collision_front_offset", monitor.collision_front_offset);
|
||||
readDouble(monitor_nh, "collision_rear_offset", monitor.collision_rear_offset);
|
||||
readDouble(monitor_nh, "collision_side_offset", monitor.collision_side_offset);
|
||||
readDouble(monitor_nh, "collision_footprint_padding", monitor.collision_footprint_padding);
|
||||
readBool(monitor_nh, "collision_exclude_baseline", monitor.collision_exclude_baseline);
|
||||
readDouble(monitor_nh, "collision_min_speed", monitor.collision_min_speed);
|
||||
readDouble(monitor_nh, "collision_stop_time", monitor.collision_stop_time);
|
||||
readDouble(monitor_nh, "collision_stop_angle", monitor.collision_stop_angle);
|
||||
readDouble(monitor_nh, "collision_lookahead_angle", monitor.collision_lookahead_angle);
|
||||
readDouble(monitor_nh, "collision_brake_decel", monitor.collision_brake_decel);
|
||||
|
||||
// Phép đo 4 (2026-09-04): planner đòi đi mà robot không tiến.
|
||||
readBool(monitor_nh, "progress_enabled", monitor.progress_enabled);
|
||||
readString(monitor_nh, "progress_action", monitor.progress_action);
|
||||
readDouble(monitor_nh, "progress_window", monitor.progress_window);
|
||||
readDouble(monitor_nh, "progress_min_commanded", monitor.progress_min_commanded);
|
||||
readDouble(monitor_nh, "progress_min_efficiency", monitor.progress_min_efficiency);
|
||||
readDouble(monitor_nh, "progress_clear_efficiency", monitor.progress_clear_efficiency);
|
||||
readDouble(monitor_nh, "progress_confirm_time", monitor.progress_confirm_time);
|
||||
readDouble(monitor_nh, "progress_goal_zone", monitor.progress_goal_zone);
|
||||
|
||||
std::vector<std::string> names;
|
||||
monitor_nh.param("profiles", names, std::vector<std::string>{});
|
||||
if (names.empty())
|
||||
@@ -208,6 +240,7 @@ void readMoveBase2Fields(robot::NodeHandle& nh, MoveBase2Config& config)
|
||||
readDouble(nh, "sensor_patience", config.state_machine.sensor_patience);
|
||||
readDouble(nh, "oscillation_timeout", config.state_machine.oscillation_timeout);
|
||||
readDouble(nh, "oscillation_distance", config.state_machine.oscillation_distance);
|
||||
readDouble(nh, "recovery_reset_min_travel", config.state_machine.recovery_reset_min_travel);
|
||||
readDouble(nh, "action_patience", config.state_machine.action_patience);
|
||||
readInt(nh, "max_planning_retries", config.state_machine.max_planning_retries);
|
||||
readBool(nh, "recovery_behavior_enabled", config.state_machine.recovery_enabled);
|
||||
@@ -394,11 +427,122 @@ bool MoveBase2Config::validate(std::string& error) const
|
||||
error = "path_monitor/grace_after_new_plan must be >= 0 [s]";
|
||||
return false;
|
||||
}
|
||||
if (!(path_monitor.horizon > 0.0) && !(path_monitor.max_cross_track > 0.0))
|
||||
if (path_monitor.collision_enabled)
|
||||
{
|
||||
// Bật khối mà tắt cả hai phép đo là mâu thuẫn: người khai tưởng giám sát đang chạy.
|
||||
error = "path_monitor is enabled but both checks are off; set horizon > 0 [m] and/or "
|
||||
"max_cross_track > 0 [m], or set enabled: false";
|
||||
const auto bad = [](double v) { return !std::isfinite(v) || v < 0.0; };
|
||||
if (!std::isfinite(path_monitor.collision_lookahead) || path_monitor.collision_lookahead <= 0.0)
|
||||
{
|
||||
error = "path_monitor/collision_lookahead must be > 0 [m]";
|
||||
return false;
|
||||
}
|
||||
if (path_monitor.collision_max_samples < 1)
|
||||
{
|
||||
error = "path_monitor/collision_max_samples must be >= 1";
|
||||
return false;
|
||||
}
|
||||
if (bad(path_monitor.collision_stop_distance) ||
|
||||
path_monitor.collision_stop_distance > path_monitor.collision_lookahead)
|
||||
{
|
||||
error = "path_monitor/collision_stop_distance must be in [0, collision_lookahead] [m]";
|
||||
return false;
|
||||
}
|
||||
if (path_monitor.collision_confirm_cycles < 1)
|
||||
{
|
||||
error = "path_monitor/collision_confirm_cycles must be >= 1";
|
||||
return false;
|
||||
}
|
||||
if (path_monitor.collision_cost_threshold < 1 || path_monitor.collision_cost_threshold > 254)
|
||||
{
|
||||
error = "path_monitor/collision_cost_threshold must be in [1, 254] (254 = LETHAL only)";
|
||||
return false;
|
||||
}
|
||||
if (bad(path_monitor.collision_front_offset) || bad(path_monitor.collision_rear_offset) ||
|
||||
bad(path_monitor.collision_side_offset) || bad(path_monitor.collision_footprint_padding))
|
||||
{
|
||||
error = "path_monitor/collision_*_offset and collision_footprint_padding must be >= 0 [m]";
|
||||
return false;
|
||||
}
|
||||
{
|
||||
// Cả ba = 0: lấy thân từ footprint costmap lúc chạy. Khai tay thì phải đủ cả ba > 0 — mũi = 0
|
||||
// là chỉ dò tâm (dừng khi tâm đã ở trong tường), hông = 0 là bỏ hai cạnh hông.
|
||||
const int declared = (path_monitor.collision_front_offset > 0.0 ? 1 : 0) +
|
||||
(path_monitor.collision_rear_offset > 0.0 ? 1 : 0) +
|
||||
(path_monitor.collision_side_offset > 0.0 ? 1 : 0);
|
||||
if (declared != 0 && declared != 3)
|
||||
{
|
||||
error = "path_monitor/collision_front_offset, collision_rear_offset and "
|
||||
"collision_side_offset must either all be 0 (take the body from the costmap "
|
||||
"footprint) or all be > 0 [m]";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!std::isfinite(path_monitor.collision_stop_time) || path_monitor.collision_stop_time <= 0.0)
|
||||
{
|
||||
error = "path_monitor/collision_stop_time must be > 0 [s]";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.collision_stop_angle) || path_monitor.collision_stop_angle <= 0.0 ||
|
||||
path_monitor.collision_stop_angle > M_PI)
|
||||
{
|
||||
error = "path_monitor/collision_stop_angle must be in (0, pi] [rad]";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.collision_lookahead_angle) ||
|
||||
path_monitor.collision_lookahead_angle < path_monitor.collision_stop_angle ||
|
||||
path_monitor.collision_lookahead_angle > M_PI)
|
||||
{
|
||||
error = "path_monitor/collision_lookahead_angle must be in [collision_stop_angle, pi] [rad]";
|
||||
return false;
|
||||
}
|
||||
if (bad(path_monitor.collision_min_speed) || bad(path_monitor.collision_brake_decel))
|
||||
{
|
||||
error = "path_monitor/collision_min_speed [m/s] and collision_brake_decel [m/s^2] must be >= 0";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (path_monitor.progress_enabled)
|
||||
{
|
||||
if (path_monitor.progress_action != "log" && path_monitor.progress_action != "recover")
|
||||
{
|
||||
error = "path_monitor/progress_action must be 'log' or 'recover'";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.progress_window) || path_monitor.progress_window <= 0.0)
|
||||
{
|
||||
error = "path_monitor/progress_window must be > 0 [s]";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.progress_min_commanded) ||
|
||||
path_monitor.progress_min_commanded <= 0.0)
|
||||
{
|
||||
// 0 là đo cả lúc đứng yên: cmd = 0, eff = 0/0 -> mọi lần chờ hợp lệ đều thành "kẹt".
|
||||
error = "path_monitor/progress_min_commanded must be > 0 [m]";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.progress_min_efficiency) ||
|
||||
!std::isfinite(path_monitor.progress_clear_efficiency) ||
|
||||
path_monitor.progress_min_efficiency < 0.0 ||
|
||||
path_monitor.progress_clear_efficiency <= path_monitor.progress_min_efficiency)
|
||||
{
|
||||
// clear == min là cờ nhấp nháy quanh một ngưỡng: bật, xoá, bật... mỗi lượt quét.
|
||||
error = "path_monitor/progress_clear_efficiency must be > progress_min_efficiency >= 0";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.progress_confirm_time) ||
|
||||
path_monitor.progress_confirm_time < 0.0 ||
|
||||
!std::isfinite(path_monitor.progress_goal_zone) || path_monitor.progress_goal_zone < 0.0)
|
||||
{
|
||||
error = "path_monitor/progress_confirm_time [s] and progress_goal_zone [m] must be >= 0";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!(path_monitor.horizon > 0.0) && !(path_monitor.max_cross_track > 0.0) &&
|
||||
!path_monitor.collision_enabled && !path_monitor.progress_enabled)
|
||||
{
|
||||
// Bật khối mà tắt cả bốn phép đo là mâu thuẫn: người khai tưởng giám sát đang chạy.
|
||||
error = "path_monitor is enabled but all checks are off; set horizon > 0 [m], "
|
||||
"max_cross_track > 0 [m], collision_enabled: true and/or progress_enabled: true, "
|
||||
"or set enabled: false";
|
||||
return false;
|
||||
}
|
||||
if (path_monitor.profiles.empty())
|
||||
|
||||
Reference in New Issue
Block a user