kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.04k stars 471 forks source link

yaw slowly converged on quick rotate around z #314

Open mbui0327 opened 6 years ago

mbui0327 commented 6 years ago

Hi Kris, thank you very much for the great resource. I will definitely buy you a glass of beer when we meet?

I have three quick questions on yaw measurement.

I am using Madgwick algorithm. What happened is when I rotate the MPU around z quickly, yaw will always go up to y+~4, then it slowly come back down to a true value which y. The convergence would normally took 4-5s.

Also, there is a big warmup time of about 1 minute for the the yaw to converge to the stable value. Why is it?

And lastly, I see you use some kind of location based bias in your calibration algorithm magbias. Where did you get those numbers?

Thanks.

kriswiner commented 6 years ago

Are you calibrating your sensors? How?

There is no location-based bias, there is correction for local magnetic declination.

If your orientation solution is laggy you need a faster MCU.

On Wed, Oct 10, 2018 at 3:46 PM robotdreamers notifications@github.com wrote:

Hi Kris, thank you very much for the great resource. I will definitely buy you a glass of beer when we meet?

I have three quick questions on yaw measurement.

I am using Madgwick algorithm. What happened is when I rotate the MPU around z quickly, yaw will always go up to y+~4, then it slowly come back down to a true value which y. The convergence would normally took 4-5s.

Also, there is a big warmup time of about 1 minute for the the yaw to converge to the stable value. Why is it?

And lastly, I see you use some kind of location based bias in your calibration algorithm magbias. Where did you get those numbers?

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/314, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qq3aLwxo4bEDG8zHoGWN83N27gj5ks5ujnipgaJpZM4XWeDF .

mbui0327 commented 6 years ago

So I did try to do the calibration but the output of the calibration is not good. Now that you said, may be the issue is the MCU. I am using Mega2560. Do you have any comment? I am using max sample rate + max low pass filter rate. I have tried with lower freq but still got the same problem.

kriswiner commented 6 years ago

200 H accel and gyro rate, 100 Hz mag rate, 41 hz LPF. You could also double gyro and accel rates or even go to 1 kHz with 100 Hz LPF. But the fusion rate should be several kHz. Not sure if an AVR can do this. Might try one of these https://www.tindie.com/products/TleraCorp/dragonfly-stm32l47696-development-board/ or these https://www.tindie.com/products/TleraCorp/ladybug-stm32l432-development-board/ .

On Wed, Oct 10, 2018 at 3:56 PM robotdreamers notifications@github.com wrote:

So I did try to do the calibration but the output of the calibration is not good. Now that you said, may be the issue is the MCU. I am using Mega2560. Do you have any comment? I am using max sample rate + max low pass filter rate. I have tried with lower freq but still got the same problem.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/314#issuecomment-428760853, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qjfve5SjYGlFsfvYUAZxeMkAXsp4ks5ujnsEgaJpZM4XWeDF .

mbui0327 commented 6 years ago

I measured the time it takes between each readsensor. It is about 4ms on my board. So it seems the sample rate is only about 250Hz. Does this sound like it is too low as you mentioned the fusion rate should be several khz?

Also, if the sensor output rate is only 200Hz i.e. SRD=4. How can fusion rate to be at Khz level. Thanks.

kriswiner commented 6 years ago

The fusion rate will be determined by how many iterations of the fusion filter can be accomplished by your MCU for each new data set.

On Thu, Oct 11, 2018 at 10:28 AM robotdreamers notifications@github.com wrote:

I measured the time it takes between each readsensor. It is about 4ms on my board. So it seems the sample rate is only about 250Hz. Does this sound like it is too low as you mentioned the fusion rate should be several khz?

Also, if the sensor output rate is only 200Hz i.e. SRD=4. How can fusion rate to be at Khz level. Thanks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/314#issuecomment-429045639, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qrhxqCT1MEKVgbi_5TyhaVlWmVAZks5uj3-ygaJpZM4XWeDF .

mbui0327 commented 6 years ago

Since after each sensor read, we apply the filter update once. So basically my deltat=4ms which means the fusion rate is 250Hz way below what you said of few Khz. is my logic correct?

kriswiner commented 6 years ago

In my sketches the fusion function is iterated while the MCU waits for new data, so the rate depends on how fast the MCU is. For very fast MCUs (like STM32L4) I limit the iterations to 10 or 20.

On Thu, Oct 11, 2018 at 10:39 AM robotdreamers notifications@github.com wrote:

Since after each sensor read, we apply the filter update once. So basically my deltat=4ms which means the fusion rate is 250Hz way below what you said of few Khz. is my logic correct?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/314#issuecomment-429049683, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1quh5cyqfWzby0IUo-VhxC6ZJwD1Nks5uj4IigaJpZM4XWeDF .

mbui0327 commented 6 years ago

ok so I change the code to make it read sensor on interrupt. and keep the filter update running constantly, the deltat is still around 4ms. So clearly Mega board seem too slow, do you think?

kriswiner commented 6 years ago

Is this 16 MHz AVR? Probably yes, too slow.

On Thu, Oct 11, 2018 at 11:04 AM robotdreamers notifications@github.com wrote:

ok so I change the code to make it read sensor on interrupt. and keep the filter update running constantly, the deltat is still around 4ms. So clearly Mega board seem too slow, do you think?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/314#issuecomment-429059718, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qrndWR3WRpiCm-FIi3dOdUB5QR5Nks5uj4gXgaJpZM4XWeDF .

mbui0327 commented 6 years ago

yes 16Mhz

kriswiner commented 6 years ago

Tooooo sloooooow

On Thu, Oct 11, 2018 at 11:13 AM robotdreamers notifications@github.com wrote:

yes 16Mhz

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/314#issuecomment-429063041, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qkUI46O_8Hto05Ee5Wvp-E5-936eks5uj4pagaJpZM4XWeDF .

mbui0327 commented 6 years ago

will order your board then :)

mbui0327 commented 6 years ago

I figured out that the beta value greatly affect the speed of convergence. which makes sense after the fact :). so if i have slow MCU, i can increase the beta to get decent performance with the downside is a little bit bigger vibration around the convergence point.