Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
air_data.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Gautier Hattenberger
3 * 2014 Felix Ruess <felix.ruess@gmail.com>
4 *
5 * This file is part of paparazzi
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
20 */
21
30
31#ifndef AIR_DATA_H
32#define AIR_DATA_H
33
34#include "std.h"
36#include "pprzlink/pprzlink_device.h"
37#include "pprzlink/pprzlink_transport.h"
38
40#ifndef AIR_DATA_MAX_SENSORS
41#define AIR_DATA_MAX_SENSORS 4
42#endif
43
46 bool offset: 1;
47 bool scale: 1;
48};
49
71
111
114extern struct AirData air_data;
115
118extern void air_data_init(void);
119
122extern void air_data_periodic(void);
123
127extern void air_data_CalibrateBaro(bool calibrate);
128
132extern void air_data_ZeroAirspeed(bool zero);
133
134extern void air_data_SetAirspeedFilter(float freq);
135
143
146extern void air_data_parse_WIND_INFO(struct link_device *dev, struct transport_tx *trans, uint8_t *buf);
147
151extern float air_data_get_amsl(void);
152
161extern float eas_from_dynamic_pressure(float q);
162
171extern float get_tas_factor(float p, float t);
172
179extern float tas_from_eas(float eas);
180
187extern float eas_from_tas(float tas);
188
197extern float tas_from_dynamic_pressure(float q);
198
199
200#endif
struct AirData air_data
global AirData state Statically initialized, the persistent settings are loaded before air_data_init(...
Definition air_data.c:153
float eas_from_dynamic_pressure(float q)
Calculate equivalent airspeed from dynamic pressure.
Definition air_data.c:882
float dt
Filtered interval between the values (s), for the health check.
Definition air_data.h:64
void air_data_ZeroAirspeed(bool zero)
Zero the differential pressures (setting handler).
Definition air_data.c:588
void air_data_periodic(void)
Check health.
Definition air_data.c:806
#define AIR_DATA_MAX_SENSORS
Maximum number of sensors of each kind (barometers, differential pressure, airspeed,...
Definition air_data.h:41
float airspeed_filter
Low-pass filter cut-off frequency (Hz) of the airspeed sensor in use, 0 for no filter.
Definition air_data.h:87
struct air_data_sensor_t airspeeds[AIR_DATA_MAX_SENSORS]
Sensors that only give an airspeed.
Definition air_data.h:76
float scale
Scale.
Definition air_data.h:59
uint8_t type
Temperature type (TEMPERATURE_TYPE_*), only for the temperatures.
Definition air_data.h:56
float sideslip
sideslip angle (rad)
Definition air_data.h:107
float wind_dir
wind direction (rad, 0 north, >0 clockwise)
Definition air_data.h:109
bool zero_airspeed
Zero the differential pressures, true while running.
Definition air_data.h:90
float air_data_get_amsl(void)
Return AMSL (altitude AboveSeaLevel).
Definition air_data.c:796
uint8_t airspeed_send_id
Airspeed sensor in the AIRSPEED_RAW telemetry (ABI id), ABI_BROADCAST for all in turn,...
Definition air_data.h:86
void air_data_SetAirspeedFilter(float freq)
Definition air_data.c:595
float qfe
Static pressure at the last calibration (Pa), -1 if unknown.
Definition air_data.h:92
void air_data_CalibrateBaro(bool calibrate)
Line up the barometers with the one in use and reset the QFE (setting handler).
Definition air_data.c:581
uint8_t baro_send_id
Barometer in the BARO_RAW telemetry (ABI id), ABI_BROADCAST for all in turn, ABI_DISABLE for none.
Definition air_data.h:85
float tas_factor
factor to convert equivalent airspeed (EAS) to true airspeed (TAS), from pressure and temperature (or...
Definition air_data.h:100
float eas_from_tas(float tas)
Calculate equivalent airspeed from true airspeed.
Definition air_data.c:967
bool calib_armed
Allow the calibration while the motors are armed.
Definition air_data.h:91
bool offset
Offset calibrated (airframe or calibration).
Definition air_data.h:46
Butterworth2LowPass filter
Low-pass filter of the raw value.
Definition air_data.h:69
float temperature
temperature in degrees Celcius, -1000 if unknown
Definition air_data.h:96
float offset
Offset, in the raw unit.
Definition air_data.h:58
float value
Last calibrated value (Pa, m/s or deg Celcius).
Definition air_data.h:61
float aoa
angle of attack (rad)
Definition air_data.h:106
float tas_from_dynamic_pressure(float q)
Calculate true airspeed from dynamic pressure.
Definition air_data.c:981
float wind_speed
wind speed (m/s)
Definition air_data.h:108
float filter_freq
Low-pass filter cut-off frequency (Hz), 0 for no filter.
Definition air_data.h:67
uint8_t airspeed_id
Differential pressure or airspeed sensor to use (ABI id), ABI_BROADCAST for automatic.
Definition air_data.h:80
bool calc_qnh_once
flag to calculate QNH with next pressure measurement
Definition air_data.h:104
float calib_sum
Sum of the raw values while calibrating.
Definition air_data.h:65
struct air_data_calib_t calibrated
Calibration bitmask.
Definition air_data.h:57
float airspeed
Equivalent Air Speed (equals to Calibrated Air Speed at low speed/altitude) (in m/s,...
Definition air_data.h:98
struct air_data_sensor_t baros[AIR_DATA_MAX_SENSORS]
Barometers (static pressure).
Definition air_data.h:74
struct air_data_sensor_t diffs[AIR_DATA_MAX_SENSORS]
Differential pressure sensors.
Definition air_data.h:75
uint8_t abi_id
ABI sender id of the driver, ABI_DISABLE when unused.
Definition air_data.h:55
bool scale
Scale calibrated (airframe).
Definition air_data.h:47
uint8_t temp_used
Temperature in use (ABI id), ABI_DISABLE if none.
Definition air_data.h:84
uint32_t stamp
Driver timestamp of the last value (us).
Definition air_data.h:62
float differential
Differential pressure (total - static pressure) (Pa).
Definition air_data.h:95
uint8_t baro_id
Barometer to use (ABI id), ABI_BROADCAST for the first healthy one.
Definition air_data.h:79
void air_data_parse_WIND_INFO(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
Parse datalink wind info message.
Definition air_data.c:839
bool calibrate_baro
Line up the barometers with the one in use, true while running.
Definition air_data.h:89
float pressure
Static atmospheric pressure (Pa), -1 if unknown.
Definition air_data.h:94
float amsl_baro
altitude above sea level in m from pressure and QNH
Definition air_data.h:102
float time
System time of the last valid value (s), 0 if never.
Definition air_data.h:63
float tas
True Air Speed (TAS) in m/s, -1 if unknown.
Definition air_data.h:99
uint8_t airspeed_used
Airspeed sensor in use (ABI id), ABI_DISABLE if none.
Definition air_data.h:83
bool amsl_baro_valid
TRUE if amsl_baro is currently valid.
Definition air_data.h:103
float qnh
Barometric pressure adjusted to sea level in hPa, -1 if unknown.
Definition air_data.h:101
uint8_t baro_used
Barometer in use (ABI id), ABI_DISABLE if none.
Definition air_data.h:82
void air_data_init(void)
AirData initialization.
Definition air_data.c:732
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.
Definition air_data.c:213
float raw
Last raw value (Pa, m/s or deg Celcius).
Definition air_data.h:60
struct air_data_sensor_t temps[AIR_DATA_MAX_SENSORS]
Temperatures.
Definition air_data.h:77
float get_tas_factor(float p, float t)
Calculate true airspeed (TAS) factor.
Definition air_data.c:915
float filter_dt
Interval the filter is set up for (s), 0 if not running.
Definition air_data.h:68
float tas_from_eas(float eas)
Calculate true airspeed from equivalent airspeed.
Definition air_data.c:952
uint8_t temp_id
Temperature to use (ABI id), ABI_BROADCAST for automatic (air, then pitot, then baro).
Definition air_data.h:81
uint16_t calib_cnt
Number of raw values while calibrating.
Definition air_data.h:66
Air Data structure.
Definition air_data.h:73
Calibration bitmask of a sensor.
Definition air_data.h:45
One air data sensor: barometer, differential pressure, airspeed or temperature.
Definition air_data.h:54
#define sensors(...)
static struct uart_periph * dev
static float p[2][2]
Simple first order low pass filter with bilinear transform.
struct SecondOrderLowPass Butterworth2LowPass
Second order Butterworth low pass filter.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.