Ask Your Question

Extract data from .bag without messages built

asked 2014-12-13 17:19:56 -0500

cpiury gravatar image

Hi, I am looking for a way to extract data from .bag files without messages built. Is this possible?, I have some .bag files but I don't have the messages built in my system so I can't see what types they have and I can't extract data from this bags files following the tutorials steps. However, when I run "rosrun rqt_bag rqt_bag" and open my bag file, I can see the data published (data value).

So I think that this is possible but I can't find out information about how to do this.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-12-13 19:55:44 -0500

ahendrix gravatar image

The message definitions that the bag file was recorded with are stored in the bag file.

You can use the rosbag command-line tool to list the topics and their message types from a bag file: rosbag info my_data.bag

You can also use the -b option to rostopic echo to print messages from a single topic in a bag file.

The python API to rosbag dynamically constructs messages based on the message definitions that are stored in the bag file, so you can use the python API to read and introspect all of the messages in a bag file.

Since C++ is statically typed, you have to have headers from your message definitions in order to compile a program which reads those messages - this means that you can't use the C++ API unless you have the message definitions.

edit flag offensive delete link more

answered 2014-12-14 04:35:13 -0500

cpiury gravatar image

I tried rosbag tools to extract data type information from messages like: "rosmsg show /message_name" and this doesn't work if I haven't got the messages built in my system, but it works perfectly with the rest of messages built in my system.

So from your help I guess that "rqt_bag" is implemented in Python, since it can read messages and show the value published without the messages pre-built requirement.

Thanks you very much ahendrix!

edit flag offensive delete link more



rosmsg does not know anything about bag files.

ahendrix gravatar image ahendrix  ( 2014-12-14 12:59:29 -0500 )edit

If you dig deep enough into the rosbag python API, it should be possible to extract the text representation of each message stored in the bag file. It sounds like that's what you're looking for.

ahendrix gravatar image ahendrix  ( 2014-12-14 12:59:52 -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


Asked: 2014-12-13 17:19:56 -0500

Seen: 562 times

Last updated: Dec 14 '14