[ros-users] [Discourse.ros.org] [Next Generation ROS] ROS 2 …

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: andreaspasternak via ros-users
Date:  
To: ros-users
CC: andreaspasternak
Subject: [ros-users] [Discourse.ros.org] [Next Generation ROS] 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.






---
[Visit Topic](https://discourse.ros.org/t/ros-2-time-vs-std-chrono/6293/9) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list

http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>