ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

created tf listener, how to rosbag?

asked 2014-08-11 17:52:37 -0500

Orso gravatar image

I run tf tf_echo /Pioneer3AT/map /Pioneer3AT/base_link and compute exact data needed (so far so good):

At time 1407419581.729
- Translation: [-8.999, -22.000, 0.000]
- Rotation: in Quaternion [-0.000, 0.000, 0.850. 0.526]
         in RPY [0.000. -0.000, 2.034]

I set up the following listener:

import roslib
import rospy
import tf
import sys, traceback
from nav_msgs.msg import Odometry

if __name__ == '__main__':
    listener = tf.TransformListener()
    rate = rospy.Rate(10.0)

    while not rospy.is_shutdown():
            now = rospy.Time(0)
            (trans, rot) = listener.lookupTransform("/Pioneer3AT/map", "/Pioneer3AT/base_link", now)
    except: (tf.LookupException, tf.ConnectivityException):

    print 'translation: ',trans
    print 'rotation: ', rot


Prints out the correct data as above. Next step: I would like to record this transform with rosbag.

Is this just a matter of publishing this data within my listener file, then running rostopic echo, then running rosbag record? Thanks for reading this.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-11 20:36:56 -0500

2ROS0 gravatar image

updated 2014-08-11 20:37:52 -0500

You can use rosbag record to directly record /tf. As you mentioned, you have confirmed this using tf_echo and should work fine. You can later rosbag play that info.

Your tf_listener on the other hand is just to lookup transforms from /tf and then perform some math or logic on that. You do not need to publish the specific transform from your tf_listener nor do you need to keep rostopic echo running.

edit flag offensive delete link more


Thanks for your answer. And, I have seen this answer, applied it before, but I did not get the desired data format, which is my reason for producing the listener. Do you have a recommendation to record the tf listener that I have produced above?

Orso gravatar image Orso  ( 2014-08-13 13:04:22 -0500 )edit

I don't see why that doesn't work for you. Another option I can think of is to use rosbag filter. You will need to specify a python expression for your case. This is the syntax; rosbag filter <in-bag> <out-bag> <expression> so you are basically filtering the original bag that has all the tf.

2ROS0 gravatar image 2ROS0  ( 2014-08-13 15:57:50 -0500 )edit

This doesn't work for me because I need to perform some math on some of the other transforms. I am wanting to record the exact data provided by the tf listener from above. Is this not straight forward to broadcast and record?

Orso gravatar image Orso  ( 2014-08-13 16:14:39 -0500 )edit

Yes, you can "broadcast" it on another topic after you perform the math. You can then record just that topic (you don't need to echo it). Alternatively, if you are going to use a tf broadcaster then you are back to square one because that will again be part of /tf.

2ROS0 gravatar image 2ROS0  ( 2014-08-13 16:27:36 -0500 )edit

What do I do if I just want to record the data from the listener file above? Is this a matter of publishing the listener data?

Orso gravatar image Orso  ( 2014-08-13 16:44:43 -0500 )edit

Yes. Publish the data on a topic in whatever msg format you want. And then bag it.

2ROS0 gravatar image 2ROS0  ( 2014-08-13 16:53:46 -0500 )edit

Question Tools

1 follower


Asked: 2014-08-11 17:52:37 -0500

Seen: 1,024 times

Last updated: Aug 11 '14