Skip to content

Add custom launch file and timing issues info to Docs #549

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 3 commits into
base: rolling
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
75 changes: 75 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,78 @@ This uses the effort command interface for the cart's degree of freedom on the r

ros2 launch gz_ros2_control_demos pendulum_example_position.launch.py
ros2 run gz_ros2_control_demos example_position


Creating a Custom Launch File
=============================

To get started with your own launch file using `gz_ros2_control`, refer to the example launch files in the repository:

`Example launch files <https://github.com/ros-controls/gz_ros2_control/tree/rolling/gz_ros2_control_demos/launch>`_
Comment on lines +408 to +410
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To get started with your own launch file using `gz_ros2_control`, refer to the example launch files in the repository:
`Example launch files <https://github.com/ros-controls/gz_ros2_control/tree/rolling/gz_ros2_control_demos/launch>`_
To get started with your own launch file using `gz_ros2_control`, refer to the `example launch files <https://github.com/ros-controls/gz_ros2_control/tree/rolling/gz_ros2_control_demos/launch>`__ in the repository.


Basic Elements
--------------

1. **Launching the Gazebo simulator**

You can use the ``gz_sim.launch.py`` file provided by ``gz_ros2_control`` to launch Gazebo. Here's an example:

.. code-block:: python

gz_sim = IncludeLaunchDescription(
PythonLaunchDescriptionSource(gz_sim_launch),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will need something like

Suggested change
PythonLaunchDescriptionSource(gz_sim_launch),
PythonLaunchDescriptionSource(
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),

launch_arguments={
'gz_args': ['-r -v4 empty.sdf'],
'on_exit_shutdown': 'true'
}.items()
)

Explanation of flags:

- ``-r``: Starts the simulator immediately.
- ``-v4``: Sets the logging verbosity to level 4.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not advertise -v4, because the console log is spammed from gazebo and no one is looking at important warnings/errors of this plugin.


2. **Launching the ros_gz_bridge and publishing the `/clock` topic**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. **Launching the ros_gz_bridge and publishing the `/clock` topic**
2. **Launching the ros_gz_bridge and publishing the ``/clock`` topic**


It is essential to publish the ``/clock`` topic for the ``controller_manager`` to function correctly:

.. code-block:: python

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",
)

.. warning::

If you **do not** publish the ``/clock`` topic, the ``controller_manager`` will issue warnings or errors such as:

.. code-block:: console

[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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when should this happen? This is hardcoded from the plugin?


This results in logs like:

.. code-block:: console

[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:

.. code-block:: console

[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.
Loading