diff --git a/libraries/AP_HAL_SITL/RCOutput.cpp b/libraries/AP_HAL_SITL/RCOutput.cpp index 291df0e9df..7c49f738e8 100644 --- a/libraries/AP_HAL_SITL/RCOutput.cpp +++ b/libraries/AP_HAL_SITL/RCOutput.cpp @@ -85,7 +85,12 @@ void RCOutput::push(void) memcpy(_sitlState->pwm_output, _pending, SITL_NUM_CHANNELS * sizeof(uint16_t)); _corked = false; } - esc_telem.update(); + if (esc_telem == nullptr) { + esc_telem = new AP_ESC_Telem_SITL; + } + if (esc_telem != nullptr) { + esc_telem->update(); + } } /* diff --git a/libraries/AP_HAL_SITL/RCOutput.h b/libraries/AP_HAL_SITL/RCOutput.h index 6f226b7ab1..3472b7c49e 100644 --- a/libraries/AP_HAL_SITL/RCOutput.h +++ b/libraries/AP_HAL_SITL/RCOutput.h @@ -37,7 +37,7 @@ public: private: SITL_State *_sitlState; - AP_ESC_Telem_SITL esc_telem; + AP_ESC_Telem_SITL *esc_telem; uint16_t _freq_hz; uint16_t _enable_mask;