Coodinate Frames, Transforms, and TF
References
An excellent reference for coordinate frames and transforms is the first chapter of John Craig's book, Introduction to Robotics [1986, 1989]. We follow his conventions for transform and point indices.
Geometric objects in tf are represented by tf types, which are equivalent to corresponding bullet types; see tf data types. Bullet class references for transforms and quaternions are handy.
Frames and Points
A frame is a coordinate system. Coordinate systems in ROS are always in 3D, and are right-handed, with X forward, Y left, and Z up.
Points within a frame are represented using tf::Point, which is equivalent to the bullet type btVector3. The coordinates of a point p in a frame W are written as ^{W}p.
Frame Poses
The relationship between two frames is represented by a 6 DOF relative pose, a translation followed by a rotation. If W and A are two frames, the pose of A in W is given by the translation from W's origin to A's origin, and the rotation of A's coordinate axes in W.
The translation is a vector in W's coordinates, ^{W}t_{A}. It is represented by tf::Vector3, which is equivalent to btVector3.
The rotation of A is given by a rotation matrix, represented as ^{W}_{A}R, using our convention of the reference frame as a preceeding superscript. The way to read this is: "the rotation of the frame A in W's coordinate system." The columns of R are formed from the three unit vectors of A's axes in W: ^{W}X_{A}, ^{W}Y_{A}, and ^{W}Z_{A}.
There is no tf type for a rotation matrix; instead, tf represents rotations via tf::Quaternion, equivalent to btQuaternion. The bullet quaternion type has methods for creating quaternions from rotation matrices, and vice versa.
It's convenient to describe the translation + rotation in homogeneous coordinates, as a single 4x4 matrix ^{W}_{A}T. This can be read as: "the pose of frame A relative to frame W." The relative pose is constructed as follows:
^{W}_{A}R |
^{W}t_{A} |
0 |
1 |
In tf, relative poses are represented as tf::Pose, which is equivalent to the bullet type btTransform. The member functions are getRotation() or getBasis() for the rotation, and getOffset() for the translation of the pose. See the bullet btTransform class reference.
Frame poses as Point Mappings
There is a duality between frame poses and mapping points from one frame to another. The pose ^{W}_{A}T can also be read as, "transform a point in A's frame to W." The syntax gives a "cancellation" of the A frame: ^{W}_{A}T^{A}p = ^{W}p.
Mappings or transforms have their own type, tf::Transform. This is equivalent to the bullet btTransform, so essentially pose offsets and transforms are the same type. Transforms can be created using rotation matrices or quaternions for the rotation, and vectors for the translation. See the bullet btTransform class reference.
Transform Inverse
The inverse of a transform ^{W}_{A}T is the transform ^{A}_{W}T. The inverse maps points in the reverse direction from the original transform. Inverses are conveniently calculated using the inverse() member function of btTransform.