Skip to the content
FixTheRobot Explore Robotics / UAV / Simulation / mpc-controller

UAV Systems Engineering · Interactive simulation · M5-L3

MPC Flight Controller Simulator

Constrained trajectory tracking with a real quadratic-program solver: see what a longer horizon buys, and compare it with a saturating PD controller.

  • UAV Guidance, Navigation and Control (GNC)
  • Established engineering
  • Runs entirely in your browser

What you are looking at

The UAV is treated as a double integrator on each horizontal axis, commanded by acceleration (the inner attitude loop is modelled as a first-order lag in the plant, which the MPC deliberately ignores). Every 0.1 s the controller predicts the next N steps, chooses accelerations over a control horizon Nc that minimise tracking error and effort while respecting the acceleration and velocity limits, applies the first one, and repeats.

The plots show the reference and flown path, tracking error, and speed and acceleration against their limits. Switch to the baseline controller to see what changes when constraints are not part of the controller.

Try this

  1. On the square trajectory, reduce the prediction horizon from 15 to 3 steps. The controller can no longer see the corner coming: compare the error with a horizon of 30.
  2. Switch to the saturating PD baseline and compare peak speed against the velocity limit and the RMS error at the corners.
  3. Set the reference speed above the velocity limit. Why does the error grow steadily instead of the controller simply flying faster?
  4. Set the control horizon to 1 and then to N. Fewer free moves means a cheaper QP but a less flexible plan.
  5. Add 2 m/s² of wind and compare the steady offset for MPC and PD. What would remove it?

Model and its limits

Included: a condensed MPC with move blocking beyond the control horizon, a move-rate penalty, exact solution of the constrained QP (Hildreth’s dual method, no external solver), per-axis acceleration and velocity limits with feasibility relaxation, and a plant with actuator lag and wind that the controller does not model.

Not included: the full quadrotor dynamics (attitude is abstracted as lag), a 3-D vertical axis, obstacle constraints, a norm-bounded (circular) speed limit (limits are per axis, which lets the diagonal speed reach √2 times the limit), and real-time guarantees on embedded hardware. Production MPC for UAVs uses dedicated solvers and nonlinear models, which this lesson does not claim to reproduce.

Saved in this browser and synced to your account when you are signed in.

Back to Module 5 · UAV track overview