Skip to main content

Module 4 · Path Following & Kinematics

A good autonomous routine needs two abilities: driving to any pose on the field, and following a smooth path through many poses at speed without stopping to re-aim. This module builds up to both.

Prerequisites

This module builds on two earlier pieces:

When a follower misbehaves, the bug is usually in the pose estimate or the controller underneath, not in the path logic.

Five steps every loop​

Every follower in this module, from the simplest go-to-pose to a guided vector field, runs the same five steps every loop. They only differ in how they do steps 2 and 3.

StepWhat happensWhere it lives
1. Update poseupdate one external pose source once, then read one coherent field pose/velocity samplePose Estimation Contract
2. Plan the targetpick where to go next — a target pose, a lookahead point, or a field vectorthis module
3. Controlturn the error into a chassis command (vx,vy,ω)(v_x, v_y, \omega) with PID + feedforwardthis module + Module 2
4. Mix & correctconvert the chassis command to wheel powers, desaturate, re-run next loopMecanum kinematics
5. Resolve outcomestop on REACHED or TIMED_OUT, then advance or recover explicitlyCommon Implementation
Don't skip step 5

A follower that never decides it's done will wander around the target forever, and one that only checks position will say it's done while still coasting through. Check that the robot is close enough and slow enough. A timeout is a separate outcome, a failure to recover from, never a successful arrival.

All the followers share a few building blocks: the Pose2d and Vector2d types, wrap, the MoveStatus result, kStatic, and drive. They're defined once in Common Implementation, so each lesson's code only shows what's new.

See it on a real robot​

Before the math, here's a competitive team walking through their own movement code on real hardware.

Wolfpack Movement Breakdown -

Wolfpack & Lupine (Waring Robotics) walk through their autonomous movement code from start to finish.

Open video

Lessons, simplest first​

Start with the follower you can debug by watching it, and only add more when you hit a real limit.

  1. Mecanum kinematics (Easy): turning one drive command into four wheel powers, plus field-centric driving, joystick shaping, and a dead zone. This is step 4, and it comes first so everything later has a drivetrain to command.
  2. Angle wrapping (Easy): the small fix that stops the robot turning the long way around. Every pose controller needs it.
  3. Pose Estimation Contract (Easy): set up one localization library and check its frame, units, and timing.
  4. Common Implementation (Easy): the shared types and helpers every follower uses.
  5. PID-to-point (Medium): the simplest complete follower. Three PID loops drive to one target pose, with a friction nudge and braking that starts on time. Most autonomous routines are just a list of these.
  6. Splines (Hard): ways to describe a smooth path, with Bézier curves, quintic Hermite splines, and natural cubic splines.
  7. Pure pursuit (Hard): chase a point a fixed distance ahead on the path, and plan speed around the curves.
  8. Guided vector fields (Hard): follow a path as a field of arrows that pulls the robot onto it, instead of chasing a point.

Lessons 1 to 5 get you a working, debuggable autonomous. Lessons 6 to 8 add smooth paths and speed.

Side branch: Inverse Kinematics turns a claw target into arm joint angles. It uses the same geometry but isn't needed for the followers.

Longer derivations, like Jacobian inverse kinematics and how Pedro Pathing works, are in Advanced Topics.