1 #ifndef ROSBAG2_HELPER_HPP 2 #define ROSBAG2_HELPER_HPP 6 #include <rclcpp/rclcpp.hpp> 12 const std::string & topic_name,
const std::vector<rclcpp::TopicEndpointInfo> & endpoints)
14 rclcpp::QoS request_qos = rclcpp::SystemDefaultsQoS();
15 request_qos.best_effort().durability_volatile();
17 if (endpoints.empty()) {
20 size_t num_endpoints = endpoints.size();
21 size_t reliability_reliable_endpoints_count = 0;
22 size_t durability_transient_local_endpoints_count = 0;
23 for (
const auto & endpoint : endpoints) {
24 const auto & profile = endpoint.qos_profile().get_rmw_qos_profile();
25 if (profile.reliability == RMW_QOS_POLICY_RELIABILITY_RELIABLE) {
26 reliability_reliable_endpoints_count++;
28 if (profile.durability == RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL) {
29 durability_transient_local_endpoints_count++;
38 if (reliability_reliable_endpoints_count == num_endpoints) {
39 request_qos.reliable();
41 if (reliability_reliable_endpoints_count > 0) {
42 ROSBAG2_TRANSPORT_LOG_WARN_STREAM( topic_name <<
43 ": some, but not all, publishers on topic " 44 "are offering RMW_QOS_POLICY_RELIABILITY_RELIABLE. " 45 "Falling back to RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT " 46 "as it will connect to all publishers. " 47 "Some messages from Reliable publishers could be dropped.");
49 request_qos.best_effort();
54 if (durability_transient_local_endpoints_count == num_endpoints) {
55 request_qos.transient_local();
57 if (durability_transient_local_endpoints_count > 0) {
58 ROSBAG2_TRANSPORT_LOG_WARN_STREAM(topic_name <<
59 ": some, but not all, publishers on topic " 60 "are offering RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL. " 61 "Falling back to RMW_QOS_POLICY_DURABILITY_VOLATILE " 62 "as it will connect to all publishers. " 63 "Previously-published latched messages will not be retrieved.");
65 request_qos.durability_volatile();
84 #endif // ROSBAG2_HELPER_HPP rclcpp::QoS adapt_request_to_offers(const std::string &topic_name, const std::vector< rclcpp::TopicEndpointInfo > &endpoints)