Skip to content

Commit cddf138

Browse files
committed
Update Visualize101.ino
1 parent 0f1a839 commit cddf138

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

examples/Visualize101/Visualize101.ino

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <CurieIMU.h>
2+
// for better performance, compile this code using at least C++ 17.
23
#include <MadgwickAHRS.h>
34

45
Madgwick filter;
@@ -13,9 +14,9 @@ void setup() {
1314
CurieIMU.setGyroRate(25);
1415
CurieIMU.setAccelerometerRate(25);
1516

16-
//Setting the Madgwick's filter parameter (beta)
17+
// set the Madgwick's filter parameter (beta)
1718
filter.setBeta(0.1);
18-
//Setting the IMU update frequency in Hz
19+
// set the IMU update frequency in Hz
1920
filter.setFrequency(25);
2021

2122
// Set the accelerometer range to 2 g
@@ -34,6 +35,7 @@ void loop() {
3435
float ax, ay, az;
3536
float gx, gy, gz;
3637
float roll, pitch, heading;
38+
float q[4];
3739
unsigned long microsNow;
3840

3941
// check if it's time to read data and update the filter
@@ -69,6 +71,17 @@ void loop() {
6971
Serial.print(" ");
7072
Serial.println(roll);
7173

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+
7285
// increment previous time, so we keep proper pace
7386
microsPrevious = microsPrevious + microsPerReading;
7487
}

0 commit comments

Comments
 (0)