AP_Baro: create and use HAL_SIM_BARO_ENABLED

This commit is contained in:
Peter Barker 2021-10-30 12:15:47 +11:00 committed by Peter Barker
parent e770e2fba9
commit 721ede206d
4 changed files with 18 additions and 12 deletions

View File

@ -258,7 +258,7 @@ void AP_Baro::calibrate(bool save)
return;
}
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#if AP_SIM_BARO_ENABLED
if (AP::sitl()->baro_count == 0) {
return;
}
@ -628,7 +628,7 @@ void AP_Baro::init(void)
default:
break;
}
#elif CONFIG_HAL_BOARD == HAL_BOARD_SITL
#elif AP_SIM_BARO_ENABLED
SITL::SIM *sitl = AP::sitl();
if (sitl == nullptr) {
AP_HAL::panic("No SITL pointer");
@ -681,7 +681,7 @@ void AP_Baro::init(void)
#endif
#if !defined(HAL_BARO_ALLOW_INIT_NO_BARO) // most boards requires external baro
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#if AP_SIM_BARO_ENABLED
if (sitl->baro_count == 0) {
return;
}

View File

@ -7,6 +7,10 @@
#include <AP_MSP/msp.h>
#include <AP_ExternalAHRS/AP_ExternalAHRS.h>
#ifndef AP_SIM_BARO_ENABLED
#define AP_SIM_BARO_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL)
#endif
#ifndef HAL_MSP_BARO_ENABLED
#define HAL_MSP_BARO_ENABLED HAL_MSP_SENSORS_ENABLED
#endif

View File

@ -1,10 +1,10 @@
#include "AP_Baro_SITL.h"
#if AP_SIM_BARO_ENABLED
#include <AP_HAL/AP_HAL.h>
#include <AP_Vehicle/AP_Vehicle_Type.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include "AP_Baro_SITL.h"
extern const AP_HAL::HAL& hal;
/*
@ -182,4 +182,4 @@ float AP_Baro_SITL::wind_pressure_correction(void)
return error * 0.5 * SSL_AIR_DENSITY * AP::baro().get_air_density_ratio();
}
#endif // CONFIG_HAL_BOARD
#endif // AP_SIM_BARO_ENABLED

View File

@ -2,10 +2,12 @@
#include "AP_Baro_Backend.h"
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include <SITL/SITL.h>
#if AP_SIM_BARO_ENABLED
#include <AP_Math/vectorN.h>
#include <SITL/SITL.h>
class AP_Baro_SITL : public AP_Baro_Backend {
public:
AP_Baro_SITL(AP_Baro &);
@ -47,4 +49,4 @@ private:
float _last_altitude;
};
#endif // CONFIG_HAL_BOARD
#endif // AP_SIM_BARO_ENABLED