ros2cs
ros2cs copied to clipboard
Support use_sim_time (equivalent) in ros2cs
The implementation should be rather straightforward.
In ros2, point of interest is time_source.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).