Rosbag C++ API compress rosbag
I need to compress my rosbag before I save it. I know for the command line there is a compress option, and there should be one for the C++ API. I tried rosbag.setCompression(rosbag::compression:BZ2), but this did not save the rosbag in a compressed form.
Asked by mariyaz on 2019-09-13 09:14:08 UTC
Answers
/*
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();
}
Asked by Khalaf90 on 2019-10-11 20:08:47 UTC
Comments