diff --git a/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator b/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator index 100e0a67ca..d3437426f8 100644 --- a/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator +++ b/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator @@ -8,8 +8,48 @@ param set-default IMU_INTEG_RATE 250 param set-default COM_MODE_ARM_CHK 1 if [ "$PX4_SIMULATOR" = "sihsim" ] || [ "$(param show -q SYS_AUTOSTART)" -eq "0" ]; then - # Run SIH - . px4-rc.sihsim + + echo "INFO [init] SIH simulator" + + if [ -n "${PX4_HOME_LAT}" ]; then + param set SIH_LOC_LAT0 ${PX4_HOME_LAT} + fi + + if [ -n "${PX4_HOME_LON}" ]; then + param set SIH_LOC_LON0 ${PX4_HOME_LON} + fi + if [ -n "${PX4_HOME_ALT}" ]; then + param set SIH_LOC_H0 ${PX4_HOME_ALT} + fi + + if simulator_sih start; then + + if param compare -s SENS_EN_BAROSIM 1 + then + sensor_baro_sim start + fi + if param compare -s SENS_EN_GPSSIM 1 + then + sensor_gps_sim start + fi + if param compare -s SENS_EN_MAGSIM 1 + then + sensor_mag_sim start + fi + if param compare -s SENS_EN_ARSPDSIM 1 + then + sensor_airspeed_sim start + fi + if param compare -s SENS_EN_AGPSIM 1 + then + sensor_agp_sim start + fi + + + else + echo "ERROR [init] simulator_sih failed to start" + exit 1 + fi elif [ "$PX4_SIMULATOR" = "gz" ] || [ "$(param show -q SIM_GZ_EN)" = "1" ]; then # Run Gazebo (gz) diff --git a/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp b/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp index e8e4ae3a66..13dbe45479 100644 --- a/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp +++ b/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp @@ -106,9 +106,12 @@ void SensorAirspeedSim::Run() updateParams(); } - if (_sim_failure.get() == 0) { - if (_vehicle_local_position_sub.updated() && _vehicle_global_position_sub.updated() - && _vehicle_attitude_sub.updated()) { + if (_vehicle_local_position_sub.updated() && _vehicle_global_position_sub.updated() + && _vehicle_attitude_sub.updated()) { + + check_failure_injection(); + + if (_sim_failure.get() == 0 && !_arsp_blocked) { vehicle_local_position_s lpos{}; _vehicle_local_position_sub.copy(&lpos);