rosbag_storage Documentation

rosbag_storage

This is a set of tools for recording from and playing back ROS message without relying on the ROS client library.

rosbag is a set of tools and API's for recording/writing messages to bag files and playing/reading them back.

codeapi

The C++ and Python API's are provided for serializing bag files. The C++ API consists of the following classes:

Here's a simple example of writing to a bag file:

#include "rosbag/bag.h"
...
rosbag::Bag bag("test.bag", rosbag::bagmode::Write);
std_msgs::Int32 i;
i.data = 42;
bag.write("numbers", ros::Time::now(), i);
bag.close();

Likewise, to read from that bag file:

#include "rosbag/bag.h"
...
rosbag::Bag bag("test.bag");
rosbag::View view(bag, rosbag::TopicQuery("numbers"));
BOOST_FOREACH(rosbag::MessageInstance const m, view)
{
    std_msgs::Int32::ConstPtr i = m.instantiate<std_msgs::Int32>();
    if (i != NULL)
    	std::cout << i->data << std::endl;
}
bag.close();

The Python API is similar. Writing to a bag file:

import rosbag
from std_msgs.msg import Int32, String
bag = rosbag.Bag('test.bag', 'w')
i = Int32()
i.data = 42
bag.write('numbers', i);
bag.close();

Example usage for read:

import rosbag
bag = rosbag.Bag('test.bag')
for topic, msg, t in bag.read_messages('numbers'):
    print msg.data
bag.close();


rosbag_storage
Author(s):
autogenerated on Fri Aug 28 2015 12:33:40