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
Duration: why no .seconds()? #482
Comments
There's not floating point seconds method right now. You could do I will say that the Time interfaces (along with others) are still subject to change in C++. For one thing, the steady clock and system clocks should not be diffable and should produce a compiler error, but I don't think they do right now. |
Might such a method be subject to precision loss? In that case it might be better to not provide it. |
A conversion to double will potentially loose information. If we provide it it should have a explicit/unique signature so it's not accidentally used. Can you just use the datatypes instead of an untyped double? |
My use case is multiplying a double to integrate:
|
As long as the loss of precision is documented I think it would be ok, but I agree doing that lossy conversion for the user is not ideal. @AndyZe to answer your question
more directly: it takes seconds and nanoseconds because that's the message storage format, and it has an option to return nanoseconds (that's "as nanoseconds" not the nanoseconds component of the time) because that's the underlying storage format. Personally, I'd like to see the time and duration messages use a single integer for storage rather than the split pair, but that would be a disruptive change and I haven't had time to push for that to happen.
It's the total time in nanoseconds (as in "nanoseconds since the unix epoch"). I think it's a worth while goal to avoid methods on the time class which return only part of the represented time (i.e. no |
I think it makes sense, too. It's ambiguous, currently. What it this going to do? Is that 4 seconds, or ? |
That's correct, it is 4 seconds, see: rclcpp/rclcpp/src/rclcpp/time.cpp Lines 48 to 57 in d82ce96
|
Addressed in #536 |
…thon (ros2#482) Signed-off-by: Emerson Knapp <eknapp@amazon.com>
Bug report
Required Info:
Ubuntu 16.04
Feature description
Feedback from a new ROS2 user: I think the new clock is unnecessarily confusing. Why does the constructor take seconds and nanoseconds, but there's only a method to access nanoseconds?
When I retrieve nanoseconds like so:
Am I getting the total time (seconds+nanoseconds)? Or is it the modulo?
My initial thought was that I should do this to convert to seconds, but I have a feeling this is not correct:
delta_t_.nanoseconds()/1000000000;
The text was updated successfully, but these errors were encountered: