fix(costmap): refuse to build a costmap with a failed layer

Costmap2DROBOT::getParams() logged a layer that threw from initialize()
and returned. The constructor then finished normally with a half-built
costmap: no failed layer, no layers after it, no footprint and no update
thread. move_base2 reported READY, and the only trace was a message
blaming plugin registration.

- costmap_2d_robot.cpp: a failing layer, a malformed plugins: list and a
  missing costmap_params.yaml now throw std::runtime_error with the
  costmap and layer name, after releasing layered_costmap_ (the
  destructor does not run when the constructor throws).
  NavigationRuntime::buildCostmaps() already turns this into an
  initialization error, so the host never reports READY.
- Static/Obstacle/Voxel/Inflation layers throw when their default file
  cannot be opened, instead of running with no parameters.
- VoxelLayer: z_resolution can be overridden from the costmap config
  like the other column keys; unknown_threshold is computed after the
  final z_voxels, so overriding z_voxels alone keeps it right; z_voxels,
  z_resolution, origin_z and the thresholds are range-checked; the
  effective column is logged once at start-up.
- config/obstacle_layer_params.yaml: drop the per-source keys. The layer
  reads them only under <plugin>/<source>/, so these were never used.
This commit is contained in:
2026-10-22 09:46:11 +07:00
parent 3b89add5ee
commit ae7fce9e77
6 changed files with 87 additions and 75 deletions

View File

@@ -41,6 +41,7 @@
#include <robot_costmap_2d/footprint.h>
#include <boost/thread.hpp>
#include <boost/dll/alias.hpp>
#include <stdexcept>
using robot_costmap_2d::LETHAL_OBSTACLE;
@@ -80,7 +81,8 @@ void InflationLayer::onInitialize()
need_reinflation_ = false;
std::string config_file_name = "inflation_layer_params.yaml";
// std::cout << "InflationLayer: " << config_file_name << std::endl;
getParams(config_file_name, priv_nh);
if (!getParams(config_file_name, priv_nh))
throw std::runtime_error("InflationLayer " + name_ + ": cannot open the default file " + config_file_name);
matchSize();
}