I've got an initial quaternion , q0. And I get angular velocity measurments, I integrate the the velocities so I got 3 angles at 50Hz or so. How can make a quaternion based on the 3 angles? I can't just make 3 quaternions, can I?
So to make it clear.
Q.new=Q.new*Q.update(alfa,beta,gamma)
Q.new represents my current orientation in a quaternion, I want to update it by multiplying with a Q.update quaternion. How can I make the Q.update with the angles?
Thanks!
Forgive me thread necromancing, but the answers all seem to complicated and some, like me, may prefer this more 'convenient' approach:
Say omega=(alpha,beta,gamma) is the measured angular velocity vector of the gyros. Then we rotate
theta = ||omega||*dt; //length of angular velocity vector
many units (deg or rad dependent on gyro) around
v = omega / ( ||omega|| ); // normalized orientation of angular velocity vector
Thus, we can construct the rotation quaternion as:
Q.update = (cos(theta/2),v_x * sin(theta/2), v_y * sin(theta/2), v_z * sin(theta/2));
All that is left now is to rotate our current rotation by Q.update
. This is trivial:
Q.new = multiply_quaternions(Q.update,Q.new);
// note that Q.update * Q.new != Q.new * Q.update for quaternions
Done. Quaternions are beautiful, aren't they?
Some slides on gyros and quaternions that may be useful: http://stanford.edu/class/ee267/lectures/lecture10.pdf