Calculation of roll, pitch and yaw angles

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Calculation of roll, pitch and yaw angles

26,681 次查看
shrijan00
Contributor I

I have an IMU FXOS8700CQR1 which has an accelerometer and magnetometer. I'm trying to calculate roll, pitch from the accelerometer and yaw from the magnetometer.

roll = atan2(-accelerometer[1],accelerometer[2]);

pitch = atan2(accelerometer[0],sqrt(accelerometer[1]*accelerometer[1]+(accelerometer[2]*accelerometer[2])));

magx = magnetometer[0]*cos(pitch)+magnetometer[1]*sin(roll)*sin(pitch) + magnetometer[2]*sin(pitch)*cos(roll);

magy = -magnetometer[1]*cos(roll) + magnetometer[2]*sin(roll);

yaw =  atan2(-magy,magx)*180/M_PI; 

I'm getting incorrect yaw data but I'm not sure about the equations which I found on the internet. Does anybody have any idea in this regard?

Thanks!

标签 (2)
标记 (2)
0 项奖励
回复
3 回复数

24,477 次查看
reyes
NXP TechSupport
NXP TechSupport

Hi,

Equation 22 of the application note AN4248 may help you for this task: https://cache.freescale.com/files/sensors/doc/app_note/AN4248.pdf

 

However, if your system need the yaw, pitch and roll calculations, I would recommend you to use the FXAS21002 gyroscope sensor instead: https://www.nxp.com/docs/en/data-sheet/FXAS21002.pdf

Regards,

Jose

0 项奖励
回复

23,537 次查看
JimmyXelectroN
Contributor I

Um, how would you go about calculating the yaw angle with only a gyroscope. I have an MPU6050 6-axis accelerometer and gyroscope and I have been unsuccessfully trying to calculate yaw angle.

0 项奖励
回复

12,065 次查看
Hari123pass123
Contributor I
I have an mpu6050 which has an accelerometer and gyroscop . I'm trying to calculate roll, pitch from the accelerometer and yaw from the sensor I'm getting incorrect yaw data please help to me
0 项奖励
回复