sparkfun / SparkFun_BNO080_Arduino_Library

An Arduino Library for the BNO080 IMU combination triple axis accelerometer/gyro/magnetometer packaged with an ARM Cortex M0+ running powerful algorithms.
Other
81 stars 62 forks source link

Rotation Vector + Accelerometer Data #18

Closed vitorsotero closed 5 years ago

vitorsotero commented 5 years ago

Hi,

I want to get the Quaternion Data and the Accelerometer Data at the same time.

I read the library and found this:

"(shtpData[5] == SENSOR_REPORTID_LINEAR_ACCELERATION)"

and

"(shtpData[5] == SENSOR_REPORTID_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_GAME_ROTATION_VECTOR)"

So I am able to use just one or another? If so, how can I solve this?

Thanks,

Vitor Sotero

nseidle commented 5 years ago

Have a look at the datasheet. You should be able to enable both reports and then scan for the incoming IDs. Do this by combining Ex1 and Ex2:

myIMU.enableAccelerometer(50); //Send data update every 50ms
myIMU.enableRotationVector(50); //Send data update every 50ms

then, once data is available:

float x = myIMU.getAccelX();
float y = myIMU.getAccelY();
float z = myIMU.getAccelZ();
float quatI = myIMU.getQuatI();
float quatJ = myIMU.getQuatJ();
float quatK = myIMU.getQuatK();
float quatReal = myIMU.getQuatReal();
float quatRadianAccuracy = myIMU.getQuatRadianAccuracy();
vitorsotero commented 5 years ago

Sorry,

but when I try to enable both, the result is this: image

And if I just enable or Linear Accel or Rotation Vector, the result is like this: image

PS: the first figure I plotted only Linear Accel, but enabled Rotation Vector too.

On the "void Setup" I did: myIMU.enableRotationVector(50); //Send data update every 5ms myIMU.enableLinearAccelerometer(50); //Send data update every 5ms

And on the "void loop": float quatI = myIMU.getQuatI(); float quatJ = myIMU.getQuatJ(); float quatK = myIMU.getQuatK(); float quatReal = myIMU.getQuatReal(); float x = myIMU.getLinAccelX(); float y = myIMU.getLinAccelY(); float z = myIMU.getLinAccelZ();

// Serial.print(quatReal, 2); // Serial.print(F(",")); // Serial.print(quatI, 2); // Serial.print(F(",")); // Serial.print(quatJ, 2); // Serial.print(F(",")); // Serial.print(quatK, 2); // Serial.println();

Serial.print(x, 2);
Serial.print(F(","));
Serial.print(y, 2);
Serial.print(F(","));
Serial.print(z, 2);
Serial.println();

Thanks!

vitorsotero commented 5 years ago

Anyone can help?

I want to use a 100 Hz sample rate, but if I use "myIMU.enableRotationVector(10);" and "myIMU.enableLinearAccelerometer(10);" the data looks like the figure above (my last comment).

nseidle commented 5 years ago

Hi - I currently have a BNO080 configured in SPI mode (to deal with other issues), but I was able to get this working without too many issues.

image

All 8 data points are coming out fine at 100Hz. I had to increase serial to 115200bps. I've pushed this example to SPI Ex3.

I haven't tried this on I2C. Perhaps you can give it a go.

nseidle commented 5 years ago

Closing due to inactivity. Please re-open if you're still experiencing this issue.