ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
est_pipeline.h
Go to the documentation of this file.
1
20#ifndef EST_PIPELINE_H
21#define EST_PIPELINE_H
22
23#include <stdint.h>
24#include <stddef.h>
25#include "iekf.h"
26#include "accwin.h"
27#include "calib.h"
28#include "imu_lsm6dsv16x.h"
29
30#define EST_F_RUNNING 0x01u
31#define EST_F_MAG_NEW 0x02u
32#define EST_F_ACC_GATED 0x04u
33#define EST_F_MAG_GATED 0x08u
34#define EST_F_STILL 0x20u
35typedef struct {
36 uint8_t gyro_per_step;
37 uint8_t steps_per_acc;
38 uint16_t calib_samples;
42 float mag_map[9];
43 float mag_hard_iron[3];
44 float mag_scale[3]; /* per-axis soft-iron scale (COMPASS calibration);
45 0 = 1 (configs that do not set it) */
61
62/* ---- trace of the filter calls (parity test with MATLAB) ----
63 * Every iekf_* call within an acc-update window is recorded with its EXACT
64 * arguments. MATLAB replays it identically and compares state and covariance:
65 * this checks the filter independently of accwin, mag latency, etc.
66 * Encoding (little-endian, float32):
67 * 'P' dtheta[3] h propagation 17 bytes
68 * 'A' acc[3] trusted(u8) accelerometer update 14 bytes
69 * 'M' mag[3] extra_var magnetometer update 17 bytes */
70#define EST_TRACE_MAX 140u
71#define EST_OP_PROP 0x50u
72#define EST_OP_ACC 0x41u
73#define EST_OP_MAG 0x4Du
74typedef struct {
75 uint8_t buf[EST_TRACE_MAX];
76 uint16_t len;
77 uint8_t nops;
78 uint8_t overflow;
80
81typedef struct est_s est_t;
82typedef void (*est_cb_t)(const est_t *e, void *user);
83
115
116void est_init(est_t *e, const est_config_t *cfg, est_cb_t on_state, est_cb_t on_init, void *user);
118void est_process(est_t *e, const imu_event_t *ev, size_t n, float dt_sample);
119
120#endif /* EST_PIPELINE_H */
Windowed accelerometer mean, compensated for rotation.
static void on_init(const est_t *e, void *user)
Definition app_main.c:201
static void on_state(const est_t *e, void *user)
Definition app_main.c:158
Initial static window: references, noise and initial attitude.
uint32_t n
Definition calib_mgr.c:35
void(* est_cb_t)(const est_t *e, void *user)
void est_process(est_t *e, const imu_event_t *ev, size_t n, float dt_sample)
dt_sample: IMU sample period measured by the MCU (s)
void est_init(est_t *e, const est_config_t *cfg, est_cb_t on_state, est_cb_t on_init, void *user)
#define EST_TRACE_MAX
Attitude IEKF on SO(3), C port of iekfAttitude.m.
IMU library: LSM6DSV16X (gyro + acc) with the LIS2MDL and the barometer (LPS22DF on the X-NUCLEO-IKS4...
float mag_latency_s
Age of the mag sample on arrival: the LIS2MDL converts at f_lis, the sensor hub re-reads it at f_sh >...
float mag_latency_std_s
float calib_gyro_still
rad/s
float still_acc_tol
Stillness detector: if |a| ~ nominal and |omega| small for still_time_s, an external acceleration is ...
uint8_t gyro_per_step
2 with ODR 1920 Hz, 1 with 960 Hz
float sigma_vec_min
float still_gyro_thr
rad/s, e.g.
iekf_config_t ekf
sigma_acc/sigma_mag overwritten by calib
uint16_t calib_samples
mag samples while standing still
uint8_t steps_per_acc
4 -> acc update at 240 Hz
float still_time_s
e.g.
accwin_t win
est_config_t cfg
float t
s, estimation time since RUN start
est_cb_t on_init
once, at end of calibration
uint8_t flags
EST_F_*, cleared after each callback.
float dth[3]
step accumulators
void * user
uint32_t step
uint8_t running
uint8_t trace_enable
iekf_t f
calib_result_t calres
uint16_t gwin_n
float mag[3]
est_trace_t trace
cleared after each on_state
float still_t
s, how long the board has been still
uint32_t win_count
acc windows since RUN start
est_cb_t on_state
240 Hz, after the acc update
uint8_t k
float gsum[3]
uint8_t have_acc_mean
float omega[3]
last step gyro, bias removed
calib_t cal
float acc_mean[3]
latest quantities (telemetry / calibration)
float gwin_sum[3]
float gyro_mean[3]
uint8_t nops
uint16_t len
uint8_t overflow
Definition iekf.h:96