1.9 TF and Coordinate Transforms

1.9.1 Contents

  1. TF, Frames, and base_link

  2. Getting frame_id from Messages

  3. Querying TF Between Frames

  4. X2 Supported Frames and Data Interfaces

  5. Viewing the TF Tree

  6. FAQ

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.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 reference base_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>]
  • Translation is the position of the LiDAR Frame origin relative to base_link, in meters.

  • Rotation is the orientation of the LiDAR Frame relative to base_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 frame_id Interface

Actual Frame

TF Relationship and Usage

LiDAR

Point Cloud

/aima/hal/sensor/lidar_chest_front/lidar_pointcloud

lidar_chest_front

Connects to base_link

RGB-D

Color Image and Intrinsics

/aima/hal/sensor/rgbd_head_front/rgb_image, /aima/hal/sensor/rgbd_head_front/rgb_camera_info

rgbd_head_front

Connects to base_link

RGB-D

Depth Image and Intrinsics

/aima/hal/sensor/rgbd_head_front/depth_image, /aima/hal/sensor/rgbd_head_front/depth_camera_info

rgbd_depth_head_front

Parent Frame is rgbd_head_front; connects to base_link

Stereo

Left Compressed Image and Intrinsics

/aima/hal/sensor/stereo_head_front_left/rgb_image/compressed, /aima/hal/sensor/stereo_head_front_left/camera_info

stereo_head_front

Compressed images are disabled by default and must be enabled dynamically; primary stereo-module Frame, connected to base_link

Stereo

Right Compressed Image and Intrinsics

/aima/hal/sensor/stereo_head_front_right/rgb_image/compressed, /aima/hal/sensor/stereo_head_front_right/camera_info

stereo_head_front_right

Compressed images are disabled by default and must be enabled dynamically; parent Frame is stereo_head_front, connected to base_link

Rear RGB

Compressed Image and Intrinsics

/aima/hal/sensor/rgb_head_rear/rgb_image/compressed, /aima/hal/sensor/rgb_head_rear/camera_info

rgb_head_rear

Compressed images are disabled by default and must be enabled dynamically; connects to base_link

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 frame_id

TF Usage

Independent Body IMU

Chest IMU

/aima/hal/imu/chest/state

base_link

Data is already expressed in base_link; no additional TF query is required

Independent Body IMU

Torso IMU

/aima/hal/imu/torso/state

base_link

Data is already expressed in base_link; no additional TF query is required

Built-in Sensor IMU

Built-in LiDAR IMU

/aima/hal/sensor/lidar_chest_front/imu

lidar_imu_chest_front

Parent Frame is lidar_chest_front; connects to base_link

Built-in Sensor IMU

Built-in Stereo IMU

/aima/hal/sensor/stereo_head_front/imu

stereo_imu_head_front

Parent Frame is stereo_head_front; connects to base_link

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

/tf_static

base_link, pelvis, IMU mounting Frames, etc.

Fixed

Query fixed mounting relationships for the robot body and IMUs

Dynamic Joint Frames

/tf

head_pitch_link, left_wrist_roll_link, hip, knee, and ankle joints, etc.

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:

  1. Read the Frame name from the data message: Read header.frame_id as described in Getting frame_id from Messages; do not infer it from the topic name.

  2. Query the relationship to base_link: Use tf2_echo base_link <frame_id-from-message>. Continuous Translation and Rotation output means the Frame is connected to the robot body reference Frame.

  3. Check TF messages when a query fails: Inspect /tf and /tf_static to confirm whether the relevant Frames are being published.

  4. Generate a TF tree for the overall structure: Use view_frames to generate a current TF-tree snapshot and inspect parent-child relationships and connectivity.

Query Result

Description

Next Step

tf2_echo continuously outputs translation and rotation

The two Frames are connected

Use TF2 in the program for coordinate conversion

Reports Invalid frame ID or that the Frame does not exist

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 view_frames to inspect connectivity

The data topic has no messages

The actual frame_id used by the data cannot currently be confirmed

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.

  • .gv file: 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:

  1. Read the Frame name again from the data message’s header.frame_id.

  2. Check capitalization, underscores, and spelling; do not infer the name from the topic.

  3. Confirm that the relevant sensor or module is running.

  4. After starting the query, wait briefly for DDS discovery and the TF cache to be established.

  5. Use view_frames to 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.