35 #include "generated/airframe.h"
38 #ifndef DEBUG_VFF_EXTENDED
39 #define DEBUG_VFF_EXTENDED 0
44 #if DEBUG_VFF_EXTENDED
51 #ifndef VFF_EXTENDED_INIT_PXX
52 #define VFF_EXTENDED_INIT_PXX 1.0
56 #ifndef VFF_EXTENDED_ACCEL_NOISE
57 #define VFF_EXTENDED_ACCEL_NOISE 0.5
60 #define Qbiasbias 1e-7
68 #if PERIODIC_TELEMETRY
73 pprz_msg_send_VFF_EXTENDED(trans, dev, AC_ID,
85 void vff_init(
float init_z,
float init_zdot,
float init_accel_bias,
float init_baro_offset)
99 #if PERIODIC_TELEMETRY
134 const float FPF00 =
vff.
P[0][0] + dt * (
vff.
P[1][0] +
vff.
P[0][1] + dt *
vff.
P[1][1]);
135 const float FPF01 =
vff.
P[0][1] + dt * (
vff.
P[1][1] -
vff.
P[0][2] - dt *
vff.
P[1][2]);
136 const float FPF02 =
vff.
P[0][2] + dt * (
vff.
P[1][2]);
137 const float FPF10 =
vff.
P[1][0] + dt * (-
vff.
P[2][0] +
vff.
P[1][1] - dt *
vff.
P[2][1]);
138 const float FPF11 =
vff.
P[1][1] + dt * (-
vff.
P[2][1] -
vff.
P[1][2] + dt *
vff.
P[2][2]);
139 const float FPF12 =
vff.
P[1][2] + dt * (-
vff.
P[2][2]);
140 const float FPF20 =
vff.
P[2][0] + dt * (
vff.
P[2][1]);
141 const float FPF21 =
vff.
P[2][1] + dt * (-
vff.
P[2][2]);
142 const float FPF22 =
vff.
P[2][2];
143 const float FPF33 =
vff.
P[3][3];
156 #if DEBUG_VFF_EXTENDED
181 const float S =
vff.
P[0][0] -
vff.
P[0][3] -
vff.
P[3][0] +
vff.
P[3][3] + conf;
182 const float K0 = (
vff.
P[0][0] -
vff.
P[0][3]) * 1 / S;
183 const float K1 = (
vff.
P[1][0] -
vff.
P[1][3]) * 1 / S;
184 const float K2 = (
vff.
P[2][0] -
vff.
P[2][3]) * 1 / S;
185 const float K3 = (
vff.
P[3][0] -
vff.
P[3][3]) * 1 / S;
192 const float P0 =
vff.
P[0][0] -
vff.
P[3][0];
193 const float P1 =
vff.
P[0][1] -
vff.
P[3][1];
194 const float P2 =
vff.
P[0][2] -
vff.
P[3][2];
195 const float P3 =
vff.
P[0][3] -
vff.
P[3][3];
197 vff.
P[0][0] -= K0 * P0;
198 vff.
P[0][1] -= K0 * P1;
199 vff.
P[0][2] -= K0 * P2;
200 vff.
P[0][3] -= K0 * P3;
201 vff.
P[1][0] -= K1 * P0;
202 vff.
P[1][1] -= K1 * P1;
203 vff.
P[1][2] -= K1 * P2;
204 vff.
P[1][3] -= K1 * P3;
205 vff.
P[2][0] -= K2 * P0;
206 vff.
P[2][1] -= K2 * P1;
207 vff.
P[2][2] -= K2 * P2;
208 vff.
P[2][3] -= K2 * P3;
209 vff.
P[3][0] -= K3 * P0;
210 vff.
P[3][1] -= K3 * P1;
211 vff.
P[3][2] -= K3 * P2;
212 vff.
P[3][3] -= K3 * P3;
244 const float y = z_meas -
vff.
z;
245 const float S =
vff.
P[0][0] + conf;
246 const float K0 =
vff.
P[0][0] * 1 / S;
247 const float K1 =
vff.
P[1][0] * 1 / S;
248 const float K2 =
vff.
P[2][0] * 1 / S;
249 const float K3 =
vff.
P[3][0] * 1 / S;
256 const float P0 =
vff.
P[0][0];
257 const float P1 =
vff.
P[0][1];
258 const float P2 =
vff.
P[0][2];
259 const float P3 =
vff.
P[0][3];
261 vff.
P[0][0] -= K0 * P0;
262 vff.
P[0][1] -= K0 * P1;
263 vff.
P[0][2] -= K0 * P2;
264 vff.
P[0][3] -= K0 * P3;
265 vff.
P[1][0] -= K1 * P0;
266 vff.
P[1][1] -= K1 * P1;
267 vff.
P[1][2] -= K1 * P2;
268 vff.
P[1][3] -= K1 * P3;
269 vff.
P[2][0] -= K2 * P0;
270 vff.
P[2][1] -= K2 * P1;
271 vff.
P[2][2] -= K2 * P2;
272 vff.
P[2][3] -= K2 * P3;
273 vff.
P[3][0] -= K3 * P0;
274 vff.
P[3][1] -= K3 * P1;
275 vff.
P[3][2] -= K3 * P2;
276 vff.
P[3][3] -= K3 * P3;
307 const float S =
vff.
P[3][3] + conf;
308 const float K0 =
vff.
P[0][3] * 1 / S;
309 const float K1 =
vff.
P[1][3] * 1 / S;
310 const float K2 =
vff.
P[2][3] * 1 / S;
311 const float K3 =
vff.
P[3][3] * 1 / S;
318 const float P0 =
vff.
P[3][0];
319 const float P1 =
vff.
P[3][1];
320 const float P2 =
vff.
P[3][2];
321 const float P3 =
vff.
P[3][3];
323 vff.
P[0][0] -= K0 * P0;
324 vff.
P[0][1] -= K0 * P1;
325 vff.
P[0][2] -= K0 * P2;
326 vff.
P[0][3] -= K0 * P3;
327 vff.
P[1][0] -= K1 * P0;
328 vff.
P[1][1] -= K1 * P1;
329 vff.
P[1][2] -= K1 * P2;
330 vff.
P[1][3] -= K1 * P3;
331 vff.
P[2][0] -= K2 * P0;
332 vff.
P[2][1] -= K2 * P1;
333 vff.
P[2][2] -= K2 * P2;
334 vff.
P[2][3] -= K2 * P3;
335 vff.
P[3][0] -= K3 * P0;
336 vff.
P[3][1] -= K3 * P1;
337 vff.
P[3][2] -= K3 * P2;
338 vff.
P[3][3] -= K3 * P3;
#define VFF_EXTENDED_ACCEL_NOISE
process noise covariance Q
static void update_baro_conf(float z_meas, float conf)
Update sensor "with" offset (baro).
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define VFF_EXTENDED_INIT_PXX
initial covariance diagonal
float P[VFF_STATE_SIZE][VFF_STATE_SIZE]
covariance matrix
void vff_update_z_conf(float z_meas, float conf)
Generic transmission transport header.
Interface for extended vertical filter (in float).
Periodic telemetry system header (includes downlink utility and generated code).
float bias
accel bias estimate in m/s^2
float z
z-position estimate in m (NED, z-down)
static void update_offset_conf(float offset, float conf)
Update sensor offset (baro).
void vff_update_z(float z_meas)
void vff_update_baro_conf(float z_meas, float conf)
static void update_alt_conf(float z_meas, float conf)
Update sensor "without" offset (gps, sonar) H = [1 0 0 0]; // state residual y = rangemeter - H * Xm;...
float offset
baro offset estimate
void vff_update_offset(float offset)
#define DefaultPeriodic
Set default periodic telemetry.
float zdotdot
z-acceleration in m/s^2 (NED, z-down)
void vff_propagate(float accel, float dt)
Propagate the filter in time.
static const struct usb_device_descriptor dev
#define DefaultChannel
SITL.
void vff_realign(float z_meas)
float z_meas
last z measurement in m
float zdot
z-velocity estimate in m/s (NED, z-down)
Common code for AP and FBW telemetry.
void vff_update_baro(float z_meas)
float z_meas_baro
last z measurement from baro in m
void vff_init(float init_z, float init_zdot, float init_accel_bias, float init_baro_offset)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
#define DEBUG_VFF_EXTENDED