Can I filter out or rename topics from a bag file?
I have a bag file with several topics (a lot of them, actually), and I'm trying to launch it from a launch file.
However, in my test case that I want to run, I want to exclude a topic and insert my module to publish it instead. I was looking into either renaming the culprit topic, or just filter out a topic.
These features seemed to be available in rosbag, which from my understanding is from ROS1. I have googled and searched this site a lot, but all answers seem to be related to rosbag. Is there a way to do this in ROS2, or can I use rosbag somehow with ROS2?
In rosbag there seemed to be both a --filter
flag, and you could do /topic:=/dummy/topic
to make the whole system ignore it.
The closest solution I have found is to, in the launch file run:
ExecuteProcess(
cmd=['ros2', 'bag', 'play', os.path.expanduser(
#'~') + '/PATH/TO/BAGFILE/', '--loop', '--topics', 'TOPIC_1', ... ,'TOPIC_N']
But having a lot of topics already, this isn't really feasible with all the copy and paste that would be required, especially since I need to do this for multiple bag files with different topics on them.
Any way to solve this reasonably?
Using ROS2, Foxy.