rosbag_storage Documentation


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

rosbag_storage is a set of tools and API's for recording/writing messages to bag files and playing/reading them back without relying on the ROS client library.

The code is still in the rosbag namespace since it was extracted from the rosbag package without renaming any API.

Code API

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; = 42;
bag.write("numbers", ros::Time::now(), i);

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;

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() = 42
bag.write('numbers', i);

Example usage for read:

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

autogenerated on Tue Mar 7 2017 03:44:35