Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
air_data.c File Reference

Air Data interface. More...

#include "modules/air_data/air_data.h"
#include "modules/core/abi.h"
#include "math/pprz_isa.h"
#include "state.h"
#include "generated/airframe.h"
#include "pprzlink/dl_protocol.h"
#include "modules/datalink/telemetry.h"
+ Include dependency graph for air_data.c:

Go to the source code of this file.

Macros

#define AIR_DATA_BARO_ABS_ID   ABI_BROADCAST
 ABI binding for absolute pressure. More...
 
#define AIR_DATA_BARO_DIFF_ID   ABI_BROADCAST
 ABI binding for differential pressure. More...
 
#define AIR_DATA_TEMPERATURE_ID   ABI_BROADCAST
 ABI binding for temperature. More...
 
#define AIR_DATA_AIRSPEED_ID   ABI_BROADCAST
 ABI binding for airspeed. More...
 
#define AIR_DATA_INCIDENCE_ID   ABI_BROADCAST
 ABI binding for incidence angles. More...
 
#define AIR_DATA_TAS_FACTOR   1.0
 Default factor to convert estimated airspeed (EAS) to true airspeed (TAS) More...
 
#define AIR_DATA_CALC_AIRSPEED   TRUE
 Calculate Airspeed from differential pressure by default. More...
 
#define AIR_DATA_CALC_TAS_FACTOR   TRUE
 Calculate tas_factor from temp and pressure by default. More...
 
#define AIR_DATA_CALC_AMSL_BARO   FALSE
 Don't calculate AMSL from baro and QNH by default. More...
 

Functions

static void pressure_abs_cb (uint8_t sender_id, uint32_t stamp, float pressure)
 
static void pressure_diff_cb (uint8_t sender_id, float pressure)
 
static void temperature_cb (uint8_t sender_id, float temp)
 
static void airspeed_cb (uint8_t sender_id, float eas)
 
static void incidence_cb (uint8_t sender_id, uint8_t flag, float aoa, float sideslip)
 
static void send_baro_raw (struct transport_tx *trans, struct link_device *dev)
 
static void send_air_data (struct transport_tx *trans, struct link_device *dev)
 
static void send_amsl (struct transport_tx *trans, struct link_device *dev)
 
void air_data_init (void)
 AirData initialization. More...
 
float air_data_get_amsl (void)
 Return AMSL (altitude AboveSeaLevel). More...
 
void air_data_periodic (void)
 Check health. More...
 
void air_data_parse_WIND_INFO (struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
 Parse datalink wind info message. More...
 
float eas_from_dynamic_pressure (float q)
 Calculate equivalent airspeed from dynamic pressure. More...
 
float get_tas_factor (float p, float t)
 Calculate true airspeed (TAS) factor. More...
 
static void compute_tas_factor (void)
 Internal utility function to compute current tas factor if needed. More...
 
float tas_from_eas (float eas)
 Calculate true airspeed from equivalent airspeed. More...
 
float eas_from_tas (float tas)
 Calculate equivalent airspeed from true airspeed. More...
 
float tas_from_dynamic_pressure (float q)
 Calculate true airspeed from dynamic pressure. More...
 

Variables

struct AirData air_data
 global AirData state More...
 
static abi_event pressure_abs_ev
 
static abi_event pressure_diff_ev
 
static abi_event temperature_ev
 
static abi_event airspeed_ev
 
static abi_event incidence_ev
 
static uint8_t baro_health_counter
 counter to check baro health More...
 

Detailed Description

Air Data interface.

  • pressures
  • airspeed
  • angle of attack and sideslip
  • wind

Definition in file air_data.c.

Macro Definition Documentation

◆ AIR_DATA_AIRSPEED_ID

#define AIR_DATA_AIRSPEED_ID   ABI_BROADCAST

ABI binding for airspeed.

Definition at line 66 of file air_data.c.

◆ AIR_DATA_BARO_ABS_ID

#define AIR_DATA_BARO_ABS_ID   ABI_BROADCAST

ABI binding for absolute pressure.

Definition at line 45 of file air_data.c.

◆ AIR_DATA_BARO_DIFF_ID

#define AIR_DATA_BARO_DIFF_ID   ABI_BROADCAST

ABI binding for differential pressure.

Definition at line 52 of file air_data.c.

◆ AIR_DATA_CALC_AIRSPEED

#define AIR_DATA_CALC_AIRSPEED   TRUE

Calculate Airspeed from differential pressure by default.

Definition at line 84 of file air_data.c.

◆ AIR_DATA_CALC_AMSL_BARO

#define AIR_DATA_CALC_AMSL_BARO   FALSE

Don't calculate AMSL from baro and QNH by default.

Definition at line 94 of file air_data.c.

◆ AIR_DATA_CALC_TAS_FACTOR

#define AIR_DATA_CALC_TAS_FACTOR   TRUE

Calculate tas_factor from temp and pressure by default.

Definition at line 89 of file air_data.c.

◆ AIR_DATA_INCIDENCE_ID

#define AIR_DATA_INCIDENCE_ID   ABI_BROADCAST

ABI binding for incidence angles.

Definition at line 73 of file air_data.c.

◆ AIR_DATA_TAS_FACTOR

#define AIR_DATA_TAS_FACTOR   1.0

Default factor to convert estimated airspeed (EAS) to true airspeed (TAS)

Definition at line 79 of file air_data.c.

◆ AIR_DATA_TEMPERATURE_ID

#define AIR_DATA_TEMPERATURE_ID   ABI_BROADCAST

ABI binding for temperature.

Definition at line 59 of file air_data.c.

Function Documentation

◆ air_data_get_amsl()

float air_data_get_amsl ( void  )

Return AMSL (altitude AboveSeaLevel).

If AMSL from baro is valid, return that, otherwise from gps.

Definition at line 258 of file air_data.c.

References air_data, LlaCoor_f::alt, AirData::amsl_baro, AirData::amsl_baro_valid, and stateGetPositionLla_f().

Referenced by compute_tas_factor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ air_data_init()

◆ air_data_parse_WIND_INFO()

void air_data_parse_WIND_INFO ( struct link_device *  dev,
struct transport_tx *  trans,
uint8_t buf 
)

◆ air_data_periodic()

void air_data_periodic ( void  )

Check health.

Needs to be called periodically.

Definition at line 268 of file air_data.c.

References air_data, AirData::amsl_baro_valid, and baro_health_counter.

◆ airspeed_cb()

static void airspeed_cb ( uint8_t  sender_id,
float  eas 
)
static

Definition at line 162 of file air_data.c.

References air_data, AirData::airspeed, AirData::calc_airspeed, stateSetAirspeed_f(), AirData::tas, and tas_from_eas().

Referenced by air_data_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_tas_factor()

static void compute_tas_factor ( void  )
static

Internal utility function to compute current tas factor if needed.

Definition at line 367 of file air_data.c.

References air_data, air_data_get_amsl(), AirData::calc_tas_factor, CelsiusOfKelvin, get_tas_factor(), p, pprz_isa_pressure_of_altitude(), pprz_isa_temperature_of_altitude(), AirData::pressure, AirData::tas_factor, and AirData::temperature.

Referenced by eas_from_tas(), and tas_from_eas().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eas_from_dynamic_pressure()

float eas_from_dynamic_pressure ( float  q)

Calculate equivalent airspeed from dynamic pressure.

Dynamic pressure $q$ (also called impact pressure) is the difference between total(pitot) and static pressure.

Airspeed from dynamic pressure:

\[ v = \frac12 \sqrt{\frac{2q}{\rho}} \]

with $\rho$ as air density. Using standard sea level air density $\rho_0$ gives you equivalent airspeed (EAS).

Parameters
qdynamic pressure in Pa
Returns
equivalent airspeed in m/s

Definition at line 321 of file air_data.c.

References PPRZ_ISA_AIR_DENSITY, and sign().

Referenced by pressure_diff_cb(), and tas_from_dynamic_pressure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eas_from_tas()

float eas_from_tas ( float  tas)

Calculate equivalent airspeed from true airspeed.

EAS from True airspeed (TAS): EAS = TAS / air_data.tas_factor

Parameters
tastrue airspeed (TAS) in m/s
Returns
equivalent airspeed in m/s

Definition at line 409 of file air_data.c.

References air_data, compute_tas_factor(), and AirData::tas_factor.

Referenced by air_data_parse_WIND_INFO(), and wind_estimation_quadrotor_periodic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_tas_factor()

float get_tas_factor ( float  p,
float  t 
)

Calculate true airspeed (TAS) factor.

TAS = tas_factor * EAS

True airspeed (TAS) from equivalent airspeed (EAS):

\[\mbox{TAS} = \mbox{EAS} \sqrt{\frac{\rho_0}{\rho}}\]

and $ \frac{\rho_0}{\rho} = \frac{p_0T}{pT_0}$ where

  • $p$ is the air pressure at the flight condition
  • $p_0$ is the air pressure at sea level = 101325 Pa
  • $T$ is the air temperature at the flight condition
  • $T_0$ is the air temperature at sea level = 288.15 K
Parameters
pcurrent air pressure in Pa
tcurrent air temperature in degrees Celcius
Returns
tas factor

Definition at line 354 of file air_data.c.

References KelvinOfCelsius, p, PPRZ_ISA_SEA_LEVEL_PRESSURE, and PPRZ_ISA_SEA_LEVEL_TEMP.

Referenced by compute_tas_factor(), and temperature_cb().

+ Here is the caller graph for this function:

◆ incidence_cb()

static void incidence_cb ( uint8_t  sender_id,
uint8_t  flag,
float  aoa,
float  sideslip 
)
static

Definition at line 173 of file air_data.c.

References air_data, AirData::aoa, AirData::sideslip, stateSetAngleOfAttack_f(), and stateSetSideslip_f().

Referenced by air_data_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pressure_abs_cb()

static void pressure_abs_cb ( uint8_t  sender_id,
uint32_t  stamp,
float  pressure 
)
static

◆ pressure_diff_cb()

static void pressure_diff_cb ( uint8_t  sender_id,
float  pressure 
)
static

Definition at line 140 of file air_data.c.

References air_data, AirData::airspeed, AirData::calc_airspeed, AirData::differential, eas_from_dynamic_pressure(), AirData::pressure, stateSetAirspeed_f(), AirData::tas, and tas_from_eas().

Referenced by air_data_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_air_data()

static void send_air_data ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

Definition at line 196 of file air_data.c.

References air_data, AirData::airspeed, AirData::amsl_baro, dev, AirData::differential, AirData::pressure, AirData::qnh, AirData::tas, and AirData::temperature.

Referenced by air_data_init().

+ Here is the caller graph for this function:

◆ send_amsl()

static void send_amsl ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

Definition at line 205 of file air_data.c.

References air_data, LlaCoor_f::alt, AirData::amsl_baro, dev, and stateGetPositionLla_f().

Referenced by air_data_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_baro_raw()

static void send_baro_raw ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

Definition at line 190 of file air_data.c.

References air_data, dev, AirData::differential, and AirData::pressure.

Referenced by air_data_init().

+ Here is the caller graph for this function:

◆ tas_from_dynamic_pressure()

float tas_from_dynamic_pressure ( float  q)

Calculate true airspeed from dynamic pressure.

Dynamic pressure $q$ (also called impact pressure) is the difference between total(pitot) and static pressure.

Parameters
qdynamic pressure in Pa
Returns
true airspeed in m/s

Definition at line 423 of file air_data.c.

References eas_from_dynamic_pressure(), and tas_from_eas().

Referenced by pressure_diff_cb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tas_from_eas()

float tas_from_eas ( float  eas)

Calculate true airspeed from equivalent airspeed.

True airspeed (TAS) from EAS: TAS = air_data.tas_factor * EAS

Parameters
easequivalent airspeed (EAS) in m/s
Returns
true airspeed in m/s

Definition at line 394 of file air_data.c.

References air_data, compute_tas_factor(), and AirData::tas_factor.

Referenced by airspeed_cb(), pressure_diff_cb(), and tas_from_dynamic_pressure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ temperature_cb()

static void temperature_cb ( uint8_t  sender_id,
float  temp 
)
static

Definition at line 152 of file air_data.c.

References air_data, AirData::airspeed, baro_health_counter, AirData::calc_tas_factor, get_tas_factor(), AirData::pressure, AirData::tas_factor, and AirData::temperature.

Referenced by air_data_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ air_data

◆ airspeed_ev

abi_event airspeed_ev
static

Definition at line 68 of file air_data.c.

Referenced by air_data_init().

◆ baro_health_counter

uint8_t baro_health_counter
static

counter to check baro health

Definition at line 110 of file air_data.c.

Referenced by air_data_init(), air_data_periodic(), pressure_abs_cb(), and temperature_cb().

◆ incidence_ev

abi_event incidence_ev
static

Definition at line 75 of file air_data.c.

Referenced by air_data_init().

◆ pressure_abs_ev

abi_event pressure_abs_ev
static

Definition at line 47 of file air_data.c.

Referenced by air_data_init().

◆ pressure_diff_ev

abi_event pressure_diff_ev
static

Definition at line 54 of file air_data.c.

Referenced by air_data_init().

◆ temperature_ev

abi_event temperature_ev
static

Definition at line 61 of file air_data.c.

Referenced by air_data_init().