Kindr
Kinematics and Dynamics for Robotics

A rotation between two rigid bodies can be represented by using different parameterizations. The most wellknown parameterizations are Euler angles, rotation matrix, angleaxis, rotation vector and unit quaternion. Depending on the application, some representations may be better suited than others. For instance, a unit quaternion does not have singularity issues like Euler angles and are therefore better suited for calculations, but Euler angles are much easier to be interpreted by a user. The library provides therefore a type for each parameterization of a rotation, which enables type safe conversions between different representations.
The type of a rotation further depends on the usage of a rotation. A rotation can be considered either as an active (alibi) or a passive (alibi) transformation. The following figure visualizes the difference:
The figure shows a rotation about the zaxis with an angle . If the rotation is considered as active, the (blue) position vector expressed in frame A is rotated to the (green) position vector , which is also expressed in frame A. If the rotation is considered as passive, the (blue) vector is not rotated actively, but its coordinates are mapped from frame A to frame B, i.e. the result is . In other words, an active rotation rotates a vector, whereas a passive rotation rotates the coordinate frame. The result of rotation applied to a vector or columnwise to a matrix therefore depends on the usage type.
This library provides a passive implementation of different rotation parameterizations. The library depends on the C++ Eigen library, which already provides some of the representations, but does not feature the type safety and misses many features.
The following section describes the genric interface of all rotation classes, whereas the section Parameterizations shows the different parameterizations and explains how to use them.
The class kindr::RotationBase serves as an interface for a rotation between two rigid bodies. All types of representations of a rotation, such as quaternion, angleaxis, and Euler angles, are derived from this base class.
The type of a rotation is defined by
The default constructor of a rotation always creates an identity rotation. If the library is built with debugging symbols, an assertion is thrown if a rotation is constructed with parameter values that do not represent a valid rotation.
Any rotation can be set equal to the identity rotation by the method setIdentity().
A rotation that describes the relative orientation of two vectors can be initialized by means of the method setFromVectors().
A rotation can be represented in different ways. The quaternion and the quaternion , for instance, represent the same rotation. However, sometimes a unique representation is desired.
A unique representation is obtained by
Note that numerical issues may cause problems when this method is used to compare two rotations. We therefore recommend to use the method isNear() (see below).
The inverse of a rotation is provided by two methods:
A rotation can be composed of other rotations. The multiplication operator enables to concatenate rotations as follows:
Due to numerical issues, the result of the concatenation may become an invalid rotation. Due to speed considerations, the user is responsible to guarentee that the parameter values represent a valid rotation. The library therefore offers the method fix() to project the parameters to the admissible space. The method would, for instance, normalize the rotation quaternion.
To rotate a vector or a matrix columnwise, the following methods are provided:
The exponential map maps a vector in describing the axis and magnitude of a three degreeoffreedom rotation to the corresponding rotation parameterization. The mapping is provided by the method setExponentialMap(). The corresponding logarithmic map is provided by the method getLogarithmicMap().
The box plus operation defined as , where is a rotation, is a vector in and maps a vector to the skewsymmetric matrix corresponding to the cross product, is provided by the method boxPlus().
The box minus operation defined as is provided by the method boxMinus().
rotations_interfaces_comparison Comparison of Rotations To compare two rotations, the equal operator (operator==) can be used to check if a rotation is equal to another rotation.
Small numeric errors may however lead to a wrong result. Therefore, the function isNear() compares two rotations using a measure.
The difference between two rotations can be obtained by the method getDisparityAngle().
There are two kinds of conversions:
The following methods allow to convert between different representations of a rotation:
The conversion between different primitive data types (double/float) works the same way as the conversion between different representations.
The following representations are currently provided by the library:
The class AngleAxis provides an angleaxis representation of a rotation:
where is the rotation angle and is the rotation axis with unit length.
The angle and rotation axis ared stored in Eigen::AngleAxis.
The following typedefs are provided for convenience:
The class kindr::RotationVector implements a rotation vector representation of a rotation:
where is the rotation angle and is the rotation axis.
It stores the rotation vector in Eigen::Matrix<Scalar, 3, 1>.
The following typedefs are provided for convenience:
The class kindr::RotationQuaternion implements a Hamiltonian unit quaternion representation of a rotation:
It stores the coefficients according to the kindr::UnitQuaternion. See also Chapter Quternions for more information.
The following typedefs are provided for convenience:
The class kindr::RotationMatrix implements a 3x3 rotation matrix representation of a rotation:
It stores the coefficients in Eigen::Matrix.
The following typedefs are provided for convenience:
Note that the rotation matrix is stored internally differently than created by the constructor! Therefore, you should access the matrix using the method matrix() instead of toImplementation().
The class kindr::EulerAnglesZyx implements the Euler Angles using the ZYX convention:
where is the yaw angle, is the pitch angle, and is the roll angle. The consecutive rotations are shown in the following picture:
The following typedefs are provided for convenience:
The class kindr::EulerAnglesXyz implements the Euler Angles using the XYZ convention:
where is the yaw angle, is the pitch angle, and is the roll angle. The consecutive rotations are shown in the following picture:
It stores the coefficients in Eigen::Vector3.
The following four typedefs are provided for convenience: