Gazebo | Ignition | Community
Ask Your Question

Calculate elapsed time between tasks in simulation

asked 2018-02-22 09:47:46 -0500

JuanTelo gravatar image

updated 2018-02-22 09:52:11 -0500

Carlos Agüero gravatar image

Hi, I want to see how much time I take to perform one task in gazebo, however have no idea on how I can do it, I know it's possible to subsribe to "/clock" topic but don't know what to do with it. Keep in mind that I'm also using ROS for this simulation.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-02-22 10:41:18 -0500

Carlos Agüero gravatar image

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-02-22 09:47:46 -0500

Seen: 948 times

Last updated: Feb 22 '18