Skip to content

Setting use_sim_time on one node enables ros time on all nodes #537

@mikaelarguedas

Description

@mikaelarguedas

Bug report

Required Info:

Steps to reproduce issue

Add a print in the time source onparameter_event callback by applying this patch to rclcpp

diff --git a/rclcpp/src/rclcpp/time_source.cpp b/rclcpp/src/rclcpp/time_source.cpp
index bfd0ea2..0952d85 100644
--- a/rclcpp/src/rclcpp/time_source.cpp
+++ b/rclcpp/src/rclcpp/time_source.cpp
@@ -225,9 +225,11 @@ void TimeSource::on_parameter_event(const rcl_interfaces::msg::ParameterEvent::S
     }
     if (it.second->value.bool_value) {
       parameter_state_ = SET_TRUE;
+      RCUTILS_LOG_ERROR("enabling ros time!")
       enable_ros_time();
     } else {
       parameter_state_ = SET_FALSE;
+      RCUTILS_LOG_ERROR("disabling ros time!")
       disable_ros_time();
     }
   }

Shell 1: run a C++ listener:

ros2 run demo_nodes_cpp listener

Shell 2: run another C++ node:

ros2 run demo_nodes_cpp add_two_ints_server

Shell 3:
Set use_sim_time on the listener:

$ ros2 param set listener use_sim_time true
Set parameter successful

Expected behavior

Shell 1 should print:

[ERROR] []: enabling ros time!

Shell 2 should not print anything

Actual behavior

Both shells print

[ERROR] []: enabling ros time!

Additional information

This is due to the fact that:

  • /parameter_events is a global topic and its messages don't contain any node specific information. We could:
  • rclcpp is listening to parameter_events and parsing its data to know what's hosted on the same node. It should instead leverage its own parameter server (created in all nodes by default) to get notified when a new value of use_sim_time has been set

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions