update
This commit is contained in:
@@ -136,6 +136,62 @@ 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);
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -146,6 +202,7 @@ void readMoveBase2Fields(robot::NodeHandle& nh, MoveBase2Config& config)
|
||||
|
||||
readDouble(nh, "planner_patience", config.state_machine.planner_patience);
|
||||
readDouble(nh, "controller_patience", config.state_machine.controller_patience);
|
||||
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, "action_patience", config.state_machine.action_patience);
|
||||
@@ -159,6 +216,7 @@ void readMoveBase2Fields(robot::NodeHandle& nh, MoveBase2Config& config)
|
||||
readDouble(nh, "acc_lim_theta", config.velocity.max_accel_theta);
|
||||
|
||||
readSensors(nh, config.sensors);
|
||||
readPathMonitor(nh, config.path_monitor);
|
||||
readBool(nh, "docking_requires_marker", config.docking_requires_marker);
|
||||
|
||||
readString(nh, "recovery_namespace", config.recovery_namespace);
|
||||
@@ -253,6 +311,54 @@ bool MoveBase2Config::validate(std::string& error) const
|
||||
error = "planner_timeout is not finite [s]";
|
||||
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.horizon > 0.0) && !(path_monitor.max_cross_track > 0.0))
|
||||
{
|
||||
// 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";
|
||||
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)";
|
||||
@@ -370,6 +476,7 @@ void MoveBase2Config::fromLegacyNodeHandle(robot::NodeHandle& nh)
|
||||
readDouble(nh, "runtime_stats_period", runtime_stats_period);
|
||||
readDouble(nh, "planner_patience", state_machine.planner_patience);
|
||||
readDouble(nh, "controller_patience", state_machine.controller_patience);
|
||||
readDouble(nh, "sensor_patience", state_machine.sensor_patience);
|
||||
readDouble(nh, "oscillation_timeout", state_machine.oscillation_timeout);
|
||||
readDouble(nh, "oscillation_distance", state_machine.oscillation_distance);
|
||||
readInt(nh, "max_planning_retries", state_machine.max_planning_retries);
|
||||
@@ -505,6 +612,7 @@ ControlLoopConfig MoveBase2Config::toControlLoopConfig() const
|
||||
config.velocity = velocity;
|
||||
config.nominal_control_period =
|
||||
controller_frequency > 0.0 ? 1.0 / controller_frequency : 0.05; // [s]
|
||||
config.planner_frequency = planner_frequency; // [Hz] replan nền khi kControlling
|
||||
config.robot_base_frame = robot_base_frame;
|
||||
config.require_current_costmap = require_current_costmap;
|
||||
config.position = position;
|
||||
@@ -514,6 +622,7 @@ 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;
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user