fix(costmap): one parameter flow for every layer; fail on a bad layer

Each layer reads its default file under $PNKX_NAV_CORE_CONFIG_DIR/config,
then overrides a key from "<costmap>/<plugin>".
Costmap2DROBOT::copyParentParameters() copies the shared "<plugin>:"
block there first. This was broken in three ways:
- the copy lists covered only part of what the layers read, so a key set
  in the shared block was dropped without a word;
- DepthCameraObstacleLayer had no default file and read the shared block
  itself;
- a layer that failed to initialize left a half-built costmap that
  reported READY.

Failing loudly:
- costmap_2d_robot.cpp: a failing layer, a malformed plugins: list or a
  missing costmap_params.yaml throws std::runtime_error with the costmap
  and layer name, after releasing layered_costmap_.
  NavigationRuntime::buildCostmaps() turns this into an initialization
  error, so the host never reports READY.
- Static/Obstacle/Voxel/Inflation and DepthCameraObstacleLayer throw when
  their default file cannot be opened.
- A key whose value does not convert to the type the layer reads throws.
  getParam() used to write 0, false or "" into the value, and that was
  copied as if configured.

One flow:
- copyParentParameters() copies every key each layer reads, with the
  layer's type, including a new DepthCameraObstacleLayer branch. Copies no
  layer reads are dropped.
- DepthCameraObstacleLayer::loadParameters() reads
  config/depth_camera_obstacle_layer_params.yaml (new, equal to the C++
  defaults), then "<costmap>/<plugin>". ParamReader is gone, and so is the
  node_handle.cpp:265 warning at start-up.
- VoxelLayer: z_resolution can be overridden; unknown_threshold is
  computed after the final z_voxels; the column keys are range-checked;
  the effective column is logged once at start-up.
- config/obstacle_layer_params.yaml: drop the per-source keys the layer
  never read there.
- depth_camera_obstacle_layer_test: set PNKX_NAV_CORE_CONFIG_DIR; add
  tests for a wrong type and a missing default file.

Squash of fix/config-flow (ae7fce9, f8705e1). Checked on the KIT robot on
22/10/2026:
- the depth layer summary at start-up is unchanged;
- a shared-block key now reaches VoxelLayer;
- FOV_W 3.5, z_voxels 17, a wrong-typed key and a missing default file
  each give INITIALIZATION_FAILED.
This commit is contained in:
2026-10-22 10:49:31 +07:00
parent 3b89add5ee
commit e40e9c0104
9 changed files with 340 additions and 262 deletions

View File

@@ -43,6 +43,7 @@
#include <robot_tf3_geometry_msgs/tf3_geometry_msgs.h>
#include <boost/dll/alias.hpp>
#include <stdexcept>
#include <fstream>
#include <cxxabi.h>
@@ -71,7 +72,8 @@ void StaticLayer::onInitialize()
global_frame_ = layered_costmap_->getGlobalFrameID();
std::string config_file_name = "static_layer_params.yaml";
getParams(config_file_name, priv_nh);
if (!getParams(config_file_name, priv_nh))
throw std::runtime_error("StaticLayer " + name_ + ": cannot open the default file " + config_file_name);
robot::log_warning("Initializing static layer with map topic \"%s\" in frame \"%s\"", map_topic_.c_str(), global_frame_.c_str());
}