Skip to content

Commit 97e8c0f

Browse files
committed
Implementing the GeomagneticRotationVector data
-also added attribution at top header comment with links to original forum post and github issue.
1 parent 8abe0f9 commit 97e8c0f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

examples/Example_19_GeomagneticRotationVector_to_EulerAngles/Example_19_GeomagneticRotationVector_to_EulerAngles.ino

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
/*
33
Using the BNO08x IMU
44
5-
Example : Euler Angles
5+
Example : Geomagnetic Rotation Vector to Euler Angles
6+
7+
This example was initially created by github user SFSailor November 2023
8+
https://github.com/sparkfun/SparkFun_BNO08x_Arduino_Library/issues/10
9+
https://forum.sparkfun.com/viewtopic.php?f=83&t=60523&p=245145#p245145
10+
11+
Modified from original example of Euler Angles
612
By: Paul Clark
713
Date: April 28th, 2020
814
15+
Using the Geomagnetic Rotation vectors,
916
This example shows how to output the Euler angles: roll, pitch and yaw.
1017
The yaw (compass heading) is tilt-compensated, which is nice.
1118
https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
@@ -97,11 +104,11 @@ void setup() {
97104
// Here is where you define the sensor outputs you want to receive
98105
void setReports(void) {
99106
Serial.println("Setting desired reports");
100-
if (myIMU.enableRotationVector() == true) {
101-
Serial.println(F("Rotation vector enabled"));
107+
if (myIMU.enableGeomagneticRotationVector() == true) {
108+
Serial.println(F("Geomagnetic Rotation vector enabled"));
102109
Serial.println(F("Output in form roll, pitch, yaw"));
103110
} else {
104-
Serial.println("Could not enable rotation vector");
111+
Serial.println("Could not enable geomagnetic rotation vector");
105112
}
106113
}
107114

@@ -117,7 +124,7 @@ void loop() {
117124
if (myIMU.getSensorEvent() == true) {
118125

119126
// is it the correct sensor data we want?
120-
if (myIMU.getSensorEventID() == SENSOR_REPORTID_ROTATION_VECTOR) {
127+
if (myIMU.getSensorEventID() == SENSOR_REPORTID_GEOMAGNETIC_ROTATION_VECTOR) {
121128

122129
float roll = (myIMU.getRoll()) * 180.0 / PI; // Convert roll to degrees
123130
float pitch = (myIMU.getPitch()) * 180.0 / PI; // Convert pitch to degrees

0 commit comments

Comments
 (0)