diff --git a/ros_gz_bridge/src/factory.hpp b/ros_gz_bridge/src/factory.hpp index 83e48351..9f32a7a7 100644 --- a/ros_gz_bridge/src/factory.hpp +++ b/ros_gz_bridge/src/factory.hpp @@ -22,6 +22,7 @@ #include #include +#include // include ROS 2 #include @@ -118,18 +119,16 @@ class Factory : public FactoryInterface rclcpp::PublisherBase::SharedPtr ros_pub, bool override_timestamps_with_wall_time) { - std::function subCb = - [this, ros_pub, override_timestamps_with_wall_time](const GZ_T & _msg, - const gz::transport::MessageInfo & _info) + std::function subCb = + [this, ros_pub, override_timestamps_with_wall_time](const GZ_T & _msg) { - // Ignore messages that are published from this bridge. - if (!_info.IntraProcess()) { - this->gz_callback(_msg, ros_pub, override_timestamps_with_wall_time); - } + this->gz_callback(_msg, ros_pub, override_timestamps_with_wall_time); }; - 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: