ROS 2 time handling
In ROS 1 my node has code like this in a subscribed message callback:
ros::Time now = ros::Time::now();
ros::Duration frameSkip = ros::Duration(m_frameSyncMs/1000.0);
// Proceed if time interval has elapsed or if clock has gone backwards
if (m_previousTimeStamp + frameSkip > now)
// etc...
Basically, when m_frameSyncMs
is 100 ms with the topic being a camera feed at 30 fps, just pick out every third frame or so. This works quite happily.
Now, for ROS 2 there no longer is a Time::now()
, and looking at various web pages there might be a node clock, or there might be an rcl_get_time_point_now()
but shouldn't that also take the result of rcl_get_default_ros_time()
?
What is the best way to do this? Furthermore, where is the best place to learn about the latest ROS 2 developments; GitHub and Discord, for instance seem a bit too light on information, and reading the source might work, but the next beta may very well invalidate everything. Finally is there a ros2bag
or equivalent for recording and playing back runs?