Sefat Noor Orni
Sefat Noor Orni

Reputation: 247

Formula for getting Roll, Pitch and Yaw values from MPU-9150 raw data

I am a newbie in MPU9150 9-axis IMU sensor, working on a project in which the Roll, pitch and Yaw value will be showed in a GUI. I have used the code from here: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU9150 The problem is, as in GUI I will show the 3D representation of the roll, pitch and yaw. What will be the specific conversion formula from the raw data?

my WHO_AM_I resistor value: 0x68,

Accelerometer configured : 2g ,

Gyroscope configured: 250 dps,

Any help will be GREAT. Thanks in advance!

Upvotes: 1

Views: 4118

Answers (1)

Sefat Noor Orni
Sefat Noor Orni

Reputation: 247

In java,

    float alpha=(float) 0.5;
    double fXg=0.0,fYg=0.0,fZg=0.0;
    fXg = xx * alpha + (fXg * (1.0 - alpha));
    fYg = yy * alpha + (fYg * (1.0 - alpha));
    fZg = zz * alpha + (fZg * (1.0 - alpha));

    //Roll,Pitch & Yaw Equations
   double roll  = (Math.atan2(-fYg, fZg)*180.0)/3.14;
   double pitch =( Math.atan2(fXg, Math.sqrt(fYg*fYg + fZg*fZg))*180.0)/3.14;
   double yaw = 180 * Math.atan (fZg/Math.sqrt(fXg*fXg + fZg*fZg))/3.14;

Upvotes: 3

Related Questions