Add clock type to node_options
Signed-off-by: Jeffery Hsu [email protected] This PR adds the option for selecting clock source in Node/LifecycleNode thru NodeOptions. A similar option is already present in rclcpp::Timer but it is currently missing in Nodes/LifecycleNode. There's currently no way to set Node::now() and all other time-related functions to use clock sources other than ROS_TIME.
NOTE: this PR is from iRobot. It looks good to me, but I would like also feedbacks from other reviewers
Forgive me if I misunderstand this PR, but I think being able to have Node::now() driven by sim time is currently possible with setting use_sim_time=true parameter on the node. After this PR lands you should be able to create both sim and wall timers with Node::create_timer() and Node::create_wall_timer(). Is there a use case beyond these that I'm missing?
@asymingt the purpose of this PR is to allow to set the node clock type. There are 3 types of clocks in ros: real time, monotonic and "ros".
Currently, you must use a clock of type "ros" for a node. A clock of this type uses a real time clock and also the clock topic if available (and if use_sim_time is set to true).
There are a lot of applications where a real time clock is not suitable and it is required to use a monotonic clock (and as said before, the "ros" clock is not monotoni)
@asymingt the purpose of this PR is to allow to set the node clock type. There are 3 types of clocks in ros: real time, monotonic and "ros".
Currently, you must use a clock of type "ros" for a node. A clock of this type uses a real time clock and also the clock topic if available (and if use_sim_time is set to true).
There are a lot of applications where a real time clock is not suitable and it is required to use a monotonic clock (and as said before, the "ros" clock is not monotoni)
Understood. Thank you, and sorry for the distraction.
@fujitatomoya I think that comments have been addressed. Anything else to do?
either @iuhilnehc-ynos or @Barry-Xu-2018 , could you help us review on this?
I was thinking that, i may be missing something.
-
TimeSourceandClockStateare dedicated to manage the ROS simulation time. User must be able to switch on/off simulation time afterward. - Having
Node::Option::clock_typecan be used to default clock type creating timer and so on.
CC: @alsora @jefferyyjhsu
@fujitatomoya I agree on having the clock type to be used as the default clock type for timers... I was assuming that it was already the case.
About simulated time: users should be able to turn it on/off UNLESS they manually set the node clock to monotonic... In that case simulated time is not currently expected to work and it should throw an exception/error somewhere.
Hi, are there any more changes that we should address before proceeding with this PR? I see that there are some failures in windows tests, are these known problems?
@alsora @jefferyyjhsu sorry to be late, just left couple of comments.
@ivanpauno can you also take a look at this, this changes behavior a bit.
CC: @clalancette
CI seems to run with the wrong settings.
Hi, anything else to address before merging this PR?
@fujitatomoya @iuhilnehc-ynos is there anything else we should address before merging this PR?
@alsora some comments are not resolved or addressed yet?
I am okay to go with this, but requesting another maintainer to take a look at this, since it changes Node API and meaning of NodeClock::ros_clock_.
CC: @ivanpauno @clalancette @wjwwood
@fujitatomoya, I went back and resolved some of the minor comments that @alsora and I discussed internally and decided to keep it the same way. Please let me know if I am still missing anything. Thanks!
@jefferyyjhsu can you address DCO issue?
@fujitatomoya , yeah. Sorry, I did remember to fix it by rebasing it locally but forgot to finish it before pushing.
The windows failure happens also in a completely unrelated PR https://github.com/ros2/rclcpp/pull/1979
See https://github.com/ros2/rclcpp/pull/1979#issuecomment-1329448949
Running full CI. The github check reports failures on rclcpp tests but they seem unrelated.
Ping; can we merge this PR?