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
   /* 
          Desc: Node Allows to programmatically use rosbag_record :
      start a record --> initialize some options & give them to recorder --> run 
   */

#include <ros/ros.h>
#include <rosbag/recorder.h>

int main(int argc, char **argv)
{
ros::init(argc, argv, "rosbag_record");
ros::NodeHandle n;

 rosbag::RecorderOptions options;

 // Set the options for this recording
 options.append_date = true;
 options.trigger = false;
 options.min_space = 0; // If the minimum free space on disk is below this, recorder terminates
 options.verbose = true; //Outputs a log when a message is received.
 options.compression = rosbag::compression::LZ4; // or BZ2
 options.split = true; //Split the bag file and continue recording when maximum duration reached
 options.regex = false; //If true, topics is expected to be a list of regular expressions.
 //options.buffer_size = 1000; //Use an internal buffer of SIZE MB (Default: 256)
 options.topics.push_back("/chatter"); //topic name
 options.max_duration = ros::Duration(600.0);//Record a bag of maximum duration in seconds
 //path
 std::string bag_path="/media/ubuntu/omma_osterode_ae/test_bagfiles_cam1/";
 options.prefix = bag_path + "Test1_";
 rosbag::Recorder recorder(options);
 recorder.run();
}