AI Glossary / Reinforcement learning and robotics / Intermediate
Costmap
Definition
A costmap is a spatial representation that assigns navigation costs to locations. In mobile robotics, it commonly uses a grid whose cells indicate obstacles, free areas, unknown space or degrees of difficulty for movement. Planners and controllers use these costs, together with other constraints, to choose routes and motion.
What it means
A map can show where things are, but a robot also needs to reason about where it should travel. A costmap translates environmental information into a form that a navigation algorithm can evaluate. An open corridor might receive a low cost, while cells close to an obstacle receive higher costs.
Cost does not necessarily mean money, probability of collision or travel time. Its meaning depends on the representation and navigation algorithm. Some values are special labels, such as lethal obstacle or unknown, rather than quantities to add indiscriminately.
How it works
Sensors, stored maps and configured rules supply spatial information. A layered costmap can combine a static map, observed obstacles and additional navigation preferences. Inflation raises costs around obstacles, helping account for clearance rather than treating a robot as a dimensionless point.
A planner searches or scores candidate paths using the representation; a controller may use nearby costs when choosing motion. Resolution, coordinate frames, robot footprint and update timing all influence interpretation. The rules for merging layers and handling unknown cells must be specified. A costmap is an input to navigation, not a complete navigation system.
Three practical examples
1. A warehouse robot uses obstacle observations to discourage routes through a newly occupied aisle. Whether the map updates promptly depends on sensor processing and configuration.
2. A simulated cart prefers a wider corridor because cells near its walls carry higher costs than cells near the center.
3. A facility model marks a restricted region as unavailable to the planner. This encodes a navigation rule that may not correspond to a visible physical obstacle.
Think of it this way
Think of a floor plan with annotations showing where travel is easy, awkward, forbidden or not yet understood. The annotations help compare routes, but they are only as useful as the information behind them. A clean-looking area on the plan might reflect missing data rather than a confirmed clear passage. The navigation system must interpret that distinction.
Worked example
Consider a toy grid where two candidate paths have already passed a separate collision check. Path A enters five cells with illustrative costs 1, 1, 8, 1 and 1. Path B enters seven cells, each costing 1. Ignore the common starting cell and define the path score solely as the sum of entered-cell costs.
A's score is 1 + 1 + 8 + 1 + 1 = 12. B's score is 7. Under this deliberately simple rule, the longer path B is preferred.
Now define a different score: cell-cost sum plus 3 for every entered cell. A scores 12 + 3 × 5 = 27, while B scores 7 + 3 × 7 = 28. Under that objective, A is preferred.
The map did not change; the scoring rule did. These arbitrary numbers are not a Nav2 encoding or recommended tuning. An obstacle marked forbidden must remain excluded rather than being traded off as merely a moderately expensive cell.
Illustrative case study
Fictional case: Cedar Mobility tests a simulated stockroom robot. A route planner repeatedly selects a narrow gap that looks free at the map's resolution, but the robot's represented footprint does not fit comfortably. The team checks footprint settings, cell size and obstacle inflation before adjusting the planner.
It also tests whether temporary boxes disappear from the costmap after sensors observe clear space. Reviewers inspect both false obstacles and missed obstacles, then evaluate complete navigation behavior. This invented case illustrates representation checks; it reports no actual robot deployment, measured safety improvement or guaranteed collision avoidance.
Common misconceptions and mistakes
A costmap is not always an occupancy-probability map. A cell can have a high navigation cost because it is near an obstacle or subject to a rule, not because it has a corresponding probability of being occupied.
Finer resolution does not automatically solve navigation problems: it increases resource use and cannot recover information the sensors never observed. Inflation is also not a universal collision guarantee. Incorrect localization, stale data, unmodeled geometry and dynamic motion can invalidate an apparently clear route. Finally, unknown cells should not silently be treated as confirmed free space without an explicit policy.
Business use
Costmaps connect sensing and operational rules to robot movement. Teams should define what each layer represents, who maintains persistent restrictions and how temporary observations are cleared. Changes in layouts, robot loads or operating conditions may require reassessment of the representation.
For evaluation, examine route feasibility, clearance, update delays and computational load. A visually attractive map is insufficient evidence of good navigation. Test the complete system under realistic conditions and ensure that obstacle handling, planning and control agree about the robot's geometry and the meaning of cost values.
People also ask
Does a costmap contain only obstacles?
No. It can also represent proximity costs, unknown space and navigation preferences or restrictions.
Is the lowest-cost path always the shortest?
No. The outcome depends on the objective and how distance, clearance and cell costs are combined.
Are global and local costmaps identical?
They can use the same general representation while differing in extent, frame, resolution, update settings and the planning or control role they support.
Check your understanding
Why does the worked example switch from preferring B to preferring A without changing any cell costs?
Answer: The second objective adds a larger penalty for the number of entered cells. A is shorter, so that extra term outweighs its higher original cell-cost sum. Costmap interpretation depends on the scoring rule.
Related terms
- Occupancy grid
- Global costmap
- Local costmap
- Path planning
- Localization
- obstacle inflation
- robot footprint
- sensor fusion
- collision checking
Learn next
Learn how spatial grids, coordinate frames and robot footprints are represented. Inspect separate costmap layers before their combined output. Then trace how the chosen planner and controller use costs, including forbidden and unknown cells, and test updates when the environment changes.
More in Reinforcement learning and robotics
- Cloud robotics - Cloud robotics uses network-accessible computation, data, or services to support robots and automation systems.
- Conservative policy iteration - Conservative policy iteration is a reinforcement-learning approach that improves a policy by mixing it with a candidate improvement instead of replacing it...
- Conservative Q-learning - Conservative Q-learning (CQL) is an offline reinforcement-learning framework that discourages inflated action-value estimates when learning from a fixed...
- Curse of horizon in off-policy evaluation - The curse of horizon in off-policy evaluation refers to the difficulty of estimating a policy's performance from another policy's data as decision sequences...
- DAgger - DAgger, short for Dataset Aggregation, is an iterative imitation-learning algorithm.
- Deep deterministic policy gradient - Deep deterministic policy gradient, or DDPG, is an off-policy actor-critic reinforcement-learning algorithm for continuous action spaces.
Sources
Nav2, Environmental Representation, official explanation of costmaps and layers: https://docs.nav2.org/rolling/getting_started/navigation_concepts/environmental_representation/
The example deliberately specifies its own scoring rule rather than assuming a universal interpretation of costmap values. The path calculations and Cedar Mobility case are original hypothetical illustrations.
Previous: Cost-sensitive machine learning Next: Count data