Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
nps_sensor_temperature.c
Go to the documentation of this file.
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 
11 #ifndef NPS_TEMPERATURE_DT
12 #define NPS_TEMPERATURE_DT 0.01
13 #endif
14 
15 #ifndef NPS_TEMPERATURE_NOISE_STD_DEV
16 #define NPS_TEMPERATURE_NOISE_STD_DEV 0.1
17 #endif
18 
19 void nps_sensor_temperature_init(struct NpsSensorTemperature *temperature, double time)
20 {
21  temperature->value = 0.;
23  temperature->next_update = time;
24  temperature->data_available = FALSE;
25 }
26 
27 
29 {
30  if (time < temperature->next_update) {
31  return;
32  }
33 
34  /* termperature in degrees Celcius */
35  temperature->value = fdm.temperature;
36  /* add noise with std dev */
37  temperature->value += get_gaussian_noise() * temperature->noise_std_dev;
38 
39  temperature->next_update += NPS_TEMPERATURE_DT;
40  temperature->data_available = TRUE;
41 }
double temperature
current temperature in degrees Celcius
Definition: nps_fdm.h:113
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
double get_gaussian_noise(void)
Definition: nps_random.c:109
void nps_sensor_temperature_init(struct NpsSensorTemperature *temperature, double time)
#define NPS_TEMPERATURE_DT
10Hz default
void nps_sensor_temperature_run_step(struct NpsSensorTemperature *temperature, double time)
#define NPS_TEMPERATURE_NOISE_STD_DEV
double noise_std_dev
noise standard deviation
double value
temperature in degrees Celcius
#define TRUE
Definition: std.h:4
#define FALSE
Definition: std.h:5