← Projects · Real-time MPC › Quadrotor
Real-time MPC for aggressive quadrotor flight
A nonlinear predictive controller that flies a quadrotor through a figure-8 at up to 12 m/s and 75° of tilt, commanding the four rotor thrusts directly in under half a millisecond per step. It tracks more accurately than a standard geometric (SE(3)) tracking controller with an autopilot-style mixer at every speed (2.4× at 10 m/s), and keeps flying at 12 m/s, where that controller crashes. With a damaged propeller, it plans with rotor limits certified from one second of flight data and keeps flying where the others crash.

NoteHow much grip can a controller count on? →

Rotor 3 limited to 3.5 N, figure-8 at 10 m/s: planning with the rated 7 N, the NMPC crashes after 5.4 s; with the limits certified by ddma (3.48 N), it flies the whole run with 0.10 m RMS error.
What it does
At high speed a quadrotor spends most of its thrust on accelerating, and a rotor can run out of thrust in the middle of a manoeuvre. A controller that computes a collective thrust and torques and only then splits them over the rotors finds out too late: it loses attitude control. This controller plans with the four rotor thrusts themselves:
- ModelFull rigid-body model with quaternion attitude, the four rotor thrusts as inputs and rotor drag. The reference comes with its attitude, rates and thrusts (differential flatness).
- Optimise in real timeA 1-second plan of the four rotor thrusts, re-solved 100 times a second with acados, warm-started from the last plan.
- Know the rotorsddma turns one second of flight data into a guaranteed lower bound on what each rotor can deliver.
- DeployGenerated C code inside a ROS 2 C++ node, next to a 1 kHz simulator with motor dynamics and rotor faults.
When a manoeuvre would saturate a rotor, the plan gives up a little position accuracy instead of attitude control.
Demo: a figure-8 at increasing speed
Two laps of a 10 m wide figure-8; the simulated quadrotor adds 30 ms motor dynamics that the controllers do not model.
| Peak speed | Nonlinear MPC | Geometric controller | Linear MPC |
|---|---|---|---|
| 4 m/s | 0.4 cm | 0.6 cm | 1.5 cm |
| 8 m/s | 1.1 cm | 2.4 cm | 26 cm |
| 10 m/s | 1.8 cm | 4.4 cm | crash |
| 12 m/s (75° tilt) | 2.6 cm | crash | crash |
RMS position error. The geometric controller is the SE(3) tracking controller of Lee, Leok and McClamroch with full flatness feedforward, drag compensation and the attitude-priority mixer real autopilots use. The linear MPC is linearised at hover and solved with OSQP.
Demo: a damaged propeller
Rotor 3 delivers at most 3.5 N of its rated 7 N; no controller is told. Before the flight, the quadrotor does a one-second vertical hop and records each rotor’s command and its thrust, measured in flight from the IMU (with noise). Assuming only that thrust rises with the command, can only saturate, and lags the command like a first-order motor, ddma gives a lower bound on each rotor’s thrust curve that holds even during transients. Certified maximum thrusts: 6.6, 5.5, 3.48 and 6.3 N for a true 7, 7, 3.5 and 7 N.
| Figure-8 at 10 m/s with the damaged rotor | Result |
|---|---|
| NMPC planning with the rated thrust | crashes after 5.4 s |
| NMPC planning with the certified thrust | flies both laps, 10 cm RMS |
| NMPC knowing the true limits (oracle) | flies both laps, 9 cm RMS |
| Geometric controller | crashes after 1.8 s |

Algorithms and performance
- Solver: acados, multiple shooting, Gauss-Newton SQP with one real-time iteration per step, HPIPM; per-rotor thrust limits are updated at run time without rebuilding the solver.
- Horizon: 1 s, ten 10 ms steps then 60 ms steps.
| Solver (two laps at 10 m/s) | Median | 99th percentile | Tracking error |
|---|---|---|---|
| acados, 15 / 25 / 40 shooting intervals | about 0.3 / 0.4 / 0.6 ms | 0.4 / 0.7 / 1.1 ms | 1.4 / 1.8 / 2.0 cm |
| acados at 200 Hz | about 0.4 ms | 0.8 ms | 1.7 cm |
| ROS 2 C++ node, state → command | about 0.5 ms | 0.9 ms | 1.7 cm |
| Solved to convergence every step | about 2 ms | 3.4 ms | 1.8 cm |

Engineering specific to this project
- One source of numbers: the export script writes the solver and a header with the vehicle constants, so Python and C++ cannot drift apart; the C++ flatness reference matches Python to 10⁻⁹.
- Rotor faults in the simulator: the 1 kHz simulator node models motor lag and per-rotor thrust loss; rotor limits are a run-time parameter of the controller node.
- In ROS 2, in real time: 1.7 cm at 10 m/s; with the damaged rotor, 14 cm with certified limits, while rated limits lose the quadrotor.
Next
Certifying rotor thrust during flight, to detect a fault mid-air and re-plan; a gate-racing track with time-optimal references; a hardware-in-the-loop run with PX4.