A PX4 module is a self-contained software component that runs as an independent task or a work queue item. Each module has a defined responsibility — a single module estimates attitude, another manages mission execution, another handles MAVLink communication — and modules interact exclusively through uORB topics. This strict separation makes it possible to start, stop, replace, or debug any module independently without affecting the rest of the system.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.
Module execution model
Modules run in one of two execution contexts:- Independent task — has its own stack and OS scheduling priority. Can sleep, block on I/O, and perform long-running computation. Visible in
topoutput. - Work queue task — shares a stack with other items on the same work queue. Must not block or sleep; scheduled by time interval or uORB topic update callback. Consumes less RAM and produces fewer context switches. Not visible in
top; usework_queue statusinstead.
ekf2, mc_att_control) run as independent tasks with elevated priority. Lower-frequency management tasks often run on work queues.
Core module reference
| Module | Category | Role |
|---|---|---|
commander | System | Vehicle state machine, arming/disarming, failsafe logic, mode management, calibration |
navigator | Controller | Autonomous mission execution, holds, return-to-launch, geofence enforcement |
mc_pos_control | Controller | Multicopter position and velocity control; outputs attitude and thrust setpoints |
mc_att_control | Controller | Multicopter attitude and rate control; outputs actuator torque commands |
fw_pos_control | Controller | Fixed-wing position, altitude, and airspeed control |
vtol_att_control | Controller | VTOL transition logic and attitude control blending |
ekf2 | Estimator | Extended Kalman Filter fusing IMU, GPS, baro, mag, optical flow; produces state estimates |
sensors | System | Aggregates and calibrates sensor data; publishes sensor_combined |
mavlink | Communication | MAVLink telemetry, commands, parameters, and missions over UDP/serial |
uxrce_dds_client | Communication | Bridges uORB topics to ROS 2 via Micro XRCE-DDS |
logger | System | High-rate ULog data recorder to SD card |
land_detector | System | Detects landed state; gates arming and triggers failsafes |
control_allocator | Controller | Maps body force/torque demands to individual actuator commands (mixing) |
battery_status | System | Monitors battery voltage/current and publishes state-of-charge estimates |
Starting and stopping modules
You control modules from the NuttX shell (via serial or MAVLink shell) or from the SITLpxh> prompt.
Modules that run on a work queue (rather than as independent tasks) do not appear in
top. Look for entries like wq:lp_default in top output, then run work_queue status to see which modules are scheduled on it.The commander module
commander is the vehicle’s central state machine. It arbitrates:
- Arming and disarming — checks all health and arming conditions before permitting arm.
- Flight mode transitions — translates RC switch positions, MAVLink commands, and offboard requests into navigation states.
- Failsafe logic — monitors link loss, battery level, geofence violations, and sensor failures, then triggers the appropriate failsafe action.
- Calibration routines — manages accelerometer, gyroscope, magnetometer, barometer, RC, and ESC calibration sequences.
src/modules/commander/) contains separate compilation units for each major responsibility:
The module.yaml descriptor
Every module that exposes parameters or has configurable behavior provides amodule.yaml file alongside its source code. The build system reads these files to auto-generate parameter documentation and the module’s command-line help text.
A minimal module.yaml looks like this:
Supported parameter types
| Type | Description |
|---|---|
boolean | 0 or 1 |
int32 | 32-bit signed integer |
float | 32-bit float |
enum | Integer with named values |
bitmask | Integer interpreted as bit flags |
Enum and bitmask parameters
Writing a new module
Create the module directory
Add a new directory under
src/modules/ (or src/drivers/ for a hardware driver). Your directory needs at minimum:Define the CMakeLists.txt
Register your module with the PX4 build system and declare its source files and uORB dependencies:
Implement the module class
Subclass
ModuleBase and ModuleParams. Override task_spawn, run, and print_status: