PX4 Autopilot is built on a two-layer architecture: the flight stack handles guidance, navigation, and control algorithms, while the middleware provides device drivers, inter-process communication, and external connectivity. Every component in the system is a self-contained module that communicates exclusively through the uORB publish-subscribe message bus, making the entire design reactive, asynchronous, and highly modular.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PX4/PX4-Autopilot/llms.txt
Use this file to discover all available pages before exploring further.
The reactive design principle
PX4’s architecture follows the Reactive Manifesto. In practice this means:- All functionality is divided into exchangeable, reusable components (modules).
- Communication between components is done by asynchronous message passing over uORB.
- The system updates instantly when new data is available, without polling.
- All operations are fully parallelized — modules run independently and consume data from anywhere in a thread-safe way.
The two layers
- Flight stack
- Middleware
The flight stack contains all algorithms specific to autonomous flight. It processes the full pipeline from sensor data and RC input through to motor and servo commands.Key subsystems:
- Estimators — combine multiple sensor inputs to compute vehicle state. The primary estimator is
ekf2, which fuses IMU, GPS, barometer, magnetometer, and optical flow data to produce position and attitude estimates. - Controllers — take a setpoint and a measured or estimated state, and compute a correction output. For example, the position controller (
mc_pos_control) receives a position setpoint and outputs an attitude and thrust setpoint. - Mixers — translate force and torque commands into individual motor commands, accounting for motor geometry, direction, and vehicle-specific limits.
- Navigator — manages autonomous mission execution, holds, returns, and high-level mode transitions by publishing position setpoints.
Data flow: sensors to actuators
The following steps describe how sensor data becomes motor commands at runtime.Sensor drivers publish raw data
Hardware drivers (e.g., the ICM-42688-P IMU driver) read sensor hardware and publish calibrated measurements to topics such as
sensor_combined and sensor_gyro at up to 1 kHz.EKF2 estimates vehicle state
The
ekf2 module subscribes to sensor topics, fuses measurements using an Extended Kalman Filter, and publishes vehicle_local_position, vehicle_global_position, and vehicle_attitude at 250 Hz.Controllers compute setpoints
Mode-specific controllers (e.g.,
mc_pos_control, mc_att_control) subscribe to state estimates and setpoints from the navigator, then publish attitude rate setpoints and thrust commands.Mixers translate to actuator commands
The actuator allocation module reads rate and thrust setpoints, applies the vehicle’s mixing geometry, and publishes
actuator_motors and actuator_servos topics.Module execution model
PX4 modules run in one of two modes on NuttX (the primary flight controller RTOS):- Independent tasks
- Work queue tasks
A module spawned as an independent task gets its own stack, file descriptor list, and scheduling priority. Use this for modules that need to sleep, block on I/O, or do heavy computation.
Runtime inspection
You can inspect and control modules live from the NuttX shell or the SITLpxh> prompt.
Explore the architecture further
uORB message bus
Learn how PX4 modules exchange typed messages asynchronously through the publish-subscribe bus.
Modules reference
Explore the key flight stack modules — what they do, how to start and stop them, and how to describe a new module.
MAVLink integration
Understand how PX4 communicates with ground stations, companion computers, and MAVLink SDKs.