Ask Your Question

How to save static transforms in bag files?

asked 2015-04-21 14:45:00 -0500

TommyP gravatar image

How do I save a static transform in a bag file so I get a self contaned bag file that can be replayed?

Not it seems like for example rviz do not understand a static transform in a bag file.

edit retag flag offensive close merge delete

Comments is a related issue- the tf_static is only recorded in the first bag when splitting bags.

lucasw gravatar image lucasw  ( 2016-06-02 08:48:24 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2015-04-22 15:56:57 -0500

tfoote gravatar image

updated 2015-04-24 16:39:10 -0500

If you record /tf and /tf_static topics that should capture all the tf data.


@TommyP You're right, there is a problem that rosbag doesn't record/reproduce the latched topics. This is additionally a problem in that if you have multiple latched publishers, the latching is per publisher and if it all comes from rosbag that's a problem as only the latest message will be latched.

The recording side of rosbag is probably adaquate, but for full functionality a node which aggregates the static transforms published by rosbag and republishes them would be needed. My suggestion would be to create that node which will aggregate the static transforms subscribed to something like /tf_static_consolidated publishing to the usual tf_static topic and remap the rosbag play /tf_static to the consolidated topic when playing back.

edit flag offensive delete link more


But rosbag play is problematic. It seems to publish the static transform once so all programs like rviz that you happen to start after starting playing the file will not get the static transform. Shouldn't rosbag play publish the static transforms on a latched topic?

TommyP gravatar image TommyP  ( 2015-04-23 01:43:20 -0500 )edit

My mistake. It seems to be published on a latched topic. So I wonder why we had strange problems with rviz.

TommyP gravatar image TommyP  ( 2015-04-23 01:46:19 -0500 )edit

As I mentioned you probably had trouble since latching is per publisher, and since rosbag is a single publisher I expect that you lose some of the values if you logged multiple static transform publishers.

tfoote gravatar image tfoote  ( 2015-04-26 14:29:13 -0500 )edit

That sounds reasonable. Good to know that there is a design issue here and not just us using things wrongly.

TommyP gravatar image TommyP  ( 2015-04-26 14:54:49 -0500 )edit

answered 2019-09-24 05:38:01 -0500

marcoesposito1988 gravatar image

I was also bitten by this - (and a solution is not on the horizon).

As an alternative to the accepted answer, another workaround is to replicate the static tf transform as a standard tf message through the bag. For example every time another transform of your interest is published. Here is a brief python script that achieves this. You can replace the 'world' link with the one you need.

In my case, this made the updated bag work out-of-the-box. I hope anyone else can find this useful.

edit flag offensive delete link more

answered 2015-04-24 13:42:57 -0500

juftho gravatar image

We had the same problem with static transforms. As far as I remember /tf_static is a latched topic, but latched topics does provide the last arrived message only. So rviz gets the last tf which was published by rosbag play in /tf_static. This is a problem only if you have more than one static tf.

I'm not sure but i think rosbag play just publishes the tf-messages stored in/tf_static instead of using a tf2 static transform broadcaster, which would lead to a different behaviour when playing a bagfile instead of using ROS "online", since normally you use a static transform broadcaster in your node to publish a static tf instead of writing a tf message to the /tf_static topic. Can somebody confirm this?

A desired behaviour would be to have the static tf's available as soon as the bag file is opened - regardless at which time the playing is started

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: 2015-04-21 14:45:00 -0500

Seen: 3,723 times

Last updated: Sep 24 '19