AeroCoder Logo

System Internals

Parameters & Configs

How PX4 exposes hundreds of tuning values, stores them in flash, and syncs them with ground stations.

PX4 exposes hundreds of parameters — named float or int32 values that control everything from PID gains to failsafe thresholds. Parameters are stored in non-volatile memory (flash or SD card) and loaded into RAM on boot.

Parameters are defined in module source code using the PARAM_DEFINE_FLOAT and PARAM_DEFINE_INT32 macros. Metadata (description, min, max, default, group) is extracted at build time into an XML file used by QGroundControl for its parameter editor.

c

/**
 * Roll rate proportional gain.
 *
 * @unit 1/s
 * @min 0.01
 * @max 0.5
 * @decimal 3
 * @increment 0.005
 * @group Multicopter Rate Control
 */
PARAM_DEFINE_FLOAT(MC_ROLLRATE_P, 0.15f);

Parameter protocol flow

GCS sends PARAM_REQUEST_LIST → autopilot streams all PARAM_VALUE messages. To read one: PARAM_REQUEST_READ. To write: PARAM_SET → autopilot echoes the new value as PARAM_VALUE. The param_count and param_index fields let the GCS detect missing values on noisy links.

The param shell command provides runtime access. param show lists all parameters. param set MC_ROLLRATE_P 0.18 changes a value. param save persists to flash. param reset restores defaults. param set-default sets the default without changing the current value (used in airframe scripts).

bash

# Common param commands in the PX4 shell
param show MC_*          # list all MC parameters
param set MC_ROLLRATE_P 0.18   # change roll rate P gain
param save              # persist to flash
param reset_all         # reset all to defaults
param export /fs/microsd/params.bson  # export to file
param import /fs/microsd/params.bson  # import from file

Configuration files on the SD card can override parameters at boot. Place param set-default commands in /etc/config.txt on the microSD. This is loaded after the airframe script but before the system starts, making it ideal for per-vehicle tuning without modifying firmware.

← Previous

PWM Limit State Machine

Next →

uORB Pub-Sub Messaging

Source: docs.px4.io ↗

On This Page

Parameter protocol flow

© 2024 AeroCoder. All rights reserved

TwitterYouTubeInstagram