Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
ins_flow.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Guido de Croon <g.c.h.e.decroon@tudelft.nl>
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 
28 #ifndef INS_FLOW_H
29 #define INS_FLOW_H
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #define CONSTANT_ALT_FILTER 1
36 #define OF_DRAG 1
37 // Only for constant alt for now!
38 #define OF_TWO_DIM 1
39 // Only for changing alt
40 #define OF_THRUST_BIAS 0
41 // Whether to use gyros:
42 #define OF_USE_GYROS 1
43 // Predicting gyros with roll command and optic flow (normally 0):
44 #define PREDICT_GYROS 0
45 
46 #if CONSTANT_ALT_FILTER == 1
47 
48 #if OF_TWO_DIM == 0
49 
50 
51 #define OF_V_IND 0
52 #define OF_ANGLE_IND 1
53 #define OF_Z_IND 2
54 #define OF_ANGLE_DOT_IND 3
55 #if OF_USE_GYROS == 1
56 #define N_MEAS_OF_KF 3
57 #else
58 // gyros not used at all
59 #define N_MEAS_OF_KF 2
60 #endif
61 
62 #define OF_THETA_IND -1
63 #define OF_VX_IND -1
64 
65 #if OF_THRUST_BIAS == 0
66 #define N_STATES_OF_KF 4
67 #define OF_THRUST_BIAS_IND -1
68 #else
69 // does this work with thrust bias?
70 #define N_STATES_OF_KF 5
71 #define OF_THRUST_BIAS_IND 4
72 #endif
73 
74 #else
75 #define N_STATES_OF_KF 6
76 #define OF_V_IND 0
77 #define OF_ANGLE_IND 1
78 #define OF_Z_IND 2
79 #define OF_THETA_IND 3
80 #define OF_VX_IND 4
81 #define OF_ANGLE_DOT_IND 5
82 // TODO: also a theta dot ind?
83 
84 
85 #define OF_THRUST_BIAS_IND -1
86 
87 // the third measurement here is the other lateral flow:
88 #if OF_USE_GYROS == 1
89 // gyros used in the prediction and measurement
90 #define N_MEAS_OF_KF 4
91 #else
92 // gyros not used at all
93 #define N_MEAS_OF_KF 3
94 #endif
95 #endif
96 
97 #define OF_Z_DOT_IND -1
98 #else
99 #if OF_THRUST_BIAS == 0
100 #define N_STATES_OF_KF 5
101 #define OF_THRUST_BIAS_IND -1
102 #else
103 #define N_STATES_OF_KF 6
104 #define OF_THRUST_BIAS_IND 5
105 #endif
106 
107 #define OF_V_IND 0
108 #define OF_ANGLE_IND 1
109 #define OF_ANGLE_DOT_IND 2
110 #define OF_Z_IND 3
111 #define OF_Z_DOT_IND 4
112 
113 #define OF_THETA_IND -1
114 #define OF_VX_IND -1
115 
116 
117 #if OF_USE_GYROS == 1
118 // gyros used in the prediction and measurement
119 #define N_MEAS_OF_KF 3
120 #else
121 // gyros not used at all
122 #define N_MEAS_OF_KF 2
123 #endif
124 
125 #endif
126 
127 // TODO: make these parameters in the estimation scheme:
128 #define OF_TB_Q 0.02
129 #define OF_TB_P 0.5
130 
131 
132 #define OF_LAT_FLOW_IND 0
133 #define OF_DIV_FLOW_IND 1
134 #define OF_RATE_IND 2
135 #if OF_USE_GYROS == 1
136 #define OF_LAT_FLOW_X_IND 3
137 #else
138 #define OF_LAT_FLOW_X_IND 2
139 #endif
140 
141 
142 // use filter to different extents:
143 #define USE_ANGLE 1
144 #define USE_VELOCITY 2
145 #define USE_HEIGHT 3
146 
147 
148 #include "modules/ahrs/ahrs.h"
151 #include "modules/ins/ins.h"
152 
153 extern void ins_flow_init(void);
154 extern void ins_flow_update(void);
155 
156 extern float OF_X[N_STATES_OF_KF];
157 extern bool reset_filter;
158 extern bool run_filter;
159 extern int use_filter;
160 extern float thrust_factor;
161 extern float GT_phi;
162 extern float GT_theta;
163 
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* INS_FLOW_H */
Dispatcher to register actual AHRS implementations.
Interface to align the AHRS via low-passed measurements at startup.
Quaternion complementary filter (fixed-point).
Integrated Navigation System interface.
int use_filter
Definition: ins_flow.c:190
float GT_theta
Definition: ins_flow.c:196
bool run_filter
Definition: ins_flow.c:191
void ins_flow_init(void)
Definition: ins_flow.c:537
float OF_X[N_STATES_OF_KF]
Definition: ins_flow.c:177
float thrust_factor
Definition: ins_flow.c:193
void ins_flow_update(void)
Definition: ins_flow.c:732
bool reset_filter
Definition: ins_flow.c:189
float GT_phi
Definition: ins_flow.c:195
#define N_STATES_OF_KF
Definition: ins_flow.h:75