9 years, 3 months ago.

data information

Hello. Thank You. in this program what is this data?

debug.printf("%f, %f, %f, %f\r\n", q1.w, q1.v.x, q1.v.y, q1.v.z);

q1.w == ???? q1.v.x == ???? q1.v.y == ??? q1.v.z == ???

How i can calculate pitch , roll , yaw ??

Please help me;

Question relating to:

An example program that decodes the data returned from the MPU9150 DMP DMP, example, MPU9150

1 Answer

9 years, 3 months ago.

Hey, q1 is a Quaternion, quaternions are necessary when dealing with rotation manipulation (Rotation matrices are also good), and it's what the MPU9150 gives you, which although it complicates matters it a very good thing.

The class Quaternion, from the QuaternionMath lib gives some methods for manipulating them, and converting to Euler angles. Euler angles have problems depending what you are using them for its best to keep them as Quaternions.

q1.getEulerAngles() will return a Vector3, which contains the Eular angles in its x,y,z

Hi Mr. Chris , Thanks for your guide, I unable to make pitch , Roll , and Yaw parameters form Quaternion. if possible to you send me a part of code that i can make this parameters, I use this code to get Pitch , Roll and Yaw, but it's not true.

q1.getEulerAngles(); Yaw = asin(-2*(q1.v.x*q1.v.z - q1.w*q1.v.y)); Pitch = -asin(2*q1.w*q1.v.y - 2*q1.v.x*q1.v.z); Roll = -atan2(2*q1.v.y*q1.v.z + 2*q1.w*q1.v.x, -(q1.w)*q1.w + q1.v.x*q1.v.x + q1.v.y*q1.v.y - q1.v.z*q1.v.z); debug.printf("$ Yaw = %f,Pitch = %f,Roll = %f #\r\n", Yaw, Pitch, Roll);

help me please. thanks.

posted by Yashar Zamani Harghalani 18 Jan 2015