Model Predictive Control

Model predictive control (MPC) is a control strategy that, at every time step, uses a model of the system to predict its behavior over a short future horizon, solves an optimization problem to choose the best sequence of control inputs subject to constraints, applies only the first input, and then repeats with fresh measurements. This receding horizon loop lets MPC handle what PID controllers cannot express directly: hard limits on actuators and states, multiple coupled inputs and outputs, and trade-offs between competing goals.

MPC started in chemical process control and is now common in robotics, autonomous driving, drones, legged locomotion, power electronics, and building energy management. Its cost is computational: the controller must solve an optimization problem reliably within each sample period, on the target hardware, every time — and do something safe when it cannot.

TL;DR

Quick Example

A receding-horizon controller for a double integrator (a cart or a robot axis), moving to 5 m with acceleration limited to 2 m/s² and speed limited to 1.5 m/s:

The controller rides the speed limit exactly and stops on target. Note the gap between median and worst-case solve time: real-time MPC is judged by the worst case. A production controller would use a dedicated QP solver such as OSQP, acados, or a code-generated solver, which is orders of magnitude faster for this problem.

Core Concepts

The Optimization Problem

At each step, given the current state estimate x₀, MPC solves:

Horizon and Sample Time

The sample time must capture the relevant dynamics (a drone's attitude needs milliseconds; a building's temperature, minutes). The horizon (N × dt) should cover the time the system needs to respond meaningfully — for example the stopping distance at maximum speed — so the controller anticipates constraints before hitting them. Longer horizons improve foresight but increase solve time.

Linear vs Nonlinear MPC

Real-Time Feasibility

State Estimation and Model Error

MPC is only as good as its starting state and its model. Pair it with a Kalman filter or observer (see Robot Localization and Mapping), add integral action or disturbance estimation to remove steady-state error from model mismatch, and validate the model against logged data.

Where MPC Is Used in Robotics

Best Practices

Start Linear and Simple

Begin with linear MPC on a validated model; move to nonlinear MPC only when the linear version demonstrably falls short.

Measure Worst-Case Timing on Target Hardware

Benchmark solve times on the real processor under load and design the fallback for overruns.

Keep Problems Feasible

Use soft state constraints with large penalties, and keep hard constraints for true physical limits.

Test Against Model Mismatch

Simulate with perturbed parameters, delays, noise, and disturbances, and compare against a well-tuned PID or LQR baseline. See Feedback Control Systems.

Common Mistakes

Ignoring Solve-Time Variance

Hard State Constraints That Become Infeasible

Horizon Shorter Than the Stopping Distance

FAQ

What is model predictive control?

A control method that repeatedly solves an optimization problem over a finite future horizon using a system model, applies the first optimal input, and re-solves at the next step with new measurements.

How is MPC different from PID?

PID reacts to the current error with fixed gains. MPC predicts future behavior with a model and explicitly optimizes inputs subject to constraints, handling multiple inputs and outputs and hard limits directly — at a higher computational and modeling cost.

What is a receding horizon?

The practice of optimizing over a fixed-length future window, applying only the first input, and then shifting the window forward and re-optimizing at the next time step.

Which solvers are used for MPC?

QP solvers such as OSQP, qpOASES, and HPIPM for linear MPC; acados, CasADi with IPOPT, and similar tools for nonlinear MPC. Code generation produces embedded solvers for microcontrollers.

What happens if the MPC solver fails?

A robust implementation detects failures and timeouts and falls back to the shifted previous solution, a simpler backup controller, or a safe stop.

Related Topics

References