Comments (4)
I experienced the same bug. As noted in the Sparkfun forum there are still some problems with the proposed computation from Wikipedia. In fact quaternions when representing rotations, must be unit quaternions. As the MPU 9250 uses fixed point calculations this cannot be guaranteed when converting back to floating point numbers and one has to do it manually. So the corrected code would be:
void MPU9250_DMP::computeEulerAngles(bool degrees)
{
float dqw = qToFloat(qw, 30);
float dqx = qToFloat(qx, 30);
float dqy = qToFloat(qy, 30);
float dqz = qToFloat(qz, 30);
float norm = sqrt(dqw*dqw + dqx*dqx + dqy*dqy + dqz*dqz);
dqw = dqw/norm;
dqx = dqx/norm;
dqy = dqy/norm;
dqz = dqz/norm;
float ysqr = dqy * dqy;
// roll (x-axis rotation)
float t0 = +2.0 * (dqw * dqx + dqy * dqz);
float t1 = +1.0 - 2.0 * (dqx * dqx + ysqr);
roll = atan2(t0, t1);
// pitch (y-axis rotation)
float t2 = +2.0 * (dqw * dqy - dqz * dqx);
t2 = t2 > 1.0 ? 1.0 : t2;
t2 = t2 < -1.0 ? -1.0 : t2;
pitch = asin(t2);
// yaw (z-axis rotation)
float t3 = +2.0 * (dqw * dqz + dqx * dqy);
float t4 = +1.0 - 2.0 * (ysqr + dqz * dqz);
yaw = atan2(t3, t4);
}
from sparkfun_mpu-9250-dmp_arduino_library.
Above code works for me as well, however I had to change the qToFloat conversion to below code, otherwise I was getting random strange results.
MPU9250_DMP::qToFloat(long number, unsigned char q)
{
return (float)((double)number / (double)(1 << q));
}
from sparkfun_mpu-9250-dmp_arduino_library.
I can confirm this.
Opened issue before reading yours in the RAZOR IMU M0 repository sparkfun/9DOF_Razor_IMU#9
I also noticed that the yaw values change every time depending on the heading of the board every time it turns on. Is this also a bug?
from sparkfun_mpu-9250-dmp_arduino_library.
This helped a lot hbob, thank you!
from sparkfun_mpu-9250-dmp_arduino_library.
Related Issues (20)
- endless loop with vibration HOT 2
- How to change axis in DMP? HOT 5
- ~60 MS DELAY EVERY ~.5S HOT 2
- Max sampling rate for DMP HOT 1
- Unable to Read Compass in FiFO mode due to bug
- Unable to get raw accelerometer data after calculating quaternion HOT 5
- Bug in setLowPass Filter Function - Accel lowpass is never configured HOT 4
- When loading the sparkfun_mpu-9250-dmp_arduino_library library with platformio, the min function was not found HOT 1
- Use 2 IMU with 1 arduino HOT 1
- Arduino Micro Tap Detection and Wake On Motion (I2C)
- Mag Calibration Missing
- INF ouput when reading Quaternions
- dmpSetAccelBias is undefined
- Reboot in SparkFunMPU9250-DMP.cpp at line 46 HOT 2
- Change I2C address
- [Arduino IDE] Error Compiling for Raspberry Pi Pico
- MPU on raspberry pi 4
- Starkfan
- Mystical oddities with the MPU9250 and the library
- linear acceleration values
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sparkfun_mpu-9250-dmp_arduino_library.