-
Notifications
You must be signed in to change notification settings - Fork 914
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
Rework the period standard deviation calculation in Sta… #1361
Conversation
msg.period_stddev += ros::Duration(t.toSec() * t.toSec()); | ||
try | ||
{ | ||
msg.period_stddev += ros::Duration(t.toSec() * t.toSec()); |
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.
The result of this temporary result might clearly exceeding the value range of 32 bit. But in the following lines it is divided and then the sqrt
is being computed which would bring the value back into a valid range.
Therefore I would suggest to way this value is being computed rather than catching the error and skipping the input.
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.
Agreed. I will rework this.
{ | ||
msg.period_stddev = ros::Duration(period_stddev); | ||
} | ||
catch(std::runtime_error& e) |
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.
With the updated math in which cases do you expect this to happen?
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.
Short answer is never :) The slightly longer mathematial answer that I worked out for my own curiosity is that in a scenario where there are 4 samples where the first 3 arrive within nanoseconds of each other (effectively making the first 2 periods 0) and the 4th arrives much later, the 4th sample would have to arrive 5579326178 seconds or 177 years later. And I won't be around then to deal with the exception. Thanks for pointing this out, I will remove the guard.
… at the end. Fixes #1360
Thank you for the patch. The CI failure on Melodic is due to a know compiler warning which requires a new pluginlib release. So merging anyway. |
…tisticsLoggger.
Fixes #1360