1.9 TF and Coordinate Transforms
1.9.1 Contents
This page describes the confirmed body, joint, and sensor TF interfaces available on AgiBot X2, including how to read frame_id from sensor messages, query coordinate transforms, and inspect the TF tree.
For example, a LiDAR may measure a point one meter in front of itself, while the robot program needs that point’s position relative to the robot body. Because the LiDAR’s mounting position and orientation differ from the body reference, TF is required to obtain the coordinate transform.
Read the actual frame_id from the message instead of inferring the Frame from the topic name.
1.9.2 TF, Frames, and base_link
Frame: This is not a video or image frame, but a three-dimensional coordinate system fixed to a robot component or sensor. Think of it as a ruler with an origin and X, Y, and Z axes. For example,
lidar_chest_frontis the chest LiDAR coordinate system.header.frame_id: Identifies the Frame in which the current message data is expressed. It stores only the coordinate-system name, not transform values.TF: Describes the translation and rotation between two Frames. Programs use this relationship to convert a position from one Frame to another.
TF2: The ROS 2 tools and library for storing, querying, and composing TF transforms. This page uses the TF2 tools
tf2_echoandview_frames.base_link: The robot body reference Frame. Converting sensor data tobase_linkallows it to be used in a unified robot coordinate system.
Note
The presence of a frame_id in a message does not guarantee that a Frame with the same name exists in the TF tree. Query TF using the actual frame_id before using the data.
Dynamic and Static TF
Type |
Topic |
Description |
|---|---|---|
Dynamic TF |
|
Publishes coordinate relationships that change with robot posture, such as those between joints |
Static TF |
|
Publishes fixed coordinate relationships, such as sensor mounting relationships relative to the robot body |
TF2 can automatically compose intermediate Frames. For example, when a sensor is connected to base_link through head or torso joints, query only the source and target; no manual composition is required.
1.9.3 Getting frame_id from Messages
The following minimal query uses LiDAR point cloud data as an example. Before running it, ensure that the LiDAR module is running and that the current terminal has loaded ROS 2 and the AimDK environment.
Step 1: Check the data topic
ros2 topic info /aima/hal/sensor/lidar_chest_front/lidar_pointcloud --no-daemon --spin-time 6 # Check the LiDAR topic type and publisher count (the flags skip daemon cold start, see the FAQ)
In the output, Type is the message type and Publisher count is the number of current publishers. A count greater than 0 indicates that a node is publishing the topic.
Step 2: Read one message
ros2 topic echo /aima/hal/sensor/lidar_chest_front/lidar_pointcloud --once --no-arr # Read one LiDAR message and inspect header.frame_id
The message header should contain:
header:
frame_id: lidar_chest_front
Parameter description:
--once: Exit after receiving one message.--no-arr: Do not expand large arrays such as point clouds, making the message header easier to inspect.
The lidar_chest_front value is the actual Frame used by the point cloud. Use this name for subsequent TF queries instead of inferring it from the topic name.
1.9.4 Querying TF Between Frames
The basic tf2_echo syntax is:
ros2 run tf2_ros tf2_echo <reference_frame> <target_frame> # Query the target Frame position and orientation relative to the reference
Parameter description:
<reference-frame>: The observation reference, such as the robot body referencebase_link.<target-frame>: The sensor or robot component Frame to query.Translation: Translation of the target Frame relative to the reference Frame, in meters.Rotation: Rotation of the target Frame relative to the reference Frame.
tf2_echo continuously prints results. Press Ctrl+C after confirming them.
Complete LiDAR Example
After reading frame_id: lidar_chest_front from the point-cloud message, run:
ros2 run tf2_ros tf2_echo base_link lidar_chest_front # Query the LiDAR position and orientation relative to the robot body
Continuous Translation and Rotation output indicates that lidar_chest_front is connected to base_link through the TF tree.
The output format is similar to:
- Translation: [<x>, <y>, <z>]
- Rotation: in Quaternion (xyzw) [<x>, <y>, <z>, <w>]
Translationis the position of the LiDAR Frame origin relative tobase_link, in meters.Rotationis the orientation of the LiDAR Frame relative tobase_link.These values describe the LiDAR coordinate relationship on the robot, not obstacle distances measured by the LiDAR.
Important
tf2_echo only queries and prints the transform between two Frames; it does not modify point-cloud, image, or IMU messages. To transform sensor data, call the TF2 data-conversion API in your program.
Querying the Stereo Camera Relationship
ros2 run tf2_ros tf2_echo stereo_head_front stereo_head_front_right # Query the right stereo camera relative to the stereo main Frame
Querying the RGB-D Color and Depth Camera Relationship
ros2 run tf2_ros tf2_echo rgbd_head_front rgbd_depth_head_front # Query the depth camera relative to the color camera
1.9.5 X2 Supported Frames and Data Interfaces
Public Frames are grouped into three categories: sensor TF, IMU, and robot body and joint TF. For first use, complete the LiDAR example above, then locate other Frames by category below.
Sensor TF
Sensor data interfaces provide point clouds, images, intrinsics, or IMU measurements; /tf_static provides fixed sensor mounting relationships on the robot. These interfaces serve different purposes.
Point cloud: Environment data composed of many three-dimensional points.
Camera intrinsics: Parameters describing the camera imaging model; they do not contain image pixels.
IMU: An inertial sensor that measures orientation, angular velocity, and linear acceleration.
Parent Frame: The immediate parent of the current Frame in the TF tree; TF2 can continue along the tree to
base_link.
Sensor Module |
Data |
Data or |
Actual Frame |
TF Relationship and Usage |
|---|---|---|---|---|
LiDAR |
Point Cloud |
|
|
Connects to |
RGB-D |
Color Image and Intrinsics |
|
|
Connects to |
RGB-D |
Depth Image and Intrinsics |
|
|
Parent Frame is |
Stereo |
Left Compressed Image and Intrinsics |
|
|
Compressed images are disabled by default and must be enabled dynamically; primary stereo-module Frame, connected to |
Stereo |
Right Compressed Image and Intrinsics |
|
|
Compressed images are disabled by default and must be enabled dynamically; parent Frame is |
Rear RGB |
Compressed Image and Intrinsics |
|
|
Compressed images are disabled by default and must be enabled dynamically; connects to |
Note
A camera camera_info message contains intrinsics and header.frame_id, but no image pixels. Obtain image data from the corresponding image interface.
IMU
X2 provides four IMU data interfaces: two independent body IMUs and the built-in IMUs in the LiDAR and stereo modules. They are listed together below but use TF differently.
Type |
Data |
Data Interface |
Actual |
TF Usage |
|---|---|---|---|---|
Independent Body IMU |
Chest IMU |
|
|
Data is already expressed in |
Independent Body IMU |
Torso IMU |
|
|
Data is already expressed in |
Built-in Sensor IMU |
Built-in LiDAR IMU |
|
|
Parent Frame is |
Built-in Sensor IMU |
Built-in Stereo IMU |
|
|
Parent Frame is |
The chest and torso IMUs use the same frame_id; distinguish their data sources by topic name.
Robot Body and Joint TF
Robot body and joint transforms are not published on a separate topic for each Frame; they are published collectively through /tf_static and /tf. Other data, such as joint states, remains available through the corresponding sensor or joint-state interfaces.
Type |
TF Source |
Typical Frames |
Changes |
Usage |
|---|---|---|---|---|
Fixed Body Frames |
|
|
Fixed |
Query fixed mounting relationships for the robot body and IMUs |
Dynamic Joint Frames |
|
|
Changes with robot posture |
Query real-time positions and orientations of the head, waist, arms, and legs |
1.9.6 Viewing the TF Tree
When checking sensor TF for the first time, use this sequence:
Read the Frame name from the data message: Read
header.frame_idas described in Gettingframe_idfrom Messages; do not infer it from the topic name.Query the relationship to
base_link: Usetf2_echo base_link <frame_id-from-message>. ContinuousTranslationandRotationoutput means the Frame is connected to the robot body reference Frame.Check TF messages when a query fails: Inspect
/tfand/tf_staticto confirm whether the relevant Frames are being published.Generate a TF tree for the overall structure: Use
view_framesto generate a current TF-tree snapshot and inspect parent-child relationships and connectivity.
Query Result |
Description |
Next Step |
|---|---|---|
|
The two Frames are connected |
Use TF2 in the program for coordinate conversion |
Reports |
TF2 has not discovered the Frame |
Check the name, module status, and TF topics |
Both Frames exist, but no relationship can be queried |
The two Frames may not be connected in the same TF tree |
Use |
The data topic has no messages |
The actual |
First confirm the sensor module and topic publishing status |
A Frame is missing from the TF tree snapshot |
The Frame was not received during sampling |
Start the corresponding module or enter the required operating state, then regenerate the snapshot |
When querying two specified Frames, prefer tf2_echo. Use view_frames only when you need the overall connectivity or are troubleshooting a disconnected TF tree.
View Dynamic TF Messages
ros2 topic echo /tf --once --no-arr # Read a batch of dynamic TF messages for runtime relationships such as joints
View Static TF Messages
ros2 topic echo /tf_static --once --no-arr # Read a batch of static TF messages for fixed relationships such as sensor mounts
You usually do not need to read every entry in /tf and /tf_static. These topics are mainly useful for confirming that the relevant Frames are being published when a tf2_echo query fails.
The key fields in a TF message are:
header:
frame_id: parent_frame
child_frame_id: child_frame
Here, header.frame_id is the parent Frame and child_frame_id is the child Frame.
Generate a Snapshot of the Current TF Tree on the Robot
This operation only reads /tf and /tf_static; it sends no control commands and does not move the robot.
In a robot development terminal with ROS 2 and AimDK loaded, go to the directory where you want to save the results:
mkdir -p tf_tree_output # Create the output directory
cd tf_tree_output
ros2 run tf2_tools view_frames # Listen for current TF and generate PDF and Graphviz files
The tool usually listens for about five seconds. When it finishes, locate the generated files in the current directory:
find . -maxdepth 1 -type f # List TF-tree files generated in the current directory
Depending on the tool version, filenames may be frames.pdf and frames.gv, or timestamped names such as frames_*.pdf and frames_*.gv:
PDF file: A TF tree diagram for viewing the overall structure.
.gvfile: Graphviz text for checking parent and child Frame names precisely.
When running inside a container, generate files in a directory mounted from the robot host so they can be retrieved outside the container.
Note
view_frames records only TF messages received during sampling. Sensors that are not running, modules that have not entered localization, or dynamic TF not published during sampling may be absent. The generated file is therefore a snapshot of the robot’s TF tree in its current state and may not include Frames from every operating state.
If ros2 run tf2_tools view_frames reports No executable found, try running the tool directly from the robot’s ROS 2 environment:
python3 /opt/ros/humble/lib/tf2_tools/view_frames
1.9.7 FAQ
Invalid frame ID or frame does not exist
This means TF2 could not find the specified Frame. Check the following in order:
Read the Frame name again from the data message’s
header.frame_id.Check capitalization, underscores, and spelling; do not infer the name from the topic.
Confirm that the relevant sensor or module is running.
After starting the query, wait briefly for DDS discovery and the TF cache to be established.
Use
view_framesto confirm that the reference and target Frames are in the same TF tree.
tf2_echo waits indefinitely
The relevant TF may not have been published yet, or the reference and target Frames may not be connected. First check whether /tf, /tf_static, and the sensor data topics have publishers.
Is 10000 Hz in the TF tree diagram the actual publishing frequency?
No. view_frames may display static TF as 10000 Hz and show a timestamp of 0. This is how the tool represents static transforms; it does not mean that the sensor or static TF is actually published 10,000 times per second.
Why are some Frames missing from the generated TF tree?
view_frames records only TF messages actually received during sampling. Confirm that the relevant sensors or modules are running and regenerate the snapshot in the required operating state. For example, localization-related Frames usually appear only after localization is active.
Do the chest and torso IMUs require an additional TF query?
No. Messages from /aima/hal/imu/chest/state and /aima/hal/imu/torso/state both use frame_id: base_link; their data is already expressed in the robot body coordinate system.
Does having a frame_id guarantee conversion to base_link?
Not necessarily. frame_id only identifies the coordinate system of the data. Conversion is possible only when a matching Frame exists in the TF tree and is connected to base_link.