File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
#include < CurieIMU.h>
2
+ // for better performance, compile this code using at least C++ 17.
2
3
#include < MadgwickAHRS.h>
3
4
4
5
Madgwick filter;
@@ -13,9 +14,9 @@ void setup() {
13
14
CurieIMU.setGyroRate (25 );
14
15
CurieIMU.setAccelerometerRate (25 );
15
16
16
- // Setting the Madgwick's filter parameter (beta)
17
+ // set the Madgwick's filter parameter (beta)
17
18
filter.setBeta (0.1 );
18
- // Setting the IMU update frequency in Hz
19
+ // set the IMU update frequency in Hz
19
20
filter.setFrequency (25 );
20
21
21
22
// Set the accelerometer range to 2 g
@@ -34,6 +35,7 @@ void loop() {
34
35
float ax, ay, az;
35
36
float gx, gy, gz;
36
37
float roll, pitch, heading;
38
+ float q[4 ];
37
39
unsigned long microsNow;
38
40
39
41
// check if it's time to read data and update the filter
@@ -69,6 +71,17 @@ void loop() {
69
71
Serial.print (" " );
70
72
Serial.println (roll);
71
73
74
+ // get and print the quaternion
75
+ filter.getQuaternion (q);
76
+ Serial.print (" Quaternion: " );
77
+ Serial.print (q[0 ]);
78
+ Serial.print (" " );
79
+ Serial.print (q[1 ]);
80
+ Serial.print (" " );
81
+ Serial.print (q[2 ]);
82
+ Serial.print (" " );
83
+ Serial.println (q[3 ]);
84
+
72
85
// increment previous time, so we keep proper pace
73
86
microsPrevious = microsPrevious + microsPerReading;
74
87
}
You can’t perform that action at this time.
0 commit comments