ros2 navigation ai_generated true

Nav2 costmap shows obstacles that have been removed, robot avoids phantom obstacles

ID: ros2/nav2-costmap-not-clearing-obstacle

Also available as: JSON · Markdown
82%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
any active

Root Cause

Nav2 costmap obstacle layer has separate 'marking' (adding obstacles) and 'clearing' (removing obstacles) behaviors. If the sensor's clearing parameters are misconfigured, obstacles are added but never removed. Raytrace clearing requires correct sensor origin and max range.

generic

Workarounds

  1. 92% success Configure obstacle layer with correct clearing parameters
    obstacle_layer: clearing: true, obstacle_max_range: 5.0, raytrace_max_range: 6.0  # raytrace must be >= obstacle max range
  2. 90% success Set correct sensor_frame and ensure TF from sensor to robot is published
    observation_sources: scan: {sensor_frame: laser_frame, clearing: true, marking: true, data_type: LaserScan}
  3. 82% success Add a voxel layer instead of obstacle layer for 3D clearing
    Voxel layer handles 3D raytrace clearing better than 2D obstacle layer for sensors with variable height

Dead Ends

Common approaches that don't work:

  1. Assume costmap automatically clears obstacles when sensor no longer sees them 85% fail

    Clearing happens via raytrace from sensor origin. If sensor origin frame is wrong, clearing rays miss the old obstacles. If obstacle_max_range < actual sensor range, far obstacles are never cleared.

  2. Increase costmap resolution to fix stale obstacles 72% fail

    Higher resolution makes the problem worse - more cells to clear. The issue is clearing behavior configuration, not resolution.