Contents · Optimal Control
Part 0 · LQR
Part 1 · Dynamic Programming
Part 2 · Trajectory Optimization
Part 3 · MPC
- Model Predictive Control
Part 4 · Continuous Optimal Control
Part 3 · MPC
Model Predictive Control
A linear-quadratic regulator hands you one gain matrix, computed once, that knows nothing about the torque and joint limits your hardware actually has. Model predictive control keeps the same quadratic cost but re-plans from the current state at every step, and that is exactly what lets it respect constraints. It is why MPC runs modern legged locomotion and manipulation controllers.
Re-solve every step
At the measured state , MPC solves a finite-horizon optimal control problem over the next steps,
subject to the dynamics and the limits,
with . It applies only the first control , throws away the rest of the plan, advances to , and solves the whole problem again from there. That re-solving from the fresh state is the receding horizon, and it is what closes the loop: disturbances and model error get absorbed because every step starts from where the system really is.
The unconstrained core is a finite-horizon LQR
Drop the constraints (, ) and the inner problem has a closed form. Dynamic programming backward in time gives the discrete Riccati recursion,1 started from the terminal cost,
The optimal plan is the time-varying feedback . MPC applies its first entry , steps, and reruns the backward pass at the next state.2
One backward pass by hand
Take a double integrator: position and velocity driven by an acceleration ,
so with ,
Run the horizon backward from . The last step ():
The first step (), now using :
Two things to read off. The applied gain weighs position error, while the one-step-ahead gain sees only velocity: a longer horizon changes the very first move. And MPC uses alone, applies , then at the next measured state runs again from scratch.
Constraints make each step a QP
Real actuators saturate: . The moment or is a bounded set, the backward Riccati recursion no longer applies, because the minimization is now over a constrained quadratic. Stack the controls into one vector , eliminate the states through , and the horizon cost collapses to a single quadratic program,
with assembled from and from the current . That QP is what MPC actually solves each step. It is convex, so it solves reliably, and handling the box on is exactly the machinery LQR's single gain cannot provide.2
The loop, live
The demo runs the constrained loop on the double integrator. Every control step it runs the full backward pass to get , applies , advances the true system, and re-solves. The faint blue curve is the planned -step trajectory rolled out from the current state, position against prediction step, redrawn every step.
position axis (drag to move target) · plan rises with prediction step
- p
- -4.00
- v
- 0.00
- u applied
- +0.00
- p − p_ref
- -6.500
Re-solving the horizon every step and applying only K_0.
Watch the blue plan lengthen as grows: a short horizon draws a plan that has not yet started decelerating, so the first control drives hard toward the target and, once clamped, cannot brake in time. A long horizon draws a plan that curves back onto the target, and applying its first step yields the smooth approach. Either way only is ever applied; the rest of the plan is advisory and is recomputed at the next state.
This is the constrained sibling of the finite-horizon LQR, and its inner solve is warm-started iLQR when the dynamics are nonlinear, which is how the same receding loop scales from this cart to a whole-body quadruped.
Footnotes
-
Bertsekas, Dynamic Programming and Optimal Control. ↩
-
Rawlings, Mayne & Diehl, Model Predictive Control: Theory, Computation, and Design (2nd ed.). ↩ ↩2