-
Notifications
You must be signed in to change notification settings - Fork 103
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
Convert ROS2 time value to signed int64_t #79
Convert ROS2 time value to signed int64_t #79
Comments
|
Unfortunately not in MISRA C 2012 land (E.g. rule 10.4). |
|
If this can help us become more compliant this seems to make sense. It does make the range checking much simpler. We'll likely want to move those methods into C but for now the C++ templated versions are very compact. |
Ok, here's CI: Thanks for the reviews @tfoote. |
@serge-nikulin looks like this set of changes affects http://ci.ros2.org/job/ci_linux/3918/warnings22Result/new/package.-275512363/ |
Above CI segment updated with ros2/rclcpp@9e26556 added |
Everything went green, but windows went unstable for what appears to be unrelated recent changes.
|
The |
The overflow periodically happens in I am currently trying to find a way to fix this issue (fighting chain of logging macros). |
Thanks @serge-nikulin for the update. It appears that the variables used in Line 39 in f37ce5b
|
@mikaelarguedas, yes, it should but this particular bug should not reveal itself for ~200 years from now. :) The immediate bug AFAIK is interaction between overflow in |
@mikaelarguedas, please see my fix in ff6bf5e Alternative (more correct?) solution would be to scale |
@tfoote, FYI: I have pushed the fix for |
Thanks @serge-nikulin new round of CI kicked off. @mikaelarguedas thanks for the heads up on the flakey tests. I confirmed they went away in a rebuild: http://ci.ros2.org/job/ci_windows/4024/#showFailuresLink |
@tfoote, it looks like some Windows node environment problem (failed before the build started?). |
Yup the node disconnected. The Job restarted automatically, I updated the link in the previous comment |
Thanks for the suggested alternative. I'm fine to go ahead and merge this as is as even if the problem is not completely solved, I don't expect anyone to hit the overflow in a reasonable future |
@mikaelarguedas , the alternative solution also might overflow. The only correct solution is to do math in 128-bit space. Please go ahead with the current solution. |
My only remark looking at the various PRs is that it may be worth forwarding the Talking with @wjwwood we'll merge this as is and will open a set of follow-up PRs to forward and use the custom type everywhere (after auditing the codebase for every use of it) |
I opened a follow up issue: ros2/ros2#458 |
I think that a signed value is a more metrologically and physically correct representation of any non-absolute, "non-Kelvin" time system in comparison the current ROS2 unsigned value.
Regardless of metrology correctness signed time value makes computations of durations (always a signed value!) more unerring in the programming sense. MISRA C 2012 rule 10.4 treats signed and unsigned as different incompatible types. It takes very messy coding to account for over- and underflow edge conditions in sign-mixed math.
The current nanoseconds
uint64_t
gives us ~584.5 years from 1970,int64_t
is twice shorter. Correspondingly it's 2554AD and 2262AD.I think both end dates are remote enough for both unsigned and signed values to be practical in today's applications.
CC: @wjwwood
The text was updated successfully, but these errors were encountered: