[ROS in 5 mins] 044 – What is ROS tf?

[ROS in 5 mins] 044 – What is ROS tf?

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

  1. It’s a Ros Package
  2. It lets the user keep tracking of multiple coordinate frames over time.
  3. 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:

TF ROS 101

ROS Basics In 5 Days (Python) 

ROS Basics In 5 Days (C++)

 

Edited by: Tony Huang


Links mentioned in the video and other useful links:

 

We love feedback, so, whether you like the video or not, please share your thoughts on the comments section below.

Thanks for watching.

[irp posts=”11242″ name=”[ROS in 5 mins] 043 – What is tf view_frames?”]

[ROS in 5 mins] 043 – What is tf view_frames?

[ROS in 5 mins] 043 – What is tf view_frames?

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:

TF ROS 101

ROS Basics In 5 Days (Python) 

ROS Basics In 5 Days (C++)

 

We love feedback, so, whether you like the video or not, please share your thoughts on the comments section below.

Thanks for watching.

 

Edited by: Tony Huang

ROS Q&A | Treating quaternions for 2D navigation

ROS Q&A | Treating quaternions for 2D navigation

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

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

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:


#include <tf/tf.h>
#include <nav_msgs/Odometry.h>
#include <geometry_msgs/Pose2D.h>

ros::Publisher pub_pose_;

void odometryCallback_(const nav_msgs::Odometry::ConstPtr msg) {
geometry_msgs::Pose2D pose2d;
pose2d.x = msg->pose.pose.position.x;
pose2d.y = msg->pose.pose.position.y;

tf::Quaternion q(
msg->pose.pose.orientation.x,
msg->pose.pose.orientation.y,
msg->pose.pose.orientation.z,
msg->pose.pose.orientation.w);
tf::Matrix3x3 m(q);
double roll, pitch, yaw;
m.getRPY(roll, pitch, yaw);

pose2d.theta = yaw;
pub_pose_.publish(pose2d);
}

int main(int argc, char **argv)
{
ros::init(argc, argv, “conversion_node”);

ros::NodeHandle nh_;

ros::Subscriber sub_odom_ = nh_.subscribe(“odom”, 1, odometryCallback_);
pub_pose_ = nh_.advertise<geometry_msgs::Pose2D>(“pose2d”, 1);

ros::spin();

return 0;
}

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.

Pin It on Pinterest