This repository has been archived by the owner on Oct 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIMURazor9DOF.cpp
83 lines (66 loc) · 1.89 KB
/
IMURazor9DOF.cpp
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
79
80
81
82
#include "IMURazor9DOF.h"
IMURazor9DOF::IMURazor9DOF(string portName) : SerialComm(portName)
{
SetBaudRate(57600); //Default value
for (int i=0;i<16;i++)
{
cout << GetLine() << endl;
}
att.setMagCalib(1.0, 0.0, 0.0); //Device 3DMGX10 has no magnetometer
att.setGyroBias(bx,by,bz); //Setting of gyro bias
}
long IMURazor9DOF::GetPitchRollYaw(double dts, double &o_pitch, double &o_roll, double &o_yaw)
{
line = GetLine();
line.erase(1,1);
// cout << line << endl;
p0=1;
stringstream sline(line);
for (int i=0;i<9;i++)
{
try
{
getline(sline,tmp,',');
gam[i] = stod(tmp);
// cout << " tmp: " << tmp << endl;
}
catch (exception& e)
{
cout << "Standard exception: " << e.what() << endl;
cout << "Sensor received -> icnli:" <<tmp << "; ori:" <<line << endl;
}
att.update(dts,gam[3]*M_PI/180,gam[4]*M_PI/180,gam[5]*M_PI/180,gam[0],gam[1],gam[2],gam[6],gam[7],gam[8]);
// pitch = estimador.eulerPitch();
// roll = estimador.eulerRoll();
o_pitch = att.fusedPitch();
o_roll = att.fusedRoll();
o_yaw = att.fusedYaw();
}
return 0;
}
long IMURazor9DOF::GetYawPitchRoll(double dts, double &o_yaw, double &o_pitch, double &o_roll)
{
line = GetLine();
// line.erase(1,1);
// cout << line << endl;
p0=1;
stringstream sline(line);
for (int i=0;i<3;i++)
{
try
{
getline(sline,tmp,',');
gam[i] = stod(tmp);
// cout << " tmp: " << tmp << endl;
}
catch (exception& e)
{
cout << "Standard exception: " << e.what() << endl;
cout << "Sensor received -> icnli:" <<tmp << "; ori:" <<line << endl;
}
o_pitch = gam[1];
o_roll = gam[2];
o_yaw = gam[0];
}
return 0;
}