Atlas Robotics
Tuning Nav2Intermediate

Costmap tuning: inflation_radius and cost_scaling_factor

Atlasbot · 17/8/2026 · 11 min read

Costmap tuning: inflation_radius and cost_scaling_factor
inflation_radius and cost_scaling_factor affect the safety buffer

The article Costmap explained the Inflation Layer spreading costs around the obstacle. This is the practice of fine-tuning the two most important parameters of this class.

Key concepts

inflation_layer:
  inflation_radius: 0.55   # meters
  cost_scaling_factor: 3.0
  • inflation_radius— radius of influence, diffuse decision how far wide
  • cost_scaling_factor— speed decreases cost by distance, which determines that prudence decreases fast or slow

How it works

inflation_radius is correct as stated in Costmap: minimum equals robot radius (in Footprint) plus safety margin. Too small, the robot calculates the path closer to the obstacle than real-world safety allows; too large, the robot refuses to go through narrow spaces that the real-world is wide enough to squeeze through.

The cost formula in the inflationary zone:

cost = 253 × e^(-cost_scaling_factor × (distance − obstacle_radius))

cost_scaling_factor increment large, cost decrease nhanh by distance — Robots are more "low - guarded" and faster as they move away from the obstacle, ready to move closer. cost_scaling_factor increment smallAs the cost slows, the robot keeps a "cautious" distance over a wider range around each obstacle.

Combined: Two parameters coordinate —inflation_radius determining how far the zone of influence is, cost_scaling_factor determining whether that prudence decreases rapidly or slowly in that zone. A crowded, high-traffic environment should give a lower cost_scaling_factor priority (more caution longer); a static, narrow-passage environment should give a higher value (more caution fast, taking advantage of narrow space).

Technical details

Formulas

obstacle_range and raytrace_range — the influence of sensor data:

obstacle_layer:
  scan:
    obstacle_range: 2.5    # mark obstacle only in this range
    raytrace_range: 3.0    # remove old obstacle traces in this range when no longer visible
  • obstacle_range— LiDAR distance limits are allowed to add "occupied" cells to the too-far — obstacle costmap (although LiDAR has a longer scan range, article Select LiDAR) without immediate flagging, avoiding the costmap "overloading" of information not needed for immediate avoidance.
  • raytrace_range— limits the allowed distance deletes the previously marked occupied cell if the laser now passes through without touching anything — the "obstacle has disappeared" mechanism

Often placing raytrace_rangelarger thanobstacle_range— is easier to erase old tracks than to add new tracks, avoiding the costmap of forever "wearing" a long-lost moving dynamic obstacle.

Parameters

Environmentcost_scaling_factor proposedReason
Lots of people, lots of dynamic obstaclesLower (VD: 2.0)Keep a careful distance longer
Static, multiple narrow passagesHigher (VD: 5.0)Less caution, more space.

Practical applications

Testing with RViz2, exactly as learned in RViz2: adding Display to the topic /local_costmap/costmap— directly observes the color (cost) region spreading around the obstacle when changing each parameter, rather than guessing only with theoretical formulas. This is the most effective way to tune costmap: correct the parameters, see the visual effects in RViz2, repeat. For warehouses with both crowded (packed) and static (storage) areas, consider a different cost_scaling_factor configuration by area (similar to the zone - based approach learned in Tuning Velocity) rather than a compromise value common to the entire space.

Practical example

Compare 2 configurations with the same inflation_radius = 0.55m,
with an object 0.3m from the obstacle (inside the inflation region):

cost_scaling_factor = 2.0 (remains cautious longer):
cost = 253 × e^(-2.0 × 0.3) ≈ 253 × 0.549 ≈ 139 (cost is still fairly high)

cost_scaling_factor = 5.0 (becomes less cautious faster):
cost = 253 × e^(-5.0 × 0.3) ≈ 253 × 0.223 ≈ 56 (cost decreases more)

At the same distance of 0.3m, a higher cost_scaling_factor makes
the robot feel much safer (lower cost), more willing to pass through
that space than with a lower cost_scaling_factor

Common mistakes

  • Set raytrace_range as less than or equal to obstacle_range— as stated, contrary to the usual recommendation, makes it difficult for the costmap to clear the dynamic obstacle trace that has moved away, easier to "paste" the high cost at the position where the real-world obstacle is no longer present.
  • The cost_scaling_factor correction without visual observation via RViz2— relies solely on a theoretical formulation that easily selects values that do not match real-world perceptions of "is the robot sufficiently cautious" in a particular environment.
  • Using the same cost_scaling_factor for every area in a diverse operating space— misses an optimal opportunity to be both safe (crowded area) and efficient (stationary, narrow-incision area), as the Parameter table suggests.
  • Using obstacle_range larger than required— costmap must process multiple distant obstacle data not necessary for immediate avoidance, computation resource-intensive disproportionate benefits.

Conclusion

inflation_radius and cost_scaling_factor work together to shape the entire robot's "caution behavior" as it walks near the — obstacle as far as it is wide and as fast or slow down. Always fine-tune with visual observations via RViz2 rather than just relying on theoretical formulas. The following article in the section — Tuning Controller — reassembles the entire learned parameter into a systematic editing procedure, closing the section Tuning Nav2.

Get new articles and lessons by email

When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.

Unsubscribe any time with the link in each email. See our Privacy policy.

Costmap tuning: inflation_radius and cost_scaling_factor — Atlas Robotics