๐ป Programming ยท Autonomous ยท Intermediate
PID Tuning
๐บ๏ธ Flowchart โ PID tuning iteration loop
Tune one constant at a time. Run a test, observe behavior, adjust. Repeat until "drives accurately" is the answer.
flowchart TD
Start([Robot doesn't drive
accurately enough]) --> Test[Run a test move:
drive 24 inches]
Test --> Q1{What's wrong
with the result?}
Q1 -->|"Stops short"| Pup[Increase kP
by 10-20%]
Q1 -->|"Overshoots target"| Pdown[Decrease kP
OR increase kD]
Q1 -->|"Wobbles / oscillates"| Ddown[Increase kD
AND/OR decrease kP]
Q1 -->|"Settles slowly
near target"| Iup[Add small kI
0.05 to 0.1 max]
Q1 -->|"Drives accurately"| Done([โ Tuned
save constants])
Pup --> Test
Pdown --> Test
Ddown --> Test
Iup --> Test
style Start fill:#1e293b,stroke:#22d3ee,stroke-width:2px,color:#e2e8f0
style Done fill:#1e293b,stroke:#22c55e,stroke-width:2px,color:#e2e8f0
style Q1 fill:#fbbf24,color:#0f172a,stroke:#fbbf24
style Test fill:#0c4a6e,color:#e2e8f0,stroke:#22d3ee
The built-in PID tuner lets you dial in drive, turn, and swing constants live on the robot โ no code re-upload between tests. This guide walks through the full tuning sequence from scratch.
📗
New to autonomous? Make sure you have a working drivetrain and a basic auton first โ start with the
Clawbot training platform → first — it covers the drivetrain build and your first moves in
Section 5 Exercise 3. This page goes deeper than that exercise, with full UI screen-by-screen walkthroughs and tuning strategies for swing PID and odom-based motions.
What this is: PID stands for ProportionalโIntegralโDerivative. It's the math that makes the robot reach a target distance or angle reliably. A PID controller calculates it for you โ you just tune three numbers per motion type until the robot behaves the way you want.
๐ฎ Interactive PID Response Simulator
Drag the sliders to see how each constant affects robot motion. The cyan line is your target. The colored line is where the robot actually goes.
Adjust kP to start tuning. Watch for overshoot and oscillation.
๐ง Tuning Live, On the Robot
The fastest way to tune is to adjust constants live on the robot and re-run the move each time โ no recompile between tries. The pattern: bind a controller button to bump the active constant up/down, another to re-run the move, and print the constants to the screen so you can read them off when it looks right. (A library you build can expose a small tuner mode for exactly this.)
// LIVE TUNE MODE (run only when NOT connected to a competition)
each driver loop:
UP / DOWN button -> raise / lower the constant being tuned
SELECT button -> switch which constant (kP -> kD -> kI)
RUN button -> re-run the test move with the new value
show kP, kD, kI on the screen so you can read the final values
// when a value looks right, write it down and bake it into your auton
๐ฏ Tuning Sequence โ Drive โ Turn โ Swing
Always tune in this order: Drive PID first, then Turn PID, then Swing. Each depends on the previous being stable. Skipping ahead means you're tuning on a shaky foundation.
1
Set the test auton โ in autons.cpp write a simple test routine:
drive 24″ — a simple test move
Register it as your “Drive Test” routine — the one you re-run after each constant change.
2
Enable the tuner (X button) โ the Brain screen shows current kP/kD/kI values. Use the controller directional buttons: Up/Down = select which constant, Left/Right = decrease/increase the value. The tuner increments by 0.1 by default.
3
Tune kP first (kI and kD = 0) โ run B, watch the robot. Increase kP until the robot overshoots the target. Back it off by ~20%. That's your starting kP. Typical 4-motor tank: kP = 0.35โ0.6.
4
Add kD to kill the oscillation โ after setting kP, increase kD until oscillation stops. kD fights rapid changes in error. Too much kD = sluggish approach. Typical kD = 2โ5ร kP.
5
Test at multiple distances โ run 12", 24", 48". Good constants work at all distances. If 48" is fine but 12" overshoots: kP too high. If 12" is fine but 48" doesn't reach: kP too low.
6
Repeat for turns โ change the test to turn 90° — the turn test move Select "Turn PID" in the tuner. Tune kP then kD the same way. Turn constants are usually different from drive constants.
7
Copy constants to your auton file โ after tuning, write down the values. Add them at the top of your auton initialization function.
Drive PID → kP 0.45, kI 0, kD 5.0
Turn PID → kP 3.0, kI 0.003, kD 20.0
๐ What Each Constant Does โ Plain Language
| Constant | Metaphor | Too Low | Too High | Typical Starting Value |
| kP (drive) | Gas pedal force | Robot creeps, never quite reaches target | Robot overshoots and bounces back | 0.35โ0.60 |
| kD (drive) | Brake force near target | Oscillates past target repeatedly | Sluggish, approaches target very slowly at the end | kP ร 3โ5 |
| kI (drive) | Persistent error correction | N/A (zero is fine) | Robot winds up and jerks at start | 0 (rarely needed) |
| kP (turn) | Rotation force | Under-turns consistently | Over-turns, spins back | 2.0โ4.0 |
| kD (turn) | Rotation brake | Wobbles around the target heading | Turns too slowly at the end | kP ร 5โ10 |
Don't add kI yet. Almost every VRC autonomous works without kI. It causes instability more often than it helps. Only add it if your robot consistently undershoots the same amount on a flat, consistent surface, and kP can't fix it without causing overshoot.
๐
The same three knobs everywhere. kP, kD, and kI behave the same whether they're steering a drive, a turn, a swing, or a lift/arm. Once you can read the robot's behavior and know which knob to turn, you can tune any PID loop you build โ that's the whole point of understanding it rather than copying numbers. See
PID Diagnostics for reading symptoms fast.
PID tuning applies control theory: the proportional term (kP) drives toward the target; the derivative term (kD) opposes the rate of change to prevent overshoot; the integral term (kI) eliminates steady-state error. Oscillation indicates insufficient kD damping. Sluggish response indicates insufficient kP. Steady-state error indicates kI need. Each symptom maps to a specific mathematical cause.
🎤 Interview line: “We tune PID constants systematically using control theory. When we see oscillation, we increase kD — the derivative term damps oscillation by opposing the rate of error change. We never change two constants simultaneously because we cannot isolate cause from effect. Our PID documentation shows 7 tuning iterations with the theory-backed reasoning for each change.”
Your drive PID oscillates past its target and corrects, then oscillates again. Which constant adjustment dampens this behavior?
⬛ Increase kI to correct the accumulated error driving the oscillation
⬛ Increase kD — the derivative term dampens oscillation by opposing the rate of error change
⬛ Decrease kP so the initial drive force is smaller
📝Notebook entry tip: Test & Evaluate — Cyan slide — Each tuning session is a test entry: record starting constants, observed symptom, what you changed and why (cite the PID principle), and the outcome metric. A sequence of 5+ tuning sessions showing progression from oscillation to convergence — with the reasoning for each step — is exactly the systematic test documentation that earns Expert-level scores.