Top Related Projects
ArduPlane, ArduCopter, ArduRover, ArduSub source
Open Source Flight Controller Firmware
INAV: Navigation-enabled flight control software
Clean-code version of the baseflight flight controller firmware
Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles. This is the main software repository.
Quick Overview
PX4-Autopilot is an open-source autopilot system for drones and other unmanned vehicles. It provides a flexible and powerful platform for controlling various types of autonomous vehicles, including multicopters, fixed-wing aircraft, and ground vehicles. The project is widely used in both research and commercial applications.
Pros
- Highly customizable and adaptable to various vehicle types and configurations
- Large and active community, providing support and continuous development
- Extensive documentation and integration with popular ground control stations
- Supports a wide range of hardware components and sensors
Cons
- Steep learning curve for beginners due to its complexity
- Requires significant technical knowledge to fully utilize and customize
- Some users report occasional stability issues with certain hardware configurations
- Limited support for some niche or specialized vehicle types
Code Examples
// Example 1: Setting up a simple waypoint mission
#include <px4_msgs/msg/vehicle_command.hpp>
// Create a waypoint command
vehicle_command_s cmd{};
cmd.command = vehicle_command_s::VEHICLE_CMD_NAV_WAYPOINT;
cmd.param5 = latitude; // Latitude in degrees
cmd.param6 = longitude; // Longitude in degrees
cmd.param7 = altitude; // Altitude in meters
// Publish the command
_vehicle_command_pub.publish(cmd);
// Example 2: Reading sensor data
#include <px4_msgs/msg/sensor_combined.hpp>
void sensor_callback(const sensor_combined_s& msg)
{
float accel_x = msg.accelerometer_m_s2[0];
float gyro_x = msg.gyro_rad[0];
// Process sensor data
}
// Subscribe to sensor data
_sensor_sub = create_subscription<sensor_combined_s>("sensor_combined", 10, sensor_callback);
// Example 3: Arming the vehicle
#include <px4_msgs/msg/vehicle_command.hpp>
vehicle_command_s arm_cmd{};
arm_cmd.command = vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM;
arm_cmd.param1 = 1.0f; // 1 to arm, 0 to disarm
arm_cmd.target_system = 1;
arm_cmd.target_component = 1;
_vehicle_command_pub.publish(arm_cmd);
Getting Started
-
Clone the repository:
git clone https://github.com/PX4/PX4-Autopilot.git cd PX4-Autopilot
-
Install dependencies:
bash ./Tools/setup/ubuntu.sh
-
Build for a specific target (e.g., px4_fmu-v5):
make px4_fmu-v5
-
Upload firmware to the flight controller:
make px4_fmu-v5 upload
For more detailed instructions and configuration options, refer to the official PX4 documentation.
Competitor Comparisons
ArduPlane, ArduCopter, ArduRover, ArduSub source
Pros of ArduPilot
- Wider range of supported hardware platforms
- More extensive documentation and community support
- Greater flexibility in customization and parameter tuning
Cons of ArduPilot
- Steeper learning curve for beginners
- Less streamlined development process compared to PX4
Code Comparison
ArduPilot (example of parameter definition):
// @Param: EXAMPLE_PARAM
// @DisplayName: Example Parameter
// @Description: This is an example parameter
// @Range: 0 100
// @User: Standard
GSCALAR(example_param, "EXAMPLE_PARAM", 50),
PX4 (example of parameter definition):
/**
* Example Parameter
*
* @min 0
* @max 100
* @group System
*/
PARAM_DEFINE_INT32(SYS_EXAMPLE, 50);
Both projects use different approaches for parameter definition, with ArduPilot using a more verbose but descriptive method, while PX4 opts for a more compact syntax.
Open Source Flight Controller Firmware
Pros of Betaflight
- Optimized for racing drones and high-performance quadcopters
- User-friendly configuration interface with Betaflight Configurator
- Extensive community support and frequent updates
Cons of Betaflight
- Limited support for larger or more complex drone configurations
- Less suitable for autonomous missions or advanced navigation features
- Narrower range of supported hardware compared to PX4-Autopilot
Code Comparison
Betaflight (flight controller initialization):
void init(void)
{
initEEPROM();
ensureEEPROMStructureIsValid();
readEEPROM();
}
PX4-Autopilot (main loop):
int px4_main(int argc, char *argv[])
{
px4::init(argc, argv, "px4");
px4::create_task(PX4_MAIN_TASK_STACK_SIZE, px4_task_main, nullptr, "px4_main");
px4::start_scheduler();
return 0;
}
Betaflight focuses on a streamlined initialization process for racing drones, while PX4-Autopilot's main loop demonstrates a more complex task management system suitable for various drone types and missions.
INAV: Navigation-enabled flight control software
Pros of iNav
- Lightweight and optimized for smaller drones and fixed-wing aircraft
- User-friendly configuration through Configurator GUI
- Strong community support for hobbyists and DIY enthusiasts
Cons of iNav
- Limited support for advanced features and larger vehicles
- Less extensive documentation compared to PX4
- Fewer integrations with professional-grade sensors and equipment
Code Comparison
PX4-Autopilot (C++):
void MulticopterPositionControl::control_position(const float dt)
{
// Position control logic
Vector3f pos_error = _pos_sp - _pos;
Vector3f vel_sp = pos_error.emult(_params.pos_p) + _vel_sp;
control_velocity(dt, vel_sp);
}
iNav (C):
void applyMulticopterPositionController(float dT)
{
// Position control logic
Vector3_t positionError = vectorSub(positionTargetGetCurrent(), stateGetPositionXY());
Vector3_t velocityTarget = vectorAdd(vectorMul(positionError, positionPGain), velocityTargetGetCurrent());
applyMulticopterVelocityController(dT, velocityTarget);
}
Both repositories implement position control for multicopters, but PX4-Autopilot uses C++ with more object-oriented design, while iNav uses C with a more procedural approach.
Clean-code version of the baseflight flight controller firmware
Pros of Cleanflight
- Lightweight and optimized for racing drones and small quadcopters
- User-friendly configuration interface with Cleanflight Configurator
- Extensive support for various flight controllers and hardware
Cons of Cleanflight
- Limited support for advanced autonomous flight features
- Less suitable for larger drones or professional/commercial applications
- Smaller developer community compared to PX4-Autopilot
Code Comparison
PX4-Autopilot (C++):
void MulticopterPositionControl::control_position(const float dt)
{
// Position control logic
Vector3f pos_error = _pos_sp - _pos;
Vector3f vel_sp = pos_error.emult(_params.pos_p) + _vel_sp;
control_velocity(dt, vel_sp);
}
Cleanflight (C):
void applyAccelerometerTrimsDelta(rollAndPitchTrims_t *rollAndPitchTrimsDelta)
{
accelerometerConfig()->accelerometerTrims.values.roll += rollAndPitchTrimsDelta->values.roll;
accelerometerConfig()->accelerometerTrims.values.pitch += rollAndPitchTrimsDelta->values.pitch;
}
The code snippets show different approaches to flight control. PX4-Autopilot uses more advanced position control algorithms, while Cleanflight focuses on simpler, performance-oriented control for racing drones.
Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles. This is the main software repository.
Pros of Paparazzi
- More flexible and customizable architecture
- Supports a wider range of hardware platforms
- Easier to integrate custom sensors and payloads
Cons of Paparazzi
- Smaller community and less commercial support
- Steeper learning curve for beginners
- Less documentation and tutorials available
Code Comparison
PX4-Autopilot (C++):
void MulticopterPositionControl::control_position()
{
// Position control logic
Vector3f pos_error = _pos_sp - _pos;
Vector3f vel_sp = pos_error.emult(_params.pos_p) + _vel_sp;
control_velocity(vel_sp);
}
Paparazzi (OCaml):
let nav_circle = fun ?wp_center ?radius () ->
let r = match radius with Some r -> r | None -> nav_radius in
let (cen_x, cen_y) = match wp_center with
| Some wp -> (wp.wp_x, wp.wp_y)
| None -> (nav_circle_x, nav_circle_y) in
nav_circle_XY cen_x cen_y r
The code snippets showcase different programming languages and approaches. PX4-Autopilot uses C++ for its core functionality, while Paparazzi primarily uses OCaml. This difference reflects the projects' design philosophies, with PX4-Autopilot focusing on performance and real-time capabilities, and Paparazzi emphasizing flexibility and high-level abstractions.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PX4 Drone Autopilot
This repository holds the PX4 flight control solution for drones, with the main applications located in the src/modules directory. It also contains the PX4 Drone Middleware Platform, which provides drivers and middleware to run drones.
PX4 is highly portable, OS-independent and supports Linux, NuttX and MacOS out of the box.
- Official Website: http://px4.io (License: BSD 3-clause, LICENSE)
- Supported airframes (portfolio):
- Multicopters
- Fixed wing
- VTOL
- Autogyro
- Rover
- many more experimental types (Blimps, Boats, Submarines, High Altitude Balloons, Spacecraft, etc)
- Releases: Downloads
Releases
Release notes and supporting information for PX4 releases can be found on the Developer Guide.
Building a PX4 based drone, rover, boat or robot
The PX4 User Guide explains how to assemble supported vehicles and fly drones with PX4. See the forum and chat if you need help!
Changing Code and Contributing
This Developer Guide is for software developers who want to modify the flight stack and middleware (e.g. to add new flight modes), hardware integrators who want to support new flight controller boards and peripherals, and anyone who wants to get PX4 working on a new (unsupported) airframe/vehicle.
Developers should read the Guide for Contributions. See the forum and chat if you need help!
Weekly Dev Call
The PX4 Dev Team syncs up on a weekly dev call.
Note The dev call is open to all interested developers (not just the core dev team). This is a great opportunity to meet the team and contribute to the ongoing development of the platform. It includes a QA session for newcomers. All regular calls are listed in the Dronecode calendar.
Maintenance Team
See the latest list of maintainers on MAINTAINERS file at the root of the project.
For the latest stats on contributors please see the latest stats for the Dronecode ecosystem in our project dashboard under LFX Insights. For information on how to update your profile and affiliations please see the following support link on how to Complete Your LFX Profile. Dronecode publishes a yearly snapshot of contributions and achievements on its website under the Reports section.
Supported Hardware
For the most up to date information, please visit PX4 User Guide > Autopilot Hardware.
Project Governance
The PX4 Autopilot project including all of its trademarks is hosted under Dronecode, part of the Linux Foundation.
Top Related Projects
ArduPlane, ArduCopter, ArduRover, ArduSub source
Open Source Flight Controller Firmware
INAV: Navigation-enabled flight control software
Clean-code version of the baseflight flight controller firmware
Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles. This is the main software repository.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot