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

problem about ros::time -- 8-digit nsec

asked 2015-10-31 10:06:15 -0500

somebodyus gravatar image

updated 2016-10-24 09:08:33 -0500

ngrennan gravatar image

Dear all,

I am trying to subscribe the RGB image topic from openni driver. The images are written into disk with the time stamps as the file names. However, the ros::time seems not continuous. The time stamps with 8-digit nsec appear regularly. These time stamps will disrupt the chronological order.

For example, the images in the following list are written chronologically, we can clearly see the time stamps with 8-digit nsec disrupting the time order.

image description

Who can tell me the reason? How to avoid this case?

Thank you so much, Jack

edit retag flag offensive close merge delete

Comments

2

Please don't use screenshots when a copy/paste from your console would work as well. If the file ever disappears, this question will become much harder to understand for future readers. Also: image files are not searchable by search engines. Please use the Preformatted text button for copy/pastes.

gvdhoorn gravatar image gvdhoorn  ( 2015-11-01 06:41:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-11-01 06:40:17 -0500

gvdhoorn gravatar image

updated 2015-11-02 02:07:20 -0500

For example, the images in the following list are written chronologically, we can clearly see the time stamps with 8-digit nsec disrupting the time order.

[..]

Who can tell me the reason?

There are only 1e9 nanoseconds in a second, so to see timestamps with the same nanoseconds is inevitable. Also: they are not "disrupting the time order", as the timestamps are always of the form seconds.nanoseconds (see wiki/roscpp/Overview/Time for more info on how time is represented in ROS). Take a look at your screenshot: you'll find them to be in proper chronological order.

How to avoid this case?

If you are asking how to avoid filename collisions in case of the nanosecond parts occurring more than once: just include the second part as well.

Edit: if you are worried that files will not be chronologically sorted by your OS (because 4e7 would come after 1e9 (in the same second) fi), then pad the nanosecond part of the timestamps with zeros before you include it in the filename.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-10-31 10:06:15 -0500

Seen: 898 times

Last updated: Nov 02 '15