The ROS TF tree - LCAS/RBT1001 GitHub Wiki

The tf system in ROS keeps track of multiple coordinate frames and maintains the relationship between them in a tree structure.

Visualising the TF

  1. Launch the visualisation of a RR arm: ros2 launch week2 view_robot.launch.py

  2. On rviz, add the TF object.

    Screenshot from 2024-02-05 12-08-02

  3. You should now see a schematic 3D representation of all your links and their reference frames (you can disable the robot model visualisation for ease of view):

    Screenshot from 2024-02-05 12-10-51

Here, the x, y, and z axes of each frame are represented by red, green, and blue lines respectively. The parent-child relationship between the coordinate frames is shown through an arrow (purple pointer tip) pointing from the child to its parent frame.

Compute transformations between frames

From a terminal window, you can visualise the computed transformations between any two frames in the TF tree. The general command is in this form:

ros2 run tf2_ros tf2_echo <source_frame> <target_frame>

For example, let's visualise the transformation between the base of the robot and the final end effector frame:

ros2 run tf2_ros tf2_echo base_link tool_link

and you'll see something translation and rotation parameters, also represented as an homogeneous transformation matrix:

At time 1707135675.157117663
- Translation: [1.332, 0.200, 1.811]
- Rotation: in Quaternion [0.000, 0.934, 0.000, 0.357]
- Rotation: in RPY (radian) [3.142, 0.730, 3.142]
- Rotation: in RPY (degree) [180.000, 41.832, 180.000]
- Matrix:
 -0.745  0.000  0.667  1.332
  0.000  1.000  0.000  0.200
 -0.667  0.000 -0.745  1.811
  0.000  0.000  0.000  1.000

Try it yourself: Check how translation and orientation changes when you move the robot's joints. Can you identify the elementary transformations you have seen in class?