ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Change /clock rate in ROS 2 Gazebo

asked 2021-11-11 13:32:47 -0500

allenh1 gravatar image

I'm trying to change the rate at which /clock is being published in ROS 2 gazebo, because 10 Hz is far too slow for my application. I found an article here that suggests I can set the parameter publish_rate to a number (in Hz as I understand it). The following, however, does not work for setting that parameter from my launch file.

Is this parameter just not exposed for some reason? Anybody have a suggestion for setting this?

gazebo = IncludeLaunchDescription(                                                                                                      
    PythonLaunchDescriptionSource([                                                                                                     
        os.path.join(                                                                                                                   
            get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py'                                                   
    ]),                                                                                                                                 
    launch_arguments={                                                                                                                  
        'gui': 'true',                                                                                                                  
        'publish_rate': '1000.0',                                                                                                       
    }.items(),                                                                                                                          
)

Thanks,

--Hunter

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-11-14 19:45:05 -0500

muronglindong gravatar image

updated 2021-11-14 20:07:48 -0500

You can try as this link shows: https://github.com/robotlabor-educati...

Create a file somewhere, for example <your package="">/config/params.yaml, with the following parameters :

gazebo: 
    ros__parameters: 
        publish_rate: 100.0

Then modify your launch file some like:

config_file_name = 'params.yaml' 

pkg_dir = get_package_share_directory('<your package name>') 

config = os.path.join(pkg_dir, 'config', config_file_name) 

gazebo = ExecuteProcess( 

cmd=['gazebo', '--verbose', world, '-s', 'libgazebo_ros_init.so',  

'-s', 'libgazebo_ros_factory.so', '--pause', '--ros-args', '--params-file', config], 

output='screen', 

)

Don't forget to edit CMakeLists.txt.

edit flag offensive delete link more

Comments

Thanks, I actually patched this upstream.

https://github.com/ros-simulation/gaz...

allenh1 gravatar image allenh1  ( 2021-11-14 19:49:12 -0500 )edit
0

answered 2022-11-04 04:52:48 -0500

josefgst gravatar image

This helped a lot, thx!

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-11-11 13:32:47 -0500

Seen: 949 times

Last updated: Nov 14 '21