FixTheRobot Explore Robotics / Navigation / M5 / M5-L3

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

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

Tune Pure Pursuit

13:30. On the long east corridor Scout weaves from wall to wall at full speed. When the porter slows it down for the lift lobby, the same controller cuts the corner and scrapes the door frame. Someone has been changing the lookahead for a week and every change fixes one and breaks the other.

You will write the three pieces of pure pursuit yourself: the steering command towards a point, the search for that point on the path, and the rule that sets the lookahead from the speed and the latency of the robot.

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 geometry: the circle through the robot's position, tangent to its heading, that passes through a goal point. It needs the goal in the robot's own frame. Stage 2 finds the goal point: where the path leaves a circle of the lookahead radius around the robot, ahead of the robot's nearest point. Stage 3 is the tuning problem: the lookahead must be several times the distance covered during the command latency, or the robot weaves, and no longer than needed, or it cuts corners.

    Stage 3 is graded in simulation. Your function is called with speeds and latencies it has not seen, and the robot is driven down a corridor with a corner using the lookahead you return.

    Theory for this lab

    Trajectories and Path Following labs

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

    Educational simplification: a unicycle at constant speed, a pure delay between command and motion, a turn-rate limit, a perfect pose estimate and a path made of straight segments. The look-ahead point is where the path leaves a circle around the robot (lesson M5-T4). Regulated variants of pure pursuit that slow down for curves are covered in lessons M5-T4 and M6-T7.

    Get the next lab

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