Skip to content

Manas-arumalla/QuadControl

Repository files navigation

QuadControl

A rigorous MATLAB quadrotor control study. Six controllers compared on a single quaternion 6-DOF plant, with frequency-domain analysis, step-response metrics, Monte-Carlo robustness, genetic-algorithm auto-tuning, 3D A* obstacle planning with fly-to-goal tracking, and animation — all on a clean, publication-quality light theme.

The focus is control-theory depth and reproducibility: every controller runs on the same plant through the same interface, so the comparison is fair, and the analysis layer (Bode, gain/phase margins, pole maps, statistical robustness) backs every claim with a figure or a number. It is deliberately toolbox-light — the continuous-time algebraic Riccati solver, Bode/margins, and step metrics are implemented from scratch, and ga/quadprog are used when present with graceful fallbacks otherwise.

A* through obstacles, then fly-to-goal tracking   Geometric SE(3) tracking a helix

Left: 3D A* through an obstacle field with fly-to-goal tracking  •  Right: geometric SE(3) helix tracking

Quick start

% from the QuadControl/ folder (so the +qc package is on the path):
run_all     % regenerate every table, figure, and animation into results/ and figures/
smoke       % fast correctness check (hover / free-fall / all controllers / A*)

Headless / CI:

matlab -batch "run_all"

Controllers

All share one interface — [wrench, cs] = ctrl(x, ref, p, cs) — and one plant.

name method notes
ctrl_pid cascaded PID leaky clamped integrators, slew-rate-limited attitude target, conditional anti-windup
ctrl_lqr full-state LQR about hover from-scratch CARE solver, heading-frame error, tilt-compensated thrust
ctrl_geometric geometric SE(3) (Lee et al.) singularity-free attitude control on the rotation matrix
ctrl_smc sliding mode + boundary layer robust to model error
ctrl_adaptive adaptive backstepping PID outer + SO(3) inner + disturbance-torque estimator (adapts on attitude error)
ctrl_mpc cascaded linear MPC quadprog when available, else a clamped closed-form; slew-limited inner loop

Package layout (+qc/)

  • Coreparams, deriv (quaternion 6-DOF), step_rk4, allocate (mixer + saturation), quaternion/rotation utilities, flat_state (differential-flatness start).
  • Controllers — the six above plus the shared flat2att flat-output-to-attitude map.
  • Analysislinearize, care_solve, freqresp_margins, step_metrics.
  • Planningoccgrid (obstacle voxel map with spherical inflation), astar3d (26-connectivity A*), simplify_path (collision-checked shortcut), path_to_traj + ppder + traj_eval (velocity-aware clamped-spline trajectory).
  • Visualizationplot_run (3D path + error + attitude + rotors), animate (3D flight GIF), palette, qc_style (light theme).
  • Driversbenchmark_run, analysis_run, montecarlo_run, tune_pid, maze_run, run_all.

Results

Regenerated end-to-end by run_all.

Nominal tracking RMSE (m), identical plant for every controller:

task pid lqr geometric smc adaptive mpc
hover 0.21 0.22 0.21 0.20 0.21 0.20
step 0.64 0.59 0.68 0.65 0.69 0.66
helix 0.019 0.18 0.003 0.009 0.013 0.54
lissajous 2.43 0.61 0.29 1.35 0.058 2.18

Trajectory tasks use a differential-flatness start (on-trajectory position, velocity and attitude), so the feedforward controllers track almost perfectly. The adaptive controller adapts on the attitude error e_R rather than the raw body rate, so it tracks the aggressive lissajous tightly and rejects a mid-flight rotor failure better than plain geometric (0.10 vs 0.27 RMSE on the helix). LQR and the cascaded linear MPC are regulators and lag a fast moving reference — the expected contrast with the optimal/geometric feedforward methods.

Nominal tracking RMSE by controller and task   Success rate by controller and condition

Frequency-domain and time-domain analysis

Attitude loop Bode plot with margins   LQR closed-loop pole map   Step response by controller

Wind disturbance rejection on hover   Monte-Carlo robustness under parameter uncertainty   Default vs auto-tuned step response

Figure files

  • bode_attitude.png — attitude PD loop Bode, PM ≈ 75°, GM = ∞.
  • lqr_poles.png — LQR closed-loop poles, all in the left half plane.
  • step_response.png + step_metrics.csv — rise / settle / overshoot per controller (LQR settles fastest at ~1.4 s, 0.7% overshoot).
  • disturbance_rejection.png — position deviation under a 5 m/s wind on hover.
  • montecarlo.png + montecarlo.csv — ±25% mass / ±20% inertia / ±50% drag (SMC and PID most robust).
  • compare_rmse.png, compare_energy.png, success_heatmap.png, benchmark_dashboard.png.
  • tuning_result.png — default vs auto-tuned step response.
  • maze_plan.png, maze_track.png, maze_flight.gif — A* through obstacles → spline → flown.
  • flight_geometric_helix.gif, run_geometric_helix.png.

Implementation notes

  • Quaternion attitude propagation avoids the gimbal singularity of an Euler-angle model.
  • A clean, high-contrast light theme (qc_style) and a colorblind-friendly palette (qc.palette).
  • No required dependency beyond base MATLAB; ga and quadprog are used opportunistically.

License

MIT — see LICENSE.

About

A rigorous MATLAB study of quadrotor control - PID, LQR, geometric SE(3), sliding-mode, adaptive, and MPC on one plant - with frequency-domain analysis, Monte-Carlo robustness, auto-tuning, and 3D A* planning.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages