Skip to content
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

Bug: Occasional NaN transforms #310

Closed
bluenote10 opened this issue Jul 11, 2018 · 0 comments · Fixed by #313
Closed

Bug: Occasional NaN transforms #310

bluenote10 opened this issue Jul 11, 2018 · 0 comments · Fixed by #313

Comments

@bluenote10
Copy link

We noticed that the transforms return from tf/tf2 occasionally contain NaN values in the translation part. Some debugging revealed that this is caused by the interpolation logic of the time cache. The bug is hidden here:

geometry2/tf2/src/cache.cpp

Lines 178 to 185 in 0761810

// Check for zero distance case
if( two.stamp_ == one.stamp_ )
{
output = two;
return;
}
//Calculate the ratio
tf2Scalar ratio = (time.toSec() - one.stamp_.toSec()) / (two.stamp_.toSec() - one.stamp_.toSec());

The equality check compares the timestamps based on sec/nsec integers, however the ratio converts them to double. In our case the two timestamps are only a few nanoseconds apart, and the resolution after the toSec() conversion is not enough. Thus there is a division by zero and the interpolation returns meaningless results due to ratio being NaN.

I will open a PR with the most obvious fix: Checking that the toSec() difference is non-zero instead of the stamp equality check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant