Larus glider flight sensor system 3.9.2024
Software-In-The-Loop test and validation system
Loading...
Searching...
No Matches
atmosphere.h
Go to the documentation of this file.
1/***********************************************************************/
26#ifndef APPLICATION_ATMOSPHERE_H_
27#define APPLICATION_ATMOSPHERE_H_
28
29#include "embedded_math.h"
31#include <pt2.h>
32
33#define RECIP_STD_DENSITY_TIMES_2 1.632f
34
36#define GAS_CONST_DRY_AIR 287.058f
38#define GAS_CONST_WATER_VAPOR 461.523f
40#define ONE_MINUS_RATIO_GAS_CONSTANTS 0.378f
42#define CELSIUS_TO_KELVIN_OFFSET 273.15f
43
46{
47public:
49 :
50 have_ambient_air_data(false),
51 pressure ( p_abs),
52 temperature(20.0f),
53 humidity( 0.0f),
54 density_correction(1.0f),
55 density_correction_averager(0.001f),
56 QFF(101325)
57 {
58 density_correction_averager.settle(1.0f);
59 }
61 {
62 density_correction_averager.respond(density_correction);
63 }
64 void initialize( float altitude)
65 {
66 density_QFF_calculator.initialize(altitude);
67 }
68 void set_pressure( float p_abs)
69 {
70 pressure = p_abs;
71 }
72 float get_pressure( void) const
73 {
74 return pressure;
75 }
76 float get_density( void) const
77 {
78 return (1.0496346613e-5f * pressure + 0.1671546011f) * density_correction_averager.get_output();
79 }
80 float get_negative_altitude( void) const
81 {
82 float tmp = 8.104381531e-4f * pressure;
83 return - tmp * tmp + 0.20867299170f * pressure - 14421.43945f;
84 }
86 {
87 return SQRT( 2 * dynamic_pressure / get_density());
88 }
93 void set_ambient_air_data( float temperature, float humidity)
94 {
95 this->temperature = temperature;
96 this->humidity = humidity;
97 have_ambient_air_data = true;
98 }
100 {
101 have_ambient_air_data = false;
102 }
103
104 float get_QFF () const
105 {
106 return QFF;
107 }
108
109 void feed_QFF_density_metering( float pressure, float MSL_altitude)
110 {
111 air_data_result result = density_QFF_calculator.feed_metering( pressure, MSL_altitude);
112 if( result.valid)
113 {
114 QFF = result.QFF;
115 density_correction = result.density_correction;
116 }
117 }
118
119private:
120 float calculateGasConstantHumAir(
121 float humidity, float pressure, float temperature);
122 float calculateAirDensity(
123 float humidity, float pressure, float temperature);
124 float calculateSaturationVaporPressure(float temp);
125 bool have_ambient_air_data;
126 float pressure;
127 float temperature;
128 float humidity;
129 float density_correction;
130 pt2<float,float> density_correction_averager;
131 float QFF;
132 air_density_observer density_QFF_calculator;
133};
134
135#endif /* APPLICATION_ATMOSPHERE_H_ */
air-density measurement (interface)
#define RECIP_STD_DENSITY_TIMES_2
Definition atmosphere.h:33
Maintains offset and slope of the air density measurement.
Measures air density and reference pressure.
air_data_result feed_metering(float pressure, float MSL_altitude)
void initialize(float altitude)
Maintenance of atmosphere data like pressure, density etc.
Definition atmosphere.h:46
float get_density(void) const
Definition atmosphere.h:76
void disregard_ambient_air_data(void)
Definition atmosphere.h:99
float get_pressure(void) const
Definition atmosphere.h:72
atmosphere_t(float p_abs)
Definition atmosphere.h:48
float get_negative_altitude(void) const
Definition atmosphere.h:80
float get_IAS_from_dynamic_pressure(float dynamic_pressure) const
Definition atmosphere.h:89
float get_TAS_from_dynamic_pressure(float dynamic_pressure) const
Definition atmosphere.h:85
void initialize(float altitude)
Definition atmosphere.h:64
float get_QFF() const
Definition atmosphere.h:104
void set_pressure(float p_abs)
Definition atmosphere.h:68
void feed_QFF_density_metering(float pressure, float MSL_altitude)
Definition atmosphere.h:109
void set_ambient_air_data(float temperature, float humidity)
Definition atmosphere.h:93
void update_density_correction(void)
Definition atmosphere.h:60
void settle(const datatype &present_input)
Definition pt2.h:73
datatype get_output(void) const
Definition pt2.h:88
datatype respond(const datatype &input)
Definition pt2.h:79
mathematical vector of arbitrary type and size
Definition vector.h:40
defines platform-dependent algorithms and constants
#define SQRT(x)
tunable second order IIR lowpass filter (butterworth)