-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discrepency between rclcpp::Time constructor, member functions, and builtin Time message interface #2649
Comments
Seems like a reasonable improvement. I'm adding this to the upcoming ROS 2 PMC meeting agenda. |
My preference is for option 2.
Currently we hint at that by the fact that when the nanoseconds are used to denote the time since epoch they are represented as I don't like option 3, as I think that it would be exposing an internal detail that would cause more harm than good. |
Yes, agreed.
Agreed with this as well. |
And, similarly for seconds as the
Out of curiosity, what internal details would be exposed and what harm would that potentially cause? |
The use of independent seconds and nanoseconds fields in the Users almost never need to use the two fields separately. |
Makes sense, having that within the documentation, or some form of that, would be beneficial in my opinion. Even to simply help highlight the discrepancy between the |
+1 for option 2 |
There is, in my opinion, a pretty annoying discrepancy between the
rclcpp::Time
object member functions and the Builtin Interface Time message. It's annoying in that it can easily catch out developers. It caught me out.RCLCPP Time Object
The
rclcpp::Time
object has the following constructors and member functions (only constructors and member functions relevant to the issue are provided):Constructors:
Time::Time(int32_t seconds, uint32_t nanoseconds, rcl_clock_type_t clock_type) : rcl_time_(init_time_point(clock_type))
sourceTime::Time(int64_t nanoseconds, rcl_clock_type_t clock_type) : rcl_time_(init_time_point(clock_type))
sourceTime::Time(const builtin_interfaces::msg::Time & time_msg, rcl_clock_type_t clock_type) : rcl_time_(init_time_point(clock_type))
sourceMember Functions:
int64_t Time::nanoseconds() const
source returns total time since epoch (seconds + nanoseconds)double Time::seconds() const
source returns total time since epoch (seconds + nanoseconds)Builtin Interface Time Message
The Builtin Interfaces Time message documentation is as follows:
Discrepancy
After utilising the Builtin Interface Time Message, and given the first constructor listed in the rclcpp::Time object takes in seconds and nanoseconds separately, one may accidentally assume the seconds and nanoseconds member function returns their component values only and not the total time since epoch.
Potential Fixes
I understand this is a minor issue. However, discrepancies like this cause confusion. Many pieces of code are likely built upon the
rclcpp::Time::seconds
andrclcpp::Time::nanoseconds
functions. However, would any of the following fixes have potential?rclcpp::Time::seconds
andrclcpp::Time::nanoseconds
functions. For example, "returns the total time since epoch in seconds (seconds + nanoseconds)".The text was updated successfully, but these errors were encountered: