## Saturday, April 2, 2011

### Processing

So, somehow I have to test this IMU. The usual way is to draw a box on the screen with the same orientation as the IMU, then tumble the IMU and watch the box on the screen do the same thing. To do this, I will use Processing, because it has an example which is easy to hack into what I want.

This involves getting all the conventions right. I am going to use quaternions, because they are singularity-free and relatively easy to use with a Kalman filter. Now there are about 16 different quaternion conventions, several different matrix conventions, and several different coordinate frame conventions. I am just going to figure things out by experiment. I am going to use right-handed physical quaternions.

First, an aside on the right-hand rule.

To tell the orientation of a positive rotation, point the thumb on the right hand in the POSITIVE direction of the axis you care about, and curl your fingers around. Your fingers are then curled in the POSITIVE rotation direction around that axis.

Make sure to use your right hand. Put down the pencil, keyboard, mouse, or other thing you are holding and use your right hand. I still make this mistake occasionally, because I am holding or doing something with my right hand.

A quaternion is made from an axis-angle representation as follows: The scalar part is the positive cosine of the angle, and the vector part is the positive sine of the angle multiplied by the axis.

Quaternions are used to transform a vector as follows: =q'q. This means that to combine two rotations we multiply them in direct order, first transform on the left, second on the right. This is the reverse of normal for matrices.

When I did the calibration, I consider a right-hand rotation of the box (physical body rotation) to be a positive rotation. Unfortunately, this means that the Y and Z sensor raw readings are reversed out of the box. The part is still right-handed, it just means that X was aligned with box X, but the part was rotated 180deg around X