rmw icon indicating copy to clipboard operation
rmw copied to clipboard

rmw_time_t is redundant with rcutils_duration_value_t and doesn't need to be a struct

Open rotu opened this issue 5 years ago • 9 comments

rmw_time_t is defined as:

typedef struct RMW_PUBLIC_TYPE rmw_time_t
{
  uint64_t sec;
  uint64_t nsec;
} rmw_time_t;

This differs from rcutils_duration_value_t which admits a value as just a int64_t holding nanoseconds. It probably makes sense to replace rmw_time_t with a type alias for rcutils_duration_value_t, and to make clear that it is a duration, not a time point.

rotu avatar Apr 20 '20 05:04 rotu

It occurs to me that there is (until #214) no rmw concept of absolute time. It may make sense in the future to think about adding a rmw-implemented timestamp and comparator function so the RMW can use a different time concept, like vector clocks.

rotu avatar Apr 20 '20 05:04 rotu

Why do you think rmw_time_t is supposed to be a duration? Its uses of "uint64_t" seems to suggest it's a timestamp.

That means it would be redundant with rcutils_time_point_value_t, though.

iluetkeb avatar Apr 20 '20 08:04 iluetkeb

Because every existing use of it (wait time, liveliness, lifespan, deadline) is a relative time and because https://github.com/ros2/rclcpp/blob/911291f8d32da8a9a70f69adc7bcf1e41477e017/rclcpp/include/rclcpp/duration.hpp#L111.

Both time_point and duration are int64_t. The distinction is pretty meaningless in C, but matters in C++ (where you can enforce timestamp + duration = timestamp)

rotu avatar Apr 20 '20 08:04 rotu

BTW, I don’t think this issue is high priority. I’d like to see it eventually fixed.

rotu avatar Apr 20 '20 09:04 rotu

related to https://github.com/ros2/rmw/issues/210

fujitatomoya avatar Apr 20 '20 12:04 fujitatomoya

I'm looking at working on this in parallel to #210

Right now, I think rmw_time_t is used in 11 packages of ros2.repos. Most of the use is in tests or demos, luckily most use is hidden behind language client facades (rclcpp::Duration, rclpy.duration.Duration).

It makes sense to make a pass through ros2.repos, removing use, but it seems aggressive to delete the rmw_time_t type immediately. Should we give the type a deprecation notice via RCUTILS_DEPRECATED_WITH_MSG for Galactic, waiting to remove the type in H-turtle?

emersonknapp avatar Feb 10 '21 08:02 emersonknapp

Noting discussion from middleware WG meeting - no immediate concern about calling this type deprecated in Galactic to be removed in H-turtle. Expectation would be to remove the use of the types from ros2.repos in time for Galactic so that there are not compiler warnings in the core distro

emersonknapp avatar Feb 10 '21 17:02 emersonknapp

I think certain time window should be given for deprecation, the reasons are

  • All non-Tier1 rmw implementation will get build break because of this change.
  • Possibly implementation uses rmw_time_t internally.
  • fix all of the related packages are kinda heavy.

fujitatomoya avatar Feb 22 '21 08:02 fujitatomoya

I think certain time window should be given for deprecation, the reasons are

Agreed. We actually talked about this in more detail over at https://github.com/ros2/rmw/pull/298#discussion_r579420814 , and the consensus there was to revisit this after Galactic.

clalancette avatar Feb 22 '21 13:02 clalancette