Skip to content

Frame transformations in ROS [2425]

francescodelduchetto edited this page Feb 6, 2025 · 2 revisions

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 our 6 Degree of Freedom (6DOF) arm:

ros2 launch mecharm slider_control.launch.py

▶️ 🖥️ 2. Untick the RobotModel option on the left sidebar to remove the robot visualisation

untick

You are now left with a schematic 3D representation of all the robot links and their reference frames, as shown above.

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.

▶️ 🖥️ To study more easily single rotations between frames, you can select to display only two consecutive frames. Click on "Frames" under the "TF" tool, then select only the frames you want to visualise:

frames

Compute transformations between frames

From a terminal window, you can visualise the computed transformations between any two frames in the TF tree.

▶️ 🖥️ For example, let's visualise the transformation between the base of the robot and the last frame:

ros2 run tf2_ros tf2_echo base link6

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

At time 1738847304.925373256
- Translation: [0.168, 0.000, 0.243]
- Rotation: in Quaternion [-0.500, 0.500, -0.500, 0.500]
- Rotation: in RPY (radian) [-1.570, -0.000, -1.571]
- Rotation: in RPY (degree) [-89.980, -0.000, -90.000]
- Matrix:
 -0.000  0.000  1.000  0.168
 -1.000 -0.000 -0.000  0.000
  0.000 -1.000  0.000  0.243
  0.000  0.000  0.000  1.000

▶️ 🧑‍💻 Now explore how translation and orientation change when you move the robot's joints.

▶️ 🧑‍💻 Try echoing the translation and rotation between consecutive links, such as base - link1 and link2 - link3. Can you identify the rotation matrices you have seen in class? image


Chain of rotations

▶️ 🖥️ Enable frames visualisation only for link4 and link5. You will see that they have the same point of origin (i.e. there is no translation).

Screenshot from 2025-02-06 14-32-32

▶️ 🧑‍💻 What is the fixed rotation between these two frames $R_4$? Around which axis?

▶️ 🧑‍💻 Write down the rotation matrix for $R_4$. Does it look like the one shown by the ros2 run tf2_ros tf2_echo link4 link5?

▶️ 🧑‍💻 What if we rotate joint5 (shown as joint5_to_joint4 in the joint state publisher)? What rotation $R_5$ does it perform?

▶️ 🧑‍💻 How can we represent the chain of rotations between $R_4$ and $R_5$? Try to compute it and check if it is correspond to the output of ros2 run tf2_ros tf2_echo link4 link5

2024/2025

Syllabus

2023/2024

Syllabus

Clone this wiki locally