ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
accwin.c
Go to the documentation of this file.
1
4#include "accwin.h"
5#include "so3.h"
6#include <string.h>
7
9{
10 memset(w, 0, sizeof *w);
11 w->D[0] = w->D[4] = w->D[8] = 1.0f;
12}
13
14void accwin_add(accwin_t *w, const float acc[3])
15{
16 float v[3];
17 mat3_vec(w->D, acc, v);
18 w->sum[0] += v[0]; w->sum[1] += v[1]; w->sum[2] += v[2];
19 w->n++;
20}
21
22void accwin_rotate(accwin_t *w, const float E[9])
23{
24 float Dn[9];
25 mat3_mul(w->D, E, Dn);
26 memcpy(w->D, Dn, sizeof Dn);
27}
28
29int accwin_mean(const accwin_t *w, float out[3])
30{
31 if (w->n == 0) return -1;
32 const float k = 1.0f / (float)w->n;
33 const float m[3] = { w->sum[0]*k, w->sum[1]*k, w->sum[2]*k };
34 mat3t_vec(w->D, m, out);
35 return 0;
36}
void accwin_rotate(accwin_t *w, const float E[9])
after every propagation
Definition accwin.c:22
void accwin_add(accwin_t *w, const float acc[3])
sample in the current body
Definition accwin.c:14
int accwin_mean(const accwin_t *w, float out[3])
in the current body, 0 = OK
Definition accwin.c:29
void accwin_reset(accwin_t *w)
Definition accwin.c:8
Windowed accelerometer mean, compensated for rotation.
void mat3_vec(const float A[9], const float x[3], float y[3])
y = A*x
Definition so3.c:113
void mat3t_vec(const float A[9], const float x[3], float y[3])
y = A'*x
Definition so3.c:120
void mat3_mul(const float A[9], const float B[9], float C[9])
C = A*B
Definition so3.c:106
Single-precision SO(3) Lie-group utilities (port of expSO3.m / skewSym.m + firmware helpers).
float D[9]
rotation body(start) <- body(now)
Definition accwin.h:22
uint16_t n
Definition accwin.h:24
float sum[3]
Definition accwin.h:23