-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.h
78 lines (57 loc) · 1.47 KB
/
helpers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef HELPERS_H
#define HELPERS_H
#include <QVector3D>
#include <QQuaternion>
#include <QMutex>
class MadgwickAHRS
{
public:
MadgwickAHRS() : orientation(QQuaternion(1.0, 0.0, 0.0, 0.0)) {}
MadgwickAHRS(QQuaternion orientationSeed) : orientation(orientationSeed) {}
QQuaternion orientation;
void MadgwickAHRS::Update(float gx, float gy, float gz, float ax, float ay, float az, float beta, float samplePeriod);
};
class BMI055Integrator
{
public:
BMI055Integrator() : samplesLeft(2000), ledOn(true), isCalibrating(true) {}
enum AScale
{
AFS_2G = 0x03,
AFS_4G = 0x05,
AFS_8G = 0x08,
AFS_16G = 0x0C
};
enum GScale
{
GFS_2000DPS = 0,
GFS_1000DPS,
GFS_500DPS,
GFS_250DPS,
GFS_125DPS
};
void init(AScale AccelerometerScale, GScale GyroscopeScale);
bool isCalibrating = true;
public slots:
void Recenter();
void Recalibrate();
private:
QMutex mutex;
float accRes;
float gyroRes;
float accResolution;
float gResResolution;
bool recenter = false;
int samplesLeft;
uint prevTimestamp;
bool ledOn = true;
MadgwickAHRS fusion;
QVector3D gravityVector;
QVector3D accOffset;
QVector3D gyroOffset;
QQuaternion zero;
float getAccRes(AScale Scale);
float getGyroRes(GScale Scale);
QQuaternion Integrate(QVector3D linearAcceleration, QVector3D angularAcceleration, uint timestamp);
};
#endif // HELPERS_H