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

Timestamps #14

Closed abdallahJabr closed 6 years ago

abdallahJabr commented 6 years ago

Would it be possible to add timestamps to the reports returned for the rotation vectors, accelerations, etc? I read the entire datasheet and then the example code, but I wasn't able to modify the original functionality to add the timestamps reported by the sensor.

It would be super helpful to have them!

besabestin commented 6 years ago

I second this comment. I tried to use micros() from arduino and I encountered issues, specially when collecting data from a lot of sensors.

nseidle commented 6 years ago

Alright, section 1.4.5.3 talks about time stamping. Looking through the lib, I believe the timestamp is exposed in the shtpData array here.

So I added:

timeStamp = ((uint32_t)shtpData[4] << (8 * 3)) | (shtpData[3] << (8 * 2)) | (shtpData[2] << (8 * 1)) | (shtpData[1] << (8 * 0));

And exposed it via getTimeStamp(). Then I added an example 13 to show how to print it. Looks like it's working so I've pushed v1.1.2. Please kick the tires and let me know if it's what you're looking for.

image

besabestin commented 6 years ago

I will check this out this week. But quick look on that snippet - what unit are you using? and considering a 50ms sampling myIMU.enableRotationVector(50); result doesn't feel like in microseconds - unless ofcourse myIMU.dataAvailable() isn't affected by the sampling rate.

nseidle commented 6 years ago

According to section 1.4.5.3 units are microseconds. And the time stamp is the time since the interrupt occurred (every 50ms) and when we move the bytes from the frame buffer into the global vars, then printed via the .getTimestamp() function. So ~30 micros seems reasonable.