Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
nps_sensor_sideslip.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_sideslip.h"
29 
30 #include "generated/airframe.h"
31 #include <math.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_SIDESLIP_DT
40 #define NPS_SIDESLIP_DT 0.01
41 #endif
42 
44 #ifndef NPS_SIDESLIP_NOISE_STD_DEV
45 #define NPS_SIDESLIP_NOISE_STD_DEV 0.001
46 #endif
47 
48 #ifndef NPS_SIDESLIP_OFFSET
49 #define NPS_SIDESLIP_OFFSET 0
50 #endif
51 
52 
53 void nps_sensor_sideslip_init(struct NpsSensorSideSlip *sideslip, double time)
54 {
55  sideslip->value = 0.;
56  sideslip->offset = NPS_SIDESLIP_OFFSET;
58  sideslip->next_update = time;
59  sideslip->data_available = FALSE;
60 }
61 
62 
63 void nps_sensor_sideslip_run_step(struct NpsSensorSideSlip *sideslip, double time)
64 {
65 
66  if (time < sideslip->next_update) {
67  return;
68  }
69 
70  /* equivalent airspeed + sensor offset */
71  sideslip->value = fdm.sideslip + sideslip->offset;
72  /* add noise with std dev rad */
73  sideslip->value += get_gaussian_noise() * sideslip->noise_std_dev;
74 
75  sideslip->next_update += NPS_SIDESLIP_DT;
76  sideslip->data_available = TRUE;
77 }
78 
NpsFdm::sideslip
double sideslip
sideslip angle in rad
Definition: nps_fdm.h:116
NpsSensorSideSlip::value
double value
sideslip reading in radian
Definition: nps_sensor_sideslip.h:37
nps_fdm.h
NpsSensorSideSlip::next_update
double next_update
Definition: nps_sensor_sideslip.h:40
nps_sensor_sideslip_run_step
void nps_sensor_sideslip_run_step(struct NpsSensorSideSlip *sideslip, double time)
Definition: nps_sensor_sideslip.c:63
NPS_SIDESLIP_DT
#define NPS_SIDESLIP_DT
10Hz default
Definition: nps_sensor_sideslip.c:40
fdm
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
Definition: nps_fdm_crrcsim.c:84
std.h
nps_random.h
NpsSensorSideSlip::offset
double offset
offset in meters/second
Definition: nps_sensor_sideslip.h:38
NPS_SIDESLIP_OFFSET
#define NPS_SIDESLIP_OFFSET
Definition: nps_sensor_sideslip.c:49
NpsSensorSideSlip::noise_std_dev
double noise_std_dev
noise standard deviation
Definition: nps_sensor_sideslip.h:39
get_gaussian_noise
double get_gaussian_noise(void)
Definition: nps_random.c:109
nps_sensor_sideslip.h
NpsSensorSideSlip
Definition: nps_sensor_sideslip.h:36
FALSE
#define FALSE
Definition: std.h:5
TRUE
#define TRUE
Definition: std.h:4
NpsSensorSideSlip::data_available
bool data_available
Definition: nps_sensor_sideslip.h:41
nps_sensor_sideslip_init
void nps_sensor_sideslip_init(struct NpsSensorSideSlip *sideslip, double time)
Definition: nps_sensor_sideslip.c:53
NPS_SIDESLIP_NOISE_STD_DEV
#define NPS_SIDESLIP_NOISE_STD_DEV
standard deviation in radian (default 0.001 rad)
Definition: nps_sensor_sideslip.c:45