From ffeeedc310a1026057b8364322fd556053fa8423 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Mon, 13 May 2019 14:01:32 +0200 Subject: [PATCH] init.d-posix: raise timeouts for fast SITL When simulating with lockstep we can raise the speed by setting the env variable `PX4_SIM_SPEED_FACTOR`. Some inputs like RC, MAVLink heartbeats from a ground station, or offboard controls via MAVLink are still at the normal speed which leads to timeouts getting detected in PX4. To work around this issue we can automatically multiply the timeout parameters by the speed factor. --- ROMFS/px4fmu_common/init.d-posix/rcS | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d-posix/rcS b/ROMFS/px4fmu_common/init.d-posix/rcS index 7f4edb57a6..059ff50fb6 100644 --- a/ROMFS/px4fmu_common/init.d-posix/rcS +++ b/ROMFS/px4fmu_common/init.d-posix/rcS @@ -160,6 +160,21 @@ then param set WEST_EN 0 fi +# Adapt timeout parameters if simulation runs faster or slower than realtime. +if [ ! -z $PX4_SIM_SPEED_FACTOR ]; then + COM_DL_LOSS_T_LONGER=$(($PX4_SIM_SPEED_FACTOR * 10)) + echo "COM_DL_LOSS_T set to $COM_DL_LOSS_T_LONGER" + param set COM_DL_LOSS_T $COM_DL_LOSS_T_LONGER + + COM_RC_LOSS_T_LONGER=$(($PX4_SIM_SPEED_FACTOR * 1)) + echo "COM_RC_LOSS_T set to $COM_RC_LOSS_T_LONGER" + param set COM_RC_LOSS_T $COM_RC_LOSS_T_LONGER + + COM_OF_LOSS_T_LONGER=$(($PX4_SIM_SPEED_FACTOR * 10)) + echo "COM_OF_LOSS_T set to $COM_OF_LOSS_T_LONGER" + param set COM_OF_LOSS_T $COM_OF_LOSS_T_LONGER +fi + # Autostart ID autostart_file='' for f in etc/init.d-posix/"$(param show -q SYS_AUTOSTART)"_*