feat(move_base2): direction zone delivery and costmap readiness wait

- SensorGateway::pushStaticMap also dispatches to DIRECTIONAL_LAYER on
  the global costmap, before STATIC_LAYER: with a same-geometry map the
  directional layer goes PENDING before StaticLayer can report current,
  so a plan cannot pair the new map with the old zones.
- Static maps are replayed in arrival order instead of topic order, so a
  direction grid is never replayed before its static map.
- PlannerRunner checks every enabled global layer under the same lock as
  the snapshot. While a layer is not current it keeps the goal, reports
  waiting_for_costmap, logs the stale layers (throttled) and spends no
  planner_patience or watchdog budget. After costmap_ready_timeout [s]
  (default 10, 0 = legacy behaviour) the attempt fails as before. The
  key is added to config/runtime/move_base_common_params.yaml.
- Test fixture destroys the server before its fake ports (the control
  thread could call a destroyed port).

Full history: branch feature/direction-zone.
This commit is contained in:
2026-11-04 13:24:16 +07:00
parent 75af8ccf12
commit 051e18f989
21 changed files with 483 additions and 31 deletions

View File

@@ -146,6 +146,7 @@ void readMoveBase2Fields(robot::NodeHandle& nh, MoveBase2Config& config)
readDouble(nh, "controller_frequency", config.controller_frequency);
readDouble(nh, "planner_frequency", config.planner_frequency);
readDouble(nh, "planner_timeout", config.planner_timeout);
readDouble(nh, "costmap_ready_timeout", config.costmap_ready_timeout);
readDouble(nh, "runtime_stats_period", config.runtime_stats_period);
readDouble(nh, "watchdog_period", config.watchdog.period);
readDouble(nh, "local_planner_call_budget", config.watchdog.local_planner_call_budget);
@@ -435,6 +436,11 @@ bool MoveBase2Config::validate(std::string& error) const
error = "planner_timeout is not finite [s]";
return false;
}
if (!std::isfinite(costmap_ready_timeout) || costmap_ready_timeout < 0.0)
{
error = "costmap_ready_timeout must be finite and >= 0 [s] (0 = legacy behavior)";
return false;
}
if (!watchdog.validate(error))
{
return false;
@@ -536,6 +542,8 @@ std::string MoveBase2Config::describe() const
out << " controller_frequency: " << controller_frequency << " Hz\n";
out << " planner_frequency: " << planner_frequency << " Hz\n";
out << " planner_timeout: " << planner_timeout << " s\n";
out << " costmap_ready_timeout: " << costmap_ready_timeout << " s"
<< (costmap_ready_timeout == 0.0 ? " (readiness check off)\n" : "\n");
out << " runtime_stats_period: " << runtime_stats_period << " s"
<< (runtime_stats_period > 0.0 ? "\n" : " (off)\n");
out << watchdog.describe();
@@ -582,6 +590,7 @@ void MoveBase2Config::fromLegacyNodeHandle(robot::NodeHandle& nh)
readDouble(nh, "controller_frequency", controller_frequency);
readDouble(nh, "planner_frequency", planner_frequency);
readDouble(nh, "costmap_ready_timeout", costmap_ready_timeout);
// Khoá này không có trong schema gen-1 — nó là công cụ chẩn đoán của move_base2. Vẫn đọc ở đây
// để bật được telemetry mà không phải chuyển cả cây config sang schema mới.
readDouble(nh, "runtime_stats_period", runtime_stats_period);
@@ -731,6 +740,7 @@ ControlLoopConfig MoveBase2Config::toControlLoopConfig() const
config.debug_plan = debug_plan;
config.debug_skip = debug_skip;
config.state_machine = state_machine;
config.costmap_ready_timeout = costmap_ready_timeout;
config.velocity = velocity;
config.nominal_control_period =
controller_frequency > 0.0 ? 1.0 / controller_frequency : 0.05; // [s]