A layered costmap builds a robot's picture of where it's safe to drive by stacking sources — static map, live obstacles, and safety inflation — into one grid the planner reads, the standard structure behind ROS navigation.
A costmap is a grid that scores how risky each spot near the robot is to drive on. It's built in layers — the known map, live sensor obstacles, and a safety buffer around obstacles — stacked together into one map the planner uses to choose a safe route.
Before a robot can plan a safe route, it needs a map of how risky each nearby spot is to drive on — not just occupied vs free, but with safety margins and live obstacles. That map is a costmap, and it's built in layers.
From occupancy grid to costmap
An occupancy grid says whether each cell is occupied. A costmap goes further: each cell holds a cost — how undesirable or dangerous it is to be there — which a planner (A*, DWA) uses to prefer safe, low-cost routes. The clever part is building it from multiple layers that each contribute information, composed into one final grid.
Layers combine into one costmap
Each layer adds its costs; stacked together they form the single grid the planner reads. Layers can be updated independently as the world changes.
The standard layers
Static layer. The known map (from SLAM or a saved map) — the walls and fixed structure.
Obstacle layer. Live obstacles detected by sensors (lidar, depth camera) marked in real time, and cleared when they move away. This is how the robot reacts to things not on the static map — people, boxes, doors.
Inflation layer. A safety buffer: cost radiates outward from every obstacle in a decaying gradient, so the planner keeps a margin instead of grazing obstacle edges (accounting for the robot's size and uncertainty).
Modular. Add, remove, or reconfigure a layer without rewriting the whole costmap — plug in a "speed zone" or "no-go" layer as needed.
Independently updated. The static layer rarely changes; the obstacle layer updates every sensor cycle — layering lets each refresh at its own rate.
Local + global. Navigation typically keeps a global costmap (whole map, for the global planner) and a local costmap (a rolling window around the robot, for the local planner) — both layered.
This is the structure of ROS's costmap_2d and Nav2.
Why it matters
Layered costmaps are how a navigating robot turns a jumble of map data, live sensor readings, and safety rules into one coherent picture of where it can safely go. It's the shared representation that connects mapping, perception, and planning — a foundational piece of practical mobile-robot navigation.