Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Rework the period standard deviation calculation in Sta…#1361

Merged
dirk-thomas merged 1 commit intoros:melodic-develfrom
deng02:issue-1360
Apr 27, 2018
Merged

Rework the period standard deviation calculation in Sta…#1361
dirk-thomas merged 1 commit intoros:melodic-develfrom
deng02:issue-1360

Conversation

@deng02
Copy link
Copy Markdown
Contributor

@deng02 deng02 commented Apr 9, 2018

…tisticsLoggger.

Fixes #1360

msg.period_stddev += ros::Duration(t.toSec() * t.toSec());
try
{
msg.period_stddev += ros::Duration(t.toSec() * t.toSec());
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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)
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

@deng02 deng02 Apr 26, 2018

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.

@deng02 deng02 changed the title Add try/catch around the period standard deviation calculation in Sta… Rework the period standard deviation calculation in Sta… Apr 26, 2018
@dirk-thomas dirk-thomas changed the base branch from lunar-devel to melodic-devel April 27, 2018 18:30
@dirk-thomas
Copy link
Copy Markdown
Member

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants