PX4, also known as PX4 Autopilot, is an open-source flight control software stack that runs on a drone’s flight controller and handles stabilization, navigation and autonomous missions for multicopters, fixed-wing aircraft, VTOL hybrids, rovers and other vehicles. Within Drone software & autonomy, it is one of the two dominant open autopilots, alongside ArduPilot, and it is maintained under the Dronecode Foundation of the Linux Foundation.
PX4 is distributed under the permissive BSD 3-clause license, which allows companies to modify and ship it in commercial products without publishing their changes. That licensing choice, combined with a modular, message-based architecture, has made PX4 a common base for industrial, research and defense drone platforms.
How the PX4 architecture works
PX4 is built as a set of independent modules that exchange data through uORB, a lightweight publish-subscribe message bus inside the flight controller. Each module, such as a sensor driver, an estimator or a controller, publishes topics like vehicle attitude or battery status, and any other module can subscribe to them without direct coupling.
The flight stack runs on the NuttX real-time operating system on microcontroller boards, and it can also run on Linux for companion-computer or simulation use. The core control chain follows a fixed order: sensors feed the EKF2 state estimator, which fuses IMU, GPS, magnetometer, barometer and optional vision or optical-flow data; the estimate then drives cascaded position, velocity, attitude and rate controllers before the mixer converts outputs into motor or servo commands.
The table below lists the most important building blocks of the stack and their responsibilities.
| Module | Responsibility | Practical note |
|---|---|---|
| uORB | Internal publish-subscribe messaging | Decouples drivers, estimators and controllers |
| EKF2 | Estimates position, velocity and attitude | Fuses GPS, IMU, vision and flow sensors |
| Commander | Manages arming, modes and failsafes | Enforces preflight checks before takeoff |
| Navigator | Executes missions, return and geofence | Interprets waypoint mission items |
| Control allocation | Maps forces and torques to actuators | Supports custom airframe geometries |
| MAVLink module | Communicates with ground stations | Streams telemetry and accepts commands |
| uXRCE-DDS client | Bridges uORB topics to ROS 2 | Used for offboard and robotics integration |
Flight modes and autonomous capabilities
PX4 organizes vehicle behavior into flight modes that range from fully manual control to fully autonomous operation. The pilot or a ground control station switches modes, and the Commander module only permits a mode when the required sensors and estimates are healthy.
| Mode | Control level | Requirement |
|---|---|---|
| Stabilized | Pilot sets angle, autopilot levels | IMU only |
| Altitude | Autopilot holds height | Barometer or distance sensor |
| Position | Autopilot holds position on stick release | GPS or other position source |
| Mission | Flies uploaded waypoint plan | Valid global position estimate |
| Return | Flies home and lands | Home position and position estimate |
| Offboard | External computer sends setpoints | Continuous setpoint stream |
Offboard mode is central to research and advanced autonomy. A companion computer running ROS 2 or MAVSDK computes trajectories, obstacle avoidance or visual tracking and streams position, velocity or attitude setpoints at a minimum of about 2 Hz; if the stream stops, PX4 triggers a configurable failsafe such as hold or return.
Safety logic is part of the stack rather than an add-on. Geofences, low-battery thresholds, data-link loss and RC-loss failsafes are configured as parameters, and PX4 refuses to arm when preflight checks such as sensor calibration or estimator consistency fail.
PX4 compared with ArduPilot
PX4 and ArduPilot solve the same problem with different design philosophies and licenses. Both speak MAVLink, run on many of the same Pixhawk-class boards and work with QGroundControl, so the choice usually depends on licensing, ecosystem and development style rather than raw capability.
| Aspect | PX4 | ArduPilot |
|---|---|---|
| License | BSD 3-clause, permissive | GPLv3, copyleft |
| Architecture | Modular uORB message bus | Library-based, vehicle-specific codebases |
| Robotics integration | Native ROS 2 bridge via uXRCE-DDS | ROS 2 support through DDS and MAVROS |
| Preferred ground station | QGroundControl | Mission Planner or QGroundControl |
| Typical users | OEMs, enterprise and research teams | Hobbyists, integrators and researchers |
| Vehicle range | Multicopter, fixed-wing, VTOL, rover | Broader, including boats and submarines |
The license difference is often decisive for manufacturers: a company can build proprietary features on PX4 without releasing source code, whereas ArduPilot’s GPL obliges distributors to share modifications. ArduPilot, in turn, is frequently praised for its very large parameter set and mature tuning tools.
Development, simulation and deployment
PX4 development relies heavily on software-in-the-loop (SITL) simulation, where the full flight stack runs on a desktop computer against a physics simulator such as Gazebo. Developers test missions, offboard code and failsafes in simulation before risking hardware, and the same binaries and parameters then move to real flight controllers.
Typical work follows a repeatable sequence, summarized below.
| Stage | Tool or interface | Outcome |
|---|---|---|
| Firmware build | PX4 build system with CMake | Board-specific firmware image |
| Simulation | SITL with Gazebo | Behavior verified without hardware |
| Configuration | QGroundControl | Airframe, sensors and radio calibrated |
| Tuning | PID and filter parameters | Stable, responsive flight |
| Log analysis | ULog files and Flight Review | Diagnosed vibration or estimator faults |
Commercial users often adopt enterprise distributions built on PX4, such as the Auterion platform, which adds fleet management, long-term support and certified hardware. Open-source releases follow a stable release cycle with beta testing, and production teams usually pin a specific version instead of tracking the main branch.
Limitations and common pitfalls
PX4 is powerful but not a turnkey consumer product: it expects the integrator to configure airframes, calibrate sensors and validate tuning. Most real-world problems trace back to hardware integration rather than to the software itself.
- High vibration levels corrupt IMU data and cause EKF2 errors; soft-mounting the flight controller and balancing propellers matters more than parameter changes.
- Magnetometer interference from power cables leads to heading drift and toilet-bowl circling; an external GPS-compass mast reduces it.
- Copying parameters between airframes without retuning produces oscillation or sluggish control.
- Skipping simulation of offboard code risks flyaways when setpoint streams stall or coordinate frames are mixed up.
- Regulatory compliance, such as Remote ID or certification, remains the operator’s responsibility, not the autopilot’s.
A plain-language summary
PX4 is the brain software inside many drones. It reads the sensors. It works out where the aircraft is and how it is tilted. Then it adjusts the motors hundreds of times per second to keep the flight steady.
It can help a human pilot hold still. It can also fly a whole route on its own, return home on low battery and land safely. Because it is free and open for anyone to change, many companies build their drones on it instead of writing flight software from scratch.
An example from practice
A university agriculture lab wants to map crop health across a 40-hectare field with a multispectral camera. The team builds a quadcopter around a Pixhawk-class flight controller running PX4 and first tests the entire survey in SITL simulation with Gazebo, checking turn behavior, geofence limits and the low-battery return.
In the field, they plan a lawnmower pattern in QGroundControl at 80 m altitude with 75 percent image overlap. A companion computer triggers the camera at each waypoint through MAVLink. The drone completes the survey in two flights of about 22 minutes each, and when a gust pushes it toward the geofence edge, PX4 corrects automatically. The result is a complete, georeferenced field map captured in under an hour, and ULog files confirm stable estimator performance.