Fault-tolerant quadrotor flight stack
Quadrotor guidance, navigation, and control (GNC) stack that detects a failed rotor from IMU data and flies on three rotors, using a 390-line C nonlinear MPC solver to recover 567 of 600 random failures.
[PRJ-02]Replay of the agile race lap (14.0 m/s, 3.3 g) and mid-flight rotor failure recovery into a 26 rad/s relaxed-hover spin.
[PRJ-02] 3DSelf-contained Three.js replay of the 8-gate race lap (NMPC vs geometric ghost), hover rotor failure, and 10 m/s rotor failure. Includes orbit, chase, and FPV cameras, slow-motion scrubbing, per-rotor thrust bars, and FDI HUD.
What I built
Results
[PRJ-02] Measured- Failures recovered
- 567 / 600
- Mean NMPC solve
- 0.22 ms
- Median FDI delay
- 16 ms
- 8-gate race lap (EKF feedback, 14.0 m/s, 3.3 g): position RMSE7.5 cm (NMPC) vs 34.7 cm (geometric)
- 100 Hz NMPC solve time (7,715 steps): mean / p99 / max0.22 ms / 0.55 ms / 6.07 ms
- Rotor-failure Monte Carlo recovery and landing (600 failures)567 / 600 (94.5%); 459/463 < 8 m/s; 418/418 < 50° bank
- Fault isolation without RPM feedback: accuracy and delay600 / 600 correct rotor · median 16 ms (p99 129 ms)
- Fault detector false alarms (51 min turbulent, model-mismatched flight)0 false alarms
- Hover rotor-failure demo: max deviation / altitude loss / touchdown14.6 cm / 1.1 cm / 0.32 m/s
- Sampled-data margin analysis vs nonlinear sim instability onset40.2 ms predicted vs 40.2 ms sim (0.2% apart); 6 gain margins within 0.13 dB
- ESKF statistical consistency (30 runs): NEES / NIS / position RMSENEES 14.5 (ideal 15) · NIS 3.02 / 3.00 (ideal 3) · 1.0 cm RMSE
Architecture
-
Quaternion-manifold error-state EKF fusing 1 kHz IMU, 100 Hz magnetometer, and 50 Hz position measurements with 20 ms latency compensation and covariance inflation on gyro saturation.
-
Minimum-snap QP trajectory generation, time allocation, and differential-flatness mapping for aggressive race and figure-eight profiles.
-
Direct rotor-speed NMPC (motor states inside the prediction horizon, no inner loop) with CasADi C-generated Gauss-Newton derivatives and a 390-line hand-written C Riccati interior-point QP solver checked against KKT conditions and IPOPT.
-
IMU-residual fault detector isolating the failed rotor without ESC RPM feedback; computes the Mueller–D’Andrea relaxed-hover equilibrium at 26 rad/s inside ±34.9 rad/s gyro limits.
-
Sampled-data closed-loop stability analysis computing gain, phase, and delay margins for the geometric SE(3) baseline, checked directly against nonlinear instability onset.
Design decisions
-
Direct rotor-speed NMPC with motor dynamics inside the prediction state removes inner/outer loop bandwidth separation and lets one controller handle both 4-rotor racing and 3-rotor recovery.
-
Exploiting optimal-control block-banded structure with input-box inequalities reduces every interior-point step to one Riccati recursion in 390 lines of portable C.
-
A 26 rad/s relaxed-hover spin keeps steady recovery inside the ±34.9 rad/s gyro range while retaining lateral control authority.
-
Every one of the 33 Monte Carlo losses was a ground strike 0.6–1.5 s after rotor failure at 56°–78° bank, 5.2–12.9 m/s, and 2–3 m AGL.
Figures
6 plots and captures. Select any figure to view it at full resolution.
Limits
What the model assumes and what this work does not show.
Reproduce
Run the tests and regenerate every figure from the repository.
$ make setup
$ make test
$ uv run ftquad fly --traj race --controller nmpc --condition wind
$ make all