Files
costmap_2d/test/depth_camera_obstacle_layer_test.cpp
duongtd a5f548f0d7 refactor(depth): DepthCameraObstacleLayer follows the CostmapLayer contract
The port wrote LETHAL straight into the master from its stored 3D points and
left its own grid empty, as costmap_depth_camera does. Everything CostmapLayer
offers on top of the own grid therefore missed the layer: clearArea() (the
ClearCostmapRecovery path), reset() (Costmap2DROBOT::resetLayers()), footprint
clearing and combination_method all acted on an empty grid, and the next cycle
wrote the ghosts back. Cleared cells also stayed on the master until another
layer's bounds covered them (the source's B7).

The stored points stay the source of truth; the clearing and marking
algorithm is unchanged. The own grid now mirrors them cell by cell, the way
VoxelLayer keeps a voxel grid next to its 2D grid:

- marking sets the column's cell LETHAL, the last point of a column leaving
  sets it FREE_SPACE, and both touch the bounds, so a cleared cell leaves the
  master in the same cycle (clear_touches_bounds is gone, always on);
- updateCosts() only merges the own grid with combination_method, like
  ObstacleLayer; combination_method other than 0/1 now means "no effect";
- reset() drops the stored points and buffered observations;
- clearArea() follows CostmapLayer::clearArea(): invert_area false clears
  outside the box and keeps the inside, true clears the inside;
- footprint clearing erases the stored columns under the robot;
- markings that leave the window are dropped in updateBounds() (B6), and a
  column whose cell went missing is re-marked;
- the layer mutex guards the point map, since ClearCostmapRecovery and
  resetLayers() reach it from other threads (recursive mutex, held by the
  recovery around clearArea()).

Tests: the two clear_touches_bounds cases become one bounded-update case, and
clearArea (both directions), reset and footprint clearing get their own.
2026-10-20 13:34:08 +07:00

15 KiB