Skip to main content

How Does Pedro Pathing Work?

Harddifficulty

Prerequisites and a starting path

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:

ComponentPhysical jobFTC symptom if wrong or missing
Tangential drivemove forward along the curverobot corrects but crawls or stalls
Attractive correctionpull and damp motion back toward the curverobot stays displaced or snakes after a bump
Centripetal feedforwardanticipate inward acceleration on bendsrobot runs wide only on fast curves
Heading correctiontrack orientation independentlyposition is right but the robot faces wrong
Symptom on the robotCheck first in the official workflow
Pose axes/scale drift before followinglocalization setup
Straight paths oscillate or recover lazilytranslational follower tuning
Fast curves run wide but slow curves workcentripetal correction and velocity constraints
Heading oscillates while translation is cleanheading controller tuning
The robot reaches the end but stays busycompletion 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.

Based on the Pedro Pathing whitepaper

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.

Scope

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:

  1. The path is not just a list of waypoints. It is a smooth curve.
  2. The robot estimates its current pose from localization.
  3. The follower projects the robot onto the curve to find the closest or most relevant path parameter.
  4. It computes correction vectors around that point.
  5. 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.

Live demoThe guiding vector field: test local recovery on either side
drag the robot or blue path handles

Drag the robot or a path handle, or focus one and use the arrow keys; hold Shift for a larger step.

cross-track error e: -22.6 infield here: (0.48, 0.88)low kN: glides in gently · high kN snaps in (overshoots)
path (○ = end)robotflow line it would followfield arrows (teal near path → blue far off)Bézier control points

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 tt:

ϕ(t)=[x(t)y(t)],0≤t≤1\phi(t) = \begin{bmatrix} x(t) \\ y(t) \end{bmatrix}, \qquad 0 \le t \le 1

tt runs from 0 at the start to 1 at the end. It isn't time or distance; t=0.5t = 0.5 isn't necessarily halfway along. The derivative ϕ′(t)\phi'(t) points the way the path is going, and dividing by its length gives a length-1 direction, the tangent:

T^(t)=ϕ′(t)∥ϕ′(t)∥\hat{\mathbf{T}}(t) = \frac{\phi'(t)}{\|\phi'(t)\|}

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 p\mathbf{p}, the follower needs the tt whose path point is closest. The paper writes that as making this as small as possible:

D(t)=12∥ϕ(t)−p∥2D(t) = \frac{1}{2}\|\phi(t) - \mathbf{p}\|^2

That's half the squared distance. Squaring avoids a square root, the half makes the derivative neater, and neither changes which tt is closest. The closest point is either at an end of the path or where the derivative is zero:

D′(t)=(ϕ(t)−p)⋅ϕ′(t)=0D'(t) = \left(\phi(t) - \mathbf{p}\right) \cdot \phi'(t) = 0

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 ϕ(ψ(p))\phi(\psi(\mathbf{p})), where ψ(p)\psi(\mathbf{p}) is the closest tt. The yellow arrow is the tangent, used for forward motion, and the blue arrow is the normal, used for correction.

Live demoClosest-point projection: drag the robot and watch psi(p) move
phi(psi(p))drag the pink robot or blue Bezier handles

Drag a handle, or focus it and use the arrow keys; hold Shift for a larger step.

psi(p): 0.211distance: 11.9 insigned error e: -11.9 incondition: error line ⊥ tangent at the closest point
path phi(t)robot p and error vectorunit tangent Tunit normal NBezier control handles
Idea
Everything starts from the closest point

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:

ep=ϕ(ψ(p))−p\mathbf{e}_p = \phi(\psi(\mathbf{p})) - \mathbf{p}

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:

aattract≈kpt ep−kdt v⊥\mathbf{a}_{\text{attract}} \approx k_p^t\,\mathbf{e}_p - k_d^t\,\mathbf{v}_{\perp}

kptk_p^t and kdtk_d^t are the translation gains (the superscript tt is for translation; heading gets its own pair later). v⊥\mathbf{v}_{\perp} 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 κ\kappa at speed vv, the inward acceleration needed is

ac=v2κa_c = v^2 \kappa

At 40 in/s around a 20 in radius, that's 1600/20=801600 / 20 = 80 in/s². Drag the points below: a tighter curve has a smaller radius, a larger κ\kappa, 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.)

Live demoCurvature is 1 / radius of the circle through three points
R = 39.0 inPQR
radius R: 39.0 incurvature κ = 1/R: 0.0257tighter turn ⇒: smaller R, bigger κ
path points P, Q, Rcircle through themradius R

The paper writes the same thing in terms of the path's formula:

ξC(x)=kc(comp⁡T^(v))2T^′(ψ(p))∥ϕ′(ψ(p))∥\xi_C(x) = k_c \left( \operatorname{comp}_{\hat{\mathbf{T}}}( \mathbf{v} ) \right)^2 \frac{\hat{\mathbf{T}}'(\psi(\mathbf{p}))}{\|\phi'(\psi(\mathbf{p}))\|}

ξC\xi_C is the paper's name for the centripetal part of its field, and kck_c is a tuning gain. The squared term is the robot's speed along the path, the v2v^2 from above. The fraction is how fast the path's direction turns per inch traveled, which is the curvature. So it's kcv2κk_c v^2 \kappa, 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:

d=∫ψ(p)1∥ϕ′(s)∥ dsd = \int_{\psi(\mathbf{p})}^{1} \|\phi'(s)\|\,ds

(The integral adds up small pieces of length, because equal steps in the parameter aren't equal distances.) The paper then uses v=2adv = \sqrt{2ad}, 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:

D(v)=av2+bvD(v) = a v^2 + b v

D(v)D(v) is the distance to stop from speed vv. The av2a v^2 part is the constant-braking piece; with constant deceleration adecela_\text{decel} you'd have a=1/(2adecel)a = 1/(2a_\text{decel}). The bvb v part covers the losses that grow with speed. On Pedro's test data bb 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: e=∥xtarget−x∥−D(v)e = \lVert \mathbf{x}_{\text{target}} - \mathbf{x} \rVert - D(v). 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, dd, solve av2+bv=da v^2 + b v = d with the quadratic formula and keep the positive answer:
vdesired=−b+b2+4ad2av_{\text{desired}} = \frac{-b + \sqrt{b^2 + 4ad}}{2a}

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.

The numbers depend on how you brake

Pedro brakes actively, at about −0.2-0.2 motor power. If you just let go and coast at zero power, the robot goes farther. The same D(v)=av2+bvD(v) = av^2 + bv shape fits both, but the aa and bb values are different, so measure them for the way you actually brake.

Why this differs from a timed motion profile

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, θ(t)\theta(t). (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:

αcmd=kpr wrap⁡(θ(ψ(p))−θrobot)−kdr ω\alpha_{\text{cmd}} = k_p^r\,\operatorname{wrap}(\theta(\psi(\mathbf{p})) - \theta_{\text{robot}}) - k_d^r\,\omega

kprk_p^r and kdrk_d^r are the heading gains, ω\omega 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:

FTCPedro-style follower decomposition
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.

ExerciseDelete each vector in turn

What does the robot do with each of the three vectors removed?

Show solution

Without 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.

Without 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.

Without 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.

ExerciseHeading as a scalar, and the squared speed

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, tangentSpeed squared or the signed curvature, and which sets the direction?

Show solution

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 v2κv^2\kappa — the squared speed sets the magnitude, which is why the lean grows quadratically as you speed up, and the sign of κ\kappa sets which side of the path to lean toward.

This is architecture, not drop-in Pedro source

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 tt 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:

ξ(x)=(v,RΩ,ξP(x),ξR(x))\xi(x) = (v, R\Omega, \xi_P(x), \xi_R(x))

Here the state xx is position, rotation, velocity, and turn rate together. The four entries say how each of those should change: position changes by the velocity vv, rotation changes by the turn rate (RΩR\Omega), and ξP\xi_P and ξR\xi_R are the commanded accelerations for moving and turning. For an FTC mecanum robot, in words:

next command=drive along+pull back+curve feedforward+turn to heading\begin{gathered} \text{next command} = \text{drive along} + \text{pull back} \\[2pt] + \text{curve feedforward} + \text{turn to heading} \end{gathered}

Each term is one of the four jobs from the table at the top, with its own constants: kptk_p^t and kdtk_d^t for pulling back, kck_c for curves, kprk_p^r and kdrk_d^r for heading, and the fitted D(v)D(v) for speed along the path. Those are the numbers a team tunes.

Sources & references
  • 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 D(v)=av2+bvD(v) = av^2 + bv 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.