ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to subscribe in a topic from bagfile?

asked 2022-08-21 23:12:15 -0600

joantmor gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-08-23 02:54:37 -0600

ravijoshi gravatar image

updated 2022-08-23 02:55:15 -0600

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.

edit flag offensive delete link more
0

answered 2022-08-23 05:13:01 -0600

bc524 gravatar image

http://wiki.ros.org/ROS/Tutorials/Wri...

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
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-08-21 23:12:15 -0600

Seen: 871 times

Last updated: Aug 23 '22