Browse Source

AP_Baro: create and use HAL_SIM_BARO_ENABLED

gps-1.3.1
Peter Barker 3 years ago committed by Peter Barker
parent
commit
721ede206d
  1. 6
      libraries/AP_Baro/AP_Baro.cpp
  2. 4
      libraries/AP_Baro/AP_Baro.h
  3. 10
      libraries/AP_Baro/AP_Baro_SITL.cpp
  4. 8
      libraries/AP_Baro/AP_Baro_SITL.h

6
libraries/AP_Baro/AP_Baro.cpp

@ -258,7 +258,7 @@ void AP_Baro::calibrate(bool save) @@ -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) @@ -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) @@ -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;
}

4
libraries/AP_Baro/AP_Baro.h

@ -7,6 +7,10 @@ @@ -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

10
libraries/AP_Baro/AP_Baro_SITL.cpp

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
#include <AP_HAL/AP_HAL.h>
#include <AP_Vehicle/AP_Vehicle_Type.h>
#include "AP_Baro_SITL.h"
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#if AP_SIM_BARO_ENABLED
#include "AP_Baro_SITL.h"
#include <AP_HAL/AP_HAL.h>
#include <AP_Vehicle/AP_Vehicle_Type.h>
extern const AP_HAL::HAL& hal;
@ -182,4 +182,4 @@ float AP_Baro_SITL::wind_pressure_correction(void) @@ -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

8
libraries/AP_Baro/AP_Baro_SITL.h

@ -2,10 +2,12 @@ @@ -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: @@ -47,4 +49,4 @@ private:
float _last_altitude;
};
#endif // CONFIG_HAL_BOARD
#endif // AP_SIM_BARO_ENABLED

Loading…
Cancel
Save