Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
nps_sensor_airspeed.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2014 Felix Ruess <felix.ruess@gmail.com
3
*
4
* This file is part of paparazzi.
5
*
6
* paparazzi is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* paparazzi is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with paparazzi; see the file COPYING. If not, write to
18
* the Free Software Foundation, 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
20
*/
21
29
#include "
nps_sensor_airspeed.h
"
30
31
#include "generated/airframe.h"
32
33
#include "
std.h
"
34
#include "
nps_fdm.h
"
35
#include "
nps_random.h
"
36
#include NPS_SENSORS_PARAMS
37
39
#ifndef NPS_AIRSPEED_DT
40
#define NPS_AIRSPEED_DT 0.01
41
#endif
42
44
#ifndef NPS_AIRSPEED_NOISE_STD_DEV
45
#define NPS_AIRSPEED_NOISE_STD_DEV 0.1
46
#endif
47
48
#ifndef NPS_AIRSPEED_OFFSET
49
#define NPS_AIRSPEED_OFFSET 0
50
#endif
51
52
53
void
nps_sensor_airspeed_init
(
struct
NpsSensorAirspeed
*airspeed,
double
time)
54
{
55
airspeed->
value
= 0.;
56
airspeed->
offset
=
NPS_AIRSPEED_OFFSET
;
57
airspeed->
noise_std_dev
=
NPS_AIRSPEED_NOISE_STD_DEV
;
58
airspeed->
next_update
= time;
59
airspeed->
data_available
=
FALSE
;
60
}
61
62
63
void
nps_sensor_airspeed_run_step
(
struct
NpsSensorAirspeed
*airspeed,
double
time)
64
{
65
66
if
(time < airspeed->next_update) {
67
return
;
68
}
69
70
/* equivalent airspeed + sensor offset */
71
airspeed->
value
=
fdm
.
airspeed
+ airspeed->
offset
;
72
/* add noise with std dev meters/second */
73
airspeed->
value
+=
get_gaussian_noise
() * airspeed->
noise_std_dev
;
74
/* can't be negative, min is zero */
75
if
(airspeed->
value
< 0) {
76
airspeed->
value
= 0.0;
77
}
78
79
airspeed->
next_update
+=
NPS_AIRSPEED_DT
;
80
airspeed->
data_available
=
TRUE
;
81
}
NPS_AIRSPEED_DT
#define NPS_AIRSPEED_DT
10Hz default
Definition:
nps_sensor_airspeed.c:40
NpsSensorAirspeed
Definition:
nps_sensor_airspeed.h:37
nps_sensor_airspeed_init
void nps_sensor_airspeed_init(struct NpsSensorAirspeed *airspeed, double time)
Definition:
nps_sensor_airspeed.c:53
NpsFdm::airspeed
double airspeed
equivalent airspeed in m/s
Definition:
nps_fdm.h:109
NpsSensorAirspeed::offset
double offset
offset in meters/second
Definition:
nps_sensor_airspeed.h:39
NPS_AIRSPEED_NOISE_STD_DEV
#define NPS_AIRSPEED_NOISE_STD_DEV
standard deviation in meters/second (default 0.1 m/s)
Definition:
nps_sensor_airspeed.c:45
nps_fdm.h
fdm
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
Definition:
nps_fdm_crrcsim.c:84
std.h
NPS_AIRSPEED_OFFSET
#define NPS_AIRSPEED_OFFSET
Definition:
nps_sensor_airspeed.c:49
nps_random.h
NpsSensorAirspeed::value
double value
airspeed reading in meters/second
Definition:
nps_sensor_airspeed.h:38
nps_sensor_airspeed_run_step
void nps_sensor_airspeed_run_step(struct NpsSensorAirspeed *airspeed, double time)
Definition:
nps_sensor_airspeed.c:63
get_gaussian_noise
double get_gaussian_noise(void)
Definition:
nps_random.c:109
nps_sensor_airspeed.h
NpsSensorAirspeed::next_update
double next_update
Definition:
nps_sensor_airspeed.h:41
NpsSensorAirspeed::data_available
bool data_available
Definition:
nps_sensor_airspeed.h:42
FALSE
#define FALSE
Definition:
std.h:5
TRUE
#define TRUE
Definition:
std.h:4
NpsSensorAirspeed::noise_std_dev
double noise_std_dev
noise standard deviation
Definition:
nps_sensor_airspeed.h:40
sw
simulator
nps
nps_sensor_airspeed.c
Generated on Tue Feb 1 2022 13:51:18 for Paparazzi UAS by
1.8.17