FixTheRobot Explore Robotics / Navigation / M5 / M5-L1

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

Navigation · Trajectories and Path Following · M5-L1 · Intermediate

Smooth a Jagged Path

10:20. The tray on Scout rattles all the way from the pharmacy to ward 3. The planner's path is correct, and it is made of forty tiny steps, each one a turn of 90 degrees. The robot slows down for every one of them and the cart tinkles on every corner.

You will write the collision test that every smoother needs, shortcut the staircase down to a handful of straight lines, and then pull the remaining path straight with a gradient smoother that is not allowed to move the start, the goal or a wall.

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 test that decides what smoothing may do: does a straight segment stay in free cells? Sampling too coarsely lets a path cut through a thin wall. Stage 2 uses the test for greedy shortcutting: from each waypoint jump to the farthest one that can be seen. Stage 3 is gradient smoothing: each waypoint is pulled towards the middle of its neighbours and back towards where it started, with the start and goal pinned and every move checked against the map.

    Grading is result-based: your functions run on the practice map and on freshly generated hidden maps. The checks measure collisions, waypoints, total turning and how far the path moved, not the exact numbers of one solution.

    Theory for this lab

    Trajectories and Path Following labs

    1. M5-L1: Smooth a Jagged Path: this lab.
    2. M5-L2: Build a Velocity Profile
    3. M5-L3: Tune Pure Pursuit
    4. M5-L4: Compare Pure Pursuit and Stanley

    Educational simplification: the robot is a point on an already inflated 0.25 m grid, walls are whole cells, the jagged path is a four-connected grid path, and smoothing only moves waypoints. Curvature limits, speed limits and splines are covered in lessons M5-T2 and M5-T3.

    Get the next lab

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