[ros-users] [Discourse.ros.org] [Next Generation ROS] ROS 2 Time vs std::chrono

Sloretz ros.discourse at gmail.com
Mon Oct 8 22:43:47 UTC 2018



If I understand correctly, I think the issue is that the [`std::chrono` clock requirements](https://en.cppreference.com/w/cpp/named_req/Clock) don't allow `now()` to be a non-static member function.  `ros2_node_clock::now()` has to be `static` and could not access `m_clock`.

A while ago I did try prototyping a clock that conformed to the `std::chrono` requirements except with a non-static member `now()`. Not all C++ API's allow this. For example [`std::thread::sleep_until()`](https://en.cppreference.com/w/cpp/thread/sleep_until) tries to call `clock::now()` on the time point passed into it. I gave up because whether or not an API calls `clock::now()` in its implementation is undefined behavior.





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




More information about the ros-users mailing list