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

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

https://github.com/ros/ros_comm/issue... 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

5 Answers

Sort by ยป oldest newest most voted
2

answered 2022-01-17 07:23:58 -0500

ticotico gravatar image

updated 2022-01-17 07:50:22 -0500

Finally a nice option exists a few years later :)

This is covered by this issue on Github. The corresponding PR has been merged over a year ago and Noetic is shipped with the feature. It does so by repeating the latched topics (e.g. static TFs) for each bag.

The option you are looking for while recording is --repeat-latched, so e.g.:

 rosbag record -a --repeat-latched --duration 5 --split

Cheers

edit flag offensive delete link more
8

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.

Edit:

@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

Comments

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
1

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
1

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
0

answered 2023-05-27 08:59:49 -0500

Hi, I went through similar problems.

The issue was that we had a bag file with four /tf_static msgs, and the latching mechanisms works only for one message.

The solution was to merge all tf_static msgs into a single one.

https://github.com/miguelriemoliveira...

edit flag offensive delete link more
0

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

Question Tools

2 followers

Stats

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

Seen: 6,021 times

Last updated: Jan 17 '22