From f92fde806f2409fea3ebee228ff973a7318ad4e0 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 23 Jan 2025 10:20:53 +1100 Subject: [PATCH] AP_HAL: SIMState: do a single nullptr check in SIMState servo sim mirrors if c1016ae52ee4de3181b2c0a07369e51f05eb46f7 --- libraries/AP_HAL/SIMState.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/AP_HAL/SIMState.cpp b/libraries/AP_HAL/SIMState.cpp index 6c3ea8235a..c15602071c 100644 --- a/libraries/AP_HAL/SIMState.cpp +++ b/libraries/AP_HAL/SIMState.cpp @@ -274,6 +274,10 @@ void SIMState::fdm_input_local(void) */ void SIMState::_simulator_servos(struct sitl_input &input) { + if (_sitl == nullptr) { + return; + } + // output at chosen framerate uint32_t now = AP_HAL::micros(); @@ -288,7 +292,7 @@ void SIMState::_simulator_servos(struct sitl_input &input) // give 5 seconds to calibrate airspeed sensor at 0 wind speed if (wind_start_delay_micros == 0) { wind_start_delay_micros = now; - } else if (_sitl && (now - wind_start_delay_micros) > 5000000 ) { + } else if ((now - wind_start_delay_micros) > 5000000) { // The EKF does not like step inputs so this LPF keeps it happy. wind_speed = _sitl->wind_speed_active = (0.95f*_sitl->wind_speed_active) + (0.05f*_sitl->wind_speed); wind_direction = _sitl->wind_direction_active = (0.95f*_sitl->wind_direction_active) + (0.05f*_sitl->wind_direction); @@ -317,7 +321,7 @@ void SIMState::_simulator_servos(struct sitl_input &input) input.wind.speed = wind_speed; input.wind.direction = wind_direction; - input.wind.turbulence = _sitl?_sitl->wind_turbulance:0; + input.wind.turbulence = _sitl->wind_turbulance; input.wind.dir_z = wind_dir_z; for (uint8_t i=0; ifetteconewireesc_sim.enabled()) { _sitl->fetteconewireesc_sim.update_sitl_input_pwm(input); for (uint8_t i=0; istate.battery_voltage <= 0) { } else { // FDM provides voltage and current