From 8ab6e50f4392787845a4eb113d9ed69742e6f817 Mon Sep 17 00:00:00 2001 From: Walter Lucetti Date: Fri, 8 Dec 2023 11:23:46 +0100 Subject: [PATCH 1/3] Fix QoS setting to allow IPC --- .../DepthImageToLaserScanROS.hpp | 1 + src/DepthImageToLaserScanROS.cpp | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/depthimage_to_laserscan/DepthImageToLaserScanROS.hpp b/include/depthimage_to_laserscan/DepthImageToLaserScanROS.hpp index 10401dc..1327d7d 100644 --- a/include/depthimage_to_laserscan/DepthImageToLaserScanROS.hpp +++ b/include/depthimage_to_laserscan/DepthImageToLaserScanROS.hpp @@ -75,6 +75,7 @@ class DEPTHIMAGETOLASERSCANROS_EXPORT DepthImageToLaserScanROS final : public rc ///< Instance of the DepthImageToLaserScan conversion class. std::unique_ptr dtl_; + }; } // namespace depthimage_to_laserscan diff --git a/src/DepthImageToLaserScanROS.cpp b/src/DepthImageToLaserScanROS.cpp index 2c4c0fe..a15d669 100644 --- a/src/DepthImageToLaserScanROS.cpp +++ b/src/DepthImageToLaserScanROS.cpp @@ -45,22 +45,31 @@ namespace depthimage_to_laserscan { +const int QOS_QUEUE_SIZE = 10; + DepthImageToLaserScanROS::DepthImageToLaserScanROS(const rclcpp::NodeOptions & options) : rclcpp::Node("depthimage_to_laserscan", options) -{ - auto qos = rclcpp::SystemDefaultsQoS(); +{ + rclcpp::QoS qos(QOS_QUEUE_SIZE); + + auto pub_opt = rclcpp::PublisherOptions(); + pub_opt.qos_overriding_options = rclcpp::QosOverridingOptions::with_default_policies(); + + auto sub_opt = rclcpp::SubscriptionOptions(); + pub_opt.qos_overriding_options = rclcpp::QosOverridingOptions::with_default_policies(); + cam_info_sub_ = this->create_subscription( "depth_camera_info", qos, std::bind( &DepthImageToLaserScanROS::infoCb, this, - std::placeholders::_1)); + std::placeholders::_1),sub_opt ); depth_image_sub_ = this->create_subscription( "depth", qos, - std::bind(&DepthImageToLaserScanROS::depthCb, this, std::placeholders::_1)); + std::bind(&DepthImageToLaserScanROS::depthCb, this, std::placeholders::_1),sub_opt); - scan_pub_ = this->create_publisher("scan", qos); + scan_pub_ = this->create_publisher("scan", qos, pub_opt); float scan_time = this->declare_parameter("scan_time", 0.033); From 3d828d971963aca1c779551a711f98112df7a560 Mon Sep 17 00:00:00 2001 From: Walter Lucetti Date: Fri, 8 Dec 2023 11:55:36 +0100 Subject: [PATCH 2/3] Fix linting --- .../depthimage_to_laserscan/DepthImageToLaserScanROS.hpp | 1 - src/DepthImageToLaserScanROS.cpp | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/depthimage_to_laserscan/DepthImageToLaserScanROS.hpp b/include/depthimage_to_laserscan/DepthImageToLaserScanROS.hpp index 1327d7d..10401dc 100644 --- a/include/depthimage_to_laserscan/DepthImageToLaserScanROS.hpp +++ b/include/depthimage_to_laserscan/DepthImageToLaserScanROS.hpp @@ -75,7 +75,6 @@ class DEPTHIMAGETOLASERSCANROS_EXPORT DepthImageToLaserScanROS final : public rc ///< Instance of the DepthImageToLaserScan conversion class. std::unique_ptr dtl_; - }; } // namespace depthimage_to_laserscan diff --git a/src/DepthImageToLaserScanROS.cpp b/src/DepthImageToLaserScanROS.cpp index a15d669..52c2850 100644 --- a/src/DepthImageToLaserScanROS.cpp +++ b/src/DepthImageToLaserScanROS.cpp @@ -49,7 +49,7 @@ const int QOS_QUEUE_SIZE = 10; DepthImageToLaserScanROS::DepthImageToLaserScanROS(const rclcpp::NodeOptions & options) : rclcpp::Node("depthimage_to_laserscan", options) -{ +{ rclcpp::QoS qos(QOS_QUEUE_SIZE); auto pub_opt = rclcpp::PublisherOptions(); @@ -62,12 +62,12 @@ DepthImageToLaserScanROS::DepthImageToLaserScanROS(const rclcpp::NodeOptions & o "depth_camera_info", qos, std::bind( &DepthImageToLaserScanROS::infoCb, this, - std::placeholders::_1),sub_opt ); + std::placeholders::_1), sub_opt ); depth_image_sub_ = this->create_subscription( "depth", qos, - std::bind(&DepthImageToLaserScanROS::depthCb, this, std::placeholders::_1),sub_opt); + std::bind(&DepthImageToLaserScanROS::depthCb, this, std::placeholders::_1), sub_opt); scan_pub_ = this->create_publisher("scan", qos, pub_opt); From 88a7f25c4cb518e40629b5dd1dc15265c63c5158 Mon Sep 17 00:00:00 2001 From: Walter Lucetti Date: Fri, 8 Dec 2023 12:04:24 +0100 Subject: [PATCH 3/3] Fix Linting --- src/DepthImageToLaserScanROS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DepthImageToLaserScanROS.cpp b/src/DepthImageToLaserScanROS.cpp index 52c2850..85ac6e4 100644 --- a/src/DepthImageToLaserScanROS.cpp +++ b/src/DepthImageToLaserScanROS.cpp @@ -62,7 +62,7 @@ DepthImageToLaserScanROS::DepthImageToLaserScanROS(const rclcpp::NodeOptions & o "depth_camera_info", qos, std::bind( &DepthImageToLaserScanROS::infoCb, this, - std::placeholders::_1), sub_opt ); + std::placeholders::_1), sub_opt); depth_image_sub_ = this->create_subscription(