mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[modules] air_data: init vars as unknown
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<settings>
|
||||
<dl_settings>
|
||||
<dl_settings name="air_data">
|
||||
<dl_setting min="800" max="1200" step="1" module="air_data/air_data" var="air_data.qnh" shortname="QNH" handler="SetQNH"/>
|
||||
<dl_setting min="800" max="1200" step="1" module="air_data/air_data" var="air_data.qnh" shortname="QNH"/>
|
||||
<dl_setting min="0.8" max="1.3" step="0.01" module="air_data/air_data" var="air_data.tas_factor" shortname="TASfactor" param="AIR_DATA_TAS_FACTOR"/>
|
||||
<dl_setting min="0" max="1" step="1" var="air_data.calc_qnh_once" module="air_data/air_data" shortname="calcQNH"/>
|
||||
<dl_setting min="0" max="1" step="1" var="air_data.calc_airspeed" module="air_data/air_data" shortname="calcAirspeed" param="AIR_DATA_CALC_AIRSPEED"/>
|
||||
|
||||
@@ -91,9 +91,6 @@ PRINT_CONFIG_MSG("USE_AIRSPEED_AIR_DATA automatically set to TRUE")
|
||||
* Internal variable to keep track of validity.
|
||||
*/
|
||||
|
||||
/** TRUE if QNH has been set */
|
||||
static bool_t qnh_set;
|
||||
|
||||
/** counter to check baro health */
|
||||
static uint8_t baro_health_counter;
|
||||
|
||||
@@ -107,10 +104,9 @@ static void pressure_abs_cb(uint8_t __attribute__((unused)) sender_id, const flo
|
||||
float h = stateGetPositionLla_f()->alt;
|
||||
air_data.qnh = pprz_isa_ref_pressure_of_height_full(air_data.pressure, h) / 100.f;
|
||||
air_data.calc_qnh_once = FALSE;
|
||||
qnh_set = TRUE;
|
||||
}
|
||||
|
||||
if (air_data.calc_amsl_baro && qnh_set) {
|
||||
if (air_data.calc_amsl_baro && air_data.qnh > 0) {
|
||||
air_data.amsl_baro = pprz_isa_height_of_pressure_full(air_data.pressure,
|
||||
air_data.qnh * 100.f);
|
||||
air_data.amsl_baro_valid = TRUE;
|
||||
@@ -134,7 +130,7 @@ static void pressure_diff_cb(uint8_t __attribute__((unused)) sender_id, const fl
|
||||
static void temperature_cb(uint8_t __attribute__((unused)) sender_id, const float *temp)
|
||||
{
|
||||
air_data.temperature = *temp;
|
||||
if (air_data.calc_tas_factor && baro_health_counter > 0) {
|
||||
if (air_data.calc_tas_factor && baro_health_counter > 0 && air_data.pressure > 0) {
|
||||
air_data.tas_factor = get_tas_factor(air_data.pressure, air_data.temperature);
|
||||
}
|
||||
}
|
||||
@@ -171,13 +167,14 @@ void air_data_init(void)
|
||||
air_data.amsl_baro_valid = FALSE;
|
||||
|
||||
/* initialize the output variables
|
||||
* pressure and qnh to sea level conditions, rest to zero
|
||||
* pressure, qnh, temperature and airspeed to invalid values,
|
||||
* rest to zero
|
||||
*/
|
||||
air_data.pressure = PPRZ_ISA_SEA_LEVEL_PRESSURE;
|
||||
air_data.qnh = PPRZ_ISA_SEA_LEVEL_PRESSURE / 100.0f;
|
||||
air_data.pressure = -1.0f;
|
||||
air_data.qnh = -1.0f;
|
||||
air_data.airspeed = -1.0f;
|
||||
air_data.temperature = -1000.0f;
|
||||
air_data.differential = 0.0f;
|
||||
air_data.temperature = 0.0f;
|
||||
air_data.airspeed = 0.0f;
|
||||
air_data.amsl_baro = 0.0f;
|
||||
air_data.aoa = 0.0f;
|
||||
air_data.sideslip = 0.0f;
|
||||
@@ -185,7 +182,6 @@ void air_data_init(void)
|
||||
air_data.wind_dir = 0.0f;
|
||||
|
||||
/* internal variables */
|
||||
qnh_set = FALSE;
|
||||
baro_health_counter = 0;
|
||||
|
||||
AbiBindMsgBARO_ABS(AIR_DATA_BARO_ABS_ID, &pressure_abs_ev, pressure_abs_cb);
|
||||
@@ -219,12 +215,6 @@ void air_data_periodic(void)
|
||||
}
|
||||
}
|
||||
|
||||
void air_data_SetQNH(float qnh)
|
||||
{
|
||||
air_data.qnh = qnh;
|
||||
qnh_set = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate equivalent airspeed from dynamic pressure.
|
||||
|
||||
@@ -35,13 +35,13 @@
|
||||
|
||||
/** Air Data strucute */
|
||||
struct AirData {
|
||||
float pressure; ///< Static atmospheric pressure (Pa)
|
||||
float pressure; ///< Static atmospheric pressure (Pa), -1 if unknown
|
||||
float differential; ///< Differential pressure (total - static pressure) (Pa)
|
||||
float temperature; ///< temperature in degrees Celcius
|
||||
float temperature; ///< temperature in degrees Celcius, -1000 if unknown
|
||||
|
||||
float airspeed; ///< Conventional Air Speed (m/s)
|
||||
float airspeed; ///< Conventional Air Speed in m/s, -1 if unknown
|
||||
float tas_factor; ///< factor to convert equivalent airspeed (EAS) to true airspeed (TAS)
|
||||
float qnh; ///< Barometric pressure adjusted to sea level in hPa
|
||||
float qnh; ///< Barometric pressure adjusted to sea level in hPa, -1 if unknown
|
||||
float amsl_baro; ///< altitude above sea level in m from pressure and QNH
|
||||
bool_t amsl_baro_valid; ///< TRUE if #amsl_baro is currently valid
|
||||
bool_t calc_airspeed; ///< if TRUE, calculate airspeed from differential pressure
|
||||
@@ -72,12 +72,6 @@ extern void air_data_periodic(void);
|
||||
*/
|
||||
extern float air_data_get_amsl(void);
|
||||
|
||||
/**
|
||||
* Handler to set QNH manually.
|
||||
* @param qnh QNH in hPa
|
||||
*/
|
||||
extern void air_data_SetQNH(float qnh);
|
||||
|
||||
/**
|
||||
* Calculate equivalent airspeed from dynamic pressure.
|
||||
* Dynamic pressure @f$q@f$ (also called impact pressure) is the
|
||||
|
||||
Reference in New Issue
Block a user