Skip to content

Commit 0b3c4af

Browse files
authored
Merge pull request #46 from Filimindji/master
Add support for AR/VR Stabilized RotationVector and AR/VR Stabilized GameRotationVector
2 parents 52bcc37 + 8010200 commit 0b3c4af

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ printPacket KEYWORD2
3131

3232
enableRotationVector KEYWORD2
3333
enableGameRotationVector KEYWORD2
34+
enableARVRStabilizedRotationVector KEYWORD2
35+
enableARVRStabilizedGameRotationVector KEYWORD2
3436
enableAccelerometer KEYWORD2
3537
enableGyro KEYWORD2
3638
enableMagnetometer KEYWORD2

src/SparkFun_BNO080_Arduino_Library.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,18 @@ void BNO080::parseInputReport(void)
295295
rawMagY = data2;
296296
rawMagZ = data3;
297297
}
298-
else if (shtpData[5] == SENSOR_REPORTID_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_GAME_ROTATION_VECTOR)
298+
else if (shtpData[5] == SENSOR_REPORTID_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_GAME_ROTATION_VECTOR ||
299+
shtpData[5] == SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR)
299300
{
300301
quatAccuracy = status;
301302
rawQuatI = data1;
302303
rawQuatJ = data2;
303304
rawQuatK = data3;
304305
rawQuatReal = data4;
305-
rawQuatRadianAccuracy = data5; //Only available on rotation vector, not game rot vector
306+
307+
//Only available on rotation vector and ar/vr stabilized rotation vector,
308+
// not game rot vector and not ar/vr stabilized rotation vector
309+
rawQuatRadianAccuracy = data5;
306310
}
307311
else if (shtpData[5] == SENSOR_REPORTID_STEP_COUNTER)
308312
{
@@ -878,12 +882,24 @@ void BNO080::enableRotationVector(uint16_t timeBetweenReports)
878882
setFeatureCommand(SENSOR_REPORTID_ROTATION_VECTOR, timeBetweenReports);
879883
}
880884

885+
//Sends the packet to enable the ar/vr stabilized rotation vector
886+
void BNO080::enableARVRStabilizedRotationVector(uint16_t timeBetweenReports)
887+
{
888+
setFeatureCommand(SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR, timeBetweenReports);
889+
}
890+
881891
//Sends the packet to enable the rotation vector
882892
void BNO080::enableGameRotationVector(uint16_t timeBetweenReports)
883893
{
884894
setFeatureCommand(SENSOR_REPORTID_GAME_ROTATION_VECTOR, timeBetweenReports);
885895
}
886896

897+
//Sends the packet to enable the ar/vr stabilized rotation vector
898+
void BNO080::enableARVRStabilizedGameRotationVector(uint16_t timeBetweenReports)
899+
{
900+
setFeatureCommand(SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR, timeBetweenReports);
901+
}
902+
887903
//Sends the packet to enable the accelerometer
888904
void BNO080::enableAccelerometer(uint16_t timeBetweenReports)
889905
{

src/SparkFun_BNO080_Arduino_Library.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ const byte CHANNEL_GYRO = 5;
9595
#define SENSOR_REPORTID_RAW_GYROSCOPE 0x15
9696
#define SENSOR_REPORTID_RAW_MAGNETOMETER 0x16
9797
#define SENSOR_REPORTID_PERSONAL_ACTIVITY_CLASSIFIER 0x1E
98+
#define SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR 0x28
99+
#define SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR 0x29
98100

99101
//Record IDs from figure 29, page 29 reference manual
100102
//These are used to read the metadata for each sensor type
@@ -147,6 +149,8 @@ class BNO080
147149

148150
void enableRotationVector(uint16_t timeBetweenReports);
149151
void enableGameRotationVector(uint16_t timeBetweenReports);
152+
void enableARVRStabilizedRotationVector(uint16_t timeBetweenReports);
153+
void enableARVRStabilizedGameRotationVector(uint16_t timeBetweenReports);
150154
void enableAccelerometer(uint16_t timeBetweenReports);
151155
void enableLinearAccelerometer(uint16_t timeBetweenReports);
152156
void enableGyro(uint16_t timeBetweenReports);

0 commit comments

Comments
 (0)