FixTheRobot Explore Robotics / Navigation / M2 / M2-L1

This lab works on phones, but writing code is much easier on a laptop.

Navigation · Maps and Costmaps · M2-L1 · Beginner

Build an Inflated Costmap

09:40. Scout keeps clipping door frames on the way to the pharmacy, and in the evening it refuses the same doors with "no path". The map is correct. The costmap built from it is not.

You will write the cost function that turns a distance into a number the planner can use, inflate a whole hospital hall with it, and then measure what is left of a 0.9 m door.

Your task

    Simulation
    solution.pyLoading Python…
    Ctrl+Enter runs
    What Python can I use?

    Plain Python with math and heapq. Your code runs in a background worker: an endless loop is stopped after a few seconds and the page stays usable. It runs in your browser and is never sent anywhere.

    Hints

    What this lab teaches

    Stage 1 is the cost function: lethal at the obstacle, inscribed within the robot's inscribed radius, and an exponential decay beyond that, down to zero at the inflation radius. Stage 2 applies it to a map, and the distance must be measured in metres, not cells. Stage 3 asks what the inflation does to a doorway and why the inscribed radius is a fact about the robot rather than a tuning knob.

    Grading is result-based: your functions are run on the practice example and on freshly generated hidden maps, and compared with the exact answer.

    Theory for this lab

    Maps and Costmaps labs

    1. M2-L1: Build an Inflated Costmap: this lab.
    2. M2-L2: Compute a Distance Field
    3. M2-L3: Find the Ghost Obstacles

    Educational simplification: a circular robot, distances between cell centres, Nav2-style cost values (254 lethal, 253 inscribed, 0 to 252 decaying), a single static layer, and no unknown space. Real costmaps combine several layers (lesson M2-T4).

    Get the next lab

    Get notified when new robotics labs are released. One email per new lab, nothing else.