Skip to content

Allow rclcpp::Time::max() to support other clock types than RCL_SYSTEM_TIME. #2348

@jrutgeer

Description

@jrutgeer

As of yet, rclcpp::Time::max() calls the Time() constructor without specified value for rcl_clock_type_t:

Time
Time::max()
{
return Time(std::numeric_limits<int32_t>::max(), 999999999);
}

Hence, rclcpp::Time::max() returns a Time value with clock type RCL_SYSTEM_TIME:

Time(int32_t seconds, uint32_t nanoseconds, rcl_clock_type_t clock_type = RCL_SYSTEM_TIME);


This means that you can't compare time values of type RCL_ROS_TIME to rclcpp::Time::max().

I propose to change the max() implementation as follows:

Time
Time::max(rcl_clock_type_t clock_type = RCL_SYSTEM_TIME)
{
  return Time(std::numeric_limits<int32_t>::max(), 999999999, clock_type);
}

This is backwards-compatible with the current implementation, yet allows to specify RCL_ROS_TIME if needed, e.g.:

if( reported_time_ < rclcpp::Time::max(RCL_ROS_TIME) {
  [...]
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions