Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nps_sensor_baro.c
Go to the documentation of this file.
1 #include "nps_sensor_baro.h"
2 
3 #include "generated/airframe.h"
4 
5 #include "std.h"
6 #include "nps_fdm.h"
7 #include "nps_random.h"
8 #include NPS_SENSORS_PARAMS
9 
10 #ifndef NPS_BARO_NOISE_STD_DEV
11 #define NPS_BARO_NOISE_STD_DEV 0.
12 #endif
13 
14 void nps_sensor_baro_init(struct NpsSensorBaro *baro, double time)
15 {
16  baro->value = 0.;
18  baro->next_update = time;
19  baro->data_available = FALSE;
20 }
21 
22 
23 void nps_sensor_baro_run_step(struct NpsSensorBaro *baro, double time)
24 {
25  if (time < baro->next_update) {
26  return;
27  }
28 
29  /* pressure in Pascal */
30  baro->value = fdm.pressure;
31  /* add noise with std dev Pascal */
32  baro->value += get_gaussian_noise() * baro->noise_std_dev;
33 
34  baro->next_update += NPS_BARO_DT;
35  baro->data_available = TRUE;
36 }
#define NPS_BARO_NOISE_STD_DEV
void nps_sensor_baro_run_step(struct NpsSensorBaro *baro, double time)
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
double get_gaussian_noise(void)
Definition: nps_random.c:109
#define FALSE
Definition: std.h:5
#define TRUE
Definition: std.h:4
double pressure
current (static) atmospheric pressure in Pascal
Definition: nps_fdm.h:110
double value
pressure in Pascal
void nps_sensor_baro_init(struct NpsSensorBaro *baro, double time)
double noise_std_dev
noise standard deviation