ROBOTICS 101Concept explainer

TF2 and the Transform Tree

A robot has many coordinate frames: the map, its odometry, its base, each arm link, its camera, its gripper. ROS 2's TF2 library keeps them in a tree, where each frame has one parent and a transform to it. To answer "where is the cup, seen by the camera, in map coordinates?", TF2 walks the tree and chains the transforms together.

A tree of frames

Each edge stores the transform from a parent to a child, published by whatever knows it: localization publishes map → odom, odometry publishes odom → base_link, the robot state publisher publishes the arm links from the URDF and joint angles. A query between two frames goes up to their common ancestor and back down, composing transforms along the way:

$$T^{\text{map}}_{\text{camera}} = T^{\text{map}}_{\text{odom}}\;T^{\text{odom}}_{\text{base}}\;T^{\text{base}}_{\text{camera}}$$

What to notice

Moving the arm joint changes the gripper frame but not the camera, which is mounted on the base. Odometry drift shows up as the gap between map and odom: localization corrects for it by adjusting that one transform, so everything below stays consistent. TF2 also stores transforms over time, so you can ask where a frame was when a sensor reading was taken, which matters for moving robots. ros2 run tf2_tools view_frames draws this tree for a real robot.