How to subscribe in a topic from bagfile?
Hello guys, I'm newbie on ROS and I've trained with exercises, but I don't know how to subscribe in a topic from a bagfile, because the only hint and file attached of this exercise is a bagfile. I can read with the library bagpy and panda, but the order says the next: "Create a code to subscribe to the topic /lineal/velocity.". I'm using google colab with the library roslab to run the bagfile.
I'm really grateful with your answers. Best Regardings.
Asked by joantmor on 2022-08-21 23:12:15 UTC
Answers
Subscribing a topic from a bag file is the same as subscribing to a ROS topic.
In one terminal, please play your bag file as shown below:
rosbag play file.bag
Please see the wiki page for more info on the rosbag play
command. Next, in another terminal, please subscribe to your recorded topic. Again, please see the wiki page on how to write a subscriber.
By the way, are you trying to extract messages from a bag file? If yes, I recommend you look at the rosbag/Code API page.
Asked by ravijoshi on 2022-08-23 02:54:37 UTC
Comments
http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29
This tutorial breaks down a bit on how topics are shared between a publishing source and a receiving subscriber.
It's the same thing when trying to subscribe a topic from a bagfile. Only this time, your publisher is the bagfile being played. As long as you reference the correct topic you're trying to subscribe to, you will be able to extract it.
To play the bagfiles, you can use:
rosbag play filename.bag
This will playback the bag file and publish all the topics recorded within the file. If you only want specific topics to be published, you can use:
rosbag play filename.bag --topics /topic1 /topic2 /topicEtc
Asked by bc524 on 2022-08-23 05:13:01 UTC
Comments