ros2/rclcpp

Minor suggestion for `rclcpp::Node::now()` documentation string

Closed this issue · 4 comments

/// Returns current time from the time source specified by clock_type.
/**
* \sa rclcpp::Clock::now
*/
RCLCPP_PUBLIC
Time
now() const;

Notice how "clock_type" is never referenced in the node.hpp file.
I believe this is a copy-paste from rclcpp::Clock::now() method docstring.

Maybe it's better to say something like:

Returns current time from the node time source.
If `use_sim_time` parameter is set to `true` while
constructing the `Node`, the simulation time is returned,
otherwise system time is returned.
Returns current time from the node time source.
If `use_sim_time` parameter is set to `true` while
constructing the `Node`, the simulation time is returned,
otherwise system time is returned.

I think it doesn't need to be set before construction but can be set afterwards like in gz_ros2_control

Refined proposal:

Returns current time from the node time source.
If `use_sim_time` parameter is set to `true`
the simulation time is returned,
otherwise system time is returned.

@roncapat thanks for the suggestion. can you create the PR for this? i am happy to review that.

and one comment for the PR, LifecycleNode::now() should be updated accordingly.

Sure! Yep, I always forget to check LifecycleNode, I will also fix that there :)