From b4ebae5e1bd0f5fbc3a22c9a1b7434a5ae7f30c3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 29 Apr 2024 09:30:55 +1000 Subject: [PATCH] HAL_SITL: use baro atmospheric tables --- libraries/AP_HAL_SITL/sitl_airspeed.cpp | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/libraries/AP_HAL_SITL/sitl_airspeed.cpp b/libraries/AP_HAL_SITL/sitl_airspeed.cpp index 2c149c1916..cf3e666aa1 100644 --- a/libraries/AP_HAL_SITL/sitl_airspeed.cpp +++ b/libraries/AP_HAL_SITL/sitl_airspeed.cpp @@ -24,27 +24,6 @@ using namespace HALSITL; #define VOLTS_TO_PASCAL 819 #define PASCAL_TO_VOLTS(_p) (_p/VOLTS_TO_PASCAL) -// return current scale factor that converts from equivalent to true airspeed -// valid for altitudes up to 10km AMSL -// assumes standard atmosphere lapse rate -static float get_EAS2TAS(float altitude) -{ - float pressure = AP::baro().get_pressure(); - if (is_zero(pressure)) { - return 1.0f; - } - - float sigma, delta, theta; - AP_Baro::SimpleAtmosphere(altitude * 0.001, sigma, delta, theta); - - float tempK = C_TO_KELVIN(25) - ISA_LAPSE_RATE * altitude; - const float eas2tas_squared = SSL_AIR_DENSITY / (pressure / (ISA_GAS_CONSTANT * tempK)); - if (!is_positive(eas2tas_squared)) { - return 1.0; - } - return sqrtf(eas2tas_squared); -} - /* convert airspeed in m/s to an airspeed sensor value */ @@ -52,7 +31,7 @@ void SITL_State::_update_airspeed(float true_airspeed) { for (uint8_t i=0; iairspeed[i]; - float airspeed = true_airspeed / get_EAS2TAS(_sitl->state.altitude); + float airspeed = true_airspeed / AP_Baro::get_EAS2TAS_for_alt_amsl(_sitl->state.altitude); const float diff_pressure = sq(airspeed) / arspd.ratio; float airspeed_raw;