A simple introduction to transformations and tf in ROS

Coordinate systems (also called frames) in ROS define the origin and directions of the x, y, and z axes in the world. Each frame has its own frame_id. The most basic frame is usually called world or map and it is the reference for all other frames. Typically, the robot's base has its own frame called base_link.

Here is an example of different coordinate systems of two robots – an industrial manipulator and the popular PR2 humanoid robot.

Red indicates the x direction, blue the y direction, and green the z direction.

The transformation determines the shift and rotation necessary to get from the source frame to the target frame. All possible transformations between all frames available in the system form a transformation tree. The presence of a transformation tree allows you to obtain the necessary transformation between any two directly unrelated frames through a chain of transformations.

Tools for working with transformations in ROS

ROS has a special package for working with transformations tf. The package provides convenient tools for interacting with the transformation tree.

tf has several useful utilities for obtaining information about the transformation tree.

The first utility is tf_monitor.

Let's run the command:

rosrun tf tf_monitor

You will have something like this result in the terminal (if the SLAM algorithm works)

The second is tf_echo.

We obtain information about the transformation between two coordinate systems:

rosrun tf tf_echo /map /odom

The output will be like this:

..

Another useful utility is static_transform_publisher. static_transform_publisher allows you to publish a static transformation to tf.

Its syntax is like this

static_transform_publisher xyz yaw pitch roll frame_id child_frame_id period_in_ms

For example:

rosrun tf static_transform_publisher x_val y_val z_val yaw_val pitch_val roll_val base_link base_laser period_hz

static_transform_publisher can also be used in the launch file.

And finally view_frames

rosrun tf view_frames

This command collects information about the transformation tree and saves it in a convenient graphical form in the frames.pdf file.

Let's open the frames.pdf file and see something like this:

Example program for working with tf

https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=http://wiki.ros.org/tf&ved=2ahUKEwjk4t7gz92IAxU4RvEDHdQDHtcQFnoECAsQAQ&usg=AOvVaw3bRx384trpqZPISRDPPoCe

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *