Friday, April 17, 2015

What We Learned About Quaternions

         Quaternions. Quuuaaaaternions. What an interesting word. Quaternions. Quaternions. Quaternions. Okay, that's enough.

So, at this point, you are probably already getting ready to ask 3 things:
1. What are quaternions?
2. What does quaternions have to do with the iARoC competition?
3. When will I stop saying 'quaternions'?
VectorTo answer the first question, let's talk about vectors first. For those of you that don't know, a vector can be defined as an direction and a magnitude (see diagram). A vector can be 2D or 3D. If you set a body coordinate system (i.e. with the x and y (and z) axis), where the tail is the origin,  you can define a vector with a point (e.g. (3,4), or, for 3D, (3,4,1)). In this same way, a quaternion is pretty much a 4D vector. 

You: But wait, this isn't a sci-fi competition! Are you intentionally trying to confuse me?
Me: No! Wait! I'm not done yet! Bear with me...
So, it would seem pretty obvious that a quaternion can be, say, (6,3,1,4). And this has to do... with rotation! See, you can define an object's rotation with a 3D vector representing the direction of spin and another number representing the amount of spin. Sound's familiar? Yep, it's a quaternion. That 6, 3, and 1 tells us the direction... and that 4 tells us the spin! 

Now let's answer the second question: what does this have to do with the iARoC? I mean, yabayabayaba, interesting math stuff, but where does programming play a part in this? Well, right now, in order to code the robot, we first code on the computer, and then have the phone download from the computer. Then, we have the Roomba (the robot) to use the code on the phone! If we attach the phone to the robot, then we'll be able to use some of the phone's tools to our advantage, so what we want to utilize this year is the phone's gyroscope and accelerometer. These two nifty tools can do similar, but different things. The gyroscope senses what direction the phone is tilted in. This will give us back a quaternion, so it is essential to know what quaternions are. The accelerometer senses how the phone is, well, accelerating, giving us a 3D vector. What we'll need to do is get rid of gravity's affect on the phone, or else we'll get flawed responses. 

As for the third question, well, let's just say it's... not going to happen. Quaternions. Quaternions. Quaternions.Quaternions. Quaternions. Quaternions...

No comments:

Post a Comment