kriswiner/MPU9250

calculation yaw from mpu 9250

Opened this issue · 12 comments

Hi Kris
I have a problem. I have read your all comment. But ı havent solved my problem.
I calibrated my all sensor (Accel, gyro and mag). I get 9 data very well. Although I apply all your formula, I dont have good yaw angle. Couldu you help me please?

First of all thank you for your reply me. I follow your study. They are very useful.
mpu 9250.txt
This is my study.
I use your mag calibration code. But data is very strange. After, I get mx,my and mz data. I used this data on Magneto 1.2 program. This program helps me to find bias and scale matrix. ı put my code Bias and Scale data to calibrate magnetometer. This job was very good. My mx,my and mz data is very acceptable. for exp: mx:-0,29 my:-0,37 mz:0
I think this value is good.
If you dont have time to examine my code, ı apply this
//apply offsets (bias) and scale factors from Magneto
tempt[0] = (Mxyz[0] - M_b[0]);
tempt[1] = (Mxyz[1] - M_b[1]);
tempt[2] = (Mxyz[2] - M_b[2]);
Mxyz[0] = M_Ainv[0][0] * tempt[0] + M_Ainv[0][1] * tempt[1] + M_Ainv[0][2] * tempt[2];
Mxyz[1] = M_Ainv[1][0] * tempt[0] + M_Ainv[1][1] * tempt[1] + M_Ainv[1][2] * tempt[2];
Mxyz[2] = M_Ainv[2][0] * tempt[0] + M_Ainv[2][1] * tempt[1] + M_Ainv[2][2] * tempt[2];

mx = Mxyz[0];
my = Mxyz[1];
mz = Mxyz[2];

Thank you

Also ı dont know about MCU and fusion rate. Could you explain me please?
Thank you again.

Actually I didint control mag calibration. How can I do this section? How can I find fusion rate?
My sensor fusion algoritm is
#ifdef RESTRICT_PITCH
roll = atan2(ay, az) * RAD_TO_DEG;
pitch = atan(-ax / sqrt(ay * ay + az * az)) * RAD_TO_DEG;
#else // Eq. 28 and 29
roll = atan(ay / sqrt(ax * ax + az * az)) * RAD_TO_DEG;
pitch = atan2(-ax, az) * RAD_TO_DEG;
#endif

I just use Arduino Mega and MPU 9250.

Sorry Kris. My sensor fusion code is
// 3. deneme
double Mx = mx * cos(pitch) + my * sin(roll) * sin(pitch) + mz * cos(roll) * sin(pitch);
double My = my * cos(roll) - mz * sin(roll);

/* ikinci deneme
double My = mz * sin(roll) - my * cos(roll);
double Mx = mx * cos(pitch) + my * sin(pitch) * sin(roll) + mz * sin(pitch) * cos(roll);
/
/
//bizim ilk eklediğimiz
float Mx = mx * cos(pitch) + mz * sin(pitch);
float My = mx * sin(roll) * sin(pitch) + my * cos(roll) - mz * sin(roll) * cos(pitch);*/

double yaw = atan2(-My, Mx) * RAD_TO_DEG;

There are three different ways. But they are not working.
Could you check my code plz?

ı think you offer me to use quaternion code. Actually ı have tried this. But Q values are always zero. I have a big problem

Again Hi Kris,
Can you meet on Skype, If you have short time? I would be very pleased. I realy need your help. Thank you
My Skype ID is aykutturgut45@gmail.com