45 #include <px4_platform_common/defines.h> 59 float tube_len,
float tube_dia_mm,
float differential_pressure,
float pressure_ambient,
float temperature_celsius)
63 const float rho_air =
get_air_density(pressure_ambient, temperature_celsius);
65 const float dp = fabsf(differential_pressure);
84 const float dp_corr = dp * 96600.0f / pressure_ambient;
86 float flow_SDP33 = (300.805f - 300.878f / (0.00344205f * powf(dp_corr, 0.68698
f) + 1.0f)) * 1.29f / rho_air;
89 if (flow_SDP33 < 0.0
f) {
93 float dp_pitot = 0.0f;
97 dp_pitot = (0.0032f * flow_SDP33 * flow_SDP33 + 0.0123f * flow_SDP33 + 1.0f) * 1.29
f / rho_air;
106 const float dp_tube = (flow_SDP33 * 0.674f) / 450.0
f * tube_len * rho_air / 1.29
f;
109 dv = 0.125f * flow_SDP33;
112 dp_tot = dp_corr + dp_tube + dp_pitot;
122 if ((tube_dia_mm > 0.0
f) && (dp > 0.0f)) {
123 const float d_tubePow4 = powf(tube_dia_mm * 1e-3
f, 4);
124 const float denominator =
M_PI_F * d_tubePow4 * rho_air * dp;
129 if (fabsf(denominator) > 1e-32
f) {
130 const float viscosity = (18.205f + 0.0484f * (temperature_celsius - 20.0f)) * 1e-6
f;
134 eps = -64.0f * tube_len * viscosity * 4.79f * 1e-7f * (sqrtf(1.0f + 8.0f * dp / 59.3319f) - 1.0f) / denominator;
138 if (fabsf(eps) >= 1.0f) {
143 dp_tot = dp / (1.0f + eps);
179 const float airspeed_corrected = airspeed_uncorrected + dv;
182 return (differential_pressure > 0.0
f) ? airspeed_corrected : -airspeed_corrected;
199 if (differential_pressure > 0.0
f) {
218 float calc_TAS_from_EAS(
float speed_equivalent,
float pressure_ambient,
float temperature_celsius)
221 temperature_celsius));
234 return speed_indicated * scale;
249 float calc_TAS(
float total_pressure,
float static_pressure,
float temperature_celsius)
253 if (density < 0.0001
f || !PX4_ISFINITE(density)) {
257 float pressure_difference = total_pressure - static_pressure;
259 if (pressure_difference > 0) {
260 return sqrtf((2.0
f * (pressure_difference)) / density);
263 return -sqrtf((2.0
f * fabsf(pressure_difference)) / density);
static constexpr float CONSTANTS_AIR_GAS_CONST
static constexpr float CONSTANTS_ABSOLUTE_NULL_CELSIUS
float calc_IAS_corrected(enum AIRSPEED_COMPENSATION_MODEL pmodel, enum AIRSPEED_SENSOR_MODEL smodel, float tube_len, float tube_dia_mm, float differential_pressure, float pressure_ambient, float temperature_celsius)
Calculate indicated airspeed.
Definition of geo / math functions to perform geodesic calculations.
float calc_TAS_from_EAS(float speed_equivalent, float pressure_ambient, float temperature_celsius)
Calculate true airspeed (TAS) from equivalent airspeed (EAS).
float calc_EAS_from_TAS(float speed_true, float pressure_ambient, float temperature_celsius)
Calculate equivalent airspeed (EAS) from true airspeed (TAS).
float calc_IAS(float differential_pressure)
Calculate indicated airspeed (IAS).
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
float calc_TAS(float total_pressure, float static_pressure, float temperature_celsius)
Directly calculate true airspeed (TAS)
AIRSPEED_COMPENSATION_MODEL
static constexpr float CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C
float calc_EAS_from_IAS(float speed_indicated, float scale)
Calculate equivalent airspeed (EAS) from indicated airspeed (IAS).
float get_air_density(float static_pressure, float temperature_celsius)
Calculates air density.