Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
air_data.h File Reference

Air Data interface. More...

#include "std.h"
#include "filters/low_pass_filter.h"
#include "pprzlink/pprzlink_device.h"
#include "pprzlink/pprzlink_transport.h"
Include dependency graph for air_data.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  air_data_calib_t
 Calibration bitmask of a sensor. More...
struct  air_data_sensor_t
 One air data sensor: barometer, differential pressure, airspeed or temperature. More...
struct  AirData
 Air Data structure. More...

Macros

#define AIR_DATA_MAX_SENSORS   4
 Maximum number of sensors of each kind (barometers, differential pressure, airspeed, temperature).

Functions

void air_data_init (void)
 AirData initialization.
void air_data_periodic (void)
 Check health.
void air_data_CalibrateBaro (bool calibrate)
 Line up the barometers with the one in use and reset the QFE (setting handler).
void air_data_ZeroAirspeed (bool zero)
 Zero the differential pressures (setting handler).
void air_data_SetAirspeedFilter (float freq)
struct air_data_sensor_t * air_data_get_sensor (struct air_data_sensor_t *sensors, uint8_t abi_id, bool create)
 Find (or create) the sensor of an ABI id.
void air_data_parse_WIND_INFO (struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
 Parse datalink wind info message.
float air_data_get_amsl (void)
 Return AMSL (altitude AboveSeaLevel).
float eas_from_dynamic_pressure (float q)
 Calculate equivalent airspeed from dynamic pressure.
float get_tas_factor (float p, float t)
 Calculate true airspeed (TAS) factor.
float tas_from_eas (float eas)
 Calculate true airspeed from equivalent airspeed.
float eas_from_tas (float tas)
 Calculate equivalent airspeed from true airspeed.
float tas_from_dynamic_pressure (float q)
 Calculate true airspeed from dynamic pressure.

Variables

struct AirData air_data
 global AirData state

Detailed Description

Air Data interface.

  • pressures (several barometers and differential pressure sensors)
  • airspeed
  • angle of attack and sideslip
  • wind

Definition in file air_data.h.


Data Structure Documentation

◆ air_data_calib_t

struct air_data_calib_t

Calibration bitmask of a sensor.

Definition at line 45 of file air_data.h.

Data Fields
bool offset: 1 Offset calibrated (airframe or calibration).
bool scale: 1 Scale calibrated (airframe).

◆ air_data_sensor_t

struct air_data_sensor_t

One air data sensor: barometer, differential pressure, airspeed or temperature.

The drivers send the raw values (BARO_ABS_RAW, BARO_DIFF_RAW, AIRSPEED_RAW, TEMPERATURE_RAW) and the calibrated value is (raw - offset) * scale.

Definition at line 54 of file air_data.h.

Collaboration diagram for air_data_sensor_t:
Data Fields
uint8_t abi_id ABI sender id of the driver, ABI_DISABLE when unused.
uint16_t calib_cnt Number of raw values while calibrating.
float calib_sum Sum of the raw values while calibrating.
struct air_data_calib_t calibrated Calibration bitmask.
float dt Filtered interval between the values (s), for the health check.
Butterworth2LowPass filter Low-pass filter of the raw value.
float filter_dt Interval the filter is set up for (s), 0 if not running.
float filter_freq Low-pass filter cut-off frequency (Hz), 0 for no filter.
float offset Offset, in the raw unit.
float raw Last raw value (Pa, m/s or deg Celcius).
float scale Scale.
uint32_t stamp Driver timestamp of the last value (us).
float time System time of the last valid value (s), 0 if never.
uint8_t type Temperature type (TEMPERATURE_TYPE_*), only for the temperatures.
float value Last calibrated value (Pa, m/s or deg Celcius).

◆ AirData

struct AirData

Air Data structure.

Definition at line 73 of file air_data.h.

Collaboration diagram for AirData:
Data Fields
float airspeed Equivalent Air Speed (equals to Calibrated Air Speed at low speed/altitude) (in m/s, -1 if unknown.
float airspeed_filter Low-pass filter cut-off frequency (Hz) of the airspeed sensor in use, 0 for no filter.
uint8_t airspeed_id Differential pressure or airspeed sensor to use (ABI id), ABI_BROADCAST for automatic.
uint8_t airspeed_send_id Airspeed sensor in the AIRSPEED_RAW telemetry (ABI id), ABI_BROADCAST for all in turn, ABI_DISABLE for none.
uint8_t airspeed_used Airspeed sensor in use (ABI id), ABI_DISABLE if none.
struct air_data_sensor_t airspeeds[AIR_DATA_MAX_SENSORS] Sensors that only give an airspeed.
float amsl_baro altitude above sea level in m from pressure and QNH
bool amsl_baro_valid TRUE if amsl_baro is currently valid.
float aoa angle of attack (rad)
uint8_t baro_id Barometer to use (ABI id), ABI_BROADCAST for the first healthy one.
uint8_t baro_send_id Barometer in the BARO_RAW telemetry (ABI id), ABI_BROADCAST for all in turn, ABI_DISABLE for none.
uint8_t baro_used Barometer in use (ABI id), ABI_DISABLE if none.
struct air_data_sensor_t baros[AIR_DATA_MAX_SENSORS] Barometers (static pressure).
bool calc_qnh_once flag to calculate QNH with next pressure measurement
bool calib_armed Allow the calibration while the motors are armed.
bool calibrate_baro Line up the barometers with the one in use, true while running.
float differential Differential pressure (total - static pressure) (Pa).
struct air_data_sensor_t diffs[AIR_DATA_MAX_SENSORS] Differential pressure sensors.
float pressure Static atmospheric pressure (Pa), -1 if unknown.
float qfe Static pressure at the last calibration (Pa), -1 if unknown.
float qnh Barometric pressure adjusted to sea level in hPa, -1 if unknown.
float sideslip sideslip angle (rad)
float tas True Air Speed (TAS) in m/s, -1 if unknown.
float tas_factor factor to convert equivalent airspeed (EAS) to true airspeed (TAS), from pressure and temperature (or ISA at the altitude)
uint8_t temp_id Temperature to use (ABI id), ABI_BROADCAST for automatic (air, then pitot, then baro).
uint8_t temp_used Temperature in use (ABI id), ABI_DISABLE if none.
float temperature temperature in degrees Celcius, -1000 if unknown
struct air_data_sensor_t temps[AIR_DATA_MAX_SENSORS] Temperatures.
float wind_dir wind direction (rad, 0 north, >0 clockwise)
float wind_speed wind speed (m/s)
bool zero_airspeed Zero the differential pressures, true while running.

Macro Definition Documentation

◆ AIR_DATA_MAX_SENSORS

#define AIR_DATA_MAX_SENSORS   4

Maximum number of sensors of each kind (barometers, differential pressure, airspeed, temperature).

Definition at line 41 of file air_data.h.

Referenced by air_data_finish_calibration(), air_data_get_sensor(), air_data_init(), air_data_next(), air_data_select(), air_data_start_calibration(), and send_airspeed_raw().

Function Documentation

◆ air_data_CalibrateBaro()

void air_data_CalibrateBaro ( bool calibrate)
extern

Line up the barometers with the one in use and reset the QFE (setting handler).

Refused while the motors are armed, unless AirData.calib_armed.

Definition at line 581 of file air_data.c.

References air_data_start_calibration(), and calib_running.

Here is the call graph for this function:

◆ air_data_get_amsl()

float air_data_get_amsl ( void )
extern

Return AMSL (altitude AboveSeaLevel).

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

Definition at line 796 of file air_data.c.

References air_data, LlaCoor_f::alt, 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_get_sensor()

struct air_data_sensor_t * air_data_get_sensor ( struct air_data_sensor_t * sensors,
uint8_t abi_id,
bool create )
extern

Find (or create) the sensor of an ABI id.

Parameters
sensorsThe sensors (air_data.baros, diffs, airspeeds or temps)
abi_idThe ABI sender id
createTake a free slot if not found
Returns
The sensor, NULL if not found or full

Definition at line 213 of file air_data.c.

References ABI_BROADCAST, ABI_DISABLE, air_data_sensor_t::abi_id, AIR_DATA_MAX_SENSORS, air_data_sensor_defaults(), and sensors.

Referenced by air_data_sensor_temp(), air_data_SetAirspeedFilter(), airspeed_raw_cb(), baro_raw_cb(), diff_raw_cb(), send_baro_raw(), and temp_raw_cb().

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 )
extern

Parse datalink wind info message.

Definition at line 839 of file air_data.c.

References air_data, dev, eas_from_tas(), float_vect2_norm(), stateGetAirspeed_f(), stateSetAirspeed_f(), stateSetHorizontalWindspeed_f(), stateSetVerticalWindspeed_f(), FloatVect2::x, and FloatVect2::y.

Here is the call graph for this function:

◆ air_data_periodic()

void air_data_periodic ( void )
extern

◆ air_data_SetAirspeedFilter()

void air_data_SetAirspeedFilter ( float freq)
extern

Definition at line 595 of file air_data.c.

References air_data, air_data_filter_init(), air_data_get_sensor(), and s.

Here is the call graph for this function:

◆ air_data_ZeroAirspeed()

void air_data_ZeroAirspeed ( bool zero)
extern

Zero the differential pressures (setting handler).

Refused while the motors are armed, unless AirData.calib_armed.

Definition at line 588 of file air_data.c.

References air_data_start_calibration(), and calib_running.

Here is the call graph for this function:

◆ eas_from_dynamic_pressure()

float eas_from_dynamic_pressure ( float q)
extern

Calculate equivalent 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
equivalent airspeed in m/s

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 882 of file air_data.c.

References PPRZ_ISA_AIR_DENSITY, and sign().

Referenced by diff_raw_cb(), send_airspeed_raw(), 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)
extern

Calculate equivalent airspeed from true airspeed.

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

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 967 of file air_data.c.

References air_data, and compute_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 )
extern

Calculate true airspeed (TAS) factor.

TAS = tas_factor * EAS

Parameters
pcurrent air pressure in Pa
tcurrent air temperature in degrees Celcius
Returns
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 915 of file air_data.c.

References KelvinOfCelsius, p, PPRZ_ISA_SEA_LEVEL_PRESSURE, and PPRZ_ISA_SEA_LEVEL_TEMP.

Referenced by compute_tas_factor().

Here is the caller graph for this function:

◆ tas_from_dynamic_pressure()

float tas_from_dynamic_pressure ( float q)
extern

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 981 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)
extern

Calculate true airspeed from equivalent airspeed.

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

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 952 of file air_data.c.

References air_data, and compute_tas_factor().

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

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

Variable Documentation

◆ air_data