35 #include "generated/airframe.h"
38 #ifndef DEBUG_VFF_EXTENDED
39 #define DEBUG_VFF_EXTENDED 0
44 #if DEBUG_VFF_EXTENDED
46 #include "pprzlink/messages.h"
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
71 static void send_vffe(
struct transport_tx *trans,
struct link_device *
dev)
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)
104 #if PERIODIC_TELEMETRY
139 const float FPF00 =
vff.
P[0][0] + dt * (
vff.
P[1][0] +
vff.
P[0][1] + dt *
vff.
P[1][1]);
140 const float FPF01 =
vff.
P[0][1] + dt * (
vff.
P[1][1] -
vff.
P[0][2] - dt *
vff.
P[1][2]);
141 const float FPF02 =
vff.
P[0][2] + dt * (
vff.
P[1][2]);
142 const float FPF10 =
vff.
P[1][0] + dt * (-
vff.
P[2][0] +
vff.
P[1][1] - dt *
vff.
P[2][1]);
143 const float FPF11 =
vff.
P[1][1] + dt * (-
vff.
P[2][1] -
vff.
P[1][2] + dt *
vff.
P[2][2]);
144 const float FPF12 =
vff.
P[1][2] + dt * (-
vff.
P[2][2]);
145 const float FPF20 =
vff.
P[2][0] + dt * (
vff.
P[2][1]);
146 const float FPF21 =
vff.
P[2][1] + dt * (-
vff.
P[2][2]);
147 const float FPF22 =
vff.
P[2][2];
148 const float FPF33 =
vff.
P[3][3];
161 #if DEBUG_VFF_EXTENDED
186 const float S =
vff.
P[0][0] -
vff.
P[0][3] -
vff.
P[3][0] +
vff.
P[3][3] + conf;
187 const float K0 = (
vff.
P[0][0] -
vff.
P[0][3]) * 1 / S;
188 const float K1 = (
vff.
P[1][0] -
vff.
P[1][3]) * 1 / S;
189 const float K2 = (
vff.
P[2][0] -
vff.
P[2][3]) * 1 / S;
190 const float K3 = (
vff.
P[3][0] -
vff.
P[3][3]) * 1 / S;
197 const float P0 =
vff.
P[0][0] -
vff.
P[3][0];
198 const float P1 =
vff.
P[0][1] -
vff.
P[3][1];
199 const float P2 =
vff.
P[0][2] -
vff.
P[3][2];
200 const float P3 =
vff.
P[0][3] -
vff.
P[3][3];
202 vff.
P[0][0] -= K0 * P0;
203 vff.
P[0][1] -= K0 * P1;
204 vff.
P[0][2] -= K0 * P2;
205 vff.
P[0][3] -= K0 * P3;
206 vff.
P[1][0] -= K1 * P0;
207 vff.
P[1][1] -= K1 * P1;
208 vff.
P[1][2] -= K1 * P2;
209 vff.
P[1][3] -= K1 * P3;
210 vff.
P[2][0] -= K2 * P0;
211 vff.
P[2][1] -= K2 * P1;
212 vff.
P[2][2] -= K2 * P2;
213 vff.
P[2][3] -= K2 * P3;
214 vff.
P[3][0] -= K3 * P0;
215 vff.
P[3][1] -= K3 * P1;
216 vff.
P[3][2] -= K3 * P2;
217 vff.
P[3][3] -= K3 * P3;
249 const float y = z_meas -
vff.
z;
250 const float S =
vff.
P[0][0] + conf;
251 const float K0 =
vff.
P[0][0] * 1 / S;
252 const float K1 =
vff.
P[1][0] * 1 / S;
253 const float K2 =
vff.
P[2][0] * 1 / S;
254 const float K3 =
vff.
P[3][0] * 1 / S;
261 const float P0 =
vff.
P[0][0];
262 const float P1 =
vff.
P[0][1];
263 const float P2 =
vff.
P[0][2];
264 const float P3 =
vff.
P[0][3];
266 vff.
P[0][0] -= K0 * P0;
267 vff.
P[0][1] -= K0 * P1;
268 vff.
P[0][2] -= K0 * P2;
269 vff.
P[0][3] -= K0 * P3;
270 vff.
P[1][0] -= K1 * P0;
271 vff.
P[1][1] -= K1 * P1;
272 vff.
P[1][2] -= K1 * P2;
273 vff.
P[1][3] -= K1 * P3;
274 vff.
P[2][0] -= K2 * P0;
275 vff.
P[2][1] -= K2 * P1;
276 vff.
P[2][2] -= K2 * P2;
277 vff.
P[2][3] -= K2 * P3;
278 vff.
P[3][0] -= K3 * P0;
279 vff.
P[3][1] -= K3 * P1;
280 vff.
P[3][2] -= K3 * P2;
281 vff.
P[3][3] -= K3 * P3;
312 const float S =
vff.
P[3][3] + conf;
313 const float K0 =
vff.
P[0][3] * 1 / S;
314 const float K1 =
vff.
P[1][3] * 1 / S;
315 const float K2 =
vff.
P[2][3] * 1 / S;
316 const float K3 =
vff.
P[3][3] * 1 / S;
323 const float P0 =
vff.
P[3][0];
324 const float P1 =
vff.
P[3][1];
325 const float P2 =
vff.
P[3][2];
326 const float P3 =
vff.
P[3][3];
328 vff.
P[0][0] -= K0 * P0;
329 vff.
P[0][1] -= K0 * P1;
330 vff.
P[0][2] -= K0 * P2;
331 vff.
P[0][3] -= K0 * P3;
332 vff.
P[1][0] -= K1 * P0;
333 vff.
P[1][1] -= K1 * P1;
334 vff.
P[1][2] -= K1 * P2;
335 vff.
P[1][3] -= K1 * P3;
336 vff.
P[2][0] -= K2 * P0;
337 vff.
P[2][1] -= K2 * P1;
338 vff.
P[2][2] -= K2 * P2;
339 vff.
P[2][3] -= K2 * P3;
340 vff.
P[3][0] -= K3 * P0;
341 vff.
P[3][1] -= K3 * P1;
342 vff.
P[3][2] -= K3 * P2;
343 vff.
P[3][3] -= K3 * P3;
376 const float yd = vz -
vff.
zdot;
377 const float S =
vff.
P[1][1] + conf;
378 const float K0 =
vff.
P[0][1] * 1 / S;
379 const float K1 =
vff.
P[1][1] * 1 / S;
380 const float K2 =
vff.
P[2][1] * 1 / S;
381 const float K3 =
vff.
P[3][1] * 1 / S;
388 const float P0 =
vff.
P[1][0];
389 const float P1 =
vff.
P[1][1];
390 const float P2 =
vff.
P[1][2];
391 const float P3 =
vff.
P[1][3];
393 vff.
P[0][0] -= K0 * P0;
394 vff.
P[0][1] -= K0 * P1;
395 vff.
P[0][2] -= K0 * P2;
396 vff.
P[0][3] -= K0 * P3;
397 vff.
P[1][0] -= K1 * P0;
398 vff.
P[1][1] -= K1 * P1;
399 vff.
P[1][2] -= K1 * P2;
400 vff.
P[1][3] -= K1 * P3;
401 vff.
P[2][0] -= K2 * P0;
402 vff.
P[2][1] -= K2 * P1;
403 vff.
P[2][2] -= K2 * P2;
404 vff.
P[2][3] -= K2 * P3;
405 vff.
P[3][0] -= K3 * P0;
406 vff.
P[3][1] -= K3 * P1;
407 vff.
P[3][2] -= K3 * P2;
408 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)
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
void vff_update_vz_conf(float vz_meas, float conf)
float z
z-position estimate in m (NED, z-down)
static void update_vz_conf(float vz, float conf)
static void send_vffe(struct transport_tx *trans, struct link_device *dev)
static void update_offset_conf(float offset, float conf)
Update sensor offset (baro).
static const float offset[]
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
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