sparkfun / SparkFun_MPU-9250-DMP_Arduino_Library

Arduino library for the MPU-9250 enabling its digital motion process (DMP) features.
Other
229 stars 151 forks source link

Quaternion DMP calulation not working on Mega 2560 #22

Open raomin opened 6 years ago

raomin commented 6 years ago

I ran MPU9250_DMP_Quaternion.ino without any problem on an ESP8266. Now I want to use it on a Arduino Mega 2560 and it returns the following:

Q:    INF,    INF,    INF,    INF
R/P/Y:  NAN, 180.00,  NAN
Time: 32761 ms

MPU9250_DMP_Gyro_Cal.ino works correctly on the same Arduino Mega 2560.

I tried DMP_FEATURE_6X_LP_QUAT and DMP_FEATURE_LP_QUAT both gives the same.

Also, dmpBegin returns INV_SUCCESS.

I also tried with Wire.setClock(400000), no success...

Any idea what could cause this issue?

kolosy commented 6 years ago

I'm actually running into the same exact issue (same mcu, too). Still debugging, but my hunch is that it's the function that converts the quaternion values from integer math to floats. The raw values seem legit, but go to INF after the call to qToFloat()

kolosy commented 6 years ago

Yeah, confirmed. I'll try to get a PR open when I have a minute, but edit MPU9250_DMP::qToFloat and change the integer literals from 1 and 2 to 1L and 2L, respectively. That got it working for me.

raomin commented 6 years ago

Good spot! It does return some values now... but the values are weird: 0.5847,2.2581,2.6837,2.9126

Values should stay within [-1,1] and it's not just off by +2... Do you observe the same in your setup? seems related to https://github.com/sparkfun/SparkFun_MPU-9250-DMP_Arduino_Library/issues/15

kolosy commented 6 years ago

I don't see that on mine.. not sure how it's different from yours

pradeep8892 commented 6 years ago

Hello everyone. I am also facing the same issue. DId anyone get the solution

marcoarnold99 commented 5 years ago

Yeah, confirmed. I'll try to get a PR open when I have a minute, but edit MPU9250_DMP::qToFloat and change the integer literals from 1 and 2 to 1L and 2L, respectively. That got it working for me.

Hey kolosy Just wanted to say thank you. I've been looking for a way to read this IMU for about 1 month now. With your solution everything works. Thank you so much and have a great day ^^

raomin commented 5 years ago

I'll close this issue as @kolosy found a solution for the NAN.

kolosy commented 5 years ago

@raomin I'd recommend keeping it open until it's actually fixed in the codebase...

raomin commented 5 years ago

good point.