State Estimation and Control: From PID to MPC
You'll be able to:
You can tune a PID loop by hand and explain what each term does to a step response, describe what a Kalman filter adds when sensors are noisy, and say what model predictive control buys over PID and what it costs — and why learned policies still sit on top of these loops rather than replacing them.
The loops under the policy
Every robot you will ever work on has a feedback controller running at hundreds or thousands of hertz between the thing that decides where to go and the motors that go there. A learned policy issues targets at 10–50 Hz; a servo loop makes the joints follow them. Understanding that lower loop is what lets you tell whether a failure is the policy's fault or the controller's, and it is the vocabulary every robotics colleague will assume you share.
PID, term by term
The controller sees an error e = setpoint - measurement and outputs a command u:
u = Kp · e + Ki · ∫ e dt + Kd · de/dt
- Proportional pushes harder the further you are from the target. Alone it is a spring: higher Kp means a stiffer, faster response, but a spring oscillates.
- Derivative resists the rate of change: it is damping. It takes the ring out of the step response, at the price of amplifying sensor noise, since differentiating a noisy signal is noisy.
- Integral accumulates error over time. It is the only term that can cancel a constant disturbance, because P alone settles where the spring force exactly balances the disturbance, leaving a steady-state error.
Worked example: tuning by the numbers
A 1 kg mass on a frictionless rail, commanded with a force u. With PD control the closed loop is m·ẍ = -Kp·x - Kd·ẋ, a damped oscillator with natural frequency ω = √(Kp/m) and damping ratio ζ = Kd / (2·√(Kp·m)). Choose Kp = 100 N/m: ω = 10 rad/s, so the response settles in a few tenths of a second. Critical damping (no overshoot) needs ζ = 1, so Kd = 2·√(100·1) = 20 N·s/m. For a slightly faster response with small overshoot, ζ ≈ 0.7 gives Kd ≈ 14. Now hang a 2 N constant load on the mass. With P only, the loop settles where Kp·x = 2, so x is 2 cm short of the target forever. Add Ki and the integral winds up until the integral term supplies the 2 N; the steady-state error goes to zero. Two cautions: integral windup, when the actuator saturates and the integral keeps growing, and the fact that Kd must act on a filtered velocity, because differencing raw encoder ticks at 1 kHz produces garbage. Steve Brunton's Control Bootcamp walks through these effects with the pictures that make them stick.
Try the same system yourself. Set Kd to 20, then to 2, then add the load and switch the integral on:
Lab
A controller on a rail
Mass 1 kg, target 1 m, three seconds.
- Natural frequency
- 10 rad/s
- Damping ratio
- 1
- Overshoot
- 0%
- Settles within 2% after
- 0.59 s
- Short of the target at the end by
- 0 cm
Try a question
A mass of 2 kg is held by a controller with Kp = 25 N/m. Which Kd, in N·s/m, gives critical damping (no overshoot)?
The numbers change each time. The answer is computed by the lab.
Runs in your browser. Nothing is sent or saved.
State estimation: the Kalman filter in one paragraph
Your controller wants position and velocity; your sensors give noisy position. A Kalman filter keeps a Gaussian belief over the state and alternates two steps: predict (push the belief forward with the dynamics model, which widens it) and update (correct it with a measurement, which narrows it, weighted by how much you trust sensor versus model). The output is a smooth estimate of position and velocity with an honest covariance. It is also the standard way to fuse an IMU, encoders and a camera into a single pose estimate. Roger Labbe's free book builds the filter up from a one-dimensional example in Python; work through its first chapters and the matrices stop being frightening.
Model predictive control
PID reacts to the current error. MPC, at every control step, solves a small optimisation: given a model of the dynamics, find the sequence of controls over the next N steps that minimises a cost (tracking error plus effort) subject to constraints (joint limits, torque limits, obstacles). Apply only the first control, then re-solve from the new measurement. That receding-horizon trick makes it a feedback controller, and the explicit constraints are what PID cannot offer: an MPC controller will not command a torque it knows is out of range or a path through a wall.
The costs are real. MPC needs a model, and a bad model produces confident bad plans. It needs compute at loop rate; a quadratic program for a 7-joint arm at 1 kHz is feasible, a nonlinear one for a humanoid is a research problem. Tedrake's Underactuated Robotics explains why systems that cannot apply force in every direction, like a walking robot mid-stride, need this kind of planning rather than simple servoing.
Why learned policies still need all this
Three reasons. Rate: a neural policy at 10 Hz cannot stabilise a joint that needs 1 kHz. Safety: the low-level loop is where limits and stops live, and it is simple enough to verify. Abstraction: a policy that outputs end-effector targets or joint velocity targets, with a well-tuned controller underneath, learns faster than one that must also discover how to servo. Most published learned-manipulation systems, including the VLAs in module 6, output targets that an engineered controller tracks. What is unsettled is where the boundary should sit: some groups learn torque-level policies for locomotion and swear by it; nobody yet does that for precision manipulation on hardware.
What to remember
- P is a spring, D is damping, I is the only term that cancels constant disturbances.
- ω = √(Kp/m) and ζ = Kd/(2√(Kp·m)) let you pick gains instead of guessing.
- Filter before you differentiate; guard the integral against windup.
- A Kalman filter is predict-then-update, and gives you velocity and uncertainty, not just position.
- MPC trades compute and a model for explicit constraints; PID trades those away for simplicity.
- Learned policies issue targets; engineered loops track them, at a higher rate and with the safety limits.
Curated Materials
2.8hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- Cenotian raises $48M to underwrite robotics deployments and cut factory riskDealroom.co ·
- DeepSeek Officially Posts Job for Talent in Embodied Intelligence36Kr ·
- NVIDIA Expands US Technology Initiatives Across Energy, Robotics and Quantum ComputingThe Quantum Insider ·
Test your knowledge
5 questions in 100 seconds, on a page of its own. Read everything above first.
Test your knowledge →Module Mission
35–45 minSimulate a 1 kg mass on a frictionless rail driven by a force you choose, 100 Hz, with Gaussian noise on the position sensor. Implement a PID position controller and tune it to reach a 1 m setpoint with under 10% overshoot. Then add a 2 N constant disturbance (a sagging cable) and show that P-only control leaves a steady-state error while adding I removes it. Deliver the two plots and the final gains.
Loading your work…