ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A

ROS Time in beta1

I see in the RCL API docs that there is a file rcl/time.h which has definitions and functions to get time.
Is this the right mechanism we should be using to align Sim time and System time moving forward? (I realize the SIM time mechanism may not fully work yet…)

In the Migration guide it says that we still need to wait for a good replacement for ros::Time::now().
Is that still the case? Or do we use rcl_get_time_point_now() or some other function?

1 Like

That is the skeleton of what will support the ROS 2 version of ros::Time::now(). It has the abstraction in place for sim time versus real time, but we haven’t prototyped sim time yet and we haven’t exposed these interfaces through the language specific client libraries (like in rclcpp).

If you want to use that right now that would ok, but in the future expect there to be a rclcpp::Time::now() that you should use instead.

The theoretical ideas behind this abstraction are in this design doc:

@tfoote might be able to give more pointers, he was the architect of this part of rcl. Also, we don’t really have a good example of how this should be used, as far as I can find, at the moment. I think the ideas was that we would do that once we had it exposed in c++ and python.

So, with the release of Ardent, is time now fully functional?
That is to say, will it work like ROS1 time when we are simulating on a computer? Or replaying bagged data through the bridge? Or running distributed ROS2 nodes across computers?

What are the limitations of Time in V1?


I’m not 100% certain of where the state landed, @tfoote can you describe it?

I know we got ROS Time into the C++ API in some form, but I’m unclear on the status of sim time itself and how to enable it (via parameters I guess?). Also, I’m not sure if it’s been tested with bagged data via the bridge.

In C++ ROS time is operational using the /clock topic if the parameter use_sim_time is set, following the Clock and TIme design article.

The rclcpp Node has been extended to automatically setup a time source and provides now() and get_clock() convenience methods.

It has not been tested with the bridge and ROS1. I suspect that it would work if the right alias is defined between ROS1’s rosgraph_msgs/Clock and ROS2’s builtin_msgs/Time as the datatypes are the same and the topic is the same.

Note that there’s slightly different semantics on the parameter too as it’s on the node and not global anymore.