Paparazzi UAS  v5.18.0_stable
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_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 }
NpsSensorBaro
Definition: nps_sensor_baro.h:9
NpsSensorBaro::data_available
bool data_available
Definition: nps_sensor_baro.h:13
nps_fdm.h
NpsSensorBaro::next_update
double next_update
Definition: nps_sensor_baro.h:12
fdm
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
Definition: nps_fdm_crrcsim.c:84
std.h
nps_random.h
nps_sensor_baro.h
nps_sensor_baro_init
void nps_sensor_baro_init(struct NpsSensorBaro *baro, double time)
Definition: nps_sensor_baro.c:14
NPS_BARO_NOISE_STD_DEV
#define NPS_BARO_NOISE_STD_DEV
Definition: nps_sensor_baro.c:11
nps_sensor_baro_run_step
void nps_sensor_baro_run_step(struct NpsSensorBaro *baro, double time)
Definition: nps_sensor_baro.c:23
get_gaussian_noise
double get_gaussian_noise(void)
Definition: nps_random.c:109
NpsFdm::pressure
double pressure
current (static) atmospheric pressure in Pascal
Definition: nps_fdm.h:110
NpsSensorBaro::value
double value
pressure in Pascal
Definition: nps_sensor_baro.h:10
FALSE
#define FALSE
Definition: std.h:5
TRUE
#define TRUE
Definition: std.h:4
NpsSensorBaro::noise_std_dev
double noise_std_dev
noise standard deviation
Definition: nps_sensor_baro.h:11