ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
calib.h File Reference

Initial static window: references, noise and initial attitude. More...

#include <stdint.h>
#include "iekf.h"
Include dependency graph for calib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  calib_t
 
struct  calib_result_t
 

Macros

#define CALIB_MAX_SAMPLES   256
 

Functions

void calib_reset (calib_t *c)
 
int calib_add (calib_t *c, const float acc[3], const float gyro[3], const float mag[3], float gyro_still_thr)
 Returns 0 if the sample is compatible with "still", -1 if moving.
 
uint32_t calib_count (const calib_t *c)
 
int calib_finish (const calib_t *c, float sigma_min, calib_result_t *out)
 
float direction_noise_std (const float(*v)[3], uint32_t n)
 

Detailed Description

Initial static window: references, noise and initial attitude.

C equivalent of section 2 of runRealData.m + directionNoiseStd.m, with ONE deliberate difference: the world frame is not "body at t=0" but a levelled NWU frame (x = horizontal magnetic north, y = west, z = up), built with the TRIAD method. Reason: the tilt-compensated magnetometer update assumes a vertical world z; with world = body(t0) and the board not perfectly level that assumption is violated. As a bonus, the MATLAB triad shows a true heading.

Definition in file calib.h.

Macro Definition Documentation

◆ CALIB_MAX_SAMPLES

#define CALIB_MAX_SAMPLES   256

Definition at line 19 of file calib.h.

Function Documentation

◆ calib_reset()

void calib_reset ( calib_t *  c)

Definition at line 10 of file calib.c.

Referenced by est_init(), and on_mag().

Here is the caller graph for this function:

◆ calib_add()

int calib_add ( calib_t *  c,
const float  acc[3],
const float  gyro[3],
const float  mag[3],
float  gyro_still_thr 
)

Returns 0 if the sample is compatible with "still", -1 if moving.

Definition at line 14 of file calib.c.

References calib_t::acc, CALIB_MAX_SAMPLES, calib_t::gyro_norm_max, calib_t::gyro_sum, calib_t::mag, calib_t::n, and vec3_norm().

Referenced by on_mag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calib_count()

uint32_t calib_count ( const calib_t *  c)

Definition at line 12 of file calib.c.

References calib_t::n.

Referenced by on_mag().

Here is the caller graph for this function:

◆ calib_finish()

int calib_finish ( const calib_t *  c,
float  sigma_min,
calib_result_t *  out 
)

Definition at line 52 of file calib.c.

References calib_t::acc, direction_noise_std(), calib_t::gyro_sum, calib_t::mag, mat3_vec(), calib_t::n, s, calib_result_t::seed, calib_result_t::sigma_acc, calib_result_t::sigma_acc_raw, calib_result_t::sigma_mag, calib_result_t::sigma_mag_raw, vec3_cross(), vec3_dot(), vec3_norm(), and vec3_normalize().

Referenced by on_mag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ direction_noise_std()

float direction_noise_std ( const float(*)  v[3],
uint32_t  n 
)

Definition at line 29 of file calib.c.

References n, vec3_dot(), vec3_norm(), and vec3_normalize().

Referenced by calib_finish().

Here is the call graph for this function:
Here is the caller graph for this function: