In this video, we’ll see what the ROS tf package is, and what it does, and how to use one of its tools (rqt_tf_tree), in just about 5 minutes!
Let’s go!
Step 0. Create a project in Robot Ignite Academy(RIA)
We have the best online ROS course available in RIA. It helps you learn ROS in the easiest way without setting up ROS environment locally. The only thing you need is a browser! Create an account here and start to browse the trial course for free now! We’ll use the TF ROS 101 as an example today.
Step 1. What is TF?
The TF
It’s a Ros Package
It lets the user keep tracking of multiple coordinate frames over time.
It allows making computations in one frame and then transforming to another.
You can see the available TF in ROS by typing the following command
rosrun rqt_tf_tree rqt_tf_tree
You can see that there are 3 coordinate frames in this simulation world, turtle 1 and turtle 2. The rqt_tf_tree will only show the relationship for a particular timestep.
Want to learn more?
If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:
In today’s video we’re going to see what is tf view_frame and how it works.
Step 0. Create a project in Robot Ignite Academy(RIA)
We have the best online ROS course available in RIA. It helps you learn ROS in the easiest way without setting up ROS environment locally. The only thing you need is a browser! Create an account here and start to browse the trial course for free now! We’ll use the TF ROS 101 unit 4 as an example today.
Step 1. TF
To publish tf topic, you have to execute the following command in this example.
roslaunch pi_robot_pkg pi_robot_control.launch
Then check it with
rostopic echo /tf -n1
It will public all the coordinate frame available in the simulation, but it’s a mass.
We can also use RViz to visualize the TF by launching
rosrun rviz rviz
But it also looks not so nice.
It turns out the tf put the coordinate frames in a tree structure. You can run the following command to plot the tree.
rosrun tf view_frames
If you open the .pdf file it generated, you all see all the frames in tf and their relationship.
Want to learn more?
If you are new to ROS, I highly recommend you to take any of the following courses on Robot Ignite Academy:
Are you having problems to make your robot navigate because of the kind of data you have to treat? It’s very common to get stuck when we have to work with quaternions, instead of RPY angles. Quaternions are used in robotics to represent the rotation, in 3 axis, of a rigid body in respect with a coordinate frame. But sometimes it’s too much for what we want to do.
In this post, we are going to see how to get only the necessary data from a quaternion for a 2D application. It is very helpful, since robotics algorithms works with quaternions, but user’s interface, RPY angles.
Let’s start with a robot, to make it clear. In this post, we are going to use the Turtlebot simulation, available in ROS Development Studio (RDS).
Turtlebot Simulation
We have provided by the robot sensors a /odom topic, which publishes messages of the nav_msgs/Odometry type. See below a single message example:
Odometry message
Now, unless you have a path described using quaternions, we need to convert this quaternion to RPY. To do the following, we will use the TF library. In the image below, you can see the program in charge of this task:
First, we are creating a node and subscribing the /odom topic. In the callback of this subscriber, we are getting the information that matters for us, which are the X, Y and Yaw data. To have the Yaw angle, we are using the quaternion data and converting to RPY (We need a Matrix3x3 object in the middle process). Since our robot has only three degrees of freedom (linear in X and Y, angular in Z), we are not considering Roll and Pitch, the Pose2D message type is enough for us. This is a simplification for a ground robot navigating in a planar scenario.