# Adding a Frame Configuration

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 (opens new window) folder (configuration files for POSIX simulators are stored in ROMFS/px4fmu_common/init.d-posix (opens new window)). 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

구성 파일에서 설정하는 매개변수를 결정하려면, 먼저 일반 기체를 할당하고 차량을 조정한 다음 param show-for-airframe을 사용하여 변경된 매개변수를 나열합니다.

# Developing a Frame Configuration

The recommended process for developing a new frame configuration is:

  1. Start by selecting an appropriate "generic configuration" for the target vehicle type in QGC, such as Generic Quadcopter.
  2. Configure the geometry and actuator outputs.
  3. Perform other basic configuration.
  4. Tune the vehicle.
  5. 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:

  1. Create a new config file in the init.d/airframes (opens new window) 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).
  2. Add the name of the new frame config file to the CMakeLists.txt (opens new window) in the relevant section for the type of vehicle
  3. 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.

# 구성 파일 개요

The configuration file consists of several main blocks:

  • Documentation (used in the Airframes Reference and QGroundControl). Airframe-specific parameter settings
  • The controllers and apps it should start, such as multicopter or fixed wing controllers, land detectors etc.

이러한 측면은 대부분 독립적이므로, 많은 구성이 기체의 동일한 물리적 레이아웃을 공유하고 동일한 응용 프로그램을 시작하며 튜닝 이득이 가장 차이가 납니다.

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 (opens new window)). 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.

#!/bin/sh

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.

# @name Generic Quadcopter
#
# @type Quadrotor x
# @class Copter
#
# @maintainer Lorenz Meier <lorenz@px4.io>
#

The next line imports generic parameters that are appropriate for all vehicles of the specified type (see init.d/rc.mc_defaults (opens new window)).

. ${R}etc/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.

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

# 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 (opens new window)).

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.

#!/bin/sh
#
# @name BabyShark VTOL
#
# @type Standard VTOL
# @class VTOL
#
# @maintainer Silvan Fuhrer <silvan@auterion.com>
#
# @output Motor1 motor 1
# @output Motor2 motor 2
# @output Motor3 motor 3
# @output Motor4 motor 4
# @output Motor5 Pusher motor
# @output Servo1 Ailerons
# @output Servo2 A-tail left
# @output Servo3 A-tail right
#
# @board px4_fmu-v2 exclude
# @board bitcraze_crazyflie exclude
# @board holybro_kakutef7 exclude
#

As for the generic frame, we then include the generic VTOL defaults.

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

Then we define configuration parameters and tuning gains:

param set-default MAV_TYPE 22

param set-default BAT1_N_CELLS 6

param set-default FW_AIRSPD_MAX 30
param set-default FW_AIRSPD_MIN 19
param set-default FW_AIRSPD_TRIM 23
param set-default FW_L1_R_SLEW_MAX 40
param set-default FW_PSP_OFF 3
param set-default FW_P_LIM_MAX 18
param set-default FW_P_LIM_MIN -25
param set-default FW_RLL_TO_YAW_FF 0.1
param set-default FW_RR_P 0.08
param set-default FW_R_LIM 45
param set-default FW_R_RMAX 50
param set-default FW_THR_TRIM 0.65
param set-default FW_THR_MIN 0.3
param set-default FW_THR_SLEW_MAX 0.6
param set-default FW_T_HRATE_FF 0
param set-default FW_T_SINK_MAX 15
param set-default FW_T_SINK_MIN 3
param set-default FW_YR_P 0.15

param set-default IMU_DGYRO_CUTOFF 15
param set-default MC_PITCHRATE_MAX 60
param set-default MC_ROLLRATE_MAX 60
param set-default MC_YAWRATE_I 0.15
param set-default MC_YAWRATE_MAX 40
param set-default MC_YAWRATE_P 0.3

param set-default MPC_ACC_DOWN_MAX 2
param set-default MPC_ACC_HOR_MAX 2
param set-default MPC_ACC_UP_MAX 3
param set-default MC_AIRMODE 1
param set-default MPC_JERK_AUTO 4
param set-default MPC_LAND_SPEED 1
param set-default MPC_MAN_TILT_MAX 25
param set-default MPC_MAN_Y_MAX 40
param set-default COM_SPOOLUP_TIME 1.5
param set-default MPC_THR_HOVER 0.45
param set-default MPC_TILTMAX_AIR 25
param set-default MPC_TKO_RAMP_T 1.8
param set-default MPC_TKO_SPEED 1
param set-default MPC_VEL_MANUAL 3
param set-default MPC_XY_CRUISE 3
param set-default MPC_XY_VEL_MAX 3.5
param set-default MPC_YAWRAUTO_MAX 40
param set-default MPC_Z_VEL_MAX_UP 2

param set-default NAV_ACC_RAD 3

param set-default PWM_MAIN_DIS3 1000
param set-default PWM_MAIN_MIN3 1120

param set-default SENS_BOARD_ROT 4

param set-default VT_ARSP_BLEND 10
param set-default VT_ARSP_TRANS 21
param set-default VT_B_DEC_MSS 1.5
param set-default VT_B_TRANS_DUR 12
param set-default VT_ELEV_MC_LOCK 0
param set-default VT_FWD_THRUST_SC 1.2
param set-default VT_F_TR_OL_TM 8
param set-default VT_PSHER_RMP_DT 2
param set-default VT_TRANS_MIN_TM 4
param set-default VT_TYPE 2

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 acutators.

param set-default CA_AIRFRAME 2
param set-default CA_ROTOR_COUNT 5
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
param set-default CA_ROTOR4_AX 1.0
param set-default CA_ROTOR4_AZ 0.0

param set-default CA_SV_CS_COUNT 3
param set-default CA_SV_CS0_TYPE 15
param set-default CA_SV_CS0_TRQ_R 1.0
param set-default CA_SV_CS1_TRQ_P 0.5000
param set-default CA_SV_CS1_TRQ_R 0.0000
param set-default CA_SV_CS1_TRQ_Y -0.5000
param set-default CA_SV_CS1_TYPE 13
param set-default CA_SV_CS2_TRQ_P 0.5000
param set-default CA_SV_CS2_TRQ_Y 0.5000
param set-default CA_SV_CS2_TYPE 14

param set-default PWM_MAIN_FUNC1 201
param set-default PWM_MAIN_FUNC2 202
param set-default PWM_MAIN_FUNC3 105
param set-default PWM_MAIN_FUNC4 203
param set-default PWM_MAIN_FUNC5 101
param set-default PWM_MAIN_FUNC6 102
param set-default PWM_MAIN_FUNC7 103
param set-default PWM_MAIN_FUNC8 104

param set-default PWM_MAIN_TIM0 50
param set-default PWM_MAIN_DIS1 1500
param set-default PWM_MAIN_DIS2 1500
param set-default PWM_MAIN_DIS4 1500

# 새 기체 그룹 추가

Airframe "groups" are used to group similar airframes for selection in QGroundControl (opens new window) and in the Airframe Reference. 모든 그룹에는 그룹화된 기체에 대한 공통 지오메트리, 모터 수, 및 모터 회전 방향을 나타내는 이름과 연관된 svg 이미지가 있습니다.

QGroundControl에서 사용하는 기체 메타데이터 파일과 문서 소스 코드는 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 (opens new window).

기체가 새 그룹을 위한 것이라면, 추가로 다음 작업을 수행하여야 합니다.

  1. 그룹에 대한 svg 이미지를 사용자 가이드 문서에 추가합니다(이미지가 제공되지 않은 경우 자리 표시자 이미지가 표시됨): assets/airframes/types (opens new window)
  2. srcparser.py (opens new window) 메소드 GetImageName()에서 새 그룹 이름과 이미지 파일 이름 간의 매핑을 추가합니다(아래 패턴을 따릅니다).
    def GetImageName(self):
        """
        Get parameter group image base name (w/o extension)
        """
        if (self.name == "Standard Plane"):
            return "Plane"
        elif (self.name == "Flying Wing"):
            return "FlyingWing"
         ...
     ...
        return "AirframeUnknown"
    
  3. QGroundControl을 업데이트 합니다.
    • 그룹에 대한 svg 이미지를 src/AutopilotPlugins/Common/images (opens new window)에 추가합니다.
    • 아래 패턴에 따라 svg 이미지에 대한 참조를 qgcimages.qrc (opens new window)에 추가합니다.
      <qresource prefix="/qmlimages">
         ...
         <file alias="Airframe/AirframeSimulation">src/AutoPilotPlugins/Common/Images/AirframeSimulation.svg</file>
         <file alias="Airframe/AirframeUnknown">src/AutoPilotPlugins/Common/Images/AirframeUnknown.svg</file>
         <file alias="Airframe/Boat">src/AutoPilotPlugins/Common/Images/Boat.svg</file>
         <file alias="Airframe/FlyingWing">src/AutoPilotPlugins/Common/Images/FlyingWing.svg</file>
         ...
      

Note

나머지 기체 메타데이터는 펌웨어에 자동으로 포함되어야 합니다(srcparser.py가 업데이트되면).

# 게인 튜닝

구성 파일에 지정될 매개변수를 조정하는 방법을 설명합니다.

# Add Frame to QGroundControl

To make a new airframe available for section in the QGroundControl frame configuration:

  1. 깨끗한 빌드 만들기(예: make clean을 실행한 다음 make px4_fmu-v5_default 실행)
  2. QGC를 열고 아래와 같이 **맞춤 펌웨어 파일...**을 선택합니다.

QGC 커스텀 펌웨어 플래시

플래시할 .px4 펌웨어 파일을 선택하라는 메시지가 표시됩니다(이 파일은 압축된 JSON 파일이며 기체 메타데이터가 포함되어 있습니다).

  1. 빌드 폴더로 이동하여 펌웨어 파일을 선택합니다(예: PX4-Autopilot/build/px4_fmu-v5_default/px4_fmu-v5_default.px4).
  2. 확인을 눌러, 펌웨어 플래시를 시작합니다.
  3. QGroundControl을 재시작합니다.

The new frame will then be available for selection in QGroundControl.