diff --git a/rosbag2_transport/src/rosbag2_transport/record_options.cpp b/rosbag2_transport/src/rosbag2_transport/record_options.cpp index 3e22ac62e..127d0b831 100644 --- a/rosbag2_transport/src/rosbag2_transport/record_options.cpp +++ b/rosbag2_transport/src/rosbag2_transport/record_options.cpp @@ -60,6 +60,13 @@ bool convert::decode( { optional_assign(node, "all_topics", record_options.all_topics); optional_assign(node, "all_services", record_options.all_services); + bool record_options_all{false}; // Parse `all` for backward compatability and convenient usage + optional_assign(node, "all", record_options_all); + if (record_options_all) { + record_options.all_topics = true; + record_options.all_services = true; + } + optional_assign(node, "is_discovery_disabled", record_options.is_discovery_disabled); optional_assign>(node, "topics", record_options.topics); optional_assign>(node, "topic_types", record_options.topic_types); @@ -71,6 +78,8 @@ bool convert::decode( node, "topic_polling_interval", record_options.topic_polling_interval); optional_assign(node, "regex", record_options.regex); + // Map exclude to the "exclude_regex" for backward compatability. + optional_assign(node, "exclude", record_options.exclude_regex); optional_assign(node, "exclude_regex", record_options.exclude_regex); optional_assign>(node, "exclude_topics", record_options.exclude_topics); optional_assign>( diff --git a/rosbag2_transport/test/rosbag2_transport/test_record_options.cpp b/rosbag2_transport/test/rosbag2_transport/test_record_options.cpp index 015b1ae09..9aa5e4d79 100644 --- a/rosbag2_transport/test/rosbag2_transport/test_record_options.cpp +++ b/rosbag2_transport/test/rosbag2_transport/test_record_options.cpp @@ -59,3 +59,21 @@ TEST(record_options, test_yaml_serialization) CHECK(rmw_serialization_format); #undef CHECK } + +TEST(record_options, test_yaml_decode_for_all_and_exclude) +{ + std::string serialized_record_options = + " all: true\n" + " all_topics: false\n" + " topics: []\n" + " rmw_serialization_format: \"\" # defaults to using the format of the input topic\n" + " regex: \"[xyz]/topic\"\n" + " exclude: \"[x]/topic\"\n"; + + YAML::Node loaded_node = YAML::Load(serialized_record_options); + auto record_options = loaded_node.as(); + ASSERT_EQ(record_options.all_topics, true); + ASSERT_EQ(record_options.all_services, true); + ASSERT_EQ(record_options.regex, "[xyz]/topic"); + ASSERT_EQ(record_options.exclude_regex, "[x]/topic"); +}