Skip to content
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

Ros2: Set Gazebo clock publish rate #1305

Closed
HarunTeper opened this issue Aug 20, 2021 · 5 comments
Closed

Ros2: Set Gazebo clock publish rate #1305

HarunTeper opened this issue Aug 20, 2021 · 5 comments

Comments

@HarunTeper
Copy link

HarunTeper commented Aug 20, 2021

Hello,

the default publish rate of the gazebo clock node is 10Hz. So far, it is most convenient to use the following approach to use Ros2 and Gazebo in a launch file for me:

gazebo_launch_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gazebo.launch.py')),
launch_arguments={'world': world}.items()
)
However, looking at the launch files and some other threads, I can't manage to set the publish_rate for the gazebo clock node. Is it possible to include the parameter .yaml file in the launch arguments or to include a parameter {'publish_rate': '10'} to the list of parameters, so that it can be set by the launch file.

@allenh1
Copy link

allenh1 commented Nov 11, 2021

This is a duplicate of #1211 and #1247... Would be really great if this could be addressed. It makes the gazebo clock unusable for time-sensitive calculations.

@john-maidbot
Copy link

john-maidbot commented Dec 7, 2021

I had this same issue. Pretty frustrating 😅 If anyone else finds this, there is a workaround (it would be a good solution if not for the error message, but it worked for me on ros2 galactic, gazebo version 11.9.0):
https://answers.ros.org/question/378362/how-to-set-gazebo-clock-publish-rate-foxy/

@allenh1
Copy link

allenh1 commented Dec 11, 2021

@john-maidbot I have a pull request (see #1332) for dealing with this... It works for all my purposes, but would require you to build from source.

@jacobperron
Copy link
Collaborator

#1391 has made it more convenient to set ROS parameters (including publish_rate) from the launch file.

@pinkponk
Copy link

pinkponk commented Oct 3, 2023

For anyone else having problems with this and sees this issue, I finally got it to work with this:

    gazebo_params_path = os.path.join(
                    get_package_share_directory(package_name),'config','gazebo_params.yaml')
    gazebo_world_path = os.path.join(
                    get_package_share_directory(package_name),'worlds','AAAA.world')

    gazebo = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')]),
                    launch_arguments={
                        'params_file': gazebo_params_path,
                                      'world': gazebo_world_path }.items()
         )

Dont forget to include the config dir in the CMakeList.txt

install(
  DIRECTORY config launch worlds
  DESTINATION share/${PROJECT_NAME}
)

gazebo_config.yaml

# gazebo_params.yml
gazebo:
    ros__parameters:
        publish_rate: 400.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants