Ask Your Question

exclude some topics from rosbag play

asked 2016-03-10 04:17:05 -0600

Felix Duvallet gravatar image

updated 2018-05-23 09:45:49 -0600

I have a bag file with a bunch of topics inside of it, is it possible to exclude some topics from being played back?

For example, the bag file might have:

topics:      /camera/depth/image            150 msgs    : sensor_msgs/Image          
             /camera/rgb/image_color        150 msgs    : sensor_msgs/Image          
             /joint_states                 2500 msgs    : sensor_msgs/JointState     
             /rosout                         35 msgs    : rosgraph_msgs/Log          
             /rosout_agg                     35 msgs    : rosgraph_msgs/Log          
             /tf                           7697 msgs    : tf2_msgs/TFMessage

And I might be interested in playing back everything except the /tf topic.

Is there a shorter way than rosbag play file.bag --topics <topic> with all topics?

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2016-03-10 06:51:12 -0600

gvdhoorn gravatar image

If you don't mind having to create a new bag, then perhaps you could use the filter command.

To end up with a new bag file that excludes the /tf topic would be something like:

$ rosbag filter file.bag file-no-tf.bag "topic != '/tf'"
edit flag offensive delete link more


On my system this is taking about 10 minutes per gigabyte, also the bags were 10 minutes in duration- I'm not sure if that is a coincidence.

lucasw gravatar imagelucasw ( 2017-01-05 16:25:17 -0600 )edit

answered 2017-08-01 14:28:34 -0600

Jay Gowdy gravatar image

If you don't mind the potential wastefulness, I believe you can get the effect you want by remapping the offending topic to an unused name, like this

rosbag play my_bag.bag /tf:=/tf_dev_null

I'm fairly new to ROS, but I believe this won't even cause wasted message bandwidth unless something in the system subscribes to it under its new name.

edit flag offensive delete link more


Yepp, can confirm this works out..

Wolf gravatar imageWolf ( 2017-08-02 15:49:44 -0600 )edit

answered 2018-09-13 01:06:18 -0600

josh_m gravatar image

This problem was annoying me enough to write a quick tool to solve the issue. You can't avoid playing all the topics, but you can rename them so you don't have to worry about them.

It's at:

edit flag offensive delete link more

answered 2016-03-10 04:28:07 -0600

As far as I know you're right. There is not simpler way than defining each of the topics you do want to play back. If you need to run this a lot though, you could always make a simple bash file with the command in it to save you all the typing!

edit flag offensive delete link more

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: 2016-03-10 04:17:05 -0600

Seen: 13,104 times

Last updated: May 23 '18