The implementation should be rather straightforward.
In ros2, point of interest is _timesource.cpp. It involves adding a "/clock" subscription that runs in it's own executor and using it as a time source if the parameter is set (with rcl_set_ros_time_override). This is preceded by resetting clocks and calling rcl_enable_ros_time_override. Since we interface with rcl, we need to replicate the behavior around calling these.
The work is as follows:
Expose API to set use_sim_time (on Ros2cs level)
Make this setting control whether we add a subscriber to "/clock" topic which in callback calls the *ros_time_override api. We would do this internally within Ros2cs. The subscription is best effort, keep last 1.
The current api for getting time should then just work (give system or "/clock" time depending on the parameter).
The implementation should be rather straightforward.
In ros2, point of interest is _timesource.cpp. It involves adding a "/clock" subscription that runs in it's own executor and using it as a time source if the parameter is set (with
rcl_set_ros_time_override
). This is preceded by resetting clocks and callingrcl_enable_ros_time_override
. Since we interface with rcl, we need to replicate the behavior around calling these.The work is as follows:
use_sim_time
(on Ros2cs level)The current api for getting time should then just work (give system or "/clock" time depending on the parameter).