0
$\begingroup$

Rosanswers logo

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,

max


Originally posted by max on ROS Answers with karma: 1 on 2012-05-15

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by DimitriProsser with karma: 11163 on 2012-05-15

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Lorenz on 2012-05-15:
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.

Comment by DimitriProsser on 2012-05-15:
I believe you might be correct

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.