Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
pprz_isa.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Gautier Hattenberger
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
38#ifndef PPRZ_ISA_H
39#define PPRZ_ISA_H
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#include "std.h"
46#include <math.h>
47
48// Standard Atmosphere constants
50#define PPRZ_ISA_SEA_LEVEL_PRESSURE 101325.0
52#define PPRZ_ISA_SEA_LEVEL_TEMP 288.15
54#define PPRZ_ISA_TEMP_LAPS_RATE 0.0065
56#define PPRZ_ISA_GRAVITY 9.80665
58#define PPRZ_ISA_GAS_CONSTANT 8.31447
60#define PPRZ_ISA_MOLAR_MASS 0.0289644
62#define PPRZ_ISA_AIR_GAS_CONSTANT (PPRZ_ISA_GAS_CONSTANT/PPRZ_ISA_MOLAR_MASS)
64#define PPRZ_ISA_AIR_DENSITY 1.225
66#define PPRZ_ISA_ABS_NULL -273.15
67
69
71#define CelsiusOfKelvin(_t) (_t - 274.15f)
73#define KelvinOfCelsius(_t) (_t + 274.15f)
74
82static inline float pprz_isa_altitude_of_pressure(float pressure)
83{
84 if (pressure > 0.) {
86 } else {
87 return 0.;
88 }
89}
90
102static inline float pprz_isa_height_of_pressure(float pressure, float ref_p)
103{
104 if (pressure > 0. && ref_p > 0.) {
105 return (PPRZ_ISA_M_OF_P_CONST * logf(ref_p / pressure));
106 } else {
107 return 0.;
108 }
109}
110
117static inline float pprz_isa_pressure_of_altitude(float altitude)
118{
120}
121
129static inline float pprz_isa_pressure_of_height(float height, float ref_p)
130{
131 return (ref_p * expf((-1. / PPRZ_ISA_M_OF_P_CONST) * height));
132}
133
134
146static inline float pprz_isa_height_of_pressure_full(float pressure, float ref_p)
147{
148 if (ref_p > 0.) {
149 const float prel = pressure / ref_p;
153 } else {
154 return 0.;
155 }
156}
157
166static inline float pprz_isa_ref_pressure_of_height_full(float pressure, float height)
167{
168 // Trel = 1 - L*h/T0;
169 const float Trel = 1.0 - PPRZ_ISA_TEMP_LAPS_RATE * height / PPRZ_ISA_SEA_LEVEL_TEMP;
172 return pressure / pow(Trel, expo);
173}
174
181static inline float pprz_isa_temperature_of_altitude(float alt)
182{
184}
185
193static inline float pprz_isa_density_of_pressure(float pressure, float temp)
194{
195 return pressure * (1.0f / (PPRZ_ISA_AIR_GAS_CONSTANT * (temp - PPRZ_ISA_ABS_NULL)));
196}
197
198#ifdef __cplusplus
199} /* extern "C" */
200#endif
201
202#endif /* PPRZ_ISA_H */
static int32_t altitude
static float pprz_isa_height_of_pressure(float pressure, float ref_p)
Get relative altitude from pressure (using simplified equation).
Definition pprz_isa.h:102
#define PPRZ_ISA_TEMP_LAPS_RATE
temperature laps rate in K/m
Definition pprz_isa.h:54
#define PPRZ_ISA_SEA_LEVEL_TEMP
ISA sea level standard temperature in Kelvin.
Definition pprz_isa.h:52
static float pprz_isa_pressure_of_height(float height, float ref_p)
Get pressure in Pa from height (using simplified equation).
Definition pprz_isa.h:129
#define PPRZ_ISA_ABS_NULL
absolute null in celcius
Definition pprz_isa.h:66
static float pprz_isa_density_of_pressure(float pressure, float temp)
Get the air density (rho) from a given pressure and temperature.
Definition pprz_isa.h:193
#define PPRZ_ISA_GRAVITY
earth-surface gravitational acceleration in m/s^2
Definition pprz_isa.h:56
#define PPRZ_ISA_MOLAR_MASS
molar mass of dry air in kg/mol
Definition pprz_isa.h:60
static float pprz_isa_pressure_of_altitude(float altitude)
Get pressure in Pa from absolute altitude (using simplified equation).
Definition pprz_isa.h:117
static float pprz_isa_temperature_of_altitude(float alt)
Get ISA temperature from a MSL altitude.
Definition pprz_isa.h:181
#define PPRZ_ISA_GAS_CONSTANT
universal gas constant in J/(mol*K)
Definition pprz_isa.h:58
static const float PPRZ_ISA_M_OF_P_CONST
Definition pprz_isa.h:68
#define PPRZ_ISA_SEA_LEVEL_PRESSURE
ISA sea level standard atmospheric pressure in Pascal.
Definition pprz_isa.h:50
static float pprz_isa_height_of_pressure_full(float pressure, float ref_p)
Get relative altitude from pressure (using full equation).
Definition pprz_isa.h:146
static float pprz_isa_altitude_of_pressure(float pressure)
Get absolute altitude from pressure (using simplified equation).
Definition pprz_isa.h:82
#define PPRZ_ISA_AIR_GAS_CONSTANT
universal gas constant / molar mass of dry air in J*kg/K
Definition pprz_isa.h:62
static float pprz_isa_ref_pressure_of_height_full(float pressure, float height)
Get reference pressure (QFE or QNH) from current pressure and height.
Definition pprz_isa.h:166
uint16_t foo
Definition main_demo5.c:58