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

Revision history [back]

click to hide/show revision 1
initial version

So, the full message definitions are captured in the bag file, but there doesn't appear to be a direct API for extracting them.

This kind of does the trick:

#!/usr/bin/env python

import rosbag
import sys

types = {}

for bagname in sys.argv[1:]:
    bag = rosbag.Bag(bagname)
    for topic, msg, t in bag.read_messages():
        if not msg._type in types:
            types[msg._type] = msg._full_text


for t in types:
    print "Message type:", t
    print "Message text:"
    print types[t]
    print