sitl: add generic way to override params via ENV variables

This commit is contained in:
Beat Küng 2023-09-04 13:44:31 +02:00
parent 7c7a3c117a
commit 36241bbdb2
No known key found for this signature in database
GPG Key ID: 866DB5F0E24821BB
2 changed files with 10 additions and 6 deletions

View File

@ -126,6 +126,15 @@ then
set AUTOCNF yes set AUTOCNF yes
fi fi
# Allow overriding parameters via env variables: export PX4_PARAM_{name}={value}
env | while IFS='=' read -r line; do
value=${line#*=}
name=${line%%=*}
case $name in
"PX4_PARAM_"*) param set "${name#PX4_PARAM_}" "$value" ;;
esac
done
# multi-instance setup # multi-instance setup
# shellcheck disable=SC2154 # shellcheck disable=SC2154
param set MAV_SYS_ID $((px4_instance+1)) param set MAV_SYS_ID $((px4_instance+1))
@ -186,11 +195,6 @@ param set-default SYS_FAILURE_EN 1
# does not go below 50% by default, but failure injection can trigger failsafes. # does not go below 50% by default, but failure injection can trigger failsafes.
param set-default COM_LOW_BAT_ACT 2 param set-default COM_LOW_BAT_ACT 2
# Allow to override SYS_MC_EST_GROUP via env
if [ -n "$SYS_MC_EST_GROUP" ]; then
param set SYS_MC_EST_GROUP $SYS_MC_EST_GROUP
fi
# Adapt timeout parameters if simulation runs faster or slower than realtime. # Adapt timeout parameters if simulation runs faster or slower than realtime.
if [ -n "$PX4_SIM_SPEED_FACTOR" ]; then if [ -n "$PX4_SIM_SPEED_FACTOR" ]; then
COM_DL_LOSS_T_LONGER=$(echo "$PX4_SIM_SPEED_FACTOR * 10" | bc) COM_DL_LOSS_T_LONGER=$(echo "$PX4_SIM_SPEED_FACTOR * 10" | bc)

View File

@ -16,7 +16,7 @@
"test_filter": "[offboard_attitude]", "test_filter": "[offboard_attitude]",
"timeout_min": 10, "timeout_min": 10,
"env": { "env": {
"SYS_MC_EST_GROUP": 3 "PX4_PARAM_SYS_MC_EST_GROUP": 3
} }
}, },
{ {