GPS-denied environments, warehouses, tunnels, indoor inspection sites, make conventional UAV navigation impossible. The challenge was to design a complete quadrotor platform from commercial off-the-shelf components and develop a full GNC stack capable of attitude control, position tracking and reactive obstacle avoidance with no GNSS signal and no pre-mapped environment.
M.Sc. thesis at Politecnico di Torino, Space Engineering, in collaboration with ALTEN Italia, Milan. Covered the full stack: hardware assembly, 6-DOF quadrotor dynamics modelling, controller synthesis, and validation through both Model-in-the-Loop (MIL) and Software-in-the-Loop (SITL) pipelines.
A complete COTS quadrotor assembled for indoor GPS-denied operations. The indoor positioning solution, Marvelmind ultrasonic beacons, delivers ±2 cm position accuracy over 50 m using Time-of-Flight triangulation, replacing GPS entirely. Companion computing splits work between a Raspberry Pi 3 (mission logic) and a STM32 Nucleo (sensor parsing, NMEA over SERIAL to the Pixhawk GPS port).
The quadrotor dynamics were linearised around the hover equilibrium point in
NED (North-East-Down) coordinates using Euler angles (φ, θ, ψ)
and discretised via MATLAB's c2dm. Two cascaded architectures were
designed and compared head-to-head.
The winning architecture, Solution 2, pairs an MPC outer loop acting on 10 states (horizontal position, body velocity, attitude, angular rates) with a PID inner loop on altitude. The MPC QP is solved at each timestep by a custom infeasible interior-point method (Wright, 1997) with a prediction horizon of Hp = 30 steps and hard state/input constraints.
Four trajectories of increasing complexity were designed to stress the controller across different manoeuvre regimes, from gentle square loops to a tight 1 m snail pattern with only 5 s per waypoint segment. All patterns were run in MATLAB/Simulink 2021b with Unreal Engine co-simulation for 3D visualisation, and independently replicated in AirSim + MAVLink/PX4 SITL.
Solution 2, MPC outer + PID altitude outperformed Solution 1 (PD outer + MPC inner) across all four patterns. The MPC produced clean waypoint-to-waypoint paths and smooth velocity references; the PD baseline showed visible overshoots at direction reversals.
A modified Artificial Potential Field (APF) algorithm provides reactive collision avoidance. The standard APF is augmented with a virtual force term to escape local minima, a failure mode of classical APF that causes the vehicle to stall in saddle-point configurations. When an obstacle is detected, the APF generates corrected reference velocities that override the nominal trajectory commands before reaching the MPC controller, keeping the avoidance logic decoupled from the core control loop.
Validated across multiple trajectory patterns with 3 obstacles per run, achieving 100% avoidance success in all cases. Unreal Engine 3D visual co-simulation confirmed correct avoidance geometry at each obstacle. On longer patterns the vehicle does not complete every waypoint within the allotted window due to detour time, demonstrating genuine real-time path adaptation rather than pre-planned routing.
Cascade architecture over a single unified MPC. A unified MPC handling all 12 states, horizontal position, velocity, attitude, angular rates, altitude, is the theoretically cleaner solution, but solving a 12-state QP at control frequency on embedded hardware is computationally expensive and numerically sensitive to tuning. The cascade split, MPC outer loop on 10 states, PID inner loop on altitude, kept the QP tractable and gave altitude control a fast, independent tuning handle without retuning the full prediction horizon.
The cost was coupling: the altitude loop can't anticipate the MPC's horizontal trajectory, so vertical disturbances don't feed into the optimal horizontal plan. On the tested trajectories this was acceptable. On longer-range trajectories with significant altitude variation, it becomes a real limitation.
The classical APF formulation caused the vehicle to stall at saddle-point configurations between obstacles, a known failure mode where the attractive and repulsive forces cancel, leaving the vehicle with zero net guidance. Standard goal-directed augmentation didn't generalise to dynamic replanning scenarios where the vehicle needs to adapt mid-trajectory.
The fix was a virtual escape force term that activates when velocity drops below a threshold near an obstacle, introducing a perturbation orthogonal to the stall axis. This allowed the vehicle to break out of saddle points and resume trajectory tracking without pre-planned routing, validated at 100% avoidance success across all simulation runs with 3 obstacles at varying distances.
I would spend less time studying the PID controller already embedded in the Pixhawk 4 autopilot and instead bypass it earlier, implementing a simple PID from scratch directly on the quadrotor. The goal was always to extract a dynamic model and inertia values for MPC, and a clean from-scratch implementation makes the system dynamics far more transparent than reverse-engineering PX4's source code. In practice, I spent a significant amount of time studying the Pixhawk's internal PID implementation before realising it added no useful information for the control law I was building. Starting from a minimal, self-owned controller from day one would have made the path to MPC shorter and the dynamics understanding deeper.