# 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_interface...

I've looked:

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

edit retag close merge delete

Sort by » oldest newest most voted

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;
};

more