Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 7 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:
![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
1 Answer
9 years, 7 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 18 Jan 2015