Skip to content

Commit 4c64bbe

Browse files
authored
Use ignoreLocalMessages in the bridge (gazebosim#559)
* Ignore local messages Signed-off-by: Carlos Agüero <[email protected]>
1 parent cadae1c commit 4c64bbe

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ros_gz_bridge/src/factory.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <string>
2121

2222
#include <gz/transport/Node.hh>
23+
#include <gz/transport/SubscribeOptions.hh>
2324

2425
// include ROS 2
2526
#include <rclcpp/rclcpp.hpp>
@@ -105,17 +106,16 @@ class Factory : public FactoryInterface
105106
size_t /*queue_size*/,
106107
rclcpp::PublisherBase::SharedPtr ros_pub)
107108
{
108-
std::function<void(const GZ_T &,
109-
const gz::transport::MessageInfo &)> subCb =
110-
[this, ros_pub](const GZ_T & _msg, const gz::transport::MessageInfo & _info)
109+
std::function<void(const GZ_T &)> subCb =
110+
[this, ros_pub](const GZ_T & _msg)
111111
{
112-
// Ignore messages that are published from this bridge.
113-
if (!_info.IntraProcess()) {
114-
this->gz_callback(_msg, ros_pub);
115-
}
112+
this->gz_callback(_msg, ros_pub);
116113
};
117114

118-
node->Subscribe(topic_name, subCb);
115+
// Ignore messages that are published from this bridge.
116+
gz::transport::SubscribeOptions opts;
117+
opts.SetIgnoreLocalMessages(true);
118+
node->Subscribe(topic_name, subCb, opts);
119119
}
120120

121121
protected:

0 commit comments

Comments
 (0)