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";
why not to use rosbag? it is a functional requirement? motivation?
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
You can call rosbag with parameters from launch file. See question http://answers.ros.org/question/52773...
thank you thats a great idea.