From d141e902220aeb349c207284faafeae6df61ecde Mon Sep 17 00:00:00 2001 From: Ramon Wijnands Date: Fri, 27 Sep 2024 14:58:32 +0200 Subject: [PATCH] Reintroduce `Don't warn for unknown types if topics are not selected` Reintroduce the fix from 51a83f4421ff335c2237e6214e9bb7e6ae206a92 which was discussed in https://github.com/ros2/rosbag2/issues/1485. This gives a massive CPU improvement. --- .../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; }