ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

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

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.

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

Thank you so much, Jack

edit retag close merge delete

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.

( 2015-11-01 06:41:46 -0600 )edit

Sort by » oldest newest most voted

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.

more