How Does Pedro Pathing Work?
Harddifficulty
Read Guided Vector Fields and Mecanum Kinematics first, and set up your pose source with the Pose Estimation Contract. The first section needs no calculus. The later sections use derivatives of Bézier curves and some of the paper's notation.
Four jobs, and what goes wrong without each
This lesson explains how the follower is put together. It isn't Pedro's source code. Each loop does four jobs and adds the results together before the mecanum mixer:
| Component | Physical job | FTC symptom if wrong or missing |
|---|---|---|
| Tangential drive | move forward along the curve | robot corrects but crawls or stalls |
| Attractive correction | pull and damp motion back toward the curve | robot stays displaced or snakes after a bump |
| Centripetal feedforward | anticipate inward acceleration on bends | robot runs wide only on fast curves |
| Heading correction | track orientation independently | position is right but the robot faces wrong |
| Symptom on the robot | Check first in the official workflow |
|---|---|
| Pose axes/scale drift before following | localization setup |
| Straight paths oscillate or recover lazily | translational follower tuning |
| Fast curves run wide but slow curves work | centripetal correction and velocity constraints |
| Heading oscillates while translation is clean | heading controller tuning |
| The robot reaches the end but stays busy | completion constraints and terminal velocity |
Work through Pedro's own localization and tuning guides before changing anything inside it. If you can name the four jobs and pick which tuner to try from a symptom, that's enough to use Pedro well. The rest of the lesson goes into the math.
This lesson is based on the paper by the Pedro Pathing developers, Second-Order Multidimensional Guiding Vector Field for Parametric Path-Following Under Holonomic Constraints (Havish Sripada & Baron Henderson, 2026), on Zenodo.
This isn't a walk through Pedro's source code. It explains what the follower is trying to compute and why each part is there, which is what you need before tuning or changing a follower.
The braking section describes the paper and Pedro 2.1.x. The current documentation covers Pedro 3, which added Foresight, new configuration, and a new path API, so use the docs for the version you have installed.
The FTC problem Pedro is solving
Pure pursuit chases a point ahead of the robot. When the robot gets bumped, it's torn between catching that point and getting back onto the path. Pedro aims to follow Bézier curves quickly and consistently and to recover from bumps. Each loop:
- The path is not just a list of waypoints. It is a smooth curve.
- The robot estimates its current pose from localization.
- The follower projects the robot onto the curve to find the closest or most relevant path parameter.
- It computes correction vectors around that point.
- It converts the desired field motion into mecanum drive power.
That's what makes Pedro reactive. It isn't replaying a plan timed in advance. Every loop, it starts from where the robot actually is.
A path becomes a field of arrows
Each arrow shows which way a robot at that spot should move. Near the path, the arrows point along it. Farther away, they lean back toward it.
Drag the robot or a path handle, or focus one and use the arrow keys; hold Shift for a larger step.
The Pedro paper goes a step further. Its field depends on how fast the robot is already moving, not just where it is, so it can decide whether to brake, lean into a curve, or correct heading.
The pieces in more detail
The path is a curve, not a waypoint list
Pedro's paths are smooth curves, usually Bézier curves. Any such path can be written as a point that depends on a parameter :
runs from 0 at the start to 1 at the end. It isn't time or distance; isn't necessarily halfway along. The derivative points the way the path is going, and dividing by its length gives a length-1 direction, the tangent:
Because the path is a formula instead of a list of points, you can ask for its direction, curvature, remaining length, and target heading anywhere along it.
Projection: which point of the curve the robot belongs to
With the robot at position , the follower needs the whose path point is closest. The paper writes that as making this as small as possible:
That's half the squared distance. Squaring avoids a square root, the half makes the derivative neater, and neither changes which is closest. The closest point is either at an end of the path or where the derivative is zero:
A dot product of zero means perpendicular: at the closest point in the middle of the path, the line from the path to the robot meets the path at a right angle. That condition also holds at the farthest points, so the follower compares all the candidates and the two ends and keeps the closest. It can start its search from last loop's answer, since the robot can't jump to a different part of the path between loops.
Drag the robot below. The green point is the path point the follower thinks is closest, written , where is the closest . The yellow arrow is the tangent, used for forward motion, and the blue arrow is the normal, used for correction.
Drag a handle, or focus it and use the arrow keys; hold Shift for a larger step.
Once the follower knows which point on the path the robot is nearest, every other term comes from that spot: the tangent, the normal, the curvature, the target heading, and the distance left.
Cross-track error and its damped spring
Define the positional error used in the paper:
This vector points from the robot to its closest point on the path. The pull-back term acts like a spring toward the path, with damping. Simplified:
and are the translation gains (the superscript is for translation; heading gets its own pair later). is the part of the robot's velocity sideways to the path, so the damping term resists drifting away and also keeps the robot from swinging back too hard. The paper's exact version handles more edge cases, but the idea is the same: if the robot is off the path, push it back, and if it's already heading back fast, ease off.
Leaning into a bend before the robot drifts
On a curve, the robot needs acceleration toward the inside even when it's exactly on the path. Without it, the robot runs wide and only corrects after it's already off. For curvature at speed , the inward acceleration needed is
At 40 in/s around a 20 in radius, that's in/s². Drag the points below: a tighter curve has a smaller radius, a larger , and needs more inward acceleration at the same speed. (The demo fits a circle through three separate points, so it matches the path's curvature at one spot best when the points are close together.)
The paper writes the same thing in terms of the path's formula:
is the paper's name for the centripetal part of its field, and is a tuning gain. The squared term is the robot's speed along the path, the from above. The fraction is how fast the path's direction turns per inch traveled, which is the curvature. So it's , pointed toward the inside of the curve: when the path bends and the robot is moving fast, it leans in before it drifts out.
Tangential speed from a measured braking model
The follower also decides how hard to push along the path, based on how much path is left. The paper measures that by adding up the path's length from the robot's point to the end:
(The integral adds up small pieces of length, because equal steps in the parameter aren't equal distances.) The paper then uses , the constant-braking formula from PID-to-point. The paper keeps it general on purpose, since it's meant for any kind of robot. The follower Pedro actually shipped goes further and uses how the robot really stops.
Real drivetrains don't brake at a constant rate. Motor braking changes with speed, and friction adds more drag at higher speeds. Measure stopping distance against starting speed on a real robot and it fits a curve with a squared term and a straight term:
is the distance to stop from speed . The part is the constant-braking piece; with constant deceleration you'd have . The part covers the losses that grow with speed. On Pedro's test data was in the hundredths. It's small, but without it the model gets short stops wrong. The braking data came from Pedro Pathing and was collected by Jacob Ophoven.
There are two ways to use it:
- Pedro 2.1.x (starting with v2.1.0) runs a position controller and subtracts the stopping distance from the error: . When the distance left equals the stopping distance, the error is zero and the controller stops pushing.
- Solving for speed, which the paper describes as future work. Given the distance left, , solve with the quadratic formula and keep the positive answer:
and track that speed with a velocity controller. It's the same fit, used as a speed target instead of an error offset. As of v2.1.2 the released library used the error-offset version.
Pedro brakes actively, at about motor power. If you just let go and coast at zero power, the robot goes farther. The same shape fits both, but the and values are different, so measure them for the way you actually brake.
A timed trajectory decides speed from where the plan says you should be at this moment. Pedro decides it from where the robot actually is. If the robot gets bumped or slips, the distance left is still correct.
Heading runs on its own controller
FTC autos often move one way while facing another: intaking while strafing, or approaching with a camera pointed a certain way. The paper gives the target heading as its own smooth function along the path, . (In the paper's general version it's a rotation matrix; on an FTC field it's just an angle.) The heading correction is the usual heading loop:
and are the heading gains, is the measured turn rate, and the target heading is looked up at the robot's closest point on the path. Translation and heading are handled separately, so the robot can follow the curve while facing whichever way the path asks.
That fills in all four jobs from the table at the top. The combined command then goes through the mecanum mixer.
Implementation shape
Pedro has its own classes and tuners. A follower built the same way would look something like this:
void startPath() {
lastT = 0;
timer.reset();
}
MoveStatus update(PoseSample sample) {
Pose2d pose = sample.pose();
Vector2d velocity = sample.fieldVelocity();
lastT = path.project(pose.vec(), lastT); // seeded from last loop
MoveStatus completion = moveStatus(sample, path.endPose(), timer.seconds());
boolean atEnd = lastT >= 1 - TERMINAL_TOL;
if (completion == TIMED_OUT || (completion == REACHED && atEnd)) {
drive(0, 0, 0);
return completion;
}
Vector2d tangent = path.tangent(lastT).unit();
Vector2d leftNormal = new Vector2d(-tangent.y(), tangent.x());
double signedCurvature = path.curvature(lastT); // + left, - right bend
double remaining = path.remainingArcLength(lastT);
double tangentSpeed = velocity.dot(tangent);
double brakingSpeed = Math.sqrt(2 * MAX_DECEL * remaining);
double endScale = clamp(remaining / END_SLOWDOWN_DISTANCE, 0, 1);
double desiredSpeed = Math.min(CRUISE_SPEED, brakingSpeed) * endScale;
Vector2d alongPath = tangent.times(
DRIVE_KP * (desiredSpeed - tangentSpeed));
Vector2d towardPath = path.position(lastT).minus(pose.vec())
.times(TRANSLATION_KP);
Vector2d centripetal = leftNormal.times(
CENTRIPETAL_K * tangentSpeed * tangentSpeed * signedCurvature);
Vector2d fieldCommand = alongPath.plus(towardPath).plus(centripetal);
double turn = HEADING_KP * wrap(path.heading(lastT) - pose.heading());
driveFieldCentric(fieldCommand, turn);
return RUNNING;
}
If the tangent's length is near zero, the path has a sharp point there, so stop and report it instead of dividing by zero. Each of the three vectors has one job: control speed along the path, pull back onto it, and lean into bends.
What does the robot do with each of the three vectors removed? Without Without Without Show solution
alongPath nothing regulates speed: the robot still converges to the path and still points
the right way, but it crawls or overruns depending only on the other two terms, and the braking plan
does nothing.towardPath there is no correction for lateral error: push the robot off the line and it
happily continues parallel to the path forever, because tangent speed and curvature are both still
satisfied.centripetal the robot enters every bend on the old tangent and drifts wide, then
towardPath yanks it back — so corners are cut on the outside and the path is tracked with a
characteristic lag that gets worse the faster you go.
Why is heading a separate number instead of a fourth vector? What kind of drivetrain does that assume,
and what changes on a tank drive? And in the centripetal term, which part sets how hard the robot leans,
Separating heading assumes a holonomic drivetrain, where translation and rotation are independent
commands. On a differential drive they are not: heading is how you translate, so the follower has to
solve for a curvature the chassis can actually execute rather than adding a turn on top. For the centripetal term, required centripetal acceleration is — the squared speed sets
the magnitude, which is why the lean grows quadratically as you speed up, and the sign of
sets which side of the path to lean toward.tangentSpeed squared or the signed curvature, and which sets the direction?Show solution
The code shows how the pieces fit, not Pedro's real implementation. It uses one convention on purpose: the normal always points left of the path, and curvature is positive for left bends. A left bend then leans left, into the curve, and a right bend's negative curvature flips it to the right. For a real robot, still follow Pedro's own setup and tuning.
What completion really means
A path isn't done just because reached 1. A reliable follower checks several things:
- path progress is at or near the end;
- position error is small enough;
- heading error is small enough;
- velocity has settled enough for the next action;
- a timeout or correction window has elapsed.
Pedro's docs describe these as end constraints, checked through follower.isBusy(). The sketch above
slows down near the end and then uses the shared MoveStatus: REACHED and TIMED_OUT both stop the
robot, but only REACHED lets the routine carry on normally. Moving on too early starts the next action
while the robot is still settling, and too late wastes match time.
What the second-order field adds
The paper gives the theory behind all of this. Its main idea is a field that depends on the robot's velocity as well as its position, so it says what acceleration to apply, not just which way to go:
Here the state is position, rotation, velocity, and turn rate together. The four entries say how each of those should change: position changes by the velocity , rotation changes by the turn rate (), and and are the commanded accelerations for moving and turning. For an FTC mecanum robot, in words:
Each term is one of the four jobs from the table at the top, with its own constants: and for pulling back, for curves, and for heading, and the fitted for speed along the path. Those are the numbers a team tunes.
- Havish Sripada and Baron Henderson, Second-Order Multidimensional Guiding Vector Field for Parametric Path-Following Under Holonomic Constraints, Pedro Pathing, 2026. Preprint, Zenodo, DOI 10.5281/zenodo.20725319.
- Pedro Pathing documentation, Introduction: Bezier curves, PIDF control, centripetal force correction, localization prerequisites, and tuning overview.
- Pedro Pathing documentation, What's new with Pedro 3: current Foresight, path API, tuning, and logging changes.
- Pedro Pathing documentation, End Constraints: current completion criteria used by
follower.isBusy(). - The braking model, the Pedro 2 vs Pedro 3 braking implementations, and the active-braking caveat are from correspondence with Havish Sripada (Pedro Pathing); the braking-distance regression data was collected by Jacob Ophoven (Pedro Pathing).
- This lesson extends Guided Vector Fields and Mecanum Kinematics.