From c3246d61f443b81762415b560fdd08353c544b06 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jun 2020 21:10:28 +1000 Subject: [PATCH] AP_HAL_SITL: add simulated LightWare serial lidar talking new binary protocol --- libraries/AP_HAL_SITL/SITL_State.cpp | 14 ++++++++++++++ libraries/AP_HAL_SITL/SITL_State.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_SITL/SITL_State.cpp b/libraries/AP_HAL_SITL/SITL_State.cpp index bf15c67192..39f0cfd688 100644 --- a/libraries/AP_HAL_SITL/SITL_State.cpp +++ b/libraries/AP_HAL_SITL/SITL_State.cpp @@ -261,6 +261,12 @@ int SITL_State::sim_fd(const char *name, const char *arg) } lightwareserial = new SITL::RF_LightWareSerial(); return lightwareserial->fd(); + } else if (streq(name, "lightwareserial-binary")) { + if (lightwareserial_binary != nullptr) { + AP_HAL::panic("Only one lightwareserial-binary at a time"); + } + lightwareserial_binary = new SITL::RF_LightWareSerialBinary(); + return lightwareserial_binary->fd(); } else if (streq(name, "lanbao")) { if (lanbao != nullptr) { AP_HAL::panic("Only one lanbao at a time"); @@ -373,6 +379,11 @@ int SITL_State::sim_fd_write(const char *name) AP_HAL::panic("No lightwareserial created"); } return lightwareserial->write_fd(); + } else if (streq(name, "lightwareserial-binary")) { + if (lightwareserial_binary == nullptr) { + AP_HAL::panic("No lightwareserial_binary created"); + } + return lightwareserial_binary->write_fd(); } else if (streq(name, "lanbao")) { if (lanbao == nullptr) { AP_HAL::panic("No lanbao created"); @@ -578,6 +589,9 @@ void SITL_State::_fdm_input_local(void) if (lightwareserial != nullptr) { lightwareserial->update(sitl_model->get_range()); } + if (lightwareserial_binary != nullptr) { + lightwareserial_binary->update(sitl_model->get_range()); + } if (lanbao != nullptr) { lanbao->update(sitl_model->get_range()); } diff --git a/libraries/AP_HAL_SITL/SITL_State.h b/libraries/AP_HAL_SITL/SITL_State.h index 3ef33b2861..f84b5be206 100644 --- a/libraries/AP_HAL_SITL/SITL_State.h +++ b/libraries/AP_HAL_SITL/SITL_State.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -249,8 +250,10 @@ private: // simulated Benewake tfmini rangefinder: SITL::RF_Benewake_TFmini *benewake_tfmini; - // simulated LightWareSerial rangefinder: + // simulated LightWareSerial rangefinder - legacy protocol:: SITL::RF_LightWareSerial *lightwareserial; + // simulated LightWareSerial rangefinder - binary protocol: + SITL::RF_LightWareSerialBinary *lightwareserial_binary; // simulated Lanbao rangefinder: SITL::RF_Lanbao *lanbao; // simulated BLping rangefinder: