This project designs and validates a Linear-Quadratic Regulator (LQR) to control a quadcopter drone through a two-phase autonomous mission: a vertical climb followed by a circular trajectory. The controller is built on a linearized state-space model of the drone's translational and rotational dynamics and validated in MATLAB/Simulink, with a 3D visualization in FlightGear.
Project carried out with one teammate, covering the full chain from optimal-control theory to a validated flight simulation: system linearization, LQR controller design for all six degrees of freedom, and simulation/visualization in MATLAB and FlightGear.
Linearized the quadcopter's roll, pitch, yaw and translational dynamics into state-space form for controller design.
Designed 6 independent LQR controllers (height, x/y position, roll/pitch, yaw) using MATLAB's lqr(A,B,Q,R) function.
Implemented a dual-loop structure, an outer position loop feeding an inner attitude loop, for multi-phase trajectory tracking.
Validated the closed-loop system in MATLAB/Simulink and produced a 3D flight visualization in FlightGear.
The LQR is an optimal control method that finds the control input minimizing a quadratic cost function while respecting the system's linear dynamics, trading off state-tracking performance against control effort.
J = ∫[xᵀQx + uᵀRu] dt the term xᵀQx penalizes state deviations, while uᵀRu penalizes control effort. Q and R are tuned to trade off performance against actuation energy.
Minimize J subject to the linear dynamic constraint ẋ = Ax + Bu, yielding the optimal control law u*(t) = -Kx(t).
The optimal gain is obtained by solving the Algebraic Riccati Equation (ARE): AᵀP + PA - PBR⁻¹BᵀP + Q = 0, for a unique symmetric positive-definite P when (A,B) is stabilizable.
K = R⁻¹BᵀP a constant, optimal, stabilizing gain, computed in MATLAB via are(A, B*inv(R)*B', Q) or the lqr() function.
The quadcopter's nonlinear dynamics were linearized around hover into independent state-space subsystems for roll, pitch, yaw and translational motion (x, y, z), each driven by a corresponding control input. A dual-loop architecture was then implemented: an outer position-control loop generates attitude references, which feed an inner attitude-control loop producing the four motor commands.
Six independent LQR controllers were tuned in MATLAB using diagonal Q and R weighting matrices, one pair per controlled axis, via the lqr(A,B,Q,R) function.
| Controller | Q | R |
|---|---|---|
| Altitude (z) | diag([5, 1]) | 3 |
| Position (x / y) | diag([15, 1]) | 1000 |
| Roll / Pitch | diag([25, 1]) | 200 |
| Yaw | diag([7, 1]) | 1 |
The controller tracked both mission phases accurately: a stable vertical climb to 200 m followed by a well-maintained 60 m radius circular trajectory, with bounded Euler angles and smooth motor commands throughout.
The LQR controller proved effective for multi-phase trajectory control of a quadcopter, combining a rigorous optimal-control formulation with a practical dual-loop implementation validated in simulation.