Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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.h"
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 }
double pressure
current (static) atmospheric pressure in Pascal
Definition: nps_fdm.h:110
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
double get_gaussian_noise(void)
Definition: nps_random.c:109
void nps_sensor_baro_init(struct NpsSensorBaro *baro, double time)
void nps_sensor_baro_run_step(struct NpsSensorBaro *baro, double time)
#define NPS_BARO_NOISE_STD_DEV
double noise_std_dev
noise standard deviation
double value
pressure in Pascal
#define TRUE
Definition: std.h:4
#define FALSE
Definition: std.h:5