Skip to content

Commit

Permalink
AP_HAL_SITL: simulate generic chinese sonar sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
khancyr committed Oct 30, 2024
1 parent d05b485 commit 385f281
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libraries/AP_HAL_SITL/SITL_State_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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());
}
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_HAL_SITL/SITL_State_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <SITL/SIM_RF_LightWareSerial.h>
#include <SITL/SIM_RF_LightWareSerialBinary.h>
#include <SITL/SIM_RF_Lanbao.h>
#include <SITL/SIM_RF_GenericCSonar_Serial.h>
#include <SITL/SIM_RF_BLping.h>
#include <SITL/SIM_RF_LeddarOne.h>
#include <SITL/SIM_RF_RDS02UF.h>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 385f281

Please sign in to comment.