简体   繁体   中英

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!

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM