← Projects · Industry

Real-time MPC: a car, a quadrotor and a robot arm

Nonlinear model predictive control that runs in milliseconds, on three platforms: a car at the handling limit, a quadrotor in aggressive flight and a 7-joint robot arm. Each controller beats the one used in practice, is timed step by step and runs as a C++ ROS 2 node. On each, a limit learned from data with ddma (tyre grip, rotor thrust, joint friction) keeps the plan within what the hardware can give.

Nonlinear MPC · Real-time · acados · ROS 2 · C++ · Python

Stack: acados · CasADi · OSQP · IPOPT · Pinocchio (tests) · Python · C++ · ROS 2 Jazzy · ddma · pytest · GitHub Actions · Docker

0.4–3.5 msmedian solve per control step, on the full nonlinear model
3 platformsa car, a quadrotor and a 7-joint arm, each against the controller used in practice
0spins or crashes when the hardware degrades, planning with limits certified from seconds of data
10⁻⁶agreement between each C++ ROS 2 controller and its Python version

The three projects

Each panel shows what ddma certified for that platform from a few seconds of data.

Side by side

Car Quadrotor Robot arm
Model Dynamic bicycle, magic-formula tyres, friction circle per axle Rigid body with quaternions, four rotor thrusts, rotor drag Full Panda dynamics, 14 states, 7 torques
Plan / rate 2 s ahead, 50 Hz 1 s ahead, 100 Hz 0.35 s ahead, 100 Hz
Median solve ≈ 1 ms ≈ 0.4 ms ≈ 3.5 ms
Against the usual controller Linear MPC spins on the same speed profile; the slowest profile it finishes is 9 % slower Geometric (SE(3)) controller: 2.4× the error at 10 m/s, crashes at 12 m/s Operational-space control: 25× the error at 1.35 m/s, joints at 135 % of their velocity limit
ddma certifies Tyre grip, from a 6 s steering ramp: 0.57 for a true 0.6 Rotor thrust, from a 1 s hop: 3.48 N for a true 3.5 N Joint friction, from a 6 s sweep: within 0.3–0.7 N m
With the certificate Finishes the slippery lap, 2 % slower than knowing the road Flies both laps with a damaged rotor 0.05 mm with joint friction, as good as knowing it
Code vehicle-nmpc quadrotor-nmpc arm-nmpc

The common recipe

  1. ModelThe platform's nonlinear model in CasADi, with the limits that matter on the real machine: grip, rotor thrust, joint torques and speeds.
  2. Optimise in real timeacados, multiple shooting, one SQP iteration per control step, warm-started from the last plan; checked against a solve to convergence.
  3. Certify the hardwareddma turns seconds of measured data into a limit that is guaranteed to hold; the plan never asks for more. Set at run time, without rebuilding the solver.
  4. DeployGenerated C code inside a ROS 2 Jazzy C++ node, next to a simulator node running the machine at 1 kHz.

Engineering, shared by all three

  • Fair baselines: each controller is compared with the design used in practice, with the same limits, and timed step by step (median and 99th percentile, not only the average).
  • C++ that matches Python: the C++ simulators reproduce the Python ones to 10⁻⁹ and the C++ controllers reproduce the Python commands to 10⁻⁶.
  • Launch tests: each ROS 2 package runs the closed loop and checks tracking, limits, solver status and latency.
  • CI (GitHub Actions): lint, Python tests with acados built from a pinned commit, the ddma certificate tests, and the ROS 2 build and tests in a ROS container; a Docker image per repository.

Next

Hardware runs (an F1TENTH-scale car, PX4 hardware-in-the-loop, a Panda through franka_ros2), and certificates that update during operation: grip while driving, rotor thrust mid-flight.