Difference between subscribing to the /odom and create a tf.TransformListener()

,

In order to get robots position and orientation, I’ve learned two methods:

  • listening to /odom topic.

  • creating a tf.TransformListener() between ‘odom’ and ‘base_footprint’ or ‘base_link’.

what is the difference between these two approaches?

In what scenario each should be implemented?

You have in your question the most important differences, the /odom topic is just that it provides nothing but raw odometry data. This data usually comes from the wheel encoders and the quality of the data can very quite a lot.

The tf.TransformListener() as you described knows about the transformations along with the position and orientation and that is a very important difference.

Use cases:
I personally use the /odom topic when I want a simple and quick way to keep track of my robots position and orientation. How accurate this is depends on the quality of the odometry source. But even good ones will drift. The other reason I use this topic is to keep track of distance travelled again the accuracy will decrease as the distance travelled increases by how much depends on the quality of your source.

tf not only keeps track of the transforms for you but it also has a buffer, this allows you to take past readings and do an interpolation with your current reading and get a better localization. As you proceed through the course you will eventually learn about sensor fusion. Take localization again, with sensor fusion you can take input from multiple sources. One very common one is to take the data from the /odometry topic and the /laser topic and fuse them (combine them) to get a better localization then you could get from them individually and it is often necessary or beneficial to keep track of the transformations which you get with tf and their are many more uses.

The most important point is the transformation information that tf provides and odometry does not. If you need transformations use tf if you just want a simple and quick way to get position/location and maybe distance use odometry.

3 Likes

thanks for your answer,
just for clarification:
so just for robot position and without any interpolation on data, the /odom topic and use of tf would result in the same position and orientation?

Yes, it provides the same basic information regarding position and orientation.