Paparazzi UAS  v5.15_devel-88-gb3ad7fe
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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_PARAMS
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 
28 void nps_sensor_temperature_run_step(struct NpsSensorTemperature *temperature, double time)
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 }
#define NPS_TEMPERATURE_NOISE_STD_DEV
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 noise_std_dev
noise standard deviation
void nps_sensor_temperature_init(struct NpsSensorTemperature *temperature, double time)
double value
temperature in degrees Celcius
#define NPS_TEMPERATURE_DT
10Hz default
void nps_sensor_temperature_run_step(struct NpsSensorTemperature *temperature, double time)
double temperature
current temperature in degrees Celcius
Definition: nps_fdm.h:113