2.4 Following, limits and calibration
How the follower tracks a trajectory, what limits the commands before they reach the motors, and how measured limits feed back into planning. Part of Core modules.
follower: PID + feedforward
The follower computes one command per control tick, normally every 20 ms.
This helper shows the types used inside tempo-core:
use crate::field::Pose2d;
use crate::follower::{ChassisSpeeds, Follower, FollowerGains};
use crate::trajectory::Trajectory;
fn first_command(
trajectory: Trajectory,
gains: FollowerGains,
pose: Pose2d,
now_s: f64,
) -> ChassisSpeeds {
let mut follower = Follower::new(trajectory, gains, now_s);
follower.tick(pose, now_s)
}Control law per tick, with L the drive’s lag (the configured
followerLatencyS, or the lag the route reads) and S the steering’s
(followerSteeringLatencyS, or the one the route reads; S = L where one
lag is known, and on every drive but a swerve):
- Feedforward is the reference velocity at
t + dt/2 + L, the middle of the interval the command is held for, after the delay before it acts. WhereSdiffers fromLits direction is the reference’s att + dt/2 + Sand its speed stays the one att + dt/2 + L: a swerve module reaches a commanded speed through its drive motor and a commanded direction through its steering, and a direction led by the drive’s lag turnsL - Searly and runs inside every bend. The direction is left as it is where the two velocities point more than a quarter turn apart or the later one is at rest. - Feedback compares pose and reference at
t + L, the moment this tick’s command starts to act. The pose is the measured pose carried forward by the commands already sent and still in flight (SentHistory::in_flight_toward, which replays them from the measured heading), and it is compared against the referenceLahead. WithL = 0both are the measured pose and the reference att. The replay moves the robot at the speed and turn rate of the command sentLbefore each instant, along the direction of the newest command that named oneSbefore it, and over the part of the window the command about to be sent steers, along that command’s direction. A direction more than a quarter turn from the one the speed was sent with is reached by reversing the wheel, so the speed changes sign there. WithS = Lthe replay is the single-lag one bit for bit. - The pose fed back on is the observed pose (
SentHistory::observe). It is the last estimate carried forward by the commands sent and then moved toward each measurement by the steady-state Kalman gain for the measurement noise of the last half second, and that noise is read from the high-frequency part of the step between measurements the commands do not explain. Measurements that agree with the commands to within 1 mm per 20 ms loop pass through bit for bit, and the gain never falls belowdt / (dt + 0.05 s), 29% at a 20 ms loop. A jump of 0.75 m or 0.5 rad, a gap over 0.1 s or a clock that stepped back restarts it from the measurement. The estimate is stored in the command record, so the auto runtime observes once per loop and every leg, replacement and blend reads the same one. On the follower benchmark’s 2 cm, 1 degree pose noise it cut module jerk from 1629 to 490 m/s³ and module-limit ticks from 3765 to 341, with lower position and heading error. - PID on that XY error is
v_cmd += kp * err + ki * integral + kd * d(err)/dt(FollowerGainscarries kp/ki/kd for both XY and heading, and the defaults are P only, 8 on XY and 6 on heading). The derivative differences the measured error, without the motion in flight. - Rotational is the heading target’s rate as feedforward plus PID on the
predicted heading error. The angular limits (
maxAngularVelocityRadS,maxAngularAccelerationRadS2) shape the planned heading profile, and a reactive aim’sturningAtshapes its reference, and feedback adds to the planned rate as it does in PathPlanner’sPPHolonomicDriveControllerand ChoreoLib’s follower. Inside an auto the sum then passes the output limit (output_limit). - The heading target is the per-sample baked heading (
target_state.target_heading_rad) att + L, orheading_override_radwhen a reactive override is active for this tick, carried tot + Lby its own recent rate. - The field command turns into the robot frame at the heading the robot will have when it acts, which is the measured heading plus the turn the sent commands still carry over the drive’s lag. A swerve whose steering answers sooner keeps that heading. On CTRE’s simulated swerve (2026-11-14, 20 runs a set, the runs with typical steering) a half turn while driving under calibrated lags of 47 and 34 ms ran 0.3 to 0.6 cm off its line at most over six sets turned at it, and 1.5 to 1.8 cm over three sets turned at the heading the robot has after the steering’s lag, with a three-piece and a ten-leg auto the same either way. On the lags a route reads itself the two ran the half turn alike, 1.9 to 3.6 against 1.8 to 2.9 cm over four sets each.
The commands sent are the route’s own record. The auto runtime keeps every
command it returned (AutoRuntime::sent, holds and coasts included) and
hands it to the leg’s replanner each tick, and the replanner hands it to its
followers, so a leg start or a replan predicts from the commands sent to the
drivetrain. A standalone Replanner keeps the record itself.
Output is robot-frame ChassisSpeeds.
wrap_pi is in field.rs and reduces in O(1) with a truncated % plus one
correction, mapping non-finite input to 0 so a degenerate heading cannot stall the
control loop. The Java, Python and C++ Mirroring wraps and reactive-aim slews use
the same arithmetic on finite angles, so an alliance flip returns the core’s bits
(tests/fixtures/api/mirroredHeadings.json, read by the core and all three
bindings). Where the core returns 0 for a non-finite angle, Java and C++ return NaN
for NaN and for an infinite angle, and Python’s _wrap_pi returns NaN for NaN and
raises ValueError (from math.fmod) for an infinite one. The host’s finite-pose
checks refuse a NaN heading.
output_limit: What reaches the motors
Every command an auto runtime returns is bounded, whether it came from the
follower’s feedforward and feedback, a hold, a blend, a replan, a
relocalization, a recovery, a stop, a Lock or an aim. The command of a
driving leg obeys the drivetrain’s ceilings. A plan keeps to its leg’s
limits, the command is that plan plus feedback, and feedback may ask for more
than the leg’s limits while it makes up a lag or a push: bounded by the leg’s
limits, a drivetrain 90 ms behind its commands with
20 ms of latency stated ran 15.0 cm wide of a 90 degree corner taken at speed,
and 3.8 cm wide bounded by the ceilings (rust/core/tests/command_ceilings.rs).
AutoRuntime::tick_with passes each command through one OutputLimiter
before it records and returns it. In the field frame, at the heading the
robot will have when the command acts:
- Speed stays within the speed bound.
- The change from the last command stays within an ellipse of half-axes
A dtalong the motion andC dtacross it, whereAis the acceleration bound andCthe centripetal bound. The friction ellipse the velocity profile plans with lies inside it, so a planned curve passes unchanged, and a command outside it is fitted inside, with a final bisection checking the rounded command against its own mean velocity. - The turn rate stays within the turn-rate bound, and its change within
the angular acceleration bound times
dt.
The bounds are the ceilings while a leg’s follower commands, its plan plus
feedback (AutoRuntime::follower_commands, leg_command_limits). Only that
feedback may ask for more than the leg’s limits. Where the ceilings are
known, the bounds on the change of a swerve leg’s commands are at least
1.10 times the leg’s own acceleration and centripetal limits
(FEEDBACK_HEADROOM), so a plan at the ceilings leaves feedback a tenth. A
tank and a mecanum leg were not measured under it and keep the ceilings. A plan there uses the whole
of the ceilings, the command is the plan a latency ahead plus feedback, and
where the plan changes at its limit a correction the same way falls outside
a bound at the plan’s own limits. On CTRE’s simulated swerve (2026-11-14,
calibrated lags, 20 runs an auto, eight autos) the limiter changed 6 to 26%
of a route’s commands by more than 0.05 m/s with the bounds at the plan’s
limits, 0 to 10% a tenth above and 0 to 6% a quarter above. The largest
cross-track error of a ten-leg auto was 5.0, 3.8 and 2.5 cm, and each of the
other curved autos stayed within 0.4 cm across the three. That simulation
has no wheel slip, so it does not show what a command above the grip limit
costs, and the smaller margin is the one kept. The speed bound takes no
margin, and a route with no ceilings keeps the leg’s own limits as its
bounds. Every stop of Tempo’s own
keeps to the leg’s own limits (leg_output_limits): a hold, the slow to rest
around blocking commands, the stop after the route ends, a loop with no pose,
and the stops a leg’s replanner commands itself
(Replanner::commands_its_follower), which are the hold while a plan is made
from a relocalized pose, a crossing’s alignment hold, a failed crossing and
the stop on arrival. The command that comes off one of those, or off the
motion a route was entered with (a measured motion, or the flow from the
route before), keeps to the leg’s limits as well until they pass the
follower’s command as it is, so the robot slows onto a plan made from rest at
the leg’s acceleration and not at the ceiling. Arrival checks that ask
whether the robot could still stop inside its tolerance read the leg’s limits
too.
On a swerve drive translation and turn share each module’s speed
(module_share: |v| + |omega| r over the speed ceiling, with r the speed
ceiling over the turn-rate ceiling). The turn-rate ceiling stands above a
leg’s own angular limit, so a command inside both chassis bounds could ask an
outer module for more than the speed ceiling: 2 m/s with 10.8 rad/s asks
5.71 m/s of a 5.12 m/s module, where a leg limit of 3 rad/s used to prevent
it. A driving command is therefore held to the speed ceiling at the modules,
or to what the leg’s own velocity and angular limits ask of them where that
is more (module_allowance, limit_within_modules). The bound is on the
command the step heads for: the feedback beyond the plan’s own motion is cut,
by the largest share of it that fits, so the planned motion is kept
(within_module_speed). The planned motion is the feedforward the follower
computed on that tick (PathFollower::feedforward), led by the lags as the
command is, so a lead is not counted as feedback: read at the tick’s own
time the plan’s velocity is a latency behind the command’s, and on a plan
that speeds up or bends the difference would be cut with the feedback. The
step
toward that command keeps the bounds on
a command’s change. A step that still ends past the module speed is cut short
of where it passes it, so the module bound never moves a command farther from
the one before it than the change bounds allow. The radius comes from the
ceilings, which no measurement moves.
The leg’s own limits can ask more than the speed ceiling because a leg at
its velocity limit with its turn-rate limit on top always could, and a plan
that turns while it drives uses the whole module speed, which leaves
feedback none under a strict bound. With the modules held strictly to the
speed ceiling, two of the Python robot simulations failed on 2026-11-13
(test_a_rotation_target_is_reached_by_its_fraction[Red1], 9.2 degrees off
its heading halfway against 8, and
test_regions_bump_crossing_under_a_stated_angular_limit[55.0-0.02], a
crossing lost after a replan); their commands asked up to 1.108 of the
module speed on 83 of 200 loops while the plan asked 1.000. Acceleration is
not shared at all: a plan does not split the drive force between translation
and turning, and a combined force bound on the commands would cut planned
motion.
The ceilings are the route config’s commandCeilings, which
ResolvedConfig writes from the drive model
(ResolvedConfig::command_ceilings,
tests/fixtures/api/limitsAreCeilings.json): the wheel free speed (the
stated 12 V speed where that is faster), the motor force at the current limit
from rest over the mass within grip, grip for the centripetal acceleration,
and the turn rate and angular acceleration those give through the drive
radius and the bumper outline’s moment of inertia. No measured limit moves
them. One measured under its ceiling is a limit the plans keep to, and
feedback needs the room above it. One measured above its ceiling is a limit
of its legs, and no bound on a leg’s commands is below that leg’s own limit,
or on a swerve below 1.10 times its acceleration and centripetal limits
(leg_command_limits), so a plan always passes. A ceiling that is not known, and
every bound of a route whose config has no drive model, is the leg’s own
limit: speed within its velocity limit, the ellipse of its acceleration and
centripetal limits, and the angular limits described below.
The follower’s own shaping is narrower than the limiter and reads the plan.
The speed it commands stays within the plan’s velocity limit, a correction
closes no faster than the plan’s acceleration can stop from
(sqrt(2 a e)), and the command near a leg’s end stays under the speed that
acceleration can still bring down to the end speed. On the follower benchmark
(tests/robot/java_sim, 2026-11-13, nominal full-route cross-track RMS)
raising each of the three to the ceilings read 4.21, 4.01 and 4.05 cm
against 3.91 cm with all three at the plan’s limits.
An active host controller receives suggestions bounded against the preceding suggestion. Its exempt final output is recorded separately for motion prediction and for native commands when the host relinquishes control, and wheel slew bounds use the same separation. A scaled suggestion can therefore keep accelerating, and native braking steps from the scaled command actually sent.
A command already inside every bound passes bit for bit, so a robot on its
plan sees no lag. dt is the time since the last command, at most 0.1 s, and
a command repeated within one tick is bounded against the one before it. The
limiter starts each route from the robot’s measured motion when the host
reports it on that tick with a pose to place it
(AutoRuntime::set_measured_motion, tempo_auto_set_measured_motion_v1),
and from rest otherwise. Motion above a leg’s speed or turn-rate cap slows
within its acceleration bounds. While an arriveWith command drives a leg the
route sends nothing and the limiter starts over, so the next command steps
from the measured motion, including braking when the route ends there, and
completion waits until that command reaches rest. A refused hand-off restores
the command history retained before the hand-off. A differential drive keeps
only the part of the bounded command along its heading, with each wheel,
v +- w b / 2 for the track b, within the velocity limit, the step
along the heading inside the acceleration ellipse, and the turn held to what
the wheels have left once that step fixes the speed. A mecanum drive’s
per-wheel limit runs again on a command the limiter changed, using the measured
seed or the preceding command in its original robot frame, the same elapsed
time, and recording the result actually sent. A cancelled, poisoned or
non-finite tick commands zero and starts the limiter over, through the C ABI
as through AutoRuntime::tick.
A leg’s angular limits, which its plan and its heading references turn
within and which bound its commands where no ceiling is known, are the route
config’s maxAngularVelocityRadS and
maxAngularAccelerationRadS2 when stated, and otherwise
outputAngularAccelerationRadS2 for the acceleration. The bindings write the
default caps there when the robot config names none
(tests/fixtures/api/defaultAngularLimits.json). The caps are v / r rad/s
for Speed.FULL’s v and the drive radius r, and a r / k^2 rad/s^2 for
Speed.FULL’s a, the wheels’ mean lever arm r (swerve module offset,
mecanum |x| + |y|) and the squared radius of gyration k^2 about the robot
center of a uniform plate over the bumper outline, the frame grown by its
bumper thicknesses (drive_model::angular_acceleration), and without wheel
positions the acceleration cap is a over the drive radius. Both caps shape
the plan too, so a holonomic leg with no stated angular acceleration plans
within outputAngularAccelerationRadS2
(plan_within_output_angular_acceleration).
A serialized route whose travel-facing holonomic leg has a turn-rate cap and
no angular acceleration from the leg, the robot or the commands is refused
as it is read (uncertified_turn_rate_leg), because under a rate cap alone
the heading lags its travel through every bend and start turn, and the planner
certifies a lagging heading clear only where it is acceleration-bounded and
leads and trails the travel. Such a leg planned only where the lag happened
to clear and was skipped elsewhere, 6 of 10 legs of a ten-leg auto on the
shipped pack at 3 rad/s. Planning such a leg as acceleration-bounded at
w / 0.02 s skips fewer legs on the shipped pack (11 against 37 over 40
autos) and more on the Field pack (127 against 96).
A heading profile planned without an acceleration limit, which only a stated
infinity leaves, steps its rate where a turn starts and ends. The commands take
the first step at the limit, so the heading trails the plan by up to
w^2 / (2 a), and slow the turn for the heading where the plan next stops
turning (brake_for_heading, with the exact stopping rate of a turn slowed in
whole loops), so it stops there and does not carry w^2 / (2 a) past it.
The plan and the rest of the runtime keep within those bounds so that the limiter rarely acts:
- A follower whose output is bounded (
PathFollower::bound_output, set by the auto runtime on every follower and replan it installs) shapes its position feedback assqrt(2 a e)beyond the linear region, so a correction asks for no more than the robot can stop from, and caps its command atsqrt(v_end^2 + 2 A L + (A dt / 2)^2) - A dt / 2, the speed that still comes down to the leg’s end speed over the pathLleft as the command steps down once per loop. A plan that starts at rest delays its clock byfollowerLatencyS, the time a command takes to act. - A leg that ends at rest arrives once its reference has slowed to within
one loop’s acceleration step of rest, a robot trailing its reference
waits for it, and a robot that, slowed from its last command at the leg’s
acceleration limit, would stop outside the arrival tolerance waits too. A
leg a custom controller or output filter paces has no reference clock to
wait for, but waits on the same stop, read from the output the host
recorded. It has no settle watchdog, so it arrives anyway once the robot
has signalled arrival on every loop for
HOST_INSIDE_TOLERANCE_S(1 s). The route completes when the limiter has brought the command to rest. - A reference that runs out at a moving end keeps that end’s speed while
the robot still closes on it from short of the end, or too fast to stop
on it (
v^2 > 2 A d), so a robot that trailed its reference hands over moving once inside the replan threshold. A robot past the end closing slowly back would settle where the end’s feedforward and the position feedback balance, so the first loop neither holds, the end is held at rest and the junction after it stops. - A swerve aim steps toward the heading its slew is headed for, braking for
the end of the turn in whole loops, and a Lock stops a turn under way at
the angular acceleration limit. A mecanum aim keeps the per-loop slew
tests/fixtures/api/mecanumAimLimit.jsonrecords.
With strict limits and a plan at those limits, feedback has no margin left
to correct with, and tracking then depends on followerLatencyS matching the
drivetrain. The auto runtime sends chassis speeds only, with no acceleration
or wheel force for the drivetrain to feed forward, so the lead is what
accounts for the drive’s inertia. Against a drive that trails its commands by
d more than the lead, the robot runs about v d behind on a straight and
swings about v d times the turn angle wide of a corner, and position
feedback against the clocked reference then adds speed where the plan slows.
A config with no stated latency and no measured lag leads by
drive_model::feedforward_latency, 0.4 of the drive’s open-loop velocity
time constant m r v / T (the mass on one module, wheel radius, 12 V speed
and stall torque at the wheel), capped at 50 ms. A drive run on a voltage
feedforward alone trails by the whole constant.
Measured on CTRE’s simulated Tuner X swerve on 2026-11-13 (drive inertia 0.035 kg m^2, a 42 ms time constant, a 61 kg robot config whose estimate is 22 ms, 20 ms loop, medians of 10 runs; the simulation has no wheel slip and reads its own odometry as the pose). The four values are the largest cross-track error on an L, an S, a slalom and a route around the tower, then the largest distance behind the reference on a 3 m straight:
| Drive request | Lead | Cross-track (cm) | Behind (cm) |
|---|---|---|---|
OpenLoopVoltage | 0 | 22.1, 22.7, 22.4, 8.9 | 21.4 |
OpenLoopVoltage | 22 ms, the estimate | 12.3, 16.6, 21.8, 10.0 | 11.4 |
OpenLoopVoltage | 30 ms | 7.5, 9.0, 21.6, 6.6 | 9.2 |
OpenLoopVoltage | 45 ms | 3.4, 3.7, 2.9, 4.0 | 4.0 |
OpenLoopVoltage | 50 ms | 5.9, 4.6, 4.8, 5.1 | 3.9 |
OpenLoopVoltage | 70 ms | 9.8, 9.0, 9.5, 7.4 | 7.5 |
Velocity, kP 0.1 beside kV 0.124 | 22 ms, the estimate | 7.5, 10.2, 20.4, 4.7 | 5.2 |
Velocity, kP 0.1 beside kV 0.124 | 35 ms | 1.3, 1.2, 2.1, 1.7 | 2.9 |
Velocity, kP 0.1 beside kV 0.124 | 50 ms | 6.0, 4.6, 5.8, 3.6 | 5.4 |
Translation kP 4 in place of 8 at the estimate read 4.6, 5.1, 9.9, 8.1 and kP 16 read 17.9, 22.3, 22.6, 9.4. A plan lowered to 4.4 m/s at the estimate ran 13.5 cm behind on the straight, and 14.3 cm lowered to 12 m/s^2 as well. The heading stayed within a degree of its reference on every route, at the estimate and with no lead.
A lead longer than the drivetrain’s lag has its own cost. With the estimate at the whole time constant (50 ms after the cap), 12 of the C++ example’s 166 tests failed on its kinematic drivetrain, which answers within the loop: through legs ended 5 to 7 cm from their targets and a keep-in route found no route.
So the estimate stays short and the route reads the drivetrain. The auto
runtime measures the lag on the way with two estimators. DriveLag reads
single loops on a steady ramp of the commands, and a lag more than half a
loop longer than the configured latency becomes the lag the followers brake
for. LeadLag filters the field-frame commands at eleven candidate time
constants from 0 to 0.1 s and keeps the one whose velocity lies closest to
the pose’s steps, once the commands have changed by 2 m/s and the robot has
moved at half its commands or more. Where the route block says
followerLatencyEstimated, which the bindings write for a latency that was
neither stated nor calibrated, the followers of a holonomic drive lead by
that reading (Replanner::lead_by_lag), and the auto runtime predicts the
motion in flight over it. The plans keep the configured latency, which names
them where they are reused. A stated or calibrated latency is never
replaced, and a drivetrain that answers within half a loop of its estimate
keeps the estimate and the commands it had.
LeadLag reads the steering’s lag beside the drive’s. A second filter per
candidate runs on the direction of the command in the robot’s frame, the
frame the modules steer in, and keeps how far across the direction it
predicts the measured velocity points, on loops where the command and the
robot both move at 0.3 m/s or more. The steering lag is the candidate where
that is least, once the commanded direction has turned through 2 m/s of
velocity (a quarter turn at 1.3 m/s, 25 degrees at 4.5 m/s). Directions are
compared within a quarter turn, since a module reaches a direction farther
away by reversing its wheel. A route that has turned nothing has no steering
lag and leads its direction by the drive lag, and a steady shortfall of
speed turns nothing, so a route’s own steering reading stands as soon as it
has one. Each lag is at most 60 ms. While the drive lag reads past those
60 ms the direction leads by the 60 ms as well, whatever the steering
reads: a drivetrain at the limit of its traction is behind its commands by
more than its lags, and its direction of travel trails for the same reason.
On FollowerBench’s maple-sim swerve (2026-11-14, Field Midline, three runs)
the route read 62 to 90 ms for the drive and 43 to 47 ms for the steering;
led by 60 and 45 ms it ran 3.9 to 7.3 cm rms off its line and took 7.5 to
8.4 s, and led by 60 ms for both 1.4 cm and 6.4 s, as it does on one lag.
Either the steering reading or the tenth of feedback headroom alone left
that route as it was.
The drive lag is read from the whole velocity and not from the speed alone. Read from the speed alone it carries the whole of a steady shortfall of speed: a first route on CTRE’s simulated swerve (2026-11-14, 20 runs an auto) read 47 to 72 ms that way and came to rest 1.0 to 2.6 cm from its last target over eight autos, short of it, against 0.3 to 1.9 cm read from the whole velocity.
Measured on CTRE’s simulated swerve on 2026-11-14 (20 runs an auto, less
the runs with a robot loop over 40 ms; the default OpenLoopVoltage
request; the simulation has no wheel slip and reads its own odometry as the
pose). The values are the medians of the largest cross-track error on an L,
an S, a slalom, a route around the tower, a half turn while driving, a
three-piece auto and a ten-leg auto, in cm. One lag is the follower before
the steering lag, the replay on two lags and the tenth of headroom:
| Lags | One lag | Two lags |
|---|---|---|
| Read on the way | 6.1, 5.7, 3.9, 5.5, 4.4, 2.8, 5.1 | 5.2, 4.2, 3.7, 5.2, 2.7, 2.0, 3.9 |
| Calibrated, 45 ms and 34 ms | 3.7, 3.6, 2.9, 4.2, 2.4, 2.0, 4.6 | 1.9, 1.4, 2.1, 2.3, 1.4, 0.7, 4.1 |
The calibrated rows share one calibration, with the steering lag added for
the two-lag row. The error at rest stayed within 0.2 cm on seven autos
there and fell 0.8 cm on the eighth, and the drive times are the same.
With the lags read on the way one run in 158 came to rest 5.2 cm from its
target, outside the 5 cm tolerance, where 152 runs on one lag stayed inside
4.5 cm. PathPlanner’s PPHolonomicDriveController on the same simulation
and day ran 1.2, 2.2, 2.6, 1.7, 4.3, 3.7 and 6.2 cm and came to rest 2.1 to
4.0 cm from its targets on the single-leg autos, against 0.2 to 0.8 cm.
That simulation’s steering lag varies from run to run: its direction of
travel trails the module targets by 30 ms or more in about half the runs
and by less in the others.
Two readings are braked for and not led by:
- The longest candidate fits best. The robot is behind its commands by more than a lag the followers can lead by.
DriveReachsays the drivetrain does not reach the plan’s acceleration. The bench robots’ plant, 50 ms late and reaching 8 m/s^2 of a 10.8 m/s^2 plan, read 0.1 s, and led by that it ended its four-leg route 0.38 s later and 4.8 cm from its last target in place of 2.8.
A lead is at most 60 ms. A drivetrain at the limit of its traction is behind its commands by more than its lag and reads long. A maple-sim swerve (FollowerBench, 2026-11-13) read 78 to 95 ms on Field Midline; with the latency stated at 92 ms that route took 9.92 s and ran 11.9 cm rms off its line, and stated at 60 ms 5.94 s and 2.9 cm. CTRE’s simulated swerve reads 45 to 57 ms.
The route’s first reading leads on the loop it appears. After that the lead follows a reading that has stood one way, to lead by or not, for 0.2 s, and a lead in effect moves once the reading has moved 2 ms from it. A reading that goes away, on a robot held in place or moving at under half its commands, counts as one not to lead by. A route that stops leading goes back to the configured latency.
A pose that steps between loops by more than a drive can move it is a
correction of the estimate, a vision update or a reset, and LeadLag leaves
that loop out: a loop whose velocity differs from the loop before by more
than 0.6 m/s, or whose turn rate by more than 3 rad/s. A 10 cm correction in
one loop reads as 5 m/s of motion and took a 45 ms drive’s reading to 16 ms.
A plan that starts from rest runs its clock late by the latency, since the
robot does not move for that long (rest_lead_s). That delay is the
follower’s own value, apart from the lead: a lead that changes while the
route drives moves the feedforward and leaves the clock alone. The one
exception is the first lead longer than the delay on a follower that has
started, which sets the clock back to the new lead once. Without it CTRE’s
simulated swerve (10 runs) ran 13.4 cm behind its reference on a straight
and 9.8, 6.1 and 8.0 cm off the L, the S and the slalom; with it, 4.1 cm
behind the reference as set back, and 4.9, 4.3 and 3.4 cm off, for 0.02 to
0.05 s more drive time. A plan that set off under a latency of zero (a
config with no drive model) waited nothing and is set back by the whole
lead. A follower that has not started takes the lead as its delay.
Leading a plan from rest from its first command, with the bound on the commands’ change stepping from the plan’s own lead and the clock not delayed, was measured against that delay and left out. On CTRE’s simulated swerve (2026-11-14, calibrated lags, 20 runs an auto) it covered the first 0.5 m of a 3 m straight in 0.288 s against 0.331 s and ended the drive 0.06 s sooner (PathPlanner 0.282 s and 0.08 s sooner), and a ten-leg auto 0.18 s sooner. It came to rest 0.4 to 0.7 cm farther from its targets on five of eight autos, and on the lags a route reads itself the ten-leg auto ran 9.4 cm off its line against 4.1 cm. After a stop the wheels turn to the next leg’s direction before the robot moves, four loops in that simulation, which the delay covers. Without it the robot trails its reference by 12 cm for the leg in place of 8, and reaches the flowing junction that follows too far off for the plan made ahead.
The lags are kept for the robot, not the route (MeasuredLead, a
follower::Lags of the drive’s and the steering’s): every config a binding
reads with followerLatencyEstimated shares one value, each later route
starts leading by it on its first loop, and a route that stops leading
clears it. tempo_measured_lag_forget_v1 clears it, and each binding calls
that as it applies a config, so a lag lasts from one applied config to the
next. A route that started before the config was applied keeps its own lead
and publishes nothing more. A route that runs as one step of a larger auto
has its auto clock set before its first tick (set_auto_start_time), and
starts on the robot’s lag and leaves its own like any other.
A route’s own first reading is long. It is taken while the robot speeds up
from rest, and a drive a steady d slower than it is told reads d / a
long while it speeds up at a and as much short while it slows; the loops
in which the wheels turn to the way they drive add to it. CTRE’s simulated
swerve reads 52 to 60 ms there and 43 to 49 ms once it has slowed, and
tracks best under 45. Summed over the loops read, the shortfall moves the
reading by d times the net change of the commanded speed over the sum of
the squared changes of the command, so the share of the commands’ change
that is speed gained and not yet given back is the share of d / a still
in the reading. A route that starts on the robot’s lag keeps it until that
share falls to a quarter (LeadLag::ONE_WAY_SHARE), and its own reading
takes over from there. A robot that does not follow its commands for 0.2 s
loses the lag it started on, as it loses any reading.
The first route after a config is applied has no lag to start on and leads by its own first reading. On CTRE’s simulated swerve (2026-11-13, 20 runs an auto, medians) a route that started on 45 ms and kept it this way ran the L, the S, the slalom, the route around the tower and the half turn at 3.8, 3.9, 3.1, 4.1 and 2.1 cm of largest cross-track error, against 5.1 to 5.4, 4.6 to 4.8, 4.4 to 4.5, 5.3 and 4.1 to 4.2 cm for a first route, and 3.8, 3.6, 3.1, 4.3 and 1.7 cm with the latency stated at 45 ms. Started on 45 ms and replaced by its own reading as soon as that appeared, it ran 5.9, 5.2, 4.0, 5.4 and 3.0 cm. Two 20-run sets of one arm differ by up to 1.5 cm on those five autos.
A first route gains nothing from a shorter first reading on that swerve (same day, 12 to 20 runs):
- On the estimate until the reading has both ways in it, the L, the S and the slalom run 8.0, 11.8 and 20.4 cm off their lines.
- With the shortfall fitted beside the lag, and that fit used once speeding up and slowing both tell the candidates apart, the first corner still comes before the fit can be used. The fit reads 38 to 43 ms late in a route, and the L and the S end 0.7 to 1.3 cm farther from their stops.
- With the loops before the robot moves at half its commands left out, the route reads 45 to 50 ms from its start. The first lead also sets the clock of a plan from rest back, by less under the shorter reading, and the slalom runs 8.7 to 9.1 cm off its line and 18 to 22 cm from its reference.
- With the long reading kept for the clock and the shorter one for the lead, the five autos run within the spread of a first route as it is, and the slalom 10 to 15 cm from its reference against 6.6.
On CTRE’s simulated swerve (2026-11-13, the default OpenLoopVoltage
request) a route read 54 ms 0.16 s after its start and 45 to 57 ms from
then on. Over 20 runs the largest cross-track error on the L, the S, the
slalom and the route around the tower was 6.3, 4.4, 4.0 and 5.6 cm, against
12.4, 16.5, 21.8 and 11.6 cm on the estimate alone, and the robot ran 4.1 cm
behind the reference as set back on the straight, against 11.6. On
FollowerBench’s maple-sim swerve, with no latency stated, Keep-In Patrol’s
largest cross-track error went from 24.4 to 5.7 cm and the other 17 routes
stayed within their run-to-run scatter; Box Drill’s went from 1.6 to 2.1
cm. The C++ example’s kinematic drivetrain reads no lag.
The route config’s planningMargin (default 0, below 1) plans
the acceleration, centripetal and angular acceleration limits at
1 - planningMargin of the leg’s. Where the limiter enforces the leg’s
limits, with no ceilings known, that leaves the feedback that share.
calibration: Measured limits
The entry point is Calibration::new(CalibrationSettings), then tick(t, pose, measured, wheels) once per control loop, which returns the robot-relative
command to send. The settings (tempo.calibration-settings/v1) carry the
routines, the space either way, respectLimits, saveToRobot with the
previous file (the report’s config line is then the merged result), the
wheel position unit
(meters over the configured wheel radius) and the route config blob
without measured. From the blob the core reads the drive model’s FULL and
angular limits with the stated ones removed (constraints 0 to 2 "inf", the
angular slots 0), the stated limits below those, the 12 V wheel speed, the
model’s acceleration curve, the lever arm and the wheel radius.
The routines command past the model’s limits. A drive or spin reaching 97%
of its command is dropped and the later ones command 1.69 times as much,
and a turning drive at its rate cap raises the cap. With respectLimits every
command is clamped and slewed to the stated limits, and a reading at 97% of a
stated speed or 90% of a stated acceleration is listed in capped.
Drives run along the first tick’s heading within space_m of the start,
and spins hold their place. A drive brakes when its
remaining distance falls to v (lag + 2 dt) + v^2 / (2 d) + 0.15 m (d half
the model’s acceleration until measured, then 90% of the measured
deceleration, and lag 0.1 s until measured). Leaving the space by 0.3 m, a
0.25 s loop gap under motion or stop ends the run. A creep, an
alignment or a wheel radius spin that stops making progress ends where the
robot stands, and a routine past its budget (90, 60 or 40 s) is recorded as
stopped. Turning, rotation and wheel radius end by turning back to the first
tick’s heading.
The routines, in Routine::ALL order:
- Translation runs step drives at 1.3 times the fastest of the model’s top
speed, the 12 V wheel speed and any measured one (four, or six under 2 m
either way), held 0.25 s once the speed changes under 1.5% in 0.2 s. Each
rise gives
[speed, acceleration]readings (a five-loop least-squares slope and mean) from 5% of the top to the brake. Speed bands (10%, 20%, …, 80%, 85%, 90%, 94%, 97%, 99% of the top, or even tenths of the fastest speed when nothing settled) with three or more readings give median points, pooled where they rise with speed (isotonic), and a settled drive ends the curve at[top, 0]. Its slowest point ismax_acceleration_mps2. Deceleration is the slope from 90% to 15% of the braking speed. - Unsettled, the top speed is the zero of the line through the readings
above half the fastest speed when it falls 10% (
"fit"), and otherwise the model’s ("motorModel"), and the curve follows the model above the last point (extrapolatedAboveMps). A top under 85% of free speed gets a note. - Lag runs a ramp out and back, and the lag is the delay that best fits the
commanded positions to the measured pose, fitted with an offset and a
steady shortfall of speed. Without the shortfall term a drive running
0.076 m/s under its commands (0.2 V of friction) read 52 to 56 ms for a
42 ms drive. A swerve then weaves out and back (
Step::Weave,weave_plan): at a held speed, the lesser of 0.4 of the top speed and what fits two swings into 0.8 of the space, the commanded velocity swings across the line by half the speed, 30 degrees either way, every 0.6 s for up to three swings, with the speed held as the direction turns. Turning the travel asks the wheels for the speed times the rate the direction turns at,v 0.5 2 pi / T, and the weave asks no more than the acceleration the drivetrain is known to reach (the model’s, then the measured one), which withrespectLimitsis the stated limit: where a swing of 0.6 s asks more, the swing takes as long as that acceleration needs, at the speed that still fits two of them, and the velocity across the line never changes faster. At 4.5 m/s and 9 m/s^2 a weave at 1.8 m/s swings every 0.63 s, and under a stated 1 m/s^2 in 3 m of floor one at 0.52 m/s swings every 1.63 s and still read 29.4 ms on a 30 ms steering. A swing goes at most 0.25 m to one side. WithrespectLimitswithin_limitsbounds every command’s velocity as one vector, its length by the stated speed and its change by the stated acceleration. The steering lag (steeringLagS) is the delay that best fits the commanded position across the line to the measured one, the mean over the weaves whose fit holds (fit_steering_lag): the best delay is short of the 0.3 s searched, and at it the commands explain half or more of the motion measured across the line and the robot made half or more of the motion commanded. A steering that follows with no lag fits a delay of zero with its motion explained and reads a steering lag of zero, a value the direction leads by; a weave that reads nothing leaves the direction to lead by the drive’s lag. The distance the pose covered is no such test. Pose noise of 5 mm either side adds up to 0.9 m over three swings that command 0.57 m, and a drivetrain that drives straight on under that noise reads no steering lag. A space or a limit that leaves a weave under 0.3 m/s leaves it out, and a differential or mecanum drive does not weave. CTRE’s simulated swerve read 42 to 48 ms for the drive over seven runs on an idle machine (2026-11-14) and 30 to 34 ms for the steering in five of them. That simulation’s steering answers with no lag in some runs: in one both weaves fitted a delay of zero, and in one the routine read 10 ms. Three runs made while other simulations loaded the machine read 47 to 49 ms and 34 to 37 ms. In the runs where the simulation’s direction of travel trailed its module targets by under 10 ms (2026-11-14, 120 runs an auto, 12 to 25 such runs), a calibrated steering lag of zero ran an L 5.8 cm off its line and a half turn 11.1 cm, against 13.4 and 15.3 cm with the direction led by the drive’s lag. Where it trailed by 30 ms or more, zero ran the L 5.8 cm off against 3.3. - Turning runs one drive per fraction of the top speed, capped to what the
space allows. Once the speed settles the turn rate ramps at four times the
known angular acceleration until the speed falls 5% or the rate stops
rising, then holds, reading
[speed, rate, angular acceleration]. - Rotation runs four spins.
- Wheel radius runs a 4 pi spin at up to 1 rad/s, and the radius is the gyro’s turn times the lever arm over the mean wheel turn between two stationary marks.
- Top speed, outside
ALL, runs one drive held until it settles, and otherwise gives a lower bound.mergedkeeps a settled top over an estimate. It keeps or replaces the two lags together: a run that read the drive’s lag saves its own steering lag or none, and a run without the lag routine keeps both.
MeasuredLimits is the result’s measured block and a route config’s
measured block. ResolvedConfig takes the measured top speed and the
smaller of the measured acceleration (else the curve’s slowest point) and
deceleration in place of the drive
model’s in every speed level (CAREFUL keeps 95% and 85% of them with a
drive model), under the blob’s constraints, and the measured angular caps
under any stated ones. Bindings write the measured values into
constraints in place of derived ones, so a stated limit stays a ceiling
and an unstated one can rise above the motor model. A measurement more than
25% from the drive model’s limits, or a wheel radius more than 2% off the
drive groups’, gives measured_warning.
ResolvedConfig also takes the module speed of a swerve drive from the
measurement. TurnHeadroom::module_speed fits the least-squares line
omega = (S - v) / r through the turning points (the in-place limits are
its point at rest when no point is), and that (S, r) becomes
settings.module_speed in place of the derived 12 V wheel speed and
farthest module offset, so every turning leg’s v + |omega| r plans within
the measured budget (HeadingSpec::module_speed). Fewer than two speeds or
a rate that does not fall with speed keeps the derived value. The turning
points’ angular accelerations become the module speed’s TurnAcceleration
curve, which limits each turning stretch’s angular acceleration at the speed
it drives (docs/contributing/angularConstraints.md).
A swerve config whose follower latency is the measured lag takes the
measured steeringLagS as the route config’s followerSteeringLatencyS
(ResolvedConfig::steering_latency), and its followers lead the direction
of their feedforward by it. The binding that resolved the latency says
where it came from: route.followerLatencyCalibrated is true where no
latency was stated and the measured block has a lag, as
followerLatencyEstimated is true where neither exists. A latency the
team stated leads speed and direction alike, also one equal to the
measured lag, as does an estimated one until the route reads its own lags.
A route block that says both, or that names followerSteeringLatencyS
itself, is refused. route_json writes the steering latency and leaves
the binding’s flag out, so a serialized route leads the same way.
settings.drive is the measured acceleration curve where one exists. A
measured acceleration without a curve scales the motor model’s curve by
measured / min(model(0), grip), which keeps its fall with speed. A
measured deceleration alone leaves the model’s curve, and without a motor
model a measured scalar leaves settings.drive none. Without turning points,
an angular acceleration measured in place (and below any stated one) gets
the same speed-dependent curve as a derived one, scaled by
min(1, drive(v) / FULL acceleration), and a stated angular acceleration
stays flat. same_route compares
the drive curve, the module speed and the measured block, so plan and
profile reuse follow both. route_json writes moduleSpeed,
driveAcceleration (with a measured curve’s measured points) and
commandCeilings, so a serialized route resolves to the same legs and bounds
its commands the same way.