Last updated
Last updated
PX4 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 in QGroundControl.
The configuration files that are compiled into firmware for NuttX targets are located in the folder (configuration files for POSIX simulators are stored in ). 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 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 to list the parameters that changed. :::
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 .
Perform other .
Tune the vehicle.
Run the 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 ("tweaking the generic configuration").
To add a frame configuration to firmware:
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).
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.
The configuration file consists of several main blocks:
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
). :::
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.
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.
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.
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
If the airframe is for a new group you additionally need to:
Update QGroundControl:
:::note The remaining airframe metadata should be automatically included in the firmware (once srcparser.py is updated). :::
The following topics explain how to tune the parameters that will be specified in the config file:
Make a clean build (e.g. by running make clean
and then make 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.
Create a new config file in the folder.
Add the name of the new frame config file to the in the relevant section for the type of vehicle
the software.
Documentation (used in the and QGroundControl). Airframe-specific parameter settings
The configuration and geometry using parameters
The configuration file for a generic Quad X copter is shown below (). This is very simple, because it defines only the minimal setup common to all quadcopters.
This is followed by the frame documentation. The @name
, @type
and @class
are used to identify and group the frame in the and QGroundControl Airframe Selection.
The next line imports generic parameters that are appropriate for all vehicles of the specified type (see ).
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 , and output mappings may be added.
A more complicated configuration file for a complete vehicle is provided below. This is the configuration for the Baby Shark ().
Then we define configuration parameters and :
Airframe "groups" are used to group similar airframes for selection in and in the . 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.
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 .
Add the svg image for the group into user guide documentation (if no image is provided a placeholder image is displayed):
Add a mapping between the new group name and image filename in the method GetImageName()
(follow the pattern below):
Add the svg image for the group into:
Add reference to the svg image into , following the pattern below:
To make a new airframe available for section in the QGroundControl :