PX4 is an open-source flight control stack licensed under the permissive BSD 3-Clause license. As a developer, you can modify flight algorithms, add support for new sensors and actuators, define custom airframe configurations, and integrate external robotics frameworks such as ROS 2. This guide introduces the tools, workflow, and code structure you need to get started.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.
What you can do with PX4
PX4 is designed to be extended. The most common developer tasks fall into four categories:- Custom modules — Implement new flight modes, state estimators, or application logic by adding a module under
src/modules/. - New drivers — Add support for sensors, actuators, or peripherals by writing a driver under
src/drivers/using the standard uORB messaging interface. - New airframes — Define a new vehicle type or configuration by adding an airframe file that maps physical geometry and mixer outputs to PX4’s control allocator.
- ROS 2 integration — Connect an onboard or offboard ROS 2 node to PX4 over the uXRCE-DDS middleware bridge, enabling full bidirectional uORB topic access from ROS 2.
Development workflow
Set up your environment
Install the build toolchain for your host OS. Ubuntu 22.04 and 24.04 are the primary supported platforms, with macOS and Windows (via WSL2) also available. See Setting Up the PX4 Development Environment.
Build and run in simulation
Validate your setup by running a software-in-the-loop (SITL) simulation before touching hardware. See Building PX4 Firmware.
Make changes and test
Edit source files, rebuild, and rerun the simulation. Use
make format before committing to satisfy the CI format check.Key tools
| Tool | Role |
|---|---|
git | Source control; all submodules are managed with --recursive |
cmake | Meta-build system; PX4 uses it to generate board-specific build files |
make | Invokes cmake and the compiler; the primary interface for all PX4 builds |
arm-none-eabi-gcc | GCC cross-compiler targeting ARM Cortex-M for NuttX/Pixhawk builds |
ninja | Fast build backend used by cmake under the hood |
python3 / pip | Required for simulation tools, code generation, and CI scripts |
The
ubuntu.sh setup script installs all of these automatically on Ubuntu. On other platforms you may need to install some tools manually.Code structure overview
The PX4 repository is organised so that related code lives together. The directories you will work in most often are:Source directory details
src/modules/ contains the high-level flight stack: the commander (state machine), position and attitude controllers, the EKF2 estimator, the navigator (mission execution), and more. Each module is a self-contained directory with its own CMakeLists.txt.
src/drivers/ contains drivers grouped by bus or peripheral type — imu/, barometer/, gps/, optical_flow/, actuator_outputs/, and many more. Drivers communicate with the rest of the system exclusively through uORB topics.
src/lib/ provides reusable components such as PID controllers, quaternion math, geo conversion utilities, and the perf counter infrastructure.
msg/ is the source of truth for all inter-module data. Adding a new message here and referencing it in a module’s CMakeLists.txt is sufficient to make it available system-wide.
Next steps
Set up your build environment
Install the toolchain on Ubuntu, macOS, or Windows so you can build PX4 from source.
Build PX4 firmware
Compile for SITL simulation and real hardware targets, and flash firmware to a flight controller.