In my organization we often filter .BAG files in many cases by variety of topics. To improve our workflow I developed this small tool hosted on Github. So now I want to kindly ask the community for opinion about is such tool useful (especially for beginners) or not?
Wow, an entire TUI written using bash and the rosbag CLI. Having a nice TUI like this is awesome.
Nice! Apparently a lot of us need this kind of tools:)
Having a TUI alternative is great!
What a god-send.
I have had countless occasions where I record a ROS bag with everything in it only to wish I could easily filter out the space consuming camera topics so I can send the bag file to another developer in another part of the world without spending a long time uploading, downloading and trying to store giant bag files. Its usually quick to verify the camera topics have been processed correctly in to another topic and once that’s done they just get in the way.
Is it possible to filter out specific transforms using this? Like if I want to remove the map to Odom corrections in a bag file to try running a localization algorithm on it? I currently use rosbag filter for that. The experience is less than ideal.
@safijari if you can find a nice UI to do that, I will be happy to implement it.
UPDATED: I did implement it, have a look
@safijari , you can find TFs of your need and then unselect them in topic list. After that they will not be kept in result .BAG file. But if these TFs set up using single node, they will be removed together. To remove some needed specific TFs you unfortunately need to recreate TF publisher with excluded TFs
An addition: using CI engine I can provide Debian packages for my script easily. Actually I am a novice with ROS buildfarm, so if you can direct me to good guide, I can try to promote my package into ROS main package tree
Actually I am a novice with ROS buildfarm, so if you can direct me to good guide, I can try to promote my package into ROS main package tree
You should take a look at this bloom/Tutorials - ROS Wiki
Found an expression for TFs, trying to integrate
There are a couple of problems with that expression:
- It is obviously not going to work for TF messages with more than 5 transforms.
- It doesn’t take the
tf_static
topic into account. - It filters out every transform that has
odom
as the parent. This is okay forodom
, since it usually only has one child (map
). In general though, I’d say it’s more convenient to filter out a specific child frame. The only drawback is that it’s a bit counter-intuitive at first that you have to specifymap
when you actually want to “remove theodom
frame”.
Anyways, here’s a small script that does all of this using the Python rosbag API, which I can highly recommend for filtering rosbags:
#!/usr/bin/python
import rosbag
import sys
remove_frames = ['imu_frame', 'map']
inbag_name = sys.argv[1]
outbag_name = inbag_name.replace('.bag', '-filtered.bag')
with rosbag.Bag(outbag_name, 'w') as outbag:
for topic, msg, t in rosbag.Bag(inbag_name).read_messages():
if topic in ['/tf', '/tf_static']:
msg.transforms = [tr for tr in msg.transforms
if tr.child_frame_id.lstrip('/') not in remove_frames]
outbag.write(topic, msg, t)