From 78f0e806ac87ffd555cbbc9ca04cd5f8f96af298 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:24:41 -0700 Subject: [PATCH] Reintroduce `Don't warn for unknown types if topics are not selected` (#1825) (#1827) Reintroduce the fix from 51a83f4421ff335c2237e6214e9bb7e6ae206a92 which was discussed in https://github.com/ros2/rosbag2/issues/1485. This gives a massive CPU improvement. Signed-off-by: Ramon Wijnands (cherry picked from commit e75d6d659fcae243b8486a94173255b237817f22) Co-authored-by: Ramon Wijnands --- .../src/rosbag2_transport/topic_filter.cpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/rosbag2_transport/src/rosbag2_transport/topic_filter.cpp b/rosbag2_transport/src/rosbag2_transport/topic_filter.cpp index 1f184b223..c2b767efe 100644 --- a/rosbag2_transport/src/rosbag2_transport/topic_filter.cpp +++ b/rosbag2_transport/src/rosbag2_transport/topic_filter.cpp @@ -129,17 +129,6 @@ bool TopicFilter::take_topic( const std::string & topic_type = topic_types[0]; bool is_service_event_topic = rosbag2_cpp::is_service_event_topic(topic_name, topic_type); - if (!record_options_.include_unpublished_topics && node_graph_ && - topic_is_unpublished(topic_name, *node_graph_)) - { - return false; - } - - if (record_options_.ignore_leaf_topics && node_graph_ && - is_leaf_topic(topic_name, *node_graph_)) - { - return false; - } if (!is_service_event_topic) { if (!record_options_.all_topics && @@ -235,6 +224,18 @@ bool TopicFilter::take_topic( return false; } + if (!record_options_.include_unpublished_topics && node_graph_ && + topic_is_unpublished(topic_name, *node_graph_)) + { + return false; + } + + if (record_options_.ignore_leaf_topics && node_graph_ && + is_leaf_topic(topic_name, *node_graph_)) + { + return false; + } + return true; }