Creating Airframe Configurations for APX4

What is an Airframe File?

After setting up, configuring, and tuning a new vehicle, an airframe configuration file should be created to store the setup and tuning parameters. Using airframe configurations the tuning can then easily be applied to other vehicles of the same type, as all relevant parameters will be loaded from this file.

In APX4 the airframe configuration file does mainly two things:

  1. Load pre-defined parameters: APX4 is configured by changing various parameters to tune the behaviour of the autopilot. Pre-defining parameters is convenient for setting up a large number of the same aircrafts

  2. Configure the Control Allocation (Input/Output mixing): Control allocation handles the mapping of control inputs to motor and servo outputs. All parameters starting with CA_ are related to Control Allocation and therefore affect the mixing.

Example of an Airframe File

The airframes supported by PX4 and Auterion PX4 can be found in PX4's official documentation.

In this example we want to create an airframe file for a Generic quadrotor x configuration. The PX4 Airframe Reference specifies that this airframe configuration has the ID 4001. Inside the PX4 Github Repository, we can find the file corresponding to the Generic quadrotor x airframe.

4001_quad_x
#!/bin/sh
#
# @name Generic Quadcopter
#
# @type Quadrotor x
# @class Copter
#
# @maintainer Lorenz Meier <lorenz@px4.io>
#

. ${R}etc/init.d/rc.mc_defaults

# Square quadrotor X PX4 numbering
param set-default CA_ROTOR_COUNT 4
param set-default CA_ROTOR0_PX 1
param set-default CA_ROTOR0_PY 1
param set-default CA_ROTOR1_PX -1
param set-default CA_ROTOR1_PY -1
param set-default CA_ROTOR2_PX 1
param set-default CA_ROTOR2_PY -1
param set-default CA_ROTOR2_KM -0.05
param set-default CA_ROTOR3_PX -1
param set-default CA_ROTOR3_PY 1
param set-default CA_ROTOR3_KM -0.05

This airframe configuration file is composed of two main parts. The first one loads the default parameters valid for a general multicopter frame:

. ${R}etc/init.d/rc.mc_defaults

The second one specifies all PX4 parameters that need to be different from the default ones. This examples shows the definition of the number of motors and the frame geometry. In a previous chapter (Actuators Setup) we have also seen how to change these parameters via the AMC UI by using the actuators tab.

param set-default CA_ROTOR_COUNT 4
param set-default CA_ROTOR0_PX 1
param set-default CA_ROTOR0_PY 1
param set-default CA_ROTOR1_PX -1
param set-default CA_ROTOR1_PY -1
param set-default CA_ROTOR2_PX 1
param set-default CA_ROTOR2_PY -1
param set-default CA_ROTOR2_KM -0.05
param set-default CA_ROTOR3_PX -1
param set-default CA_ROTOR3_PY 1
param set-default CA_ROTOR3_KM -0.05

We recommend that the motors' position specified by the CA_ROTORx_P parameters are configured to match your vehicle geometry precisely.

Creating a custom Airframe Configuration File

The easiest way to create a custom airframe file is to start with an existing one.

You can either copy one from the PX4 Github Repository, or create a completely new .txt file named ID_customName (e.g. 1230010_custom) locally on your PC/Laptop.

For our example, we would start by modifying the header and keeping the multicopter defaults, since our custom drone is also a multicopter. Our Custom Config file should look as follows:

1230010_custom.txt
#!/bin/sh
#
# @name Custom Quadcopter
#
# @type X500 Quadrotor
# @class Copter
#
# @maintainer YourName
#
. ${R}etc/init.d/rc.mc_defaults

Now you need to gather the parameters we changed during the sensors and actuators Setup. To do that the easiest way is to access the MavlinkConsole present inside AMC.

Connect your Skynode via USB-C to your PC/Laptop and open AMC. Access the Advanced Mode. Click on the "Analyze" Tab present in the Left-hand sidebar menu and then choose MAVLink Console:

Type the following command inside the MAVLink Console:

param show-for-airframe

And then type "Enter".

At this point you should be presented with the following output:

Now Select and copy the parameters inside your custom Airframe Configuration file, like this:

1230010_custom.txt
#!/bin/sh
#
# @name Custom Quadcopter
#
# @type X500 Quadrotor
# @class Copter
#
# @maintainer YourName
#
. ${R}etc/init.d/rc.mc_defaults

param set-default CA_ROTOR0_PX 0.2500
param set-default CA_ROTOR0_PY 0.2500
param set-default CA_ROTOR1_PX -0.2500
param set-default CA_ROTOR1_PY -0.2500
param set-default CA_ROTOR2_PX 0.2500
param set-default CA_ROTOR2_PY -0.2500
param set-default CA_ROTOR3_PX -0.2500
param set-default CA_ROTOR3_PY 0.2500
param set-default COM_FLTMODE1 6
param set-default COM_FLTMODE2 0
param set-default GPS_1_CONFIG 0
param set-default PWM_AUX_FUNC1 101
param set-default PWM_AUX_FUNC2 102
param set-default PWM_AUX_FUNC3 103
param set-default PWM_AUX_FUNC4 104
param set-default PWM_AUX_TIM0 -3
param set-default SENS_EN_INA226 0

Now save this file locally on your PC/Laptop.

Getting your Airframe File onto Skynode

Remove the propellers before proceeding

The airframe file we just created can be bundled with AuterionOS for deployment on Skynodes.

  1. First you have to install the Auterion OEM Tools: OEM Tools Installation

  2. Save your airframe file as aepx4-oem-tools-2.x.x/fmu/config/airframes/1230010_custom

  3. Edit the file rc.autostart under aepx4-oem-tools-2.x.x/fmu/config and add your custom airframe there:

rc.autostart
if param compare SYS_AUTOSTART 1230010
then
	sh /fs/microsd/ext_autostart/airframes/1230010_custom
fi
  1. Make sure that your Skynode is coonnected to your PC/Laptop via USB.

  2. Package your configuration file by executing the following command from your OEM tools folder:

    # In the Auterion OEM Tools directory:
    make fmu-update configurationDir=fmu/config
  3. Reboot your vehicle.

  4. ATTENTION: REMOVE THE PROPELLERS BEFORE PROCEEDING

    Check if you motors and servos move correctly by repeating the procedure explained here.

From now on you can directly upload this configuration file to your vehicles by following the procedure explained above.

Last updated