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

Publish a Clock - time stuff in ROS

asked 2014-02-05 09:57:35 -0500

Erwan R. gravatar image

updated 2014-04-20 14:09:42 -0500

ngrennan gravatar image

Hello ROS community !

I have question about Time in ROS (I'm in Fuerte on Ubuntu 12.04). Let me explain the situation : I have a basic simulator written with ROS, that receive an /action topic, publish a /perception topic, with the relevant custom messages. On the other hand, I have two nodes, a Perceptive one, that transform perception into state, and a Controller that use state and compute an action, that is sent to the simulator. The connection is :

Simulator -> /perceptiontopic -> (Percept -> /state -> Controller) -> /action -> Simulator

All my nodes are firing Timers at a certain NODERATE that trigger (or not):

  • world update for the Simulator : if the relevant time in second has gone, the world changes. The world change is independent from the NODERATE itself has the world evolution has its own "dynamic".

  • Perception update and State publishing for the perceptive node : if we received a /perception message or some time in second has gone, we publish a /state message. The involved durations are also independent from NODERATE.

  • Action computation for the Controller. When it receives a /state message, it computes the action message and publish it to the simulator.

I'm wondering about the time consistency as my simulator doesn't publish a /clock topic (nor my others nodes subscribe to /clock). I had the same NODERATE for the simulator and others nodes and a certain behavior. I changed the Perceptive and Controller nodes' NODERATE (lower than simulation one) and now the behaviour is different. In my understanding, it shouldn't as the time aspects of my nodes are supposed to be independent.

So :

  • Is it necessary to have a /clock (from the simulator) to ensure time consistency between nodes that commuicate together ?

  • If so, what time should my simulator publish ? A ros::Time::now() (+/use_sim_time setup) ? How my perceptive and control nodes handle that ? Should they explicitly subscribe to /clock and have a callback on that ? What's the difference with my ros::Timer ?

  • I understand that no realtime is guaranteed with such tools, but what is the range of frequency / period ROS can handle without risk of inconsistency ?

Thanks for reading, Erwan

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-02-11 01:26:16 -0500

demmeln gravatar image

I don't think publishing a /clock topic will help you. AFAIK it is more of a tool to enable simulators to control time (e.g. run faster or slower than realtime) rather than a means for synchronization.

edit flag offensive delete link more


Ok, thank you for you answer.

Erwan R. gravatar image Erwan R.  ( 2014-02-17 01:41:10 -0500 )edit

Hi, this question is not about Publishing to a clock, it is instead about how to coordinate time between nodes, for which you though publishing to the /clock would be an option. However, it is not about how to publish to the /clock. It would be good if you could rename it, as it currently comes up in any searches about publishing to the /clock.

Craigstar gravatar image Craigstar  ( 2020-03-27 00:42:44 -0500 )edit

Question Tools

1 follower


Asked: 2014-02-05 09:57:35 -0500

Seen: 3,942 times

Last updated: Feb 11 '14