4 Commits

Author SHA1 Message Date
757b381659 feat(depth_layer): add occlusion_guard and attach_distance
occlusion_guard (default false): keep a stored point when a nearer object blocks the ray to it, clear a point the camera sees through. attach_distance (default 0.12 m, as before) is now read per source. Both keys are forwarded from the parent costmap parameters. README, params YAML and tests updated.
2026-10-27 13:09:31 +07:00
9b93a45b45 refactor(depth_layer): read parameters like the other layers
DepthCameraObstacleLayer::loadParameters() wrapped each key in a
readParam() helper. It now reads the same way as
ObstacleLayer::getParams(): one block of loadParam() calls on the default
file, then one block of "if (priv_nh.hasParam(k)) priv_nh.getParam(k, v)"
on "<costmap>/<plugin>". The per-source keys do the same on
"<costmap>/<plugin>/<source>". Values and precedence are unchanged.

getParam() gets the current value as its default, so a value of the
wrong type keeps the file default instead of becoming 0, false or "".
The layer no longer throws on a wrong type itself. A wrong type in the
shared block still stops the costmap, in copyParentParameters(). The two
wrong-type test cases, which set the layer namespace directly, are
removed.
2026-10-22 10:56:10 +07:00
e40e9c0104 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.
2026-10-22 10:49:31 +07:00
64974d48b7 feat(depth): DepthCameraObstacleLayer replaces depth clearing in ObstacleLayer/VoxelLayer
Depth cameras now go through their own costmap layer instead of the
frustum clearing that lived in ObstacleLayer and VoxelLayer.

- Add DepthCameraObstacleLayer. It stores marked points per costmap
  column, clears stored points inside each camera frustum with a kd-tree
  check against the new cloud, keeps points outside the view, groups
  points with Euclidean clustering, and does not mark a 12 cm band at the
  frustum faces.
- The layer follows the CostmapLayer contract: updateWithMax/Overwrite by
  combination_method, reset(), clearArea() with the usual invert
  semantics, footprint clearing, matchSize() and the layer mutex. So
  ClearCostmapRecovery and costmap resets work on it.
- Add LayerType::DEPTH_CAMERA_LAYER, appended last so the existing values
  keep their numbers. The host's SensorGateway must dispatch PointCloud2
  and DepthCameraData to it (move_base2 feature/depth-camera-layer-type).
- Remove the frustum clearing code from Observation, ObservationBuffer,
  ObstacleLayer, VoxelLayer and costmap_2d_robot.cpp.
- ObstacleLayer and VoxelLayer now reject a DepthCameraData source or
  frustum_clearing_enabled: true at startup, with a message that points
  to DepthCameraObstacleLayer.
- Link PCL into the plugins library only. Add 21 unit tests for the layer
  (depth_camera_obstacle_layer_test).

Squashed from feature/depth-observed-volume (2ca0bcc..40dc70e).
2026-10-21 13:16:07 +07:00