Robotics StackExchange | Archived questions

Time message definition rationale

This might be a little bit of a dumb question, but I'm curious why the Time type is defined as an int32 and uint32.

https://github.com/ros2/rcl_interfaces/blob/master/builtin_interfaces/msg/Time.msg

I've looked:

https://design.ros2.org/articles/clock_and_time.html http://wiki.ros.org/roscpp/Overview/Time

but didn't find an answer as to why the msg itself is defined as it is as opposed to a single uint64. Obviously the int32 can be positive or negative (which honestly I don't understand in the context that the Time type is a specific point in time, as opposed to a duration).

The type is the same between ROS and ROS2, so the must be some advantage of why it is defined as it is. what are these advantages? Thanks

Asked by strike_eagle_iii on 2020-07-01 19:35:00 UTC

Comments

Answers

While I'm not sure what the advantage is, I think this is the reason for it in ROS 2.

builtin_interfaces/msg/Time is part of the builtin_interfaces package which contains "message and service definitions for types defined in the OMG IDL Platform Specific Model".

In section 2.3.2 of the OMG DDS 1.4 spec the Duration_T and Time_T types are defined:

The two types used to represent time: Duration_t and Time_t are mapped into structures that contain fields for the second and the nanosecond parts. These types are further constrained to always use a ‘normalized’ representation for the time, that is, the nanosec field must verify 0 <= nanosec < 1000000000

and a little lower down

 struct Time_t {
     long sec;
     unsigned long nanosec;
 };

Asked by sloretz on 2020-07-01 20:02:25 UTC

Comments