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

Why are the data fields of ROS::Time signed values?

asked 2019-01-28 15:35:51 -0600

BitBasher4095 gravatar image

Maybe a dumb question, but what is the motivation of having the data field of the ROS::Time structure be signed values? I suppose I can see some reason for having the "sec" field be signed in case there is a need to express a time before the epoch, but having the "nsec" field be a signed value seems to be an error to me.

How am I supposed to interpret a value where "nsec" field is negative? Does this mean that the values:

{sec: 5, nsec: 500_000_000} and {sec: 6, nsec: -500_000_000}

are equivalent values (please forgive the pseudo-Pythonic notation)?

It's just something that seemed weird to me as I went through the ROS message definitions and I was wondering if there was any motivation for this, or if it's just an "accident of history".

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-01-28 16:34:12 -0600

VictorLamoine gravatar image

ros::Time can represent time AND durations. It happens that durations can be negative, this explains why nsec needs to be signed as well.

http://wiki.ros.org/roscpp/Overview/Time

edit flag offensive delete link more

Comments

Ah, okay. I guess I missed on my previous read-throughs that "Times and durations have identical representations." Seems like a bit of a waste and could cause confusion, but as long as it's documented...

Thanks!

BitBasher4095 gravatar image BitBasher4095  ( 2019-01-28 16:36:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-01-28 15:35:51 -0600

Seen: 364 times

Last updated: Jan 28 '19