Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nps_sensor_aoa.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Johan Maurin, Gautier Hattenberger
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
28 #include "nps_sensor_aoa.h"
29 
30 #include "generated/airframe.h"
31 
32 #include "std.h"
33 #include "nps_fdm.h"
34 #include "nps_random.h"
35 #include NPS_SENSORS_PARAMS
36 
38 #ifndef NPS_AOA_DT
39 #define NPS_AOA_DT 0.01
40 #endif
41 
43 #ifndef NPS_AOA_NOISE_STD_DEV
44 #define NPS_AOA_NOISE_STD_DEV 0.001
45 #endif
46 
47 #ifndef NPS_AOA_OFFSET
48 #define NPS_AOA_OFFSET 0
49 #endif
50 
51 
52 void nps_sensor_aoa_init(struct NpsSensorAngleOfAttack *aoa, double time)
53 {
54  aoa->value = 0.;
55  aoa->offset = NPS_AOA_OFFSET;
57  aoa->next_update = time;
58  aoa->data_available = FALSE;
59 }
60 
61 
62 void nps_sensor_aoa_run_step(struct NpsSensorAngleOfAttack *aoa, double time)
63 {
64 
65  if (time < aoa->next_update) {
66  return;
67  }
68 
69  /* equivalent airspeed + sensor offset */
70  aoa->value = fdm.aoa + aoa->offset;
71  /* add noise with std dev rad */
72  aoa->value += get_gaussian_noise() * aoa->noise_std_dev;
73 
74  aoa->next_update += NPS_AOA_DT;
75  aoa->data_available = TRUE;
76 }
77 
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
#define NPS_AOA_DT
10Hz default
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
Simulated Angle Of Attack of the Wind for NPS simulator.
#define NPS_AOA_NOISE_STD_DEV
standard deviation in radian (default 0.001 rad)
void nps_sensor_aoa_run_step(struct NpsSensorAngleOfAttack *aoa, double time)
double value
angle of attack reading in radian
double offset
offset in meters/second
#define NPS_AOA_OFFSET
void nps_sensor_aoa_init(struct NpsSensorAngleOfAttack *aoa, double time)
double aoa
angle of attack in rad
Definition: nps_fdm.h:115