Convert Figma logo to code with AI

PX4 logoPX4-Autopilot

PX4 Autopilot Software

11,350
15,195
11,350
1,602

Top Related Projects

14,719

ArduPlane, ArduCopter, ArduRover, ArduSub source

Open Source Flight Controller Firmware

4,016

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

  1. Clone the repository:

    git clone https://github.com/PX4/PX4-Autopilot.git
    cd PX4-Autopilot
    
  2. Install dependencies:

    bash ./Tools/setup/ubuntu.sh
    
  3. Build for a specific target (e.g., px4_fmu-v5):

    make px4_fmu-v5
    
  4. 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

14,719

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.

4,016

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

PX4 Autopilot

The autopilot stack the industry builds on.

Releases OpenSSF Best Practices DOI Build Targets Discord


About

PX4 is an open-source autopilot stack for drones and unmanned vehicles. It supports multirotors, fixed-wing, VTOL, rovers, and many more experimental platforms from racing quads to industrial survey aircraft. It runs on NuttX, Linux, and macOS. Licensed under BSD 3-Clause.

Why PX4

Modular architecture. PX4 is built around uORB, a DDS-compatible publish/subscribe middleware. Modules are fully parallelized and thread safe. You can build custom configurations and trim what you don't need.

Wide hardware support. PX4 runs on a wide range of autopilot boards and supports an extensive set of sensors, telemetry radios, and actuators through the Pixhawk ecosystem.

Developer friendly. First-class support for MAVLink and DDS / ROS 2 integration. Comprehensive SITL simulation, hardware-in-the-loop testing, and log analysis tools. An active developer community on Discord and the weekly dev call.

Vendor neutral governance. PX4 is hosted under the Dronecode Foundation, part of the Linux Foundation. Business-friendly BSD-3 license. No single vendor controls the roadmap.

Supported Vehicles

Multicopter
Multicopter
Fixed Wing
Fixed Wing
VTOL
VTOL
Rover
Rover

…and many more: helicopters, autogyros, airships, submarines, boats, and other experimental platforms. These frames have basic support but are not part of the regular flight-test program. See the full airframe reference.

Quick Start

git clone https://github.com/PX4/PX4-Autopilot.git --recursive
cd PX4-Autopilot
make px4_sitl

[!NOTE] See the Development Guide for toolchain setup and build options.

Documentation & Resources

ResourceDescription
User GuideBuild, configure, and fly with PX4
Developer GuideModify the flight stack, add peripherals, port to new hardware
Airframe ReferenceFull list of supported frames
Autopilot HardwareCompatible flight controllers
Release NotesWhat's new in each release
Contribution GuideHow to contribute to PX4

Community

Contributing

We welcome contributions of all kinds — bug reports, documentation, new features, and code reviews. Please read the Contribution Guide to get started.

Governance

The PX4 Autopilot project is hosted by the Dronecode Foundation, a Linux Foundation Collaborative Project. Dronecode holds all PX4 trademarks and serves as the project's legal guardian, ensuring vendor-neutral stewardship — no single company owns the name or controls the roadmap. The source code is licensed under the BSD 3-Clause license, so you are free to use, modify, and distribute it in your own projects.

Dronecode Logo