Ask Your Question
0

difference between Time.now() 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,

max

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

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

Comments

3

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 imageLorenz ( 2012-05-15 07:00:44 -0500 )edit

I believe you might be correct

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 1,371 times

Last updated: May 15 '12