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

Default unit of ros::Time::now()

asked 2018-07-03 03:34:33 -0500

kk2105 gravatar image

Hi All,

Could you please let me know the default unit of ros::Time::now()

Snippet of the code is given below

ros::Time ros_time; 
while (ros::ok())
    ros_time = ros::Time::now();
    //Some code

The output what I am getting is as below

   and so on..

Current system time is 14:00

Excuse me if the question is too simple.

Thank you. KK

edit retag flag offensive close merge delete


i have same question

Panason gravatar image Panason  ( 2019-08-03 04:48:31 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-03 03:55:26 -0500

gvdhoorn gravatar image

updated 2018-07-03 03:56:13 -0500

I believe #q189867 and wiki/roscpp/Overview/Time should explain this.

If it doesn't, please edit your question and clarify what is not clear yet.

edit flag offensive delete link more



@gvdhoorn Thank you ... Got it.. Whatever time returned by ros::Time::now() is in Unix epoch time format... which can be converted to time format using this website

kk2105 gravatar image kk2105  ( 2018-07-03 07:04:57 -0500 )edit

The time: "1530606380.463231277" is in second. The number doesn't need to reflect any time zone in human world. It's for robotic world, people sometimes call it simulation time.

lukelu gravatar image lukelu  ( 2020-09-21 14:02:32 -0500 )edit

@lukelu: I'm not sure that's correct.

The epoch is defined as:

the number of seconds (or milliseconds) elapsed since an absolute point in time, midnight of Jan 1 1970 in UTC time. (UTC is Greenwich Mean Time without Daylight Savings time adjustments.)

So there is a timezone.

And an epoch stamp is not simulated time necessarily. It's just a particular notation for timestamps. The clock source could be the actual clock or a simulated source.

gvdhoorn gravatar image gvdhoorn  ( 2020-09-21 14:41:28 -0500 )edit

@gvdhoorn Great to learn that. Thanks for your correction ! Do you know why ROS chose the midnight of 1st, Jan, 1970 in UTC as the starting time ? Does the date and the year have special, historical meaning to robot community ?

lukelu gravatar image lukelu  ( 2020-09-21 15:25:09 -0500 )edit

Do you know why ROS chose the midnight of 1st, Jan, 1970 in UTC as the starting time ?

This is not something "ROS chose".

The Unix epoch or Unix time is something which has existed since long before ROS was even conceived, and probably will also outlive it.

See wikipedia/Unix_time.

gvdhoorn gravatar image gvdhoorn  ( 2020-09-22 01:53:33 -0500 )edit

Question Tools

1 follower


Asked: 2018-07-03 03:34:33 -0500

Seen: 12,005 times

Last updated: Jul 03 '18