Ask Your Question

tf2 example?

asked 2014-07-22 10:30:51 -0600

arennuit gravatar image

Hi all,

Trying to learn ROS, I understand tf is deprecated and tf2 is the currently maintained version. Now the tutorials for tf2 are rather wrong as stated here and here (and as I actually experienced just now). Is there a simple example somewhere I can rely on to know how to listen and broadcast frames?



edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-07-23 18:38:31 -0600

destogl gravatar image

Ok.... huh...

I just was trying to implement this, when I saw your question. So I will try to help you, or at least show you my solution which seams to work. It is done in C++.

So you need following headers:

#include <tf2_ros/transform_listener.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>

Than initialise all variables:

tf2_ros::Buffer tfBuffer;
tf2_ros::TransformListener tfListener(tfBuffer);
geometry_msgs::TransformStamped transform;

Ant than the magic line:

    transform = tfBuffer.lookupTransform("base_link", frame_id, ros::Time(0));
  catch (tf2::TransformException ex ){

To this solution I came by searching code of geometry_experimental stack on GitHub.

edit flag offensive delete link more


Hello destogl, this is a good to help me start with, thanks for your answer ;)

arennuit gravatar image arennuit  ( 2014-07-24 00:45:34 -0600 )edit

There is also code examples now in C++ and Python, please check this pull request:

destogl gravatar image destogl  ( 2014-07-25 18:39:55 -0600 )edit

Interesting! Thanks a lot , this will help indeed!

arennuit gravatar image arennuit  ( 2014-07-28 08:53:30 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2014-07-22 10:30:51 -0600

Seen: 2,407 times

Last updated: Jul 23 '14