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

difference between and /clock

asked 2012-05-15 05:04:28 -0500

max gravatar image

Hello!I'm new to ROS and now i have checked that to print time on screen (for example) i can use ros::Time::now() or subscribe to /clock and get time from the message. Anybody can tell me if there are differencies between these two ways? thanks,


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-05-15 06:55:20 -0500

DimitriProsser gravatar image

These two options represent the same time. In code, you should definitely use ros::Time::now(). It will get you the current ROS time that is being published to /clock without most of the overhead involved with subscribing to the topic yourself. Plus, it looks a lot better in your code.

edit flag offensive delete link more



Isn't /clock only published by simulation and only used by ros::Time when use_sim_time is true? I think on a real system, subscribing to it would just not work.

Lorenz gravatar image Lorenz  ( 2012-05-15 07:00:44 -0500 )edit

I believe you might be correct

DimitriProsser gravatar image DimitriProsser  ( 2012-05-15 07:02:09 -0500 )edit

Question Tools


Asked: 2012-05-15 05:04:28 -0500

Seen: 2,000 times

Last updated: May 15 '12