From 121e044c39760ae35ada3ff8ab133dc130cb0933 Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Mon, 29 Jul 2019 16:57:51 -0300 Subject: [PATCH] Make TimeSource ignore use_sim_time events coming from other nodes. (#799) Signed-off-by: Michel Hidalgo --- rclcpp/src/rclcpp/time_source.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rclcpp/src/rclcpp/time_source.cpp b/rclcpp/src/rclcpp/time_source.cpp index db8dd7ed15..7165afc8bf 100644 --- a/rclcpp/src/rclcpp/time_source.cpp +++ b/rclcpp/src/rclcpp/time_source.cpp @@ -220,13 +220,17 @@ void TimeSource::destroy_clock_sub() void TimeSource::on_parameter_event(const rcl_interfaces::msg::ParameterEvent::SharedPtr event) { + // Filter out events on 'use_sim_time' parameter instances in other nodes. + if (event->node != node_base_->get_fully_qualified_name()) { + return; + } // Filter for only 'use_sim_time' being added or changed. rclcpp::ParameterEventsFilter filter(event, {"use_sim_time"}, {rclcpp::ParameterEventsFilter::EventType::NEW, rclcpp::ParameterEventsFilter::EventType::CHANGED}); for (auto & it : filter.get_events()) { if (it.second->value.type != ParameterType::PARAMETER_BOOL) { - RCLCPP_ERROR(logger_, "use_sim_time parameter set to something besides a bool"); + RCLCPP_ERROR(logger_, "use_sim_time parameter cannot be set to anything but a bool"); continue; } if (it.second->value.bool_value) {