0
$\begingroup$

Rosanswers logo

Should I always manually transmit the use_sim_time manually to all my nodes in a launchfile in ROS 2, if I want to be able to slow down or accelerate the simulation time or be able to run it on rosbags ?

The only official example I have is from the robot state publisher tutorial, where it is transmitted manually.

But I would expect a way to setting it globally, since it is the entierity of a ROS 2 system that should affected by time when you slow down or accelerate a simulation, or replay a rosbag. And because it is repetitive and add length to the code.

Is there such a way instead ?


Originally posted by deb0ch on ROS Answers with karma: 101 on 2021-02-09

Post score: 7


Original comments

Comment by ottojo on 2021-04-23:
Hi! Did you since find a way to set use_sim_time globally (besides setting it in the launchfile)?

Comment by austin on 2021-04-25:
It would be convenient to have a global use_sim_time. However its up to each node to implement so i am not sure this is even possible or desirable.

however ever robot i have seen is has to pass it throughout the launch ecosystem because to your point it really does effect everything. I alsot breaks if every node is not on the same use_sim_time param. So de facto there is a global use_sim_time concept.

Therefore i think this is a good feature request and would require updated to rclcpp and rclpy i think. somewhat related and definitly good place for more info on the client library implementations of ros time: https://github.com/ros2/rclcpp/issues/595

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

Can set_parameter solve this problem? #q368802


Originally posted by Kenji Miyake with karma: 307 on 2021-04-25

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$
0
$\begingroup$

Rosanswers logo

Hey ! Nice to see some movement around this question !

Since I posted, we found a neat solution that works great for us : using the /**: syntax in the .yaml params file, where ** matches the names of all the nodes :

params/simulation.yaml

---
/**:
    ros__parameters:
        use_sim_time: true

launch/do_stuff.launch.py

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():
    """Launch stuff using ROS 2."""
    params = os.path.join(get_package_share_directory('your_package'), 'params', 'simulation.yaml')

    return LaunchDescription([
        Node(
            package='stuff',
            executable='do_stuff_node',
            name='do_stuff',
            parameters=[params],
            output='screen'),
    ])

Originally posted by deb0ch with karma: 101 on 2021-04-26

This answer was NOT ACCEPTED on the original site

Post score: 3


Original comments

Comment by NEngelhard on 2022-01-13:
but how do you use this if your node has it's own parameter file?

$\endgroup$
0
$\begingroup$

Rosanswers logo

See this PR for an alternative solution. @NEngelhard


Originally posted by tnajjar with karma: 166 on 2022-08-25

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.