Atlas Robotics
ROS2 CommunicationIntermediate

What are TF and TF2? Tracking relative positions between coordinate frames

Atlasbot · 16/8/2026 · 11 min read

What are TF and TF2? Tracking relative positions between coordinate frames
TF tree — each frame has exactly 1 parent

An AMR robot has many different "frames" (coordinate frames) coexisting: the frame of the LiDAR (mounted on the robot's head, 20cm from the center of the robot), the frame of the robot itself (base_link, moving on the floor), the overall map frame (map, fixed). When LiDAR measures an obstacle "2m ahead of the LiDAR", the real question to answer is: where on the map is that obstacle? — this is exactly the problem TF2 solves.

Key concepts

TF2 (Transform Library, version 2) tracks position and direction relative between frames over time, organizing them into one tree — each frame is correct a parent frame, no loops. Common structures on an AMR:

map
 └── odom
      └── base_link
           ├── lidar_link
           ├── imu_link
           └── camera_link
  • map → odom — updated by the global localization system (AMCL, SLAM), corrects drift errors of odometry over time
  • odom → base_link — continuously updated by the odometry calculation node, based on
  • base_link → lidar_link/imu_link/camera_link — usually fixed, determined by the actual physical installation location of each sensor on the robot frame (declared in URDF, unchanged over time)

Broadcaster and Listener

Node that knows the relationship between two frames will play the role broadcaster, continuously publish transforms to the TF2 system. Which node needs to know "where point A in frame X is located in frame Y" plays the role listener, call the lookup function — TF2 automatically chain Intermediate transforms if two frames are not directly connected, for example adjectives lidar_link come out map must go through enough lidar_link → base_link → odom → map.

In short: Without TF2, each node would have to manually calculate the coordinate conversion geometry between every pair of frames it needed — very error-prone and not reusable. TF2 standardizes this into a common lookup service for the entire system.

How it works

Generate static transform between base_link and lidar_link (LiDAR fixedly installed, 0.1m from the robot center along the X axis):

ros2 run tf2_ros static_transform_publisher 0.1 0 0.15 0 0 0 base_link lidar_link

Look up transform between any two frames, even if not directly connected — TF2 automatically calculates the intermediate string:

from tf2_ros import Buffer, TransformListener

tf_buffer = Buffer()
listener = TransformListener(tf_buffer, self)

transform = tf_buffer.lookup_transform('map', 'lidar_link', rclpy.time.Time())
# TF2 automatically accumulates: lidar_link → base_link → odom → map

Visually view the entire system's current TF tree — debugging tools are almost mandatory when robots "behave strangely":

ros2 run tf2_tools view_frames    # Export to PDF file drawing the entire TF tree

Technical details

Formulas

Each transform in TF2 includes 1 translation + 1 rotation (represented by quaternions) — mathematically essentially a 4×4 uniform transformation matrix. Multiplying multiple consecutive transforms in a series is equivalent to multiplying those matrices together:

T(A→C) = T(A→B) × T(B→C)

Simplified example (only translates along the X axis, ignores rotation):
base_link → lidar_link: translation +0.1m
odom → base_link: robot is at position +2.0m
→ odom → lidar_link: 2.0 + 0.1 = 2.1m

This is why TF2 always needs to follow the correct sequence of intermediate frames — it is impossible to "jump" calculations directly from one frame to the other if you don't know enough transforms along the way.

Parameters

Publishing frequency varies depending on the type of transform in the TF tree — dynamic transforms need a high enough frequency to avoid erroneous interpolation:

Transform typeTypical publishing frequency
odom → base_link (from odometry)20 – 50Hz
map → odom (from AMCL/SLAM)1 – 10Hz (much slower, because of heavier computation)
base_link → sensor (static, from URDF)Publish once, keep

Protocol

Downstairs, TF2 is simply 2 regular ROS2 topics: /tf (for dynamic transform, publish continuously) and /tf_static (for static transform, use QoS Transient Local learned in the QoS lesson — make sure the node that starts up later still received immediately instead of having to wait, because static transforms are usually only published once at startup). This is the clearest practical example of the reason for Durability QoS: if /tf_static uses Volatile as default, any subsequent startup nodes will never know the sensor's installation location.

Practical applications

When the camera detects an obstacle at local coordinates in frame camera_link (eg: "object 1.5m away from the camera, 0.3m left"), the obstacle handling node needs to use TF2 to convert that coordinate to the global map frame before putting it into Nav2's cost map — if not converted correctly, the obstacle location on the map will be incorrect. deviation between the camera mounting position and the robot's center, causing the robot to avoid the wrong place or not avoid the obstacle that is actually there.

Practical example

$ ros2 run tf2_ros tf2_echo base_link lidar_link
Output:
At time 1723000000.123456789
- Translation: [0.100, 0.000, 0.150]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]

Translation: [0.100, 0.000, 0.150] confirms the correct static transform published in the above example — LiDAR is 0.1m from the robot center in X and 0.15m in Z (higher), rotation is unit quaternion (no rotation). tf2_echo is the fastest tool to confirm whether a specific transform exists and has the correct value, before suspecting more complex code.

Common mistakes

  • Extrapolation error — listener asks transform at a time point that the broadcaster has not yet published (or published too long ago, exceeding the TF2 buffer "window") — usually caused by 2 nodes running at a large frequency difference or the system clock is out of sync — use rclpy.time.Time() (latest available time) instead of a specific time if not practical the need for exact timestamp synchronization.
  • Forgot to publish a static transform for a sensor — a node trying to look up lookup_transform to a frame that has never been published by any broadcaster will always fail (no transform to calculate) — check with ros2 run tf2_tools view_frames to confirm if the frame exists in the TF tree or not.
  • A frame with more than 1 parent frame — violating TF2's mandatory tree structure (only 1 parent per frame) — usually occurs when 2 different packages accidentally publish transforms to the same subframe, causing an ambiguous/unknown lookup.
  • Different system clocks between multiple computers contributing to 1 TF tree — if the robot has multiple onboard computers (eg Jetson and industrial computer) that are not time synchronized (via NTP/chrony), timestamps on transforms from different machines may be different, causing extrapolation errors even though the publish frequency is completely normal.

Conclusion

TF2 is a foundation system that solves the problem of "where is this point in that frame" for the entire robot system - based on tree structure and automatic transform multiplication mechanism, running on two familiar ROS2 topics (/tf, /tf_static). Nearly every spatial awareness package (SLAM, Nav2, point cloud processing) depends directly on TF2 to function properly. This is also the last article of the ROS2 Communication section - enough technical background to move to the ROS2 Package section, where you learn how to package these nodes and transforms into a complete package.

Get new articles and lessons by email

When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.

Unsubscribe any time with the link in each email. See our Privacy policy.

What are TF and TF2? Tracking relative positions between coordinate frames — Atlas Robotics