Nav2 can clear a local or global costmap when planning or control fails. That operation changes the navigation stack's stored grid state. It does not move a pallet, open a door, repair a lidar, correct localization, or prove that a corridor is physically clear.

This boundary is crucial in recovery design. A clear service can remove stale obstacle costs that no longer match the world, allowing a planner to try again. The same service can also temporarily remove useful evidence. Sensors and map layers may repopulate the cells on the next update, or a blind sensor region may leave them deceptively empty.

What the recovery actually does

The default Nav2 behavior trees use clear-costmap service nodes after selected planner or controller failures. The official tree examples clear the global costmap after a path-planning failure and the local costmap after a path-following failure. At the system recovery level, both can be cleared before other actions such as waiting, spinning, or backing up.

Nav2 also exposes different scopes. A deployment may clear an entire costmap, preserve a region, clear around the robot, or clear around a supplied pose. Targeted clearing can remove stale dynamic-obstacle costs at a goal while retaining useful information elsewhere.

In every case, the result is a change to costmap data. The service response confirms that the requested software operation completed. It is not a perception report that the physical region became safe.

Layers can return immediately

A Nav2 costmap is usually assembled from layers. A static layer can reintroduce map cells. Obstacle or voxel layers can mark cells again from fresh sensor observations. An inflation layer recomputes graded costs around whatever lethal cells remain. Clearing one layer or master grid therefore does not imply that every contributor stays empty.

This is often the desired behavior. If a person or cart is still in the aisle, a functioning sensor should mark it again. A rapidly returning obstacle is evidence that the world or perception stream still supports the cost, not proof that clearing failed.

The opposite case is more dangerous. If a sensor is stale, occluded, outside range, or missing a transform, the cleared cells may remain free even though the obstacle still exists. An empty costmap after recovery is only as trustworthy as the observations and map policies that repopulate it.

Distinguish stale memory from persistent reality

Before clearing, record why the cost is suspected to be stale. Useful evidence includes obstacle age, sensor timestamps, transform availability, observation and raytrace ranges, marking and clearing configuration, layer update frequency, robot pose, and the physical scene.

Then classify the outcome. If the obstruction has physically moved and fresh clearing rays remove its cells, the costmap can converge to free space without a manual reset. If the obstruction remains, fresh marking should restore it. If neither happens, investigate the data path instead of repeatedly clearing.

Repeated clearing can hide a fault

A behavior tree that clears on every failure can create a loop: plan fails, grid clears, planner briefly finds a route, obstacle returns, controller stops, and recovery repeats. The robot may appear active while making no durable progress.

Bound retries and preserve error codes. Track which failure triggered clearing, which costmap and scope were changed, how long the next plan remained valid, and whether the robot advanced. Escalate when the same evidence recurs.

Do not use clearing to override a true no-path result. A blocked aisle may simply have no traversable route for the released footprint and cost policy. The correct response can be waiting, choosing another route, requesting assistance, or ending the mission.

Validate perception after the reset

Immediately after clearing, verify that every expected observation source is current. Compare sensor header time with system time, confirm transforms at the measurement time, and check that the costmap update and publish cycles continue. Observe both marking and clearing behavior.

Use a controlled test with a movable obstacle. Place it inside the configured observation range, confirm it is marked, clear the relevant costmap, and verify that it reappears while still present. Remove it and verify that valid clearing observations eventually free the cells. Repeat near range boundaries and occlusions.

Test static-map behavior separately. Clearing should not permanently erase walls supplied by a static layer. If a wall disappears from the combined costmap, examine the layer configuration, map subscription, lifecycle state, and update ordering.

Target the smallest useful scope

Clearing an entire global costmap discards more state than clearing around one stale goal. Prefer a scope tied to the evidence. Targeted clearing reduces the period during which unrelated obstacle memory is absent and makes the recovery easier to explain.

Local and global grids serve different decisions. The global planner may be blocked by a stale cost near the goal, while the local controller has valid nearby obstacle data. Clear only the affected grid unless the failure analysis supports a broader action.

Preserve a before-and-after record

Save the costmap immediately before the service, after the service, and after at least one full sensor-and-layer update cycle. Include layer names, plugin versions, parameters, timestamps, robot pose, and the clear service used.

Overlay the physical obstacle position and sensor field of view. A blank grid image without this context cannot show whether the reset corrected stale data or merely removed evidence.

Measure recovery success narrowly

A useful recovery metric is not simply that the clear service returned success. Measure whether a valid plan was produced, whether the controller followed it, how far the robot progressed, whether obstacle cells were repopulated consistently with the scene, and whether the failure recurred within a defined interval.

Safety remains independent

Costmap clearing is not a protective stop, safety-rated perception function, or authorization to move. The robot must still respect its collision monitor, emergency stop, speed limits, and any independent safety system required by the risk assessment.

The defensible claim is modest: a named Nav2 clear service changed specified costmap state, fresh layers rebuilt the grid, and the subsequent plan and motion were validated against the observed scene. Keep software memory, perception evidence, and physical clearance separate throughout the recovery.