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

Add CLI option to expose bagfile splitting #203

Merged
merged 8 commits into from
Nov 18, 2019
Merged
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
14 changes: 11 additions & 3 deletions ros2bag/ros2bag/verb/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ def add_arguments(self, parser, cli_name): # noqa: D102
'startup will be recorded')
parser.add_argument(
'-p', '--polling-interval', type=int, default=100,
help='time in ms to wait between querying available topics for recording. It has no '
'effect if --no-discovery is enabled.'
help='time in ms to wait between querying available topics for recording. '
'It has no effect if --no-discovery is enabled.'
)
parser.add_argument(
'-b', '--max-bag-size', type=int, default=0,
help='maximum size in bytes before the bagfile will be split. '
'Default it is zero, recording written in single bagfile and splitting '
'is disabled.'
)
self._subparser = parser

Expand Down Expand Up @@ -83,7 +89,8 @@ def main(self, *, args): # noqa: D102
node_prefix=NODE_NAME_PREFIX,
all=True,
no_discovery=args.no_discovery,
polling_interval=args.polling_interval)
polling_interval=args.polling_interval,
max_bagfile_size=args.max_bag_size)
elif args.topics and len(args.topics) > 0:
# NOTE(hidmic): in merged install workspaces on Windows, Python entrypoint lookups
# combined with constrained environments (as imposed by colcon test)
Expand All @@ -99,6 +106,7 @@ def main(self, *, args): # noqa: D102
node_prefix=NODE_NAME_PREFIX,
no_discovery=args.no_discovery,
polling_interval=args.polling_interval,
max_bagfile_size=args.max_bag_size,
topics=args.topics)
else:
self._subparser.print_help()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ rosbag2_transport_record(PyObject * Py_UNUSED(self), PyObject * args, PyObject *
"all",
"no_discovery",
"polling_interval",
"max_bagfile_size",
"topics",
nullptr};

Expand All @@ -46,22 +47,25 @@ rosbag2_transport_record(PyObject * Py_UNUSED(self), PyObject * args, PyObject *
bool all = false;
bool no_discovery = false;
uint64_t polling_interval_ms = 100;
unsigned long long max_bagfile_size = 0; // NOLINT
PyObject * topics = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssss|bbKO", const_cast<char **>(kwlist),
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssss|bbKKO", const_cast<char **>(kwlist),
&uri,
&storage_id,
&serilization_format,
&node_prefix,
&all,
&no_discovery,
&polling_interval_ms,
&max_bagfile_size,
&topics))
{
return nullptr;
}

storage_options.uri = std::string(uri);
storage_options.storage_id = std::string(storage_id);
storage_options.max_bagfile_size = (uint64_t) max_bagfile_size;
record_options.all = all;
record_options.is_discovery_disabled = no_discovery;
record_options.topic_polling_interval = std::chrono::milliseconds(polling_interval_ms);
Expand Down