Skip to the lesson
FixTheRobot Explore Robotics / Navigation / M2 Maps and Costmaps / M2-T2

Navigation · Theory · M2

M2-T2 — Inflation and Footprints

Inflation turns “keep the robot’s body off the walls” into numbers a planner can add up.

  • Lesson 2 of 6
  • Module 2: Maps and Costmaps
  • Theory
  • About 7 minutes to read

The map says where the walls are. The robot is not a point, so a planner needs to know how close it may come. Inflation answers with a cost around every obstacle: forbidden where the body would touch, steeply expensive just beyond, and fading to nothing. Three parameters decide whether Scout glides through a door or refuses it.

Learning objectives

After this lesson, you should be able to:

  • Compute the inscribed and circumscribed radii of a rectangular footprint.
  • Write the inflation cost function with its lethal, inscribed and decaying regions.
  • Choose an inflation radius and decay from the footprint and the narrowest door.
  • Explain why the same parameters can make a door passable or closed.

The intuition

Walk down a corridor and you keep a little distance from the wall without thinking. You are not afraid of it. Brushing it is not allowed, being near it is merely a little undesirable, and by an arm’s length it no longer matters. An inflation layer encodes exactly that for a robot: a region around every obstacle where the planner may not put the robot’s centre, then a band where it can but would rather not.

Two circles describe the robot’s body. The inscribed radius is the largest circle that fits inside the footprint, so a centre closer than that to an obstacle is always a collision. The circumscribed radius is the smallest circle that contains the footprint, so a centre further than that is always safe at any heading. Between the two, safety depends on the direction the robot faces.

Inflation cost against distanceA plot of cost against distance from an obstacle. Cost is 254 at the obstacle, 253 up to the inscribed radius, then falls exponentially to zero at the inflation radius. distance from the nearest obstacle (m)cost 0.22 inscribed0.55 inflation radius 254 / 253decay: 252·e^(−k(d−r)) free (0)
The cost profile of an inflation layer: obstacles are lethal, cells within the inscribed radius are inscribed, and the cost decays exponentially to zero at the inflation radius.

The mathematics

Radii of a rectangle

Footprint radii
rinscribed=min⁡(length, width)2r_{\text{inscribed}}=\frac{\min \text{(length, width)}}{2}
rcircumscribed=(length2)2+(width2)2r_{\text{circumscribed}}=\sqrt{(\frac{\text{length}}{2})^{2}+(\frac{\text{width}}{2})^{2}}

The cost function

Inflation cost
cost⁡(d)=254\operatorname{cost}(d)=254
d=0d=0
the obstacle itself
253253
0<d≤rin0<d\le r_{\text{in}}
the centre here means contact
trunc⁡(252⋅e(−k⋅(d−rin)))\operatorname{trunc}(252\cdot e^{(-k\cdot (d-r_{\text{in}}))})
rin<d≤rinflr_{\text{in}}<d\le r_{\text{infl}}
00
d>rinfld>r_{\text{infl}}
d
distance from the cell centre to the nearest obstacle cell centre, in metres.
rin
inscribed radius used by the costmap (set from the footprint).
rinfl
inflation radius: no cost beyond it.
k
decay factor (cost_scaling_factor in Nav2): larger values fall faster.

The values 254 and 253 are codes, not magnitudes: a planner treats a cell with a cost of at least 253 as one the robot’s centre may not enter. The decaying values are advice that a planner can trade against distance travelled.

What the parameters do to a door

Inflation closes a door when 2 × rin reaches the door width. The decay band does not close anything, but it adds cost along the way, so a high decay factor (fast fall) leaves a cheap middle, while a low one makes the whole door expensive.

Effect of inflation parameters
ParameterToo smallToo large
rinThe robot touches walls with its cornersDoors close; the robot reports no path
rinflNo room to prefer the middle of a corridorCorridors and rooms fill with cost; planning is slower and prefers odd detours
kCost spreads far: everything feels dangerousCost vanishes quickly: the robot hugs the walls beyond the inscribed band

A worked example

Scout’s radii. The footprint is 0.60 m × 0.40 m.

Scout radii
rinscribed=0.402=0.200 mr_{\text{inscribed}}=\frac{0.40}{2}=0.200\,\mathrm{m}
rcircumscribed=0.302+0.202=0.361 mr_{\text{circumscribed}}=\sqrt{0.30^{2}+0.20^{2}}=0.361\,\mathrm{m}

Set the costmap inscribed radius to 0.22 m (the true 0.20 m plus a little for localization error), the inflation radius to 0.55 m and the decay factor to 6. The costs follow:

Cost table
d(m)  costd(m)\;\mathrm{cost}
0.000.00
254  lethal254\;\mathrm{lethal}
0.200.20
253  inscribed253\;\mathrm{inscribed}
0.300.30
155=trunc⁡(252⋅e(−6⋅0.08))155=\operatorname{trunc}(252\cdot e^{(-6\cdot 0.08)})
0.400.40
8585
0.500.50
4646
0.550.55
3434
0.600.60
00
beyond the inflation radius

The 0.90 m door. The jambs each inflate by 0.22 m to the inscribed band, so the centre may use 0.90 − 2 × 0.22 = 0.46 m of the door. Down the middle the robot is 0.45 m from each jamb, so the cost there is trunc(252 · e^(−6 · 0.23)) = 63: the door is open and has a cheap track down its centre, but a planner will prefer a wider door when the detour is short. If someone sets the inscribed radius to 0.5 m by mistake, 0.90 − 1.00 is negative and the door closes (lab M2-L1, stage 3).

The cost of rounding. A costmap on a 0.10 m grid represents distances in multiples of 0.1 m from cell centres, so the inscribed band is really “within 0.2 m” or “within 0.3 m” depending on the cell. That is why the inscribed radius in the costmap is set slightly above the true one, and why changing the map resolution without checking the parameters changes the margin.

Engineering implications and limitations

One footprint, shared

The most common cause of a robot that stops before a door it fits through is that two components use different footprints: for example 0.6 × 0.4 m in the global costmap and a leftover 0.9 × 0.9 m in the local one. Define the footprint once, in one place, and give every costmap the same value (see lab M1-L1).

Where the safety margin lives

Margin can be added to the footprint, to the inscribed radius, or to the inflation radius. Pick one place, write it down, and check that the narrowest doorway still passes with the total margin. Adding it in two places is how doors close.

Circle or polygon

A circular footprint is cheap and safe; a polygon is exact and costs more per check. Many robots use a circle for the global costmap and the real polygon for the local planner’s final check.

Tune with a map you can see

Draw the costmap and look at it. A wrongly-sized band is obvious in a picture and invisible in a parameter file.

Common misconceptions

“A bigger inflation radius is always safer.”

Beyond the inscribed radius it only changes preferences, and past a point it closes doors and makes routes absurd. Safety comes from the inscribed radius being right.

“The inscribed radius is the robot’s radius.”

It is the radius of the biggest circle that fits inside the footprint. For a long robot it is far smaller than the radius that contains the body.

“Cost 253 and cost 252 are almost the same.”

They are very different: 253 means the centre may not enter, 252 means it may, at a high price.

“Changing the grid resolution does not change inflation.”

Distances are measured between cell centres, so margins move by up to a cell. Re-check after changing the resolution.

Engineering takeaways

  1. The inscribed radius says where contact is certain; the circumscribed radius says where the body is safe at any heading.
  2. An inflation layer has lethal, inscribed and exponentially decaying regions, and zero beyond the inflation radius.
  3. A door of width w remains passable for the centre only for w − 2·rin.
  4. Set the footprint once, share it, and keep the margin in one place.
  5. Inspect the costmap visually after any change to the parameters or resolution.

References and further reading

The layered costmap paper and the Nav2 documentation.

  • D. Lu, D. Hershberger and W. Smart, “Layered Costmaps for Context-Sensitive Navigation”, IEEE/RSJ IROS, 2014.
  • Nav2 documentation, “Inflation Layer Parameters” and “Costmap 2D”, docs.nav2.org.
  • K. Konolige et al., “Navigation in Hybrid Metric-Topological Maps”, IEEE ICRA, 2011.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

A robot is 0.80 m long and 0.50 m wide. What are its inscribed and circumscribed radii?

Explanation

Inscribed: 0.50 / 2 = 0.25 m. Circumscribed: sqrt(0.40² + 0.25²) = 0.472 m.

Question 2

The costmap uses an inscribed radius of 0.25 m. What is the narrowest gap the robot’s centre can pass, and how wide must a door be to leave a 0.20 m track?

Explanation

The gap must exceed 2 × 0.25 = 0.50 m. To leave a 0.20 m track the door must be 0.50 + 0.20 = 0.70 m wide.

Question 3

With rin = 0.22, rinfl = 0.55 and k = 6, what is the cost at 0.40 m?

Explanation

trunc(252 · e^(−6 × (0.40 − 0.22))) = trunc(252 · e^(−1.08)) = trunc(85.6) = 85.

What’s next

Next: a way to get the distance to the nearest obstacle for every cell without checking every obstacle.

Practice this lesson

Build an Inflated Costmap

Scout keeps clipping door frames: inflate the obstacles correctly so the planner keeps clear.

Next lesson

M2-T3 — Distance Transforms and Euclidean Distance Fields

Compute a distance field with a two-pass sweep and use it to find clearance and a gradient away from obstacles.

Nothing below is required to finish this lesson.