ROS 2 Time vs std::chrono

@wjwwood: Thank you for your input!

I checked the code more closely and it is actually encoded in rclcpp::Time which clock was used. This is great! But if it set to RCL_ROS_TIME I have no information about the state of the clock which was used to create this rclcpp::Time, right? Maybe it was simulated time, maybe something else. Should rclcpp::Time not have a pointer to the associated rclcpp::Clock?

Maybe I am missing a feature in ROS 2 time which solves this issue but I am unable to find it.

I am also unsure about the solution how would one implement the conversion from rclcpp::Time to std::time_point.

??? to_time_point(rclcpp::Time time) {
  if(time.get_clock() == RCL_SYSTEM_TIME) {
    return std::chrono::system_clock::time_point(time.nanoseconds()ns)
  }
  else if(time.get_clock() == RCL_STEADY_TIME) {
    return std::chrono::steady_clock::time_point(time.nanoseconds()ns)
  }
  else {
    //ERROR not supported.
  }
}

One could use boost::variant or extend the standard library but those are surely not optimal solutions.