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

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
    rate.sleep();
    ros::spinOnce();
}

The output what I am getting is as below

   1530606380.304236318
   1530606380.323266596
   1530606380.343226943
   1530606380.364454049
   1530606380.383265757
   1530606380.403270513
   1530606380.423227417
   1530606380.443286735
   1530606380.463231277
   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

Comments

i have same question

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

1 Answer

Sort by » oldest newest most voted
3

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

Comments

1

@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 https://www.epochconverter.com/

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
2

@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
1

@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
2

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

Stats

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

Seen: 13,784 times

Last updated: Jul 03 '18