ROS2 TF (tf2)
309 words · 2 min read · 1 source
tf2 in ROS2 tracks every coordinate frame on a robot and lets nodes transform points and poses between them. The geometry backbone of robotics.
tf2 (transform library version 2) is the ROS2 system for managing coordinate frames over time. Every part of a robot — the base, each joint, each sensor — has its own frame, and tf2 lets any node ask, 'where is point X in the world frame right now?' tf2 answers using broadcast transforms from all over the robot.
What is ROS2 TF (tf2)?
tf2 (transform library version 2) is the ROS2 system for managing coordinate frames over time. Every part of a robot — the base, each joint, each sensor — has its own frame, and tf2 lets any node ask, 'where is point X in the world frame right now?' tf2 answers using broadcast transforms from all over the robot.
How It Works
Each rigid component publishes its pose relative to its parent on a tf topic. tf2 maintains a global tree where every node has exactly one parent, except the root (typically map). A query like 'point in base_link frame, expressed in map frame at time t' walks the tree and chains transformations using interpolation in time. Static transforms (like sensor mounting) are published once. Dynamic transforms (like joint rotations or robot pose) are published continuously.
Real-World Example
On a Spot robot, tf tracks map → odom → base_link → leg_<id>_hip → ... for every leg link. Every camera publishes its frame so you can project pixels back into world coordinates. Nav2 path planners rely entirely on tf to know where the robot and goals are.
Why It Matters for Robotics
Coordinate frames are where 90% of robotics bugs happen. Mastering tf2 — broadcasters, listeners, static vs dynamic, time-interpolation — is non-negotiable. Every ROS2 interview will probe your tf knowledge.
Try It Yourself
In a TurtleSim setup, launch the 'tf2 turtle demo' that has turtle1 chase turtle2. Visualise the transforms in RViz2, change which turtle is the parent frame, and watch the tree update live.
Quick Quiz
Quick Quiz
3 questions
1.tf2 tracks:
2.Every node in a tf2 tree has:
3.A static transform is best used for:
Further Reading
Ask R2 About This
Open the R2 Co-pilot (press ⌘K anywhere on R2BOT) and ask: "Explain ROS2 TF (tf2) for a Class 9 student in India, with one real-world Indian example." You'll get a tailored, sourced answer in seconds.
🐍 Python Playground · runs in your browser
Editor · 15 lines
Output
Press ▶ Run to execute. First run downloads Python (~6MB) — only happens once per page.
Powered by Pyodide · Python in WebAssembly · no server required.
Next: the course path
Five free courses, from zero to your own robot design
Short videos with a quiz after each one, a final activity and a certificate per course.
See the course path →Plain English. Free. Unsubscribe in one click.
Keep going
ROS2
Robot Operating System 2 — the DDS-based middleware that runs nearly every modern research and commercial robo…
ConceptROS2 URDF
URDF (Unified Robot Description Format) describes a robot's links, joints, and visuals as XML. The standard wa…
ConceptKinematics
Kinematics describes the geometry of a robot's motion — where each part is and where it will be — without aski…
Last updated · 2026-05-21
Spotted something off? Report an error →