-
Notifications
You must be signed in to change notification settings - Fork 67
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
Added functions to convert between time_point and secNsec #150
Conversation
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
I added this function to convert a time_point to string. is this the right place? 489a79e |
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Codecov Report
@@ Coverage Diff @@
## ign-math6 #150 +/- ##
=============================================
- Coverage 99.25% 99.24% -0.02%
=============================================
Files 59 59
Lines 5788 5823 +35
=============================================
+ Hits 5745 5779 +34
- Misses 43 44 +1
Continue to review full report at Codecov.
|
Signed-off-by: ahcorde <[email protected]>
Do you think it would be appropriate to also place a |
See #152 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks (and works) great! I'm currently using these helper functions in this plugin and it's quite handy. Some small nits with documentation and such but other than that I think it should be ready to go.
include/ignition/math/Helpers.hh
Outdated
_nanosec); | ||
std::chrono::system_clock::time_point result = | ||
std::chrono::system_clock::from_time_t(0); | ||
result = result + duration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: could condense with result += duration
, I'll leave it up to you though, same with all below additions like this made in the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is failing in OSX https://build.osrfoundation.org/job/ignition_math-ci-pr_any-homebrew-amd64/666/consoleFull#1943795879aa60f765-a60a-427d-900c-dc128ab22287 even if you use your suggestion. Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for making suggestions that don't actually work; I thought it would be cleaner. I'll take a look with my mac later today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into this a bit: Seems like OSX stores chrono
to only a microsecond precision, whereas Ubuntu goes to nanosecond precision. It seems like all platforms have different precisions. See eddelbuettel/nanotime#74 and https://stackoverflow.com/questions/55120594/different-behaviour-of-system-clock-on-windows-and-linux
Cast to system_clock::duration where necessary. Signed-off-by: Steve Peters <[email protected]>
I've fixed compilation on macOS in f11f678, though there is a test failure; I'll comment on the specific line |
src/Helpers_TEST.cc
Outdated
parts = math::timePointToSecNsec(point); | ||
|
||
EXPECT_EQ(parts.first, 60); | ||
EXPECT_EQ(parts.second, 5789); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this expectation is failing on macOS, it gets 5000
instead of 5789
. My guess is that the system_clock::duration
cast in line 542 is changing the time base to microseconds, presumably because that's the resolution of the system clock?
I'm not sure what the best way to account for that is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, I should have read @JShep1's comment first: #150 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we should expect duration_cast<system_clock::duration>(5789)
?
Signed-off-by: ahcorde <[email protected]>
…nitionrobotics/ign-math into ahcorde/time/helper_functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be using steady_clock
instead?
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than some documentation updates
Signed-off-by: ahcorde <[email protected]>
@@ -23,6 +23,8 @@ | |||
#include <limits> | |||
#include <string> | |||
#include <iostream> | |||
#include <sstream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're in here, can we alphabetize includes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done :) f9ef912
Signed-off-by: ahcorde <[email protected]>
* Added functions to convert between time_point and secNsec Signed-off-by: ahcorde <[email protected]> * Add function to convert a time_point in a string Signed-off-by: ahcorde <[email protected]> * Simplify math in timepoint convertions Signed-off-by: ahcorde <[email protected]> * make linters happy Signed-off-by: ahcorde <[email protected]> * make linters happy Signed-off-by: ahcorde <[email protected]> * make linters happy Signed-off-by: ahcorde <[email protected]> * Fixed test Signed-off-by: ahcorde <[email protected]> * Added test for timePointToString Signed-off-by: ahcorde <[email protected]> * Added documentation feedback Signed-off-by: ahcorde <[email protected]> * Fix macOS build Cast to system_clock::duration where necessary. Signed-off-by: Steve Peters <[email protected]> * Fixed test and added a note with the precision on different OS Signed-off-by: ahcorde <[email protected]> * Change std::chrono::system_clock for std::chrono::steady_clock Signed-off-by: ahcorde <[email protected]> * Removed comment Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * alphabetize headers in helpers.hh Signed-off-by: ahcorde <[email protected]> Co-authored-by: John Shepherd <[email protected]> Co-authored-by: Steve Peters <[email protected]>
This PR is related with this issue gazebosim/gz-common#61. The idea it's to deprecate the class
common::Time
in favor ofstd::chrono
.Related with
Added helpers fucntions to converte between
Signed-off-by: ahcorde [email protected]