Skip to content

added important info about working with ros2_control #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions harmonic/ros2_launch_gazebo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.