Sensor Scol plugin
Multi platform sensors for handled devices
gyroscopeBiasEstimator.h
1#ifndef _GYROBIASESTIMATOR_H_
2#define _GYROBIASESTIMATOR_H_
3
4#include "tools/lowPassFilter.h"
5
6#define ACCEL_LOWPASS_FREQ 1.0
7#define GYRO_LOWPASS_FREQ 10.0
8#define GYRO_BIAS_LOWPASS_FREQ 0.1500000059604645
9#define NUM_GYRO_BIAS_SAMPLES_THRESHOLD 30
10#define NUM_GYRO_BIAS_SAMPLES_INITIAL_SMOOTHING 100.0
11#define ACCEL_DIFF_STATIC_THRESHOLD 0.5
12#define GYRO_DIFF_STATIC_THRESHOLD 0.00800000037997961
13#define GYRO_FOR_BIAS_THRESHOLD 0.25
14#define IS_STATIC_NUM_FRAMES_THRESHOLD 3
15
17{
18public:
20
21 IsStaticCounter(int minFrames)
22 {
23 minStaticFrames = minFrames;
24 consecutiveIsStatic = 0;
25 lastTimestampNs = 0;
26 }
27
29
30
31 void appendFrame(bool isStatic)
32 {
33 if (!isStatic)
34 consecutiveIsStatic = 0;
35 else
36 consecutiveIsStatic += 1;
37 }
38
39 bool isRecentlyStatic()
40 {
41 return consecutiveIsStatic >= minStaticFrames;
42 }
43
44private:
45 int minStaticFrames;
46 int consecutiveIsStatic;
47 int64_t lastTimestampNs;
48
49};
50
52{
53public:
56
57 void reset();
58 void processGyroscope(Vector3d gyro, int64_t sensorTimestampNs);
59 void processAccelerometer(Vector3d accel, int64_t sensorTimestampNs);
60 void getGyroBias(Vector3d &result);
61 void updateGyroBias(Vector3d gyro, int64_t sensorTimestampNs);
62
63private:
64 LowPassFilter accelLowPass;
65 LowPassFilter gyroLowPass;
66 LowPassFilter gyroBiasLowPass;
67 Vector3d smoothedGyroDiff;
68 Vector3d smoothedAccelDiff;
69 IsStaticCounter isAccelStatic;
70 IsStaticCounter isGyroStatic;
71};
72
73#endif