35 #include "generated/airframe.h"
36 #include "pprzlink/dl_protocol.h"
44 #ifndef AIR_DATA_BARO_ABS_ID
45 #define AIR_DATA_BARO_ABS_ID ABI_BROADCAST
51 #ifndef AIR_DATA_BARO_DIFF_ID
52 #define AIR_DATA_BARO_DIFF_ID ABI_BROADCAST
58 #ifndef AIR_DATA_TEMPERATURE_ID
59 #define AIR_DATA_TEMPERATURE_ID ABI_BROADCAST
65 #ifndef AIR_DATA_AIRSPEED_ID
66 #define AIR_DATA_AIRSPEED_ID ABI_BROADCAST
72 #ifndef AIR_DATA_INCIDENCE_ID
73 #define AIR_DATA_INCIDENCE_ID ABI_BROADCAST
78 #ifndef AIR_DATA_TAS_FACTOR
79 #define AIR_DATA_TAS_FACTOR 1.0
83 #ifndef AIR_DATA_CALC_AIRSPEED
84 #define AIR_DATA_CALC_AIRSPEED TRUE
88 #ifndef AIR_DATA_CALC_TAS_FACTOR
89 #define AIR_DATA_CALC_TAS_FACTOR TRUE
93 #ifndef AIR_DATA_CALC_AMSL_BARO
94 #define AIR_DATA_CALC_AMSL_BARO FALSE
98 #ifndef USE_AIRSPEED_AIR_DATA
100 #define USE_AIRSPEED_AIR_DATA TRUE
121 float geoid_separation = 0;
146 #if USE_AIRSPEED_AIR_DATA
167 #if USE_AIRSPEED_AIR_DATA
175 if (bit_is_set(flag, 0)) {
180 if (bit_is_set(flag, 1)) {
187 #if PERIODIC_TELEMETRY
192 pprz_msg_send_BARO_RAW(trans,
dev, AC_ID,
198 pprz_msg_send_AIR_DATA(trans,
dev, AC_ID,
205 static void send_amsl(
struct transport_tx *trans,
struct link_device *
dev)
207 const float MeterPerFeet = 0.3048;
210 pprz_msg_send_AMSL(trans,
dev, AC_ID, &amsl_baro_ft, &amsl_gps_ft);
251 #if PERIODIC_TELEMETRY
280 if (DL_WIND_INFO_ac_id(buf) != AC_ID) {
return; }
281 uint8_t flags = DL_WIND_INFO_flags(buf);
284 if (bit_is_set(flags, 0)) {
285 wind.
x = DL_WIND_INFO_north(buf);
286 wind.
y = DL_WIND_INFO_east(buf);
291 if (bit_is_set(flags, 1)) {
292 upwind = DL_WIND_INFO_up(buf);
296 if (bit_is_set(flags, 2)) {
304 pprz_msg_send_WIND_INFO_RET(trans,
dev, AC_ID, &flags, &wind.
y, &wind.
x, &upwind, &airspeed);
335 return sqrtf(q * two_div_rho_0) *
sign;
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
Main include for ABI (AirBorneInterface).
Event structure to store callbacks in a linked list.
float eas_from_dynamic_pressure(float q)
Calculate equivalent airspeed from dynamic pressure.
void air_data_periodic(void)
Check health.
static abi_event airspeed_ev
static abi_event temperature_ev
static uint8_t baro_health_counter
counter to check baro health
static void compute_tas_factor(void)
Internal utility function to compute current tas factor if needed.
#define AIR_DATA_AIRSPEED_ID
ABI binding for airspeed.
struct AirData air_data
global AirData state
float air_data_get_amsl(void)
Return AMSL (altitude AboveSeaLevel).
#define AIR_DATA_TAS_FACTOR
Default factor to convert estimated airspeed (EAS) to true airspeed (TAS)
#define AIR_DATA_CALC_TAS_FACTOR
Calculate tas_factor from temp and pressure by default.
static void pressure_diff_cb(uint8_t sender_id, float pressure)
#define AIR_DATA_CALC_AMSL_BARO
Don't calculate AMSL from baro and QNH by default.
static void send_air_data(struct transport_tx *trans, struct link_device *dev)
static abi_event pressure_diff_ev
#define AIR_DATA_CALC_AIRSPEED
Calculate Airspeed from differential pressure by default.
float eas_from_tas(float tas)
Calculate equivalent airspeed from true airspeed.
static void temperature_cb(uint8_t sender_id, float temp)
#define AIR_DATA_TEMPERATURE_ID
ABI binding for temperature.
float tas_from_dynamic_pressure(float q)
Calculate true airspeed from dynamic pressure.
static void incidence_cb(uint8_t sender_id, uint8_t flag, float aoa, float sideslip)
#define AIR_DATA_BARO_ABS_ID
ABI binding for absolute pressure.
#define AIR_DATA_BARO_DIFF_ID
ABI binding for differential pressure.
static abi_event incidence_ev
static void send_amsl(struct transport_tx *trans, struct link_device *dev)
void air_data_parse_WIND_INFO(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
Parse datalink wind info message.
static abi_event pressure_abs_ev
static void pressure_abs_cb(uint8_t sender_id, uint32_t stamp, float pressure)
#define AIR_DATA_INCIDENCE_ID
ABI binding for incidence angles.
static void send_baro_raw(struct transport_tx *trans, struct link_device *dev)
void air_data_init(void)
AirData initialization.
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.
static void airspeed_cb(uint8_t sender_id, float eas)
bool calc_amsl_baro
if TRUE, calculate amsl_baro
float sideslip
sideslip angle (rad)
float wind_dir
wind direction (rad, 0 north, >0 clockwise)
bool calc_tas_factor
if TRUE, calculate tas_factor when getting a temp measurement
float tas_factor
factor to convert equivalent airspeed (EAS) to true airspeed (TAS)
float temperature
temperature in degrees Celcius, -1000 if unknown
float aoa
angle of attack (rad)
float wind_speed
wind speed (m/s)
bool calc_airspeed
if TRUE, calculate airspeed from differential pressure
bool calc_qnh_once
flag to calculate QNH with next pressure measurement
float airspeed
Equivalent Air Speed (equals to Calibrated Air Speed at low speed/altitude) (in m/s,...
float differential
Differential pressure (total - static pressure) (Pa)
float pressure
Static atmospheric pressure (Pa), -1 if unknown.
float amsl_baro
altitude above sea level in m from pressure and QNH
float tas
True Air Speed (TAS) in m/s, -1 if unknown.
bool amsl_baro_valid
TRUE if amsl_baro is currently valid.
float qnh
Barometric pressure adjusted to sea level in hPa, -1 if unknown.
static float float_vect2_norm(struct FloatVect2 *v)
#define KelvinOfCelsius(_t)
Convert temperature from Celsius to Kelvin.
#define PPRZ_ISA_SEA_LEVEL_TEMP
ISA sea level standard temperature in Kelvin.
static float pprz_isa_pressure_of_altitude(float altitude)
Get pressure in Pa from absolute altitude (using simplified equation).
#define PPRZ_ISA_AIR_DENSITY
standard air density in kg/m^3
static float pprz_isa_temperature_of_altitude(float alt)
Get ISA temperature from a MSL altitude.
#define CelsiusOfKelvin(_t)
Convert temperature from Kelvin to Celsius.
#define PPRZ_ISA_SEA_LEVEL_PRESSURE
ISA sea level standard atmospheric pressure in Pascal.
static float pprz_isa_height_of_pressure_full(float pressure, float ref_p)
Get relative altitude from pressure (using full equation).
static float pprz_isa_ref_pressure_of_height_full(float pressure, float height)
Get reference pressure (QFE or QNH) from current pressure and height.
struct LtpDef_f ned_origin_f
Definition of the local (flat earth) coordinate system.
bool ned_initialized_f
True if local float coordinate frame is initialsed.
static bool stateIsGlobalCoordinateValid(void)
Test if global coordinates are valid.
static struct LlaCoor_f * stateGetPositionLla_f(void)
Get position in LLA coordinates (float).
static void stateSetAngleOfAttack_f(float aoa)
Set angle of attack in radians (float).
static void stateSetHorizontalWindspeed_f(struct FloatVect2 *h_windspeed)
Set horizontal windspeed (float).
static void stateSetAirspeed_f(float airspeed)
Set airspeed (float).
static void stateSetSideslip_f(float sideslip)
Set sideslip angle in radians (float).
static float stateGetAirspeed_f(void)
Get airspeed (float).
static void stateSetVerticalWindspeed_f(float v_windspeed)
Set vertical windspeed (float).
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
static float sign(float x)
sign function
float alt
in meters (normally above WGS84 reference ellipsoid)
float hmsl
Height above mean sea level in meters.
struct LlaCoor_f lla
origin of local frame in LLA
Paparazzi atmospheric pressure conversion utilities.
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.