From 1f678ac2f9c6429e9396bd09e5e7342c60531fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marti=C3=B1o=20Crespo?= Date: Wed, 31 May 2023 17:07:19 +0200 Subject: [PATCH 1/2] Customize monitor subscription QoS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martiño Crespo --- ros2_benchmark/include/ros2_benchmark/common.hpp | 4 ++++ ros2_benchmark/include/ros2_benchmark/monitor_node.hpp | 6 ++++++ ros2_benchmark/src/monitor_node.cpp | 10 ++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ros2_benchmark/include/ros2_benchmark/common.hpp b/ros2_benchmark/include/ros2_benchmark/common.hpp index 4ba028d..1b185d2 100644 --- a/ros2_benchmark/include/ros2_benchmark/common.hpp +++ b/ros2_benchmark/include/ros2_benchmark/common.hpp @@ -27,6 +27,10 @@ namespace ros2_benchmark /// ROS 2 intraprocess communications is only compatible with keep_last policy const rclcpp::QoS kQoS{{RMW_QOS_POLICY_HISTORY_KEEP_LAST, 1000}}; +/// Quality-of-Service policy that +const rclcpp::QoS sensorQoS{ + {RMW_QOS_POLICY_HISTORY_KEEP_LAST, 1000}, rmw_qos_profile_sensor_data}; + /// Quality-of-Service policy that will not drop any messages const rclcpp::QoS kBufferQoS{ {RMW_QOS_POLICY_HISTORY_KEEP_LAST, 1000}, rmw_qos_profile_parameters}; diff --git a/ros2_benchmark/include/ros2_benchmark/monitor_node.hpp b/ros2_benchmark/include/ros2_benchmark/monitor_node.hpp index 76661fd..c34a5f7 100644 --- a/ros2_benchmark/include/ros2_benchmark/monitor_node.hpp +++ b/ros2_benchmark/include/ros2_benchmark/monitor_node.hpp @@ -92,6 +92,12 @@ class MonitorNode : public rclcpp::Node /// A service object for StartMonitoring. rclcpp::Service::SharedPtr start_monitoring_service_; + + /// Setting for matching QoS profile between publisher and monitor node + std::string qos_type; + + /// Custom QoS profile + rmw_qos_profile_t rmw_qos_profile_monitor_node; }; } // namespace ros2_benchmark diff --git a/ros2_benchmark/src/monitor_node.cpp b/ros2_benchmark/src/monitor_node.cpp index 78ddc0d..e78f2ce 100644 --- a/ros2_benchmark/src/monitor_node.cpp +++ b/ros2_benchmark/src/monitor_node.cpp @@ -37,7 +37,8 @@ MonitorNode::MonitorNode( std::placeholders::_1, std::placeholders::_2), rmw_qos_profile_default, - service_callback_group_)} + service_callback_group_)}, + qos_type(this->declare_parameter("qos_type", "default")) { } @@ -62,10 +63,15 @@ void MonitorNode::CreateGenericTypeMonitorSubscriber() this, std::placeholders::_1); + auto monitor_subs_qos = kQoS; + if (qos_type == "sensor"){ + monitor_subs_qos = sensorQoS; + } + monitor_sub_ = this->create_generic_subscription( "output", // topic name monitor_data_format_, // message type in the form of "package/type" - kQoS, + monitor_subs_qos, monitor_subscriber_callback); RCLCPP_INFO( From 0c251895eccfb3ff898e643690391cabfc376fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marti=C3=B1o=20Crespo?= Date: Wed, 31 May 2023 17:29:57 +0200 Subject: [PATCH 2/2] Remove unnecessary attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martiño Crespo --- ros2_benchmark/include/ros2_benchmark/monitor_node.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/ros2_benchmark/include/ros2_benchmark/monitor_node.hpp b/ros2_benchmark/include/ros2_benchmark/monitor_node.hpp index c34a5f7..94d4722 100644 --- a/ros2_benchmark/include/ros2_benchmark/monitor_node.hpp +++ b/ros2_benchmark/include/ros2_benchmark/monitor_node.hpp @@ -95,9 +95,6 @@ class MonitorNode : public rclcpp::Node /// Setting for matching QoS profile between publisher and monitor node std::string qos_type; - - /// Custom QoS profile - rmw_qos_profile_t rmw_qos_profile_monitor_node; }; } // namespace ros2_benchmark