AP_Baro: fixed SITL with SIM_BARO_COUNT==0

this allows for testing of SITL with no baro
This commit is contained in:
Andrew Tridgell 2021-01-18 16:15:59 +11:00
parent 2f8dec7c9b
commit 8e4d67a7c1
1 changed files with 11 additions and 1 deletions

View File

@ -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");
}