here https://docs.ros.org/kinetic/api/eigen_conversions/html/eigen__msg_8cpp_source.html#l00093
I quite do not understand the syntax of this line : Eigen::Quaterniond q = (Eigen::Quaterniond)e.linear();
But anyway, assuming e
is of type Eigen::Affine3d
(3x3 rotation matrix), where can I figure out how a quaternion is constructed fron a rotation matrix in Eigen library please? I did not saw any method on the doc, except https://eigen.tuxfamily.org/dox/classEigen_1_1QuaternionBase.html#title25 but I'm a real noob in c++ so I do not even understand that one...
I hope it does something like this https://arc.aiaa.org/doi/abs/10.2514/2.4654?journalCode=jgcd because my need is that the extracted quaternion must be normalized, and I would like to ensure this.
You can ensure that your
Eigen::Quaterniond
is normalised by calling it'snormalize()
method.The line in question is explicitly converting whatever
e.linear()
returns to aEigen::Quaterniond
.As to how you go from a rotation matrix to a quaternion, Wikipedia describes the relationship. It's just solving a known set of simultaneous equations. I expect the body of the method to look (more or less) like a bunch of algebra.