Ask Your Question
2

"rosbag record -a" in C++?

asked 2015-09-01 04:29:53 -0500

ZOORCK gravatar image

updated 2015-09-23 08:51:51 -0500

lucasw gravatar image

I want to implement a node which is able to start recording every topic. It should record everything like the command line rosbag record -a. is there a possibility to use that command or something similar in a node which is implemented in c++?

edit retag flag offensive close merge delete

Comments

why not to use rosbag? it is a functional requirement? motivation?

yasagitov gravatar image yasagitov  ( 2015-09-01 06:45:04 -0500 )edit

I want to use Rosbag but there are only examples like http://docs.ros.org/diamondback/api/r... but i wanted to record every topic and not single messages. the reason why i wanted to start that with a node was that it should start in the right moment

ZOORCK gravatar image ZOORCK  ( 2015-09-01 07:43:25 -0500 )edit

You can call rosbag with parameters from launch file. See question http://answers.ros.org/question/52773...

yasagitov gravatar image yasagitov  ( 2015-09-01 08:02:46 -0500 )edit

thank you thats a great idea.

ZOORCK gravatar image ZOORCK  ( 2015-09-01 08:22:34 -0500 )edit

4 Answers

Sort by » oldest newest most voted
2

answered 2015-09-01 09:20:34 -0500

Rosbag has an API: http://wiki.ros.org/rosbag/Code%20API That is the best way to use it instead of using system commands.

edit flag offensive delete link more

Comments

1

It looks like it is up to the user to continuously monitor for new topics and subscribe to all of them as they appear, substantially re-implementing rosbag record -a.

lucasw gravatar image lucasw  ( 2015-09-23 08:49:47 -0500 )edit

Well, that is what he says he wants!

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-09-23 09:06:14 -0500 )edit
2

answered 2016-02-22 06:45:41 -0500

gpldecha gravatar image

I have implemented a rosbag record node , have a look here if people would be interested in a C++ example.

edit flag offensive delete link more
2

answered 2015-11-03 09:04:15 -0500

lucasw gravatar image

Copying my answer from http://answers.ros.org/question/10714... (which wasn't really answering it for python, it really belongs here)

The best solution to programmatic rosbag recording I've found is to wrap rosbag::Recorder in a C++ node. There isn't a way to shutdown recording in Recorder, but there can be a subscriber in the recorder wrapper node which calls ros::shutdown which will cleanly close the current recording bag file, and then the the node can be set to respawn=true. The exclude list can be passed in as a parameter and then useful other parameters set like below, or have params override defaults as desired:

  recorder_options_.exclude_regex = some_string_from_ros_param;
  ROS_INFO_STREAM("exclude list \"" << recorder_options_.exclude_regex << "\"");

  recorder_options_.record_all = true;    
  recorder_options_.trigger = false;
  recorder_options_.regex = false;
  recorder_options_.do_exclude = true;
  recorder_options_.quiet = false;
  recorder_options_.append_date = true;
  recorder_options_.verbose = false;
  recorder_options_.buffer_size = 1048576 * 512;
  recorder_options_.chunk_size = 1024 * 768;
  recorder_options_.limit = 0; // 0 is unlimited
  recorder_options_.split = true;
  recorder_options_.max_size = 1024 * 1024 * 1024;
  recorder_options_.min_space = 1024 * 1024 * 1024;
  recorder_options_.min_space_str = "Recording space is running out";
edit flag offensive delete link more
1

answered 2015-09-01 07:49:10 -0500

ZOORCK gravatar image

I solved it i used

#include <stdlib.h> .... int i; i=system("rosbag record -a");

maybe there are better solutions but this was the easiest one. sorry for posting that question.

edit flag offensive delete link more

Comments

1

how do you stop the recording in cpp?

ysl208 gravatar image ysl208  ( 2018-11-28 13:56:02 -0500 )edit

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

Stats

Asked: 2015-09-01 04:29:53 -0500

Seen: 3,682 times

Last updated: Feb 22 '16