Robotics and Middleware · ROS 2 concept
TransformTF
Transform (ROS transform library, tf2)
Also known as tf2, TF tree, transform tree, tf2_ros, static transform
In ROS, the tf2 transform library and the data it manages: it tracks the position and orientation of every coordinate frame relative to its parent over time, so data can be converted between any two frames at a chosen timestamp.
Explanation
A robot or vehicle has many frames (map, odometry, vehicle base, each sensor) that move relative to each other. tf2 keeps their relationships in a tree that is buffered in time: each frame has one parent and any number of children, and each edge holds a rigid transform (translation and rotation). Users can ask questions such as where an object seen in a camera frame was relative to the map 50 ms ago.
Transforms are published as messages: static transforms, such as fixed sensor mountings, and dynamic ones, such as odometry, that are published continuously. tf2 works in distributed systems, so every component can build its own transform buffer, or a central node can collect them. Published transforms describe the frame relationship, which is the inverse of the transform applied to data. This is a common source of sign errors, which tf2 handles when traversing the tree.
Accuracy depends on calibration, timestamps and publication rates. Lookups fail if a transform is missing, too old or requested for a future time, and incorrect extrinsic calibration silently corrupts fused data.
How it works
Broadcasters publish stamped transforms containing the parent frame, child frame, timestamp, translation and quaternion rotation. A listener fills a time-indexed buffer. To convert data stamped at time t from frame A to frame B, tf2 finds the path between the frames in the tree, interpolates each dynamic transform at t, composes the transforms along the path, and applies the result to points, vectors or poses.
Automotive applications
- Projecting LiDAR points into camera images
- Expressing detections in the vehicle or map frame
- Combining odometry and localisation estimates
- Visualising sensor data in a common frame
Example
A radar detection stamped at t = 10.050 s in frame radar_front is transformed into base_link using the static mounting transform, then into map using the odometry and localisation transforms interpolated at the same timestamp. The tracker therefore receives positions in a consistent world frame.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- Tf2 (ROS 2 documentation source) (opens in a new tab)
“tf2 is the transform library, which lets the user keep track of multiple coordinate frames over time.”
- REP 105: Coordinate Frames for Mobile Platforms (opens in a new tab)
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.