Best way to add a topic to an existing rosbag?
What would be the best way to add a topic to an existing rosbag?
Play the bag and publish the topic while doing a rosbag record -a?
Thanks!
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
What would be the best way to add a topic to an existing rosbag?
Play the bag and publish the topic while doing a rosbag record -a?
Thanks!
Use the rosbag API to open the bag, and write it out while adding the new messages for the topic.
Edit: if you already have a bag that has the other topic(s) (or can easily create one), you could attempt a merge instead. No official tools afaik, but there have been some people that implemented similar things. See #q122761 fi.
Based on the rosbag API link (which only provides the 'w'
option for writing, and this erases an existing bag) and the merge code, which reads the old bag and re-writes to a new one... the answer is actually "you can't add a topic to an existing bag," right?
I believe "misleading" is a bit strong: only very few storage formats that support streaming interfaces / infrastructure will allow you to append data to the end and still have everything work correctly (ie: stream the contents in chronological order). It's simply not something that ..
For the answer, it seems simpler to write the details of the method in addition to linking vs. just linking with ambiguous phrasing. This suggests the links could hold the answer. I know how to re-write... and I was hoping to append, so I expected to be enlightened.
So that's what I meant by misleading. The answer isn't wrong, it just dangled hope before me but when I looked at the links I realized it's what I've already been doing (and could have been spared time reading). Python can append to files, so it's reasonable to think bags might allow it, too.
Asked: 2017-08-28 08:45:00 -0500
Seen: 5,378 times
Last updated: Aug 28 '17
Playback ROS1 bag files in ROS2
Is there a way to merge bag files?
How to migrate a bag file after these two types of changes?
how to extract the data from the packets of Velodyne HDL-32E
When should I need --clock parameter on rosbag play?
Interactive Marker with rosbag "ROS Time moved backwards"
Add to an bag you just created in
w
mode or add to a file by opening and appending? The latter is not possible