I want to track a robot's orientation in space and wanted to choose quaternions for their many advantages.
However I have a few questions that I haven't found to be solved anywhere. The method I use to get quaternions from a rotation matrix is the one by Bar-Itzhack (2000). I want to use the "version 3" method always whether or not the rotation matrix is imprecise since the method for precise matrix (version 1) also involves almost the same computational effort (contructing some matrix and getting eigen*)and this way it is more robust if my matrix happens to be imprecise. My questions regarding quaternions are the following:
How unique are they when tracking in 3D space? Can I track the rotations of the tool frame without worrying about going through discontinuities in space? (E.g. like with axis-angle representation when the angle gets close to 0° or 180° and even is undefined for those) And no arbitrary outcomes.
In the method mentioned above a special matrix is constructed from the rotation matrix and then the eigenvector of the highest eigenvalue is used as the resulting quaternion. I wanted to confirm the correctness with the following test. However the resulting fixed-angle is often negative. So I started to just negate the quaternion but I suspect that there may be cases where this is wrong, so what is the method to determine the sign? This is my verification method:
- Get rotation matrix of a fixed rotation around an axis (e.g. +42° about x)
- From this rotation, apply the linked method above (version 3) to get the quaternion.
- Get a rotation matrix from the quaternion back (method used by Craig)
- And finally I convert the rotation matrix back into fixed angle representation and see if the angle is the same.
Any help would be much appreciated.
On this project I am not using ROS, everything is self-build.