Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
nps_sensor_temperature.c
Go to the documentation of this file.
1
#include "
nps_sensor_temperature.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
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.;
22
temperature->
noise_std_dev
=
NPS_TEMPERATURE_NOISE_STD_DEV
;
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
}
NPS_TEMPERATURE_NOISE_STD_DEV
#define NPS_TEMPERATURE_NOISE_STD_DEV
Definition:
nps_sensor_temperature.c:16
nps_fdm.h
nps_sensor_temperature.h
fdm
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
Definition:
nps_fdm_crrcsim.c:84
NPS_TEMPERATURE_DT
#define NPS_TEMPERATURE_DT
10Hz default
Definition:
nps_sensor_temperature.c:12
std.h
nps_random.h
NpsSensorTemperature::noise_std_dev
double noise_std_dev
noise standard deviation
Definition:
nps_sensor_temperature.h:11
NpsSensorTemperature::value
double value
temperature in degrees Celcius
Definition:
nps_sensor_temperature.h:10
nps_sensor_temperature_init
void nps_sensor_temperature_init(struct NpsSensorTemperature *temperature, double time)
Definition:
nps_sensor_temperature.c:19
NpsSensorTemperature::data_available
bool data_available
Definition:
nps_sensor_temperature.h:13
NpsSensorTemperature
Definition:
nps_sensor_temperature.h:9
NpsSensorTemperature::next_update
double next_update
Definition:
nps_sensor_temperature.h:12
get_gaussian_noise
double get_gaussian_noise(void)
Definition:
nps_random.c:109
nps_sensor_temperature_run_step
void nps_sensor_temperature_run_step(struct NpsSensorTemperature *temperature, double time)
Definition:
nps_sensor_temperature.c:28
NpsFdm::temperature
double temperature
current temperature in degrees Celcius
Definition:
nps_fdm.h:113
FALSE
#define FALSE
Definition:
std.h:5
TRUE
#define TRUE
Definition:
std.h:4
sw
simulator
nps
nps_sensor_temperature.c
Generated on Tue Feb 1 2022 13:51:18 for Paparazzi UAS by
1.8.17