Control Theory (PID / LQR / MPC)
Making the robot actually do what you want.
Prerequisites
Why it matters in robotics
Control turns a planned trajectory or desired state into stable, executable motor commands, so it sits under everything that moves: arms, drones, legged robots, and self-driving stacks. A feedback loop tuned from error, its accumulation, and its rate of change is the workhorse, one method gives mathematically optimal gains for well-behaved linear systems, and another earns its extra compute by planning ahead while respecting constraints like joint limits, obstacles, and actuator saturation. The math of stability and cost functions connects directly to practical failure modes such as runaway accumulated error, steady-state error, and model mismatch.
What to study
- ✓Geometric path-tracking controllers: Pure Pursuit (lookahead-point curvature law) and the Stanley controller (cross-track + heading error law) — simple, model-light alternatives to full feedback control
- ✓PID fundamentals: P/I/D terms, tuning intuition, steady-state error, and integrator anti-windup
- ✓State-space modeling and stability: poles/eigenvalues, controllability/observability, pole placement
- ✓LQR as optimal full-state feedback: the quadratic cost, Q/R weighting tradeoffs, and the Riccati equation
- ✓MPC: receding-horizon optimization, handling state/input constraints, and the cost of online computation
Where to study
- ✎Three Methods of Vehicle Lateral Control: Pure Pursuit, Stanley, and MPC↗ArticleDing Yan· ~20 min
- ▶Understanding PID Control (Brian Douglas / MATLAB Tech Talks)↗VideoBrian Douglas / MathWorks· ~1 hr
- ▶Understanding Model Predictive Control (MATLAB Tech Talk series)↗VideoMathWorks· ~45 min
- ⌨do-mpc Getting Started: MPC tutorial (runnable MPC in Python)↗Code / projectdo-mpc· ~2 hrs
Cheatsheet
Symbols used below
Stanley controller (geometric control)
The first term aligns the heading with the path's tangent; the second steers proportionally to the cross-track error , softened by speed . A bigger gain corrects harder but risks oscillation, and the term jumps sharply as .
Pure Pursuit (geometric control)
Fit a circular arc from the vehicle to a lookahead point a distance ahead on the path; is the angle between the vehicle's heading and the line to that point. For a bicycle model, the steering angle is .
A larger smooths the path but cuts corners; a smaller tracks tighter but can oscillate, especially at speed.
PID control law
P reacts to current error, I eliminates steady-state error by accumulating it over time, D damps overshoot by reacting to the error's rate of change.
Integrator windup
If the actuator saturates, the integral term keeps accumulating error it can't act on, then overshoots badly once the actuator unsaturates.
Anti-windup clamps or back-calculates the integral term so it stops growing while the actuator is saturated.
State-space and stability
The system is stable (state decays to zero with no input) exactly when every eigenvalue of has negative real part. Controllability asks whether some input can drive the state anywhere; observability asks whether the state can be reconstructed from the outputs alone.
LQR: optimal state feedback
Minimize the quadratic cost
subject to . The optimal control is linear state feedback , with where solves the algebraic Riccati equation. penalizes state error, penalizes control effort — their ratio sets how aggressive vs. gentle the resulting controller is.
MPC: constrained, receding-horizon control
At each step, solve a finite-horizon optimization for the best sequence of future controls given the current state, apply only the first control, then re-solve at the next step with updated measurements.
Unlike PID or LQR, MPC can directly enforce constraints (joint limits, obstacle avoidance, actuator saturation) inside the optimization — at the cost of solving an optimization problem online, every control cycle.
| Geometric | PID | LQR | MPC | |
|---|---|---|---|---|
| Model needed | Vehicle kinematics only (bicycle model) | None (pure feedback on error) | Linear state-space model | Model (often linear or linearized), re-solved online |
| Optimality | None — a geometric heuristic law | None — hand-tuned gains | Optimal for the given linear model and quadratic cost | Optimal over the horizon, re-planned every step |
| Constraints | Not handled (no dynamics awareness) | Not handled natively (saturation is ad hoc) | Not handled directly | Handled explicitly (state/input limits) |
| Compute cost | Lowest (closed-form geometry) | Very low | Low (gains computed offline, once) | High (online optimization every cycle) |