← back to projects

Autonomous PX4 Drone

A quadrotor that flies missions, navigates without GPS using visual SLAM, and lands itself on a marker. Built on ROS 2, PX4, and a Raspberry Pi mounted on a Holybro X500.

ROS 2 · PX4 · SLAM · MAVLink · OpenCV · Raspberry Pi view on github ↗

GPS works fine until you go indoors or under a bridge. This project is a full autonomy stack that keeps a quadrotor flying when GPS isn’t available: visual-inertial odometry, 3D mapping, and precision landing, all running on a Raspberry Pi 4 mounted on the airframe.

Gazebo simulation with depth camera, SLAM map, and ArUco detection
In simulation: the depth camera feed, the RTAB-Map point cloud, and ArUco marker detection running together.

The stack

Five layers, from motors to mission:

  1. PX4 (Pixhawk) — low-level stabilization and flight control, in SITL or on the real airframe.
  2. ROS 2 Jazzy — orchestrates the perception and navigation nodes.
  3. MAVROS — the bridge between MAVLink and ROS 2 topics and services.
  4. VIO + RTAB-Map — local pose estimation with loop-closure drift correction, fed by an Intel RealSense D455 depth camera and fused into PX4’s EKF2.
  5. Precision landing — ArUco marker detection in OpenCV, velocity servoing toward the target, then an automatic AUTO.LAND trigger.

I wrote the mission layer twice on purpose: once in C directly against MAVLink, to understand what’s actually on the wire, and once in Python with MAVSDK for everyday use. Waypoint missions, return-to-launch, and takeoff were all tested in Gazebo SITL before I ran them on real hardware.

System architecture diagram
The full architecture, from PX4 and MAVROS up through ROS 2 and RTAB-Map on the Raspberry Pi.

The hardware

Holybro X500 V2 frame, Pixhawk flight controller, Raspberry Pi 4 as the companion computer, and an Intel RealSense D455 for depth and tracking. The software stack is containerized, so a single docker compose up brings up PX4 SITL, Gazebo, MAVROS, RTAB-Map, and the camera bridges in one tmux session, on Ubuntu or WSL2.

The full stack running in a tmux session
Everything up in one tmux session: PX4 SITL, Gazebo, MAVROS, RTAB-Map, and the camera bridges.

What was hard

Getting EKF2 to trust the RTAB-Map odometry took a lot of tuning and even more time in the PX4 documentation. CPU budget on a Pi 4 is tight, so I had to profile and trim the perception pipeline until SLAM, marker detection, and MAVROS could share four cores without starving each other. Watching the drone land itself on a 20 cm marker made it worth the effort.