From f71a05fea9340f3bd1fbc030f46f189dabd6bf04 Mon Sep 17 00:00:00 2001 From: Damien Hoffschir Date: Thu, 30 Apr 2020 19:34:17 +0200 Subject: [PATCH 1/2] Add support for AR/VR Stabilized from Rotation Vector and Game Rotation Vector --- src/SparkFun_BNO080_Arduino_Library.cpp | 20 ++++++++++++++++++-- src/SparkFun_BNO080_Arduino_Library.h | 4 ++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/SparkFun_BNO080_Arduino_Library.cpp b/src/SparkFun_BNO080_Arduino_Library.cpp index 7af5890..27b958d 100644 --- a/src/SparkFun_BNO080_Arduino_Library.cpp +++ b/src/SparkFun_BNO080_Arduino_Library.cpp @@ -295,14 +295,18 @@ void BNO080::parseInputReport(void) rawMagY = data2; rawMagZ = data3; } - else if (shtpData[5] == SENSOR_REPORTID_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_GAME_ROTATION_VECTOR) + else if (shtpData[5] == SENSOR_REPORTID_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_GAME_ROTATION_VECTOR || + shtpData[5] == SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR) { quatAccuracy = status; rawQuatI = data1; rawQuatJ = data2; rawQuatK = data3; rawQuatReal = data4; - rawQuatRadianAccuracy = data5; //Only available on rotation vector, not game rot vector + + //Only available on rotation vector and ar/vr stabilized rotation vector, + // not game rot vector and not ar/vr stabilized rotation vector + rawQuatRadianAccuracy = data5; } else if (shtpData[5] == SENSOR_REPORTID_STEP_COUNTER) { @@ -878,12 +882,24 @@ void BNO080::enableRotationVector(uint16_t timeBetweenReports) setFeatureCommand(SENSOR_REPORTID_ROTATION_VECTOR, timeBetweenReports); } +//Sends the packet to enable the ar/vr stabilized rotation vector +void BNO080::enableARVRStabilizedRotationVector(uint16_t timeBetweenReports) +{ + setFeatureCommand(SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR, timeBetweenReports); +} + //Sends the packet to enable the rotation vector void BNO080::enableGameRotationVector(uint16_t timeBetweenReports) { setFeatureCommand(SENSOR_REPORTID_GAME_ROTATION_VECTOR, timeBetweenReports); } +//Sends the packet to enable the ar/vr stabilized rotation vector +void BNO080::enableARVRStabilizedGameRotationVector(uint16_t timeBetweenReports) +{ + setFeatureCommand(SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR, timeBetweenReports); +} + //Sends the packet to enable the accelerometer void BNO080::enableAccelerometer(uint16_t timeBetweenReports) { diff --git a/src/SparkFun_BNO080_Arduino_Library.h b/src/SparkFun_BNO080_Arduino_Library.h index d363f1a..0dda209 100644 --- a/src/SparkFun_BNO080_Arduino_Library.h +++ b/src/SparkFun_BNO080_Arduino_Library.h @@ -95,6 +95,8 @@ const byte CHANNEL_GYRO = 5; #define SENSOR_REPORTID_RAW_GYROSCOPE 0x15 #define SENSOR_REPORTID_RAW_MAGNETOMETER 0x16 #define SENSOR_REPORTID_PERSONAL_ACTIVITY_CLASSIFIER 0x1E +#define SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR 0x28 +#define SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR 0x29 //Record IDs from figure 29, page 29 reference manual //These are used to read the metadata for each sensor type @@ -147,6 +149,8 @@ class BNO080 void enableRotationVector(uint16_t timeBetweenReports); void enableGameRotationVector(uint16_t timeBetweenReports); + void enableARVRStabilizedRotationVector(uint16_t timeBetweenReports); + void enableARVRStabilizedGameRotationVector(uint16_t timeBetweenReports); void enableAccelerometer(uint16_t timeBetweenReports); void enableLinearAccelerometer(uint16_t timeBetweenReports); void enableGyro(uint16_t timeBetweenReports); From 801020084e8b251d260f3f061d8615200159f569 Mon Sep 17 00:00:00 2001 From: Damien Hoffschir Date: Fri, 1 May 2020 16:40:03 +0200 Subject: [PATCH 2/2] Update keywords.txt --- keywords.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/keywords.txt b/keywords.txt index 001a45c..099b85c 100644 --- a/keywords.txt +++ b/keywords.txt @@ -31,6 +31,8 @@ printPacket KEYWORD2 enableRotationVector KEYWORD2 enableGameRotationVector KEYWORD2 +enableARVRStabilizedRotationVector KEYWORD2 +enableARVRStabilizedGameRotationVector KEYWORD2 enableAccelerometer KEYWORD2 enableGyro KEYWORD2 enableMagnetometer KEYWORD2