refactor: xoá PathMonitor và PathCheckPort, EnvMonitor là bộ giám sát duy nhất; gộp refreshSnapshot
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
This commit is contained in:
@@ -140,94 +140,6 @@ void readDockingMarkerProfiles(robot::NodeHandle& nh, DockingMarkerProfiles& pro
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Đọc khối `path_monitor`.
|
||||
*
|
||||
* Khối vắng mặt = giám sát tuyến TẮT, hành vi y hệt trước 2026-08-04d. Đây là đường lùi thứ nhất
|
||||
* (thứ hai là route `path_blocked`/`off_path` rỗng) — hai nút độc lập, cố ý.
|
||||
*/
|
||||
void readPathMonitor(robot::NodeHandle& nh, ControlLoopConfig::PathMonitorConfig& monitor)
|
||||
{
|
||||
robot::NodeHandle monitor_nh(nh, "path_monitor");
|
||||
|
||||
readBool(monitor_nh, "enabled", monitor.enabled);
|
||||
readBool(monitor_nh, "path_blocked_enabled", monitor.path_blocked_enabled);
|
||||
readBool(monitor_nh, "off_path_enabled", monitor.off_path_enabled);
|
||||
readDouble(monitor_nh, "check_period", monitor.check_period);
|
||||
readDouble(monitor_nh, "confirm_time", monitor.confirm_time);
|
||||
readDouble(monitor_nh, "horizon", monitor.horizon);
|
||||
readDouble(monitor_nh, "min_detour_distance", monitor.min_detour_distance);
|
||||
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())
|
||||
{
|
||||
return; // Giữ mặc định: chỉ profile position.
|
||||
}
|
||||
|
||||
monitor.profiles.clear();
|
||||
for (const std::string& name : names)
|
||||
{
|
||||
if (name == "position")
|
||||
{
|
||||
monitor.profiles.push_back(MotionProfile::kPosition);
|
||||
}
|
||||
else if (name == "docking")
|
||||
{
|
||||
monitor.profiles.push_back(MotionProfile::kDocking);
|
||||
}
|
||||
else if (name == "go_straight")
|
||||
{
|
||||
monitor.profiles.push_back(MotionProfile::kGoStraight);
|
||||
}
|
||||
else if (name == "rotate")
|
||||
{
|
||||
monitor.profiles.push_back(MotionProfile::kRotate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Không đoán: tên lạ mà im lặng bỏ qua thì người vận hành tưởng đã bật giám sát cho profile
|
||||
// đó. Cảnh báo rồi bỏ — profile lạ không thể tự sinh ra hành vi nào.
|
||||
robot::log_warning("[move_base2] path_monitor/profiles: unknown profile '%s', ignored.\n",
|
||||
name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Các tham số chung của move_base2, dùng chung cho schema namespace và schema root-profile.
|
||||
void readMoveBase2Fields(robot::NodeHandle& nh, MoveBase2Config& config)
|
||||
{
|
||||
@@ -271,7 +183,6 @@ void readMoveBase2Fields(robot::NodeHandle& nh, MoveBase2Config& config)
|
||||
readSensors(nh, config.sensors);
|
||||
readSensorStore(nh, config);
|
||||
readDebug(nh, config);
|
||||
readPathMonitor(nh, config.path_monitor);
|
||||
readEnvMonitor(nh, config);
|
||||
readBool(nh, "docking_requires_marker", config.docking_requires_marker);
|
||||
|
||||
@@ -514,164 +425,6 @@ bool MoveBase2Config::validate(std::string& error) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (path_monitor.enabled)
|
||||
{
|
||||
// Chỉ kiểm khi BẬT: tham số vô nghĩa trong một khối đang tắt không có lý do gì để chặn boot.
|
||||
if (!std::isfinite(path_monitor.check_period) || path_monitor.check_period <= 0.0)
|
||||
{
|
||||
error = "path_monitor/check_period must be > 0 [s]";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.confirm_time) || path_monitor.confirm_time < 0.0)
|
||||
{
|
||||
error = "path_monitor/confirm_time must be >= 0 [s]";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.horizon) || path_monitor.horizon < 0.0)
|
||||
{
|
||||
error = "path_monitor/horizon must be >= 0 [m] (0 = the blocked-path check is off)";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.min_detour_distance) || path_monitor.min_detour_distance < 0.0)
|
||||
{
|
||||
error = "path_monitor/min_detour_distance must be >= 0 [m]";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.max_cross_track) || path_monitor.max_cross_track < 0.0)
|
||||
{
|
||||
error = "path_monitor/max_cross_track must be >= 0 [m] (0 = the off-path check is off)";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(path_monitor.grace_after_new_plan) ||
|
||||
path_monitor.grace_after_new_plan < 0.0)
|
||||
{
|
||||
error = "path_monitor/grace_after_new_plan must be >= 0 [s]";
|
||||
return false;
|
||||
}
|
||||
if (path_monitor.collision_enabled)
|
||||
{
|
||||
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())
|
||||
{
|
||||
error = "path_monitor/profiles is empty; no leg would ever be monitored";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!std::isfinite(runtime_stats_period) || runtime_stats_period < 0.0)
|
||||
{
|
||||
error = "runtime_stats_period must be >= 0 [s] (0 = telemetry off)";
|
||||
@@ -971,7 +724,6 @@ ControlLoopConfig MoveBase2Config::toControlLoopConfig() const
|
||||
config.rotate = rotate;
|
||||
config.backup_global_planner_name = backup_global_planner_name;
|
||||
config.docking_requires_marker = docking_requires_marker;
|
||||
config.path_monitor = path_monitor;
|
||||
config.env_monitor = env_monitor;
|
||||
config.env_sampling = env_sampling;
|
||||
config.env_logger = env_logger;
|
||||
|
||||
Reference in New Issue
Block a user