Add a Platform to Autostart

You should have read and understood the system startup guide first!

Adding a new vehicle is relatively easy (if software support is available):

  1. Add a new entry to the autostart registry file.
  2. Add your new autostart script file.
  3. Rebuild & flash the firmware.

Adding the new Autostart Entry

You first have to pick an unused ID number from the list of files in the autostart registry folder.

This is the current partitioning:

# AUTOSTART PARTITION:
#  0   	..	 999		Reserved (historical)
#  1000	..	 1999		Simulation setups
#  2000	..	 2999		Standard planes
#  3000	..	 3999		Flying wing
#  4000	..	 4999		Quad X
#  5000	..	 5999		Quad +
#  6000	..	 6999		Hexa X
#  7000	..	 7999		Hexa +
#  8000	..	 8999		Octo X
#  9000	..	 9999		Octo +
# 10000	..	10999		Wide arm / H frame
# 11000	..	11999		Hexa Cox
# 12000	..	12999		Octo Cox

Look through the folder and pick an unused ID number from the range of your platform's type. Then make up a file name for your autostart script file. The file name should begin with the ID followed by a readable name (e.g. 4010_dji_f330).

Adding the new Autostart File

You then have to add a new autostart script file to the ROMFS/px4fmu_common/init.d folder.

The contents of the file are quite simple. Let's take the DJI F330 script as an example: 4010_dji_f330

The file should start with a comment containing the name of the platform and your name:

#!nsh
#
# DJI Flame Wheel F330 Quadcopter
#
# Anton Babushkin <anton.babushkin@me.com>
#

This comment is followed by a special section that loads decent defaults for system parameters. This block is only executed once, if SYS_AUTOCONFIG is set to 1.

if [ $DO_AUTOCONFIG == yes ]
then
	#
	# Default parameters for this platform
	#
	param set MC_ATT_P 7.0
	param set MC_ATT_I 0.0
	param set MC_ATT_D 0.0
	...
fi

The rest of the file sets environment variables as described here.

set VEHICLE_TYPE mc
set MIXER FMU_quad_x
 
set PWM_OUTPUTS 1234
set PWM_RATE 400
# DJI ESC range
set PWM_DISARMED 900
set PWM_MIN 1200
set PWM_MAX 1900

Build and Flash Firmware

Although NuttX can execute script files from microSD, the goal here is to add the new script to the flash image. Therefore the firmware needs to be compiled and uploaded:

make px4fmu-v1_default upload

Use px4fmu-v2_default for FMUv2 (contained in Pixhawk module).

Test the Setup

Set these two parameters in your ground control station:

  • SYS_AUTOSTART to the index of your new file, e.g. 4010
  • SYS_AUTOCONFIG to 1

Write the parameters to disk, reboot the system and it will set your parameters once, and now always boot the start script.

Debugging

If the new script still contains errors, its execution will fail. Use the autostart debugging instructions to track down the error (most likely a change in the command line arguments of one of the used software components).

Translations of this page:


Quick Links

QR Code: URL of current page