diff --git a/libraries/AP_HAL_SITL/SITL_State_common.cpp b/libraries/AP_HAL_SITL/SITL_State_common.cpp index 54a530bc447b1..0c8c27abbab80 100644 --- a/libraries/AP_HAL_SITL/SITL_State_common.cpp +++ b/libraries/AP_HAL_SITL/SITL_State_common.cpp @@ -100,6 +100,12 @@ SITL::SerialDevice *SITL_State_Common::create_serial_sim(const char *name, const } lanbao = NEW_NOTHROW SITL::RF_Lanbao(); return lanbao; + } else if (streq(name, "genericcsonar_serial")) { + if (generic_c_sonar_serial != nullptr) { + AP_HAL::panic("Only one genericcsonar_serial at a time"); + } + generic_c_sonar_serial = NEW_NOTHROW SITL::RF_GenericCSonar_Serial(); + return generic_c_sonar_serial; } else if (streq(name, "blping")) { if (blping != nullptr) { AP_HAL::panic("Only one blping at a time"); @@ -382,6 +388,9 @@ void SITL_State_Common::sim_update(void) if (lanbao != nullptr) { lanbao->update(sitl_model->rangefinder_range()); } + if (generic_c_sonar_serial != nullptr) { + generic_c_sonar_serial->update(sitl_model->rangefinder_range()); + } if (blping != nullptr) { blping->update(sitl_model->rangefinder_range()); } diff --git a/libraries/AP_HAL_SITL/SITL_State_common.h b/libraries/AP_HAL_SITL/SITL_State_common.h index 95ef129c1cce7..df2e05685143e 100644 --- a/libraries/AP_HAL_SITL/SITL_State_common.h +++ b/libraries/AP_HAL_SITL/SITL_State_common.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -166,6 +167,8 @@ class HALSITL::SITL_State_Common { SITL::RF_MAVLink *rf_mavlink; // simulated GYUS42v2 rangefinder: SITL::RF_GYUS42v2 *gyus42v2; + // simulated GenericCSonar_Serial: + SITL::RF_GenericCSonar_Serial *generic_c_sonar_serial; // simulated Frsky devices SITL::Frsky_D *frsky_d;