From 4c64bbea8041131b36a84692af7064a4abbfddb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Fri, 7 Jun 2024 15:07:15 +0200 Subject: [PATCH] Use `ignoreLocalMessages` in the bridge (#559) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ignore local messages Signed-off-by: Carlos Agüero --- ros_gz_bridge/src/factory.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ros_gz_bridge/src/factory.hpp b/ros_gz_bridge/src/factory.hpp index ec00af7b..1ee9ded7 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 @@ -105,17 +106,16 @@ 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) { - // 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::SubscribeOptions opts; + opts.SetIgnoreLocalMessages(true); + node->Subscribe(topic_name, subCb, opts); } protected: