I’m from team 3603 and this year we are learning how to use a NavX-Micro sensor on our robot. When I was first learning how to use it, I looked in the little box that shows up in Eclipse when you type something so I could see what all functions it has and what values I can obtain. I found a “.getQuaternionX()” function. Not only is there an “X” quaternion value, but there is also a “Y”, “Z”, and even a “W” value. I am assuming those are different axis that I can read from, but what would a W axis be? I did some research about what a quaternion value was and it only confused me even more. What is a quaternion value and how can I use it? I read they can be very useful in robot orientation.
X, Y, Z are the components of the rotation axis. W is the amount of rotation. Quaternions can be useful for complicated rotations/transforms because they avoid gimbal lock. However, if you’re just starting out, you should use euler angles (getYaw, getPitch, getRoll)
I’d like to echo this - if you’re just getting started, the yaw value is likely the only value you’ll need to use.
As experience with IMU technology increases, I think you’ll find Quaternions to be an interesting way to express rotations in 3D-space. And the SF2 library uses these to interpolate 3D rotation for video latency correction so they are indeed useful.
But first things first: it’s recommended to focus on learning to work w/the yaw angle.
I’ll echo this as well. The useful values for a robotics application are the Tait-Bryan angles (yaw, pitch and roll), and since you’re almost exclusively on a 2D plane, the yaw is really all you need (unless it’s one of the years where ramps are involved).
The quaternion representation of motion is most useful for two related reasons:
- As the others mentioned, it avoids the gimbal lock issue (if you think of yaw, pitch, and roll descriptions, they do weird things when pitch=90 degrees, since all of a sudden “roll” and “yaw” are the same thing).
- If you have to deal with compound rotations, quaternions basically just multiply together (although the multiplication is not commutative, order matters, AB is not BA). This is really useful for things like “I’ve mounted a sensor on my robot, but it’s not aligned with the robot’s axes”. Correctly converting angular rotations from one coordinate system to another with Euler angles is complicated and involves a lot of trig and special case handling for gimbal lock. Doing it with quaternions is straightforward.
It can be a fun little exercise to look at the quarternion values and see how they they vary as your robot turns, but really, the yaw value is the useful one