ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to create a node that listens to particular topic and publishes tf

asked 2013-08-08 00:27:43 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

How can I create a node that listens to that particular topic and publishes the required required tf. I have succesfully published data on a topic. Now I want to exhibit it in TF. Do I need a TF broadcaster, something like this

tf::TransformBroadcaster br;
tf::Transform transform;
transform.setOrigin( tf::Vector3(0,0,0)); 
transform.setRotation( tf::Quaternion(x,y,z,w) ); 
br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "optical", "base_link"));

Even If I have something like this. How do I listen and display it. Forexample do I need a tf listener to listen to some topic which is publishing data. If thats the case. What would the code look like if my topic is /mytopic

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-08-08 07:34:48 -0500

Here is a piece of code that publishes an odometry transform over tf.

void pub_odom::odom_callback(const nav_msgs::Odometry& odom) {

btVector3 Position;
btQuaternion Orientation;
tf::TransformBroadcaster odom_broadcaster_;
tf::StampedTransform odom_transform;


odom_transform.stamp_ = odom.header.stamp;
odom_transform.child_frame_id_= "/odom";
odom_transform.frame_id_= "/center_map";

Hope it helps you

edit flag offensive delete link more


You also could replace btVector3 and btQuaternion by tf::Vector3 and tf::Quaternion.

BennyRe gravatar image BennyRe  ( 2013-08-08 21:32:10 -0500 )edit

@Mario Garzon Can you please send me a link to your whole package so that I can visualise your package with tf. danke Schoen. Right now i cannot run your program so that I can understand better.

micheal gravatar image micheal  ( 2013-08-10 06:37:40 -0500 )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

1 follower


Asked: 2013-08-08 00:27:43 -0500

Seen: 482 times

Last updated: Aug 08 '13