Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options to support splitting a rosbag file in duration and size chunks #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ROS nodes that start/stop rosbag-record by a remote trigger
<include file="console.machine"/>

... other console nodes ...

<node name="console-record" pkg="remote_rosbag_record" type="record" respawn="true">
<rosparam file="console_topics.yml"/>
<param name="prefix" value="console"/>
Expand All @@ -29,7 +29,7 @@ ROS nodes that start/stop rosbag-record by a remote trigger
<param name="apped_date" value="true"/>
</node>
</group>

</launch>
```

Expand Down Expand Up @@ -94,6 +94,10 @@ See http://wiki.ros.org/rosbag/Commandline#record
* ~buffer_size (int)
* ~exclude_regex (string)
* ~node (string)
* ~split_duration (double)
* duration in seconds to record before splitting to a new bagfile
* ~split_size (int)
* size in MB to record before splitting to a new bagfile

### trigger
calls multiple start/stop services at once
Expand All @@ -120,4 +124,4 @@ subscribes joystick messages and calls start/stop services when a specified butt
* ~stop_regex (string, default: "<node's namespace>/stop")
* regular expression which matches stop services
* ~verbose (bool, default: true)
* verbose console output when calling services
* verbose console output when calling services
20 changes: 18 additions & 2 deletions src/record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ bool start(std_srvs::Empty::Request &, std_srvs::Empty::Response &) {
}
}
rp::get("~node", options.node);
// Support automatic splitting of rosbag file in duration chunks
double duration = -1.0;
rp::get("~split_duration", duration);
if (duration > 0.0) {
options.split = true;
options.repeat_latched = true;
options.max_duration = ros::Duration(duration);
}
// Support automatic splitting of rosbag file in size chunks
int bagsize = 0;
rp::get("~split_size", bagsize);
if (bagsize > 0) {
options.split = true;
options.repeat_latched = true;
options.max_size = bagsize * 1048576;
}
// note: this node aims to enable service-triggered logging.
// so does not support the following options that may autonomously stop logging
// trigger / snapshot / chunk_size / limit / split
Expand Down Expand Up @@ -146,9 +162,9 @@ int main(int argc, char *argv[]) {
// manually free the recorder here.
// the recorder contains a plugin loaded by class_loader so must be freed
// before static variables in class_loader library (or get an exception).
// these static variables will be destroyed before the gloval variable recorder
// these static variables will be destroyed before the gloval variable recorder
// because they are allocated when the recorder is allocated in start().
recorder.reset();

return 0;
}
}