Adding a New Airframe
PX4 uses canned airframe configurations as starting point for airframes. The configurations are defined in config files that are stored in the ROMFS/px4fmu_common/init.d folder. The config files reference mixer files that describe the physical configuration of the system, and which are stored in the ROMFS/px4fmu_common/mixers folder.
Adding a configuration is straightforward: create a new config file in the init.d/airframes folder (prepend the filename with an unused autostart ID), add the name of your new airframe config file to the CMakeLists.txt in the relevant section, then build and upload the software.
Developers who do not want to create their own configuration can instead customize existing configurations using text files on the microSD card, as detailed on the custom system startup page.
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.
Configuration File Overview
The configuration in the config and mixer files consists of several main blocks:
Airframe documentation (used in the Airframes Reference and QGroundControl).
Vehicle-specific parameter settings, including tuning gains.
The controllers and apps it should start, e.g. multicopter or fixed wing controllers, land detectors etc.
The physical configuration of the system (e.g. a plane, wing or multicopter). This is called a mixer.
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.
New airframe files are only automatically added to the build system after a clean build (run make clean
).
Config File
A typical configuration file is shown below (original file here).
The first section is the airframe documentation. This is used in the Airframes Reference and QGroundControl.
The next section specifies vehicle-specific parameters, including tuning gains:
Set frame type (MAV_TYPE):
Set the mixer to use:
Configure PWM outputs (specify the outputs to drive/activate, and the levels).
If you want to reverse a channel, never do this on your RC transmitter or with e.g RC1_REV
. The channels are only reversed when flying in manual mode, when you switch in an autopilot flight mode, the channels output will still be wrong (it only inverts your RC signal). Thus for a correct channel assignment change either your PWM signals with PWM_MAIN_REV1
(e.g. for channel one) or change the signs of the output scaling in the corresponding mixer (see below).
Mixer File
First read Concepts > Mixing. This provides background information required to interpret this mixer file.
A typical mixer file is shown below (original file here). A mixer filename, in this case wingwing.main.mix
, gives important information about the type of airframe (wingwing
), the type of output (.main
or .aux
) and lastly that it is a mixer file (.mix
).
The mixer file contains several blocks of code, each of which refers to one actuator or ESC. So if you have e.g. two servos and one ESC, the mixer file will contain three blocks of code.
The plugs of the servos / motors go in the order of the mixers in this file.
So MAIN1 would be the left aileron, MAIN2 the right aileron, MAIN3 is empty (note the Z: zero mixer) and MAIN4 is throttle (to keep throttle on output 4 for common fixed wing configurations).
A mixer is encoded in normalized units from -10000 to 10000, corresponding to -1..+1.
Where each number from left to right means:
M: Indicates two scalers for two control inputs. It indicates the number of control inputs the mixer will receive.
O: Indicates the output scaling (*1 in negative, *1 in positive), offset (zero here), and output range (-1..+1 here).
If you want to invert your PWM signal, the signs of the output scalings have to be changed:
This line can (and should) be omitted completely if it specifies the default scaling:
S: Indicates the first input scaler: It takes input from control group #0 (Flight Control) and the first input (roll). It scales the roll control input * 0.6 and reverts the sign (-0.6 becomes -6000 in scaled units). It applies no offset (0) and outputs to the full range (-1..+1)
S: Indicates the second input scaler: It takes input from control group #0 (Flight Control) and the second input (pitch). It scales the pitch control input * 0.65. It applies no offset (0) and outputs to the full range (-1..+1)
In short, the output of this mixer would be SERVO = ( (roll input * -0.6 + 0) * 1 + (pitch input * 0.65 + 0) * 1 ) * 1 + 0
Behind the scenes, both scalers are added, which for a flying wing means the control surface takes maximum 60% deflection from roll and 65% deflection from pitch.
The complete mixer looks like this:
Adding a New Airframe Group
Airframe "groups" are used to group similar airframes for selection in QGroundControl and in the Airframe Reference documentation (PX4 DevGuide and PX4 UserGuide). 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 airframe 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:
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 New Airframe to QGroundControl
To make a new airframe available for section in the QGroundControl airframe 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 airframe will then be available for selection in QGroundControl.
Last updated