Ask Your Question

Rosbag C++ API compress rosbag

asked 2019-09-13 09:14:08 -0500

mariyaz gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-11 20:08:47 -0500

Khalaf90 gravatar image
          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
 std::string bag_path="/media/ubuntu/omma_osterode_ae/test_bagfiles_cam1/";
 options.prefix = bag_path + "Test1_";
 rosbag::Recorder recorder(options);;
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-09-13 09:14:08 -0500

Seen: 412 times

Last updated: Oct 11 '19