I have been using PX4 for a while to make custom drones but only recently started to delve deeper as a software developer. In short, how can one change the Firmware Parameters, that would normally be changed via QGC, before flashing the Firmware onto the board? Perhaps even including calibration parameters?
Long Story. To allow my custom drone to work, I need to change various parameters in the PX4 firmware. For example, to communicate with the Companion computer and to enable additional sensors (PX4 Flow). Now, I would also like to develop and test my own PX4 software module but it would be very cumbersome to have to re-calibrate the drone and change almost a dozen parameters after every flash, just to be able to perform a test flght of the module.
Hopefully, there is some file somewhere that has all the parameters conveniently listed out but any help would be appreciated. I look forward to hearing any advice. Thank you in advance.
Hello and Thank you @jimdgit for your quick reply.
Unfortunately, those are not the parameters I was hoping for. In the file, I noticed parameters that seemed lower level in the Firmware such as mot_v_max which configures the motor voltage limits. After double checking inside QGC, I can confirm that mot_v_max, (likely along with the rest of the parameters in parameters_injected.xml) are not the same parameters that are normally editable through QGC.
For example, I normally need to change about 7 parameters in QGC to enable the PX4 Firmware to work with an additional sensor (PX4 Flow Sensor) I have embedded in my custom drone design. Below are a few of the parameters:
SENS_FLOW_ROT | Configures the orientation of the sensor.
SENS_FLOW_MAXHGT | Configures the max height to consider the sensor in sensor fusion.
SENS_FLOW_MINHGT | Configures the min height to consider the sensor in sensor fusion.
SENS_EN_PX4FLOW | Boolean that enables the Sensor in Firmware
SYS_MC_EST_GROUP | Select Sensor Fusion Algorithm (Select Local Position Estimator)
LPE_FUSION | Select Sensors to include in Sensor Fusion (Include PX4 Optical Flow)
I would like to be able to adjust these parameters^^, along with any other parameter normally accessible through QGC, before flashing the firmware to the board. Ideally, this would also include sensor calibration parameters so that I do not have to recalibrate the drone after every time I change/improve my custom software module.
Thank you again, and I would really appreciate any help/guidance.
Thank you both for the quick reply and @Georacer-avy for the new piece of great information.
I’d like to confirm how to change parameters via an example. Since I am using a custom drone, the airframe configuration file associated with my airframe would be found in /Firmware/ROMFS/px4fmu_common/init.d/airframes/4001_quad_x
The original file, looks like this:
#!/bin/sh
#
# @name Generic Quadcopter
#
# @type Quadrotor x
# @class Copter
#
# @output MAIN1 motor 1
# @output MAIN2 motor 2
# @output MAIN3 motor 3
# @output MAIN4 motor 4
# @output MAIN5 feed-through of RC AUX1 channel
# @output MAIN6 feed-through of RC AUX2 channel
#
# @output AUX1 feed-through of RC AUX1 channel
# @output AUX2 feed-through of RC AUX2 channel
# @output AUX3 feed-through of RC AUX3 channel
# @output AUX4 feed-through of RC FLAPS channel
#
# @maintainer Lorenz Meier <lorenz@px4.io>
#
sh /etc/init.d/rc.mc_defaults
set MIXER quad_x
set PWM_OUT 1234
To make things easy, let’s just say I want to adjust one parameter, SENS_EN_PX4FLOW, and make sure it is loaded by default. I would just have to add two lines to the file to make it look like this:
#!/bin/sh
#
#----I removed code that was commented out-----
#
sh /etc/init.d/rc.mc_defaults
set MIXER quad_x
set PWM_OUT 1234
set SENS_EN_PX4FLOW 1
set SYS_AUTOCONFIG 1
Take a look at some more (derived) airframe files. Most have a conditional clause on SYS_AUTOCONFIG, as there’s no need to re-set parameters at each boot; they are saved anyway.
You just need them to be read only once, or every time you set SYS_AUTOCONFIG=1 manually and reboot.
For example, the rover file contains:
sh /etc/init.d/rc.rover_defaults
if [ $AUTOCNF = yes ]
then
param set GND_L1_DIST 5
param set GND_SP_CTRL_MODE 1
param set GND_SPEED_D 3
param set GND_SPEED_I 0.001
param set GND_SPEED_IMAX 0.125
param set GND_SPEED_P 0.25
param set GND_SPEED_THR_SC 1
param set GND_SPEED_TRIM 4
param set GND_THR_CRUISE 0.3
param set GND_THR_IDLE 0
param set GND_THR_MAX 0.5
param set GND_THR_MIN 0
param set MIS_LTRMIN_ALT 0.01
param set MIS_TAKEOFF_ALT 0.01
param set NAV_ACC_RAD 0.5
param set NAV_LOITER_RAD 2
param set CBRK_AIRSPD_CHK 162128
param set GND_MAX_ANG 0.6
param set GND_WHEEL_BASE 2.0
fi
set MAV_TYPE 10
set MIXER_FILE etc/mixers-sitl/rover_sitl.main.mix