Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
36 #ifndef PPRZ_ISA_H
37 #define PPRZ_ISA_H
38 
39 #include "std.h"
40 #include <math.h>
41 
42 // Standard Atmosphere constants
43 #define PPRZ_ISA_SEA_LEVEL_PRESSURE 101325.0
44 #define PPRZ_ISA_SEA_LEVEL_TEMP 288.15
45 #define PPRZ_ISA_TEMP_LAPS_RATE 0.0065
46 #define PPRZ_ISA_GRAVITY 9.80665
47 #define PPRZ_ISA_AIR_GAS_CONSTANT (8.31447/0.0289644)
48 
50 
58 static inline float pprz_isa_altitude_of_pressure(float pressure) {
59  if (pressure > 0.) {
60  return (PPRZ_ISA_M_OF_P_CONST*logf(PPRZ_ISA_SEA_LEVEL_PRESSURE/pressure));
61  } else {
62  return 0.;
63  }
64 }
65 
73 static inline float pprz_isa_height_of_pressure(float pressure, float ref) {
74  if (pressure > 0. && ref > 0.) {
75  return (PPRZ_ISA_M_OF_P_CONST*logf(ref/pressure));
76  } else {
77  return 0.;
78  }
79 }
80 
87 static inline float pprz_isa_pressure_of_altitude(float altitude) {
88  return (PPRZ_ISA_SEA_LEVEL_PRESSURE*expf((-1./PPRZ_ISA_M_OF_P_CONST)*altitude));
89 }
90 
98 static inline float pprz_isa_pressure_of_height(float altitude, float ref) {
99  return (ref*expf((-1./PPRZ_ISA_M_OF_P_CONST)*altitude));
100 }
101 
102 #endif /* PPRZ_ISA_H */
#define PPRZ_ISA_GRAVITY
Definition: pprz_isa.h:46
#define PPRZ_ISA_SEA_LEVEL_PRESSURE
Definition: pprz_isa.h:43
static float pprz_isa_height_of_pressure(float pressure, float ref)
Get relative altitude from pressure (using simplified equation).
Definition: pprz_isa.h:73
#define PPRZ_ISA_SEA_LEVEL_TEMP
Definition: pprz_isa.h:44
uint16_t ref[TCOUPLE_NB]
static float pprz_isa_pressure_of_altitude(float altitude)
Get pressure in Pa from absolute altitude (using simplified equation).
Definition: pprz_isa.h:87
static float pprz_isa_pressure_of_height(float altitude, float ref)
Get pressure in Pa from height (using simplified equation).
Definition: pprz_isa.h:98
static float pprz_isa_altitude_of_pressure(float pressure)
Get absolute altitude from pressure (using simplified equation).
Definition: pprz_isa.h:58
#define PPRZ_ISA_AIR_GAS_CONSTANT
Definition: pprz_isa.h:47
static const float PPRZ_ISA_M_OF_P_CONST
Definition: pprz_isa.h:49