Larus glider flight sensor system 3.9.2024
Software-In-The-Loop test and validation system
Loading...
Searching...
No Matches
compass_ground_calibration.h
Go to the documentation of this file.
1#ifndef NAV_ALGOROTHMS_COMPASS_GROUND_CALIB
2#define NAV_ALGOROTHMS_COMPASS_GROUND_CALIB
3
5#include "pt2.h"
6#include "float3vector.h"
8
9#define CUTOFF_DIV_BY_SAMPLING_FREQ 0.01f
10
13{
14public:
17 {
18 for( unsigned axis = X; axis <= Z; ++axis)
19 {
20 max[axis]=min[axis]=0.0f; // assuming offset < 50% of range
21 }
22 }
23 void feed( const float3vector & mag_raw)
24 {
25 averager.respond( mag_raw);
26 float3vector mean_value = averager.get_output();
27 for( unsigned axis = X; axis <= Z; ++axis)
28 {
29 if( mean_value[axis] > max[axis])
30 max[axis] = mean_value[axis];
31 if( mean_value[axis] < min[axis])
32 min[axis] = mean_value[axis];
33 }
34 }
36 {
37 for( unsigned axis = X; axis <= Z; ++axis)
38 {
39 float range = max[axis]-min[axis];
40 calibration_3d[axis].scale = 2.0 / range;
41 calibration_3d[axis].offset = (max[axis] + min[axis]) / 2.0f;
42 calibration_3d[axis].variance = 0.1f; // a dummy, we don't know it here!
43 }
44}
45private:
46 float max[3];
47 float min[3];
49 enum{ X, Y, Z};
50};
51
52#endif
53
54
helper class to support manual compass calibration
void feed(const float3vector &mag_raw)
void get_calibration_result(single_axis_calibration_t *calibration_3d)
maintain offset and slope data for one sensor axis
mathematical vector of arbitrary type and size
Definition vector.h:40
Automatic compass calibration using a linear least square fit algorithm.
#define CUTOFF_DIV_BY_SAMPLING_FREQ
tunable second order IIR lowpass filter (butterworth)
collection of system tuning parameters