From 34a55166f8fc57020a01f490df723564c95139cd Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 22 May 2023 13:04:36 +1000 Subject: [PATCH] SITL: correct compilation for SimOnHardware --- libraries/SITL/SIM_PS_RPLidar.h | 8 +++----- libraries/SITL/SIM_PS_RPLidarA1.h | 9 ++++----- libraries/SITL/SIM_PS_RPLidarA2.h | 6 ++++++ libraries/SITL/SIM_SerialProximitySensor.h | 6 +----- libraries/SITL/SIM_config.h | 15 +++++++++++++++ 5 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 libraries/SITL/SIM_config.h diff --git a/libraries/SITL/SIM_PS_RPLidar.h b/libraries/SITL/SIM_PS_RPLidar.h index 4758567605..bf2444f5cd 100644 --- a/libraries/SITL/SIM_PS_RPLidar.h +++ b/libraries/SITL/SIM_PS_RPLidar.h @@ -45,14 +45,12 @@ rc 2 1450 #pragma once -#include "SIM_SerialProximitySensor.h" - -#ifndef HAL_SIM_PS_RPLIDARA2_ENABLED -#define HAL_SIM_PS_RPLIDARA2_ENABLED HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED -#endif +#include "SIM_config.h" #if HAL_SIM_PS_RPLIDARA2_ENABLED || HAL_SIM_PS_RPLIDARA1_ENABLED +#include "SIM_SerialProximitySensor.h" + #include namespace SITL { diff --git a/libraries/SITL/SIM_PS_RPLidarA1.h b/libraries/SITL/SIM_PS_RPLidarA1.h index 9a88ca4451..d374354e6b 100644 --- a/libraries/SITL/SIM_PS_RPLidarA1.h +++ b/libraries/SITL/SIM_PS_RPLidarA1.h @@ -43,13 +43,12 @@ rc 2 1450 #pragma once -#include "SIM_PS_RPLidar.h" - -#ifndef HAL_SIM_PS_RPLIDARA1_ENABLED -#define HAL_SIM_PS_RPLIDARA1_ENABLED HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED -#endif +#include "SIM_config.h" #if HAL_SIM_PS_RPLIDARA1_ENABLED + +#include "SIM_PS_RPLidar.h" + namespace SITL { class PS_RPLidarA1 : public PS_RPLidar { diff --git a/libraries/SITL/SIM_PS_RPLidarA2.h b/libraries/SITL/SIM_PS_RPLidarA2.h index dfef555664..b5beb50f3c 100644 --- a/libraries/SITL/SIM_PS_RPLidarA2.h +++ b/libraries/SITL/SIM_PS_RPLidarA2.h @@ -43,6 +43,10 @@ rc 2 1450 #pragma once +#include "SIM_config.h" + +#if HAL_SIM_PS_RPLIDARA2_ENABLED + #include "SIM_PS_RPLidar.h" namespace SITL { @@ -54,3 +58,5 @@ public: }; } + +#endif // HAL_SIM_PS_RPLIDARA2_ENABLED diff --git a/libraries/SITL/SIM_SerialProximitySensor.h b/libraries/SITL/SIM_SerialProximitySensor.h index db94bef9a9..b35d629132 100644 --- a/libraries/SITL/SIM_SerialProximitySensor.h +++ b/libraries/SITL/SIM_SerialProximitySensor.h @@ -18,11 +18,7 @@ #pragma once -#include - -#ifndef HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED -#define HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) -#endif +#include "SIM_config.h" #if HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED diff --git a/libraries/SITL/SIM_config.h b/libraries/SITL/SIM_config.h new file mode 100644 index 0000000000..e9c55f17aa --- /dev/null +++ b/libraries/SITL/SIM_config.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifndef HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED +#define HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#ifndef HAL_SIM_PS_RPLIDARA1_ENABLED +#define HAL_SIM_PS_RPLIDARA1_ENABLED HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED +#endif + +#ifndef HAL_SIM_PS_RPLIDARA2_ENABLED +#define HAL_SIM_PS_RPLIDARA2_ENABLED HAL_SIM_SERIALPROXIMITYSENSOR_ENABLED +#endif