From c1ce04a0cedacbc2a9a1b3cdd88211ac95dd659f Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 20 Dec 2024 13:38:15 +1100 Subject: [PATCH] AP_HAL_SITL: add LD06 simulator --- libraries/AP_HAL_SITL/SITL_State_common.cpp | 14 ++++++++++++++ libraries/AP_HAL_SITL/SITL_State_common.h | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/libraries/AP_HAL_SITL/SITL_State_common.cpp b/libraries/AP_HAL_SITL/SITL_State_common.cpp index ad63e21fcf..b4e6ae1742 100644 --- a/libraries/AP_HAL_SITL/SITL_State_common.cpp +++ b/libraries/AP_HAL_SITL/SITL_State_common.cpp @@ -136,6 +136,14 @@ SITL::SerialDevice *SITL_State_Common::create_serial_sim(const char *name, const crsf = NEW_NOTHROW SITL::CRSF(); return crsf; #endif +#if AP_SIM_PS_LD06_ENABLED + } else if (streq(name, "ld06")) { + if (ld06 != nullptr) { + AP_HAL::panic("Only one ld06 at a time"); + } + ld06 = NEW_NOTHROW SITL::PS_LD06(); + return ld06; +#endif // AP_SIM_PS_LD06_ENABLED #if HAL_SIM_PS_RPLIDARA2_ENABLED } else if (streq(name, "rplidara2")) { if (rplidara2 != nullptr) { @@ -314,6 +322,12 @@ void SITL_State_Common::sim_update(void) } #endif +#if AP_SIM_PS_LD06_ENABLED + if (ld06 != nullptr) { + ld06->update(sitl_model->get_location()); + } +#endif // AP_SIM_PS_LD06_ENABLED + #if HAL_SIM_PS_RPLIDARA2_ENABLED if (rplidara2 != nullptr) { rplidara2->update(sitl_model->get_location()); diff --git a/libraries/AP_HAL_SITL/SITL_State_common.h b/libraries/AP_HAL_SITL/SITL_State_common.h index eb9099ad17..9079ae0737 100644 --- a/libraries/AP_HAL_SITL/SITL_State_common.h +++ b/libraries/AP_HAL_SITL/SITL_State_common.h @@ -26,6 +26,7 @@ #include // #include // #include +#include #include #include #include @@ -115,6 +116,11 @@ public: // SITL::Frsky_SPort *frsky_sport; // SITL::Frsky_SPortPassthrough *frsky_sportpassthrough; +#if AP_SIM_PS_LD06_ENABLED + // simulated LD06: + SITL::PS_LD06 *ld06; +#endif // AP_SIM_PS_LD06_ENABLED + #if HAL_SIM_PS_RPLIDARA2_ENABLED // simulated RPLidarA2: SITL::PS_RPLidarA2 *rplidara2;