Last active
March 21, 2022 11:18
-
-
Save ayrton04/662964298a82211a7e28 to your computer and use it in GitHub Desktop.
ROS rosbag filter command for filtering out specific tf transforms from your bag files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rosbag filter original.bag filtered.bag "topic != '/tf' or ((len(m.transforms) > 0 and m.transforms[0].header.frame_id != 'odom') and (len(m.transforms) <= 1 or (len(m.transforms) > 1 and m.transforms[1].header.frame_id != 'odom')) and (len(m.transforms) <= 2 or (len(m.transforms) > 2 and m.transforms[2].header.frame_id != 'odom')) and (len(m.transforms) <= 3 or (len(m.transforms) > 3 and m.transforms[3].header.frame_id != 'odom')) and (len(m.transforms) <= 4 or (len(m.transforms) > 4 and m.transforms[4].header.frame_id != 'odom')))" |
Three years later copy/paste is not working, at least for me. Had to use '/tf' instead of 'tf'.
Might save someone half of a day, since the link is in googles top answers.
And thanks Tom, of course.
Two years later and I finally read this comment. Fixed the gist. :)
6 years later, worked like a charm. :)
How do we filter list of topics?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that if you have > 5 transforms in any one
/tf
message, you'll need to add some conditions for those. This script is only filteringtf
transforms with a frame_id of "odom," but customizing it for your needs should be pretty straightforward. It could be rolled into a shell script, but you'll want to have some means of specifying parent and/or child frames.