Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

I'm pasting here the text from the section Using Simulation Time from the /clock Topic that you can find here.

"In order for a ROS node to use simulation time according to the /clock topic, the /use_sim_time parameter must be set to true before the node is initialized. This can be done in a launchfile or from the command line.

If the /use_sim_time parameter is set, the ROS Time API will return time=0 until it has received a value from the /clock topic. Then, the time will only be updated on receipt of a message from the /clock topic, and will stay constant between updates.

For calculations of time durations when using simulation time, clients should always wait until the first non-zero time value has been received before starting, because the first simulation time value from /clock topic may be a high value."

Then, you can use the ROS Time API for converting the times to seconds or nanoseconds and calculate the elapsed time.