Frame and transform
Frame (coordinate system) is a named coordinate origin, attached to a specific object or location — the robot body, a sensor, a point on the map. Transform is the offset between two frames: translation (x, y, z) plus a rotation, describing "where the child frame is located, which direction, viewed from the parent frame".
Every message with header.frame_id in ROS 2 (almost every sensor data, every localization command) is saying: "these numbers measure from the frame with this name" — a coordinate number without the frame is meaningless.
Try it: change the transform, see the child frame move
The parent frame (left, fixed) remains unchanged. The child frame moves and rotates according to the 3 numbers you set: x, y, yaw.
Directed, not symmetric
Transform always has direction: parent → child. Knowing A→B can infer B→A (inverse), but declaring a transform is a one-way declaration. You don't do the matrix addition/inversion yourself — tf2 takes care of that. Your job has only two parts:
TransformBroadcasterBuffer.lookup_transform(), even if the two frames are not directly connectedExample in project: tf_broadcaster.py
Publish a dynamic world → moving_frame transform, rotating itself around the origin — the exact formula used in the "Self-rotate" box in the model above:
t.header.frame_id = "world" # parent frame
t.child_frame_id = "moving_frame" # child frame
t.transform.translation.x = radius * math.cos(angle)
t.transform.translation.y = radius * math.sin(angle)
t.transform.rotation.z = math.sin(angle / 2.0) # quaternion for rotation around the Z axis
t.transform.rotation.w = math.cos(angle / 2.0)
self.broadcaster.sendTransform(t)
tf_listener.py looks up that transform again without knowing how the other party published it:
t = self.buffer.lookup_transform("world", "moving_frame", rclpy.time.Time())
Try it
Need 2 terminals (already source install/setup.bash, see Module 0):
# Terminal 1 — keep running; do not close
ros2 launch ros2_basics demo_tf.launch.py
# Terminal 2
ros2 run ros2_basics tf_listener
Terminal 2 prints the position moving_frame every second — the exact number you just saw in the model, just read it as lookup_transform() instead of dragging the slider.
Example in the Atlas project
atlas_description/urdf/atlas.urdf.xacro (Module 3) — each <joint> between two <link> is the declaration of a parent→child static transform (for example, base_link → lidar_link, matching the actual LiDAR mounting position on the robot chassis). You won't call TransformBroadcaster for these frames — robot_state_publisher reads the URDF and publishes it all.