From 92847d98d89f8c0cee632a23f4a8f07d41012bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 5 Jun 2024 19:09:43 +0200 Subject: [PATCH 1/5] Ignore local messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_bridge/src/factory.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ros_gz_bridge/src/factory.hpp b/ros_gz_bridge/src/factory.hpp index ec00af7b..22b48a4b 100644 --- a/ros_gz_bridge/src/factory.hpp +++ b/ros_gz_bridge/src/factory.hpp @@ -109,13 +109,13 @@ class Factory : public FactoryInterface const gz::transport::MessageInfo &)> subCb = [this, ros_pub](const GZ_T & _msg, const gz::transport::MessageInfo & _info) { - // Ignore messages that are published from this bridge. - if (!_info.IntraProcess()) { - this->gz_callback(_msg, ros_pub); - } + this->gz_callback(_msg, ros_pub); }; - node->Subscribe(topic_name, subCb); + // Ignore messages that are published from this bridge. + gz::transport::SubscriptionOptions opts; + opts.SetIgnoreLocalMessages(true); + node->Subscribe(topic_name, subCb, opts); } protected: From 8eb01dea795414f4d792c6bf357c5347b84206f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 5 Jun 2024 19:29:51 +0200 Subject: [PATCH 2/5] Include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_bridge/src/factory.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ros_gz_bridge/src/factory.hpp b/ros_gz_bridge/src/factory.hpp index 22b48a4b..7294192e 100644 --- a/ros_gz_bridge/src/factory.hpp +++ b/ros_gz_bridge/src/factory.hpp @@ -20,6 +20,7 @@ #include #include +#include // include ROS 2 #include From ca89a313ccca7a74c871269ed5fafff81eb39435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 5 Jun 2024 19:53:10 +0200 Subject: [PATCH 3/5] Tweak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_bridge/src/factory.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros_gz_bridge/src/factory.hpp b/ros_gz_bridge/src/factory.hpp index 7294192e..b2a00dc6 100644 --- a/ros_gz_bridge/src/factory.hpp +++ b/ros_gz_bridge/src/factory.hpp @@ -20,7 +20,7 @@ #include #include -#include +#include // include ROS 2 #include From b13fe189ba96c9b1455c6f0af0f51daf9c54eaa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 5 Jun 2024 20:09:19 +0200 Subject: [PATCH 4/5] Tweak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_bridge/src/factory.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros_gz_bridge/src/factory.hpp b/ros_gz_bridge/src/factory.hpp index b2a00dc6..cc9f8c0c 100644 --- a/ros_gz_bridge/src/factory.hpp +++ b/ros_gz_bridge/src/factory.hpp @@ -114,7 +114,7 @@ class Factory : public FactoryInterface }; // Ignore messages that are published from this bridge. - gz::transport::SubscriptionOptions opts; + gz::transport::SubscribeOptions opts; opts.SetIgnoreLocalMessages(true); node->Subscribe(topic_name, subCb, opts); } From b800e82026bd5e7d206ccc40e719ca956185d2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 5 Jun 2024 20:12:00 +0200 Subject: [PATCH 5/5] Tweak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_bridge/src/factory.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ros_gz_bridge/src/factory.hpp b/ros_gz_bridge/src/factory.hpp index cc9f8c0c..1ee9ded7 100644 --- a/ros_gz_bridge/src/factory.hpp +++ b/ros_gz_bridge/src/factory.hpp @@ -106,9 +106,8 @@ class Factory : public FactoryInterface size_t /*queue_size*/, rclcpp::PublisherBase::SharedPtr ros_pub) { - std::function subCb = - [this, ros_pub](const GZ_T & _msg, const gz::transport::MessageInfo & _info) + std::function subCb = + [this, ros_pub](const GZ_T & _msg) { this->gz_callback(_msg, ros_pub); };