From 60af4cb241c65680a40e40c29e85907aba261a2d Mon Sep 17 00:00:00 2001 From: Zach Yamaoka Date: Sun, 13 Apr 2025 15:49:36 -0700 Subject: [PATCH 1/2] added important info about working with ros2_control --- harmonic/ros2_launch_gazebo.md | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/harmonic/ros2_launch_gazebo.md b/harmonic/ros2_launch_gazebo.md index 43d157b88d..2f803fe68d 100644 --- a/harmonic/ros2_launch_gazebo.md +++ b/harmonic/ros2_launch_gazebo.md @@ -142,3 +142,41 @@ In the above launch files you may notice that the `create_own_container` argumen More info about `ros_gz_bridge` can be viewed [here](ros2_integration). More info about composition can be viewed [here](ros2_overview.md#composition). + +## Further Considerations for ROS2 Control + + If you're planning to use ros2_control with Gazebo, please take a look at the [example launch files](https://github.com/ros-controls/gz_ros2_control/tree/rolling/gz_ros2_control_demos/launch) in the `gz_ros2_control` repository + + It is essential to publish the `/clock` topic for the `controller_manager` to function correctly: + + gz_bridge = Node( + package="ros_gz_bridge", + executable="parameter_bridge", + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + parameters=[{ + "qos_overrides./tf_static.publisher.durability": "transient_local" + }], + output="screen", + ) + + + If you **do not** publish the `/clock` topic, the `controller_manager` will issue warnings or errors such as: + + [gazebo-1] [WARN] [1744219953.983130822] [controller_manager]: No clock received, using time argument instead! Check your node's clock configuration (use_sim_time parameter) and if a valid clock source is available. + + Timing Issues + ------------- + + By default, the `controller_manager` launched by `gz_ros2_control` has ``use_sim_time=true``. If for any reason this is set to ``false``, it will fall back to the system clock. + + This results in logs like: + + [gazebo-1] [INFO] [1744209678.974210234] [gz_ros_control]: Loading controller_manager + [gazebo-1] [INFO] [1744209679.000651931] [controller_manager]: Using Steady (Monotonic) clock for triggering controller manager cycles. + + Eventually leading to a fatal error: + + [gazebo-1] terminate called after throwing an instance of 'std::runtime_error' + [gazebo-1] what(): can't compare times with different time sources + + Ensure `use_sim_time` is correctly set to `true` when working with simulation time to avoid such mismatches. \ No newline at end of file From 9f0700f70b9c9a17d9cb1a6f36653dfed888d4ce Mon Sep 17 00:00:00 2001 From: Zachary Yamaoka Date: Tue, 15 Apr 2025 16:18:37 -0700 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alejandro Hernández Cordero Signed-off-by: Zachary Yamaoka --- harmonic/ros2_launch_gazebo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harmonic/ros2_launch_gazebo.md b/harmonic/ros2_launch_gazebo.md index 2f803fe68d..b57ab2607c 100644 --- a/harmonic/ros2_launch_gazebo.md +++ b/harmonic/ros2_launch_gazebo.md @@ -160,7 +160,7 @@ More info about composition can be viewed [here](ros2_overview.md#composition). ) - If you **do not** publish the `/clock` topic, the `controller_manager` will issue warnings or errors such as: +If you **do not** publish the `/clock` topic, the `controller_manager` will issue warnings or errors such as: [gazebo-1] [WARN] [1744219953.983130822] [controller_manager]: No clock received, using time argument instead! Check your node's clock configuration (use_sim_time parameter) and if a valid clock source is available.