Hello everyone,
I think, the current design of simulated clocks and the parameter use_sim_time
lead to major problems and should be reworked. Here are my issues:
The use_sim_time
parameter is available on every node and instructs that node to use the /clock
topic as a time source. This allows nodes to run slower or faster e.g. during simulation or playing a bag file.
In ROS1, this was a global parameter, so every node had the same configuration. However, in ROS2, this parameter needs to be set on each node individually. This is a major design flaw because it is very easy to end up with an inconsistent clock source, leading to unexpected and undefined behavior.
Every node means:
- All simulation launch files
- All launch files and nodes, started separately for testing
- All dynamically loaded Gazebo plugins (that start a Node)
- All GUI tools (rviz, rqt, ā¦)
To make matters worse, ros2 launch
does not have the functionality to set this parameter, so you need to manually insert it in every launch file that you want to start individually in simulation, cluttering the file. And it is very easy to forget to set it.
How many of you created a dedicated launch file for rviz to start it with use_sim_time
for simulation? Probably not many. If not, you ended up with an inconsistent time setup, probably without even realizing it.
It is not a use-case to start a setup with inconsistent clocks. Therefore, it should not be possible. The time source should be unique and identical for all nodes by design.
I think, there is a pretty straight-forward solution. During the transition from ROS1 to ROS2, the robot description was moved from a global parameter to a topic, probably for the same reason. Consequently, the clock should follow the same approach and the /clock
topic exists already.