﻿# Nav2 regional clearing: a square reset to unknown, not a free-space observation

Inspect how Nav2 converts reset_distance into map bounds and clears layer cells, separating recovery state changes from fresh obstacle observations.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/robotics-costmap-clear-region-square-unknown-reset/
Language: en

## A recovery changes a map, not a corridor

A warehouse robot has accumulated an obstacle mark beside a loading bay. Its recovery clears the nearby costmap and a supervisor interprets successful completion as permission to resume. The missing question is what was erased and what replaced it. A clearing operation can remove stored evidence without acquiring a newer view of the bay. Establish the map mutation before assigning a physical meaning to the recovery result; a still-present pallet can remain outside the current sensor view.

## Read reset_distance as a side length

In the [regional clearing implementation](https://raw.githubusercontent.com/ros-navigation/navigation2/main/nav2_costmap_2d/src/clear_costmap_service.cpp), the lower coordinates are the robot position minus half of reset_distance. Each upper coordinate adds the full reset_distance to that lower bound. The requested region is consequently a centered square in map coordinates, not a disk whose radius equals the parameter. Conversion to cell indices and clipping also matter near map edges. An operator diagram showing a circular radius would misdescribe the actual cells selected by this implementation.

## Unknown is the replacement state

The [CostmapLayer source](https://raw.githubusercontent.com/ros-navigation/navigation2/main/nav2_costmap_2d/src/costmap_layer.cpp) marks the layer noncurrent and writes NO_INFORMATION into selected cells that previously contained known values. This is materially different from writing a measured free-space classification. The master costmap subsequently combines layers according to their own update and merge behavior. Inspect the relevant layer as well as the combined output; another layer may retain an obstacle, and a particular combination policy can hide the provenance of a visually cleared patch.

## Build a nonactuating boundary fixture

A proposed regression fixture should use a known grid and a fixed synthetic robot pose. Place distinct marks inside the square, outside its edge and near a corner that a circular interpretation would classify differently. Include a map-edge case. Pause sensor input while inspecting the mutation, then provide an explicitly identified new observation. This separates reset behavior from rapid repopulation by the next sensor callback. It is a suggested diagnostic protocol, not a report of a robot experiment.

## Require layer-level evidence

Retain the costmap frame, robot pose used by the service, requested distance, plugin selection and before/after layer cells. With the default regional selection, the inspected code processes layers advertising isClearable; explicit plugin selection follows its validation path. Do not generalize regional behavior to the separate clear-entirely operation. Acceptance should show both the intended rectangle and the intended layer set changed, with later observation timestamps recorded separately from the service response.

## Keep the recovery claim bounded

A successful reset can support recovery from stale marks while still requiring a fresh perception policy before movement. It does not establish sensor coverage, localization accuracy or collision-free execution. The [Habitat clearance guide](/journal/fg2-habitat-navmesh-agent-radius-geodesic-reachability/) addresses modeled traversability; the [R2R navigation guide](/journal/fg2-matterport-r2r-viewpoint-graph-not-continuous-path/) separates route representations from executable motion. Here the narrower contract is which stored cells were invalidated, under the source revision checked, and which new evidence subsequently justified using that space.
