Adding a New Airframe
PX4 frame configuration files are shell scripts that set up some (or all) of the parameters, controllers and apps needed for a particular vehicle frame, such as a quadcopter, ground vehicle, or boat. These scripts are executed when the corresponding airframe is selected and applied in QGroundControl.
The configuration files that are compiled into firmware for NuttX targets are located in the ROMFS/px4fmu_common/init.d folder (configuration files for POSIX simulators are stored in ROMFS/px4fmu_common/init.d-posix). The folder contains both complete and full configurations for specific vehicles, and partial "generic configurations" for different vehicle types. The generic configurations are often used as the starting point for creating new configuration files.
In addition, a frame configuration file can also be loaded from an SD card.
:::note You can also "tweak" the current frame configuration using text files on the SD card. This is covered in System Startup > Customizing the System Startup page. :::
:::note To determine which parameters/values need to be set in the configuration file, you can first assign a generic airframe and tune the vehicle, and then use param show-for-airframe
to list the parameters that changed. :::
Developing a Frame Configuration
The recommended process for developing a new frame configuration is:
Start by selecting an appropriate "generic configuration" for the target vehicle type in QGC, such as Generic Quadcopter.
Configure the geometry and actuator outputs.
Perform other basic configuration.
Tune the vehicle.
Run the
param show-for-airframe
console command to list the parameter difference compared to the original generic airfame.
Once you have the parameters you can create a new frame configuration file by copying the configuration file for the generic configuration, and appending the new parameters.
Alternatively you can just append the modified parameters to the startup configuration files described in System Startup > Customizing the System Startup ("tweaking the generic configuration").
How to add a Configuration to Firmware
To add a frame configuration to firmware:
Create a new config file in the init.d/airframes folder.
Give it a short descriptive filename and prepend the filename with an unused autostart ID (for example,
1033092_superfast_vtol
).Update the file with configuration parameters and apps (see section above).
Add the name of the new frame config file to the CMakeLists.txt in the relevant section for the type of vehicle
Build and upload the software.
How to add a Configuration to an SD Card
A frame configuration file to be launched from SD card is the same as one stored in firmware.
To make PX4 launch with a frame configuration, renamed it to rc.autostart
and copy it to the SD card at /ext_autostart/rc.autostart
. PX4 will find any linked files in firmware.
Configuration File Overview
The configuration file consists of several main blocks:
Documentation (used in the Airframes Reference and QGroundControl). Airframe-specific parameter settings
The configuration and geometry using control allocation parameters
The controllers and apps it should start, such as multicopter or fixed wing controllers, land detectors etc.
These aspects are mostly independent, which means that many configurations share the same physical layout of the airframe, start the same applications and differ most in their tuning gains.
:::note New frame configuration files are only automatically added to the build system after a clean build (run make clean
). :::
Example - Generic Quadcopter Frame Config
The configuration file for a generic Quad X copter is shown below (original file here). This is very simple, because it defines only the minimal setup common to all quadcopters.
The first line is a shebang, which tells the NuttX operating system (on which PX4 runs) that the configuration file is an executable shell script.
This is followed by the frame documentation. The @name
, @type
and @class
are used to identify and group the frame in the API Reference and QGroundControl Airframe Selection.
The next line imports generic parameters that are appropriate for all vehicles of the specified type (see init.d/rc.mc_defaults).
Finally the file lists the control allocation parameters (starting with CA_
that define the default geometry for the frame. These may be modified for your frame geometry in the Actuators Configuration, and output mappings may be added.
Example - Babyshark VTOL Complete Vehicle
A more complicated configuration file for a complete vehicle is provided below. This is the configuration for the Baby Shark Standard VTOL (original file here).
The shebang and documentation sections are similar to those for the generic frame, but here we also document what outputs
are mapped to each motor and actuator. Note that these outputs are documentation only; the actual mapping is done using parameters.
As for the generic frame, we then include the generic VTOL defaults.
Then we define configuration parameters and tuning gains:
Last of all, the file defines the control allocation parameters for the geometry and the parameters that set which outputs map to different motors and servos.
Adding a New Airframe Group
Airframe "groups" are used to group similar airframes for selection in QGroundControl and in the Airframe Reference. Every group has a name, and an associated svg image which shows the common geometry, number of motors, and direction of motor rotation for the grouped airframes.
The airframe metadata files used by QGroundControl and the documentation source code are generated from the airframe description, via a script, using the build command: make airframe_metadata
For a new frame belonging to an existing group, you don't need to do anything more than provide documentation in the airframe description located at ROMFS/px4fmu_common/init.d.
If the airframe is for a new group you additionally need to:
Add the svg image for the group into user guide documentation (if no image is provided a placeholder image is displayed): assets/airframes/types
Add a mapping between the new group name and image filename in the srcparser.py method
GetImageName()
(follow the pattern below):Update QGroundControl:
Add the svg image for the group into: src/AutopilotPlugins/Common/images
Add reference to the svg image into qgcimages.qrc, following the pattern below:
:::note The remaining airframe metadata should be automatically included in the firmware (once srcparser.py is updated). :::
Tuning Gains
The following topics explain how to tune the parameters that will be specified in the config file:
Add Frame to QGroundControl
To make a new airframe available for section in the QGroundControl frame configuration:
Make a clean build (e.g. by running
make clean
and thenmake px4_fmu-v5_default
)Open QGC and select Custom firmware file... as shown below:
You will be asked to choose the .px4 firmware file to flash (this file is a zipped JSON file and contains the airframe metadata).
Navigate to the build folder and select the firmware file (e.g. PX4-Autopilot/build/px4_fmu-v5_default/px4_fmu-v5_default.px4).
Press OK to start flashing the firmware.
Restart QGroundControl.
The new frame will then be available for selection in QGroundControl.
Last updated