From 8e4d67a7c1eb8a5334f9f261c6166047409ed96e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 18 Jan 2021 16:15:59 +1100 Subject: [PATCH] AP_Baro: fixed SITL with SIM_BARO_COUNT==0 this allows for testing of SITL with no baro --- libraries/AP_Baro/AP_Baro.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Baro/AP_Baro.cpp b/libraries/AP_Baro/AP_Baro.cpp index cf266e7ae8..29cbfad0b2 100644 --- a/libraries/AP_Baro/AP_Baro.cpp +++ b/libraries/AP_Baro/AP_Baro.cpp @@ -254,6 +254,12 @@ void AP_Baro::calibrate(bool save) return; } +#if CONFIG_HAL_BOARD == HAL_BOARD_SITL + if (AP::sitl()->baro_count == 0) { + return; + } +#endif + #ifdef HAL_BARO_ALLOW_INIT_NO_BARO if (_num_drivers == 0 || _num_sensors == 0 || drivers[0] == nullptr) { BARO_SEND_TEXT(MAV_SEVERITY_INFO, "Baro: no sensors found, skipping calibration"); @@ -670,7 +676,11 @@ 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 (sitl->baro_count == 0) { + return; + } +#endif if (_num_drivers == 0 || _num_sensors == 0 || drivers[0] == nullptr) { AP_BoardConfig::config_error("Baro: unable to initialise driver"); }