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