Ask Your Question
0

Publishing .bag file for different nodes

asked 2013-12-19 00:58:58 -0500

Phorce gravatar image

updated 2014-01-28 17:06:36 -0500

ngrennan gravatar image

Let's say I have two topics publishing data:

/chatter1

/chatter1

These two topics are currently saving to a rosbag file as they publish the data. I'm creating another node which extracts the features. I therefore need to create a node that subscribes to the .bag file and then writes these to an array which I can then use for extracting the features from.

Is this possible in ros? And can anyone offer any tutorials on this?

Thanks

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2013-12-19 01:24:12 -0500

David Galdeano gravatar image

updated 2013-12-19 01:24:28 -0500

Hello, you can subscribe to /chatter1 and /chatter1 with a node while rosbag is running. You can have many subscriber to one publisher.

edit flag offensive delete link more

Comments

@galdeano Hey thanks. How would I open (or get access) to the data inside the rosbag file that is recording to `/chatter1` and `/chatter2` whilst it is running though?

Phorce gravatar imagePhorce ( 2013-12-19 01:33:39 -0500 )edit

I do not understand, why would you access the data on the rosbag file, while you have the real time data published? If you still need to manipulate bag files, use: http://wiki.ros.org/rosbag/Code%20API#cpp_api but as said in the begin of the document: 'Note that the rosbag API's are not thread-safe for reading and writing any given bag file. Users of the APIs must ensure no concurrent input/output operations are performed on different threads.' So you can't read and write at the same time.

David Galdeano gravatar imageDavid Galdeano ( 2013-12-19 03:37:06 -0500 )edit

@galdeano - Very valid point. I've misunderstood. But, I do not know of a way to subscribe to multiple topics in Python and being able to store this data inside a numpy array? The problem is that, using rosbag it takes both data of the nodes and combines them. I need a way to do this

Phorce gravatar imagePhorce ( 2013-12-19 03:41:11 -0500 )edit
1

answered 2013-12-19 23:39:23 -0500

demmeln gravatar image

Are you asking how to subscribe to two topics with one node?

You can simply create multiple Subscribers, so in the tutorial http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29

ros::Subscriber sub1 = n.subscribe("chatter1", 1000, chatterCallback1);
ros::Subscriber sub2 = n.subscribe("chatter2", 1000, chatterCallback2);

and similarly in python.

edit flag offensive delete link more
0

answered 2013-12-19 01:55:24 -0500

VC gravatar image

There are 2 ways you can access the data in the bag file

  1. Play back the bag file using rosbag play <bagfile>; your processing node can then subscribe to the topics and collect the data as it is published.
  2. Access the data in the bag file programmatically using the rosbag C++ API.
edit flag offensive delete link more

Comments

@VC thanks for your reply. Are there any tutorials on the carrying out the 1st one? For example, I'm currently trying to subscribe to both the `/camera/depth_registered/points` and another topic which outputs the data?

Phorce gravatar imagePhorce ( 2013-12-19 02:27:33 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-12-19 00:58:58 -0500

Seen: 1,765 times

Last updated: Dec 19 '13