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

Mystery Nan appears from Sophus crashing the program #17

Closed
DavidPetkovsek opened this issue Jul 10, 2023 · 1 comment · Fixed by #16
Closed

Mystery Nan appears from Sophus crashing the program #17

DavidPetkovsek opened this issue Jul 10, 2023 · 1 comment · Fixed by #16
Assignees
Labels
bug Something isn't working

Comments

@DavidPetkovsek
Copy link
Owner

This seems to happen midway through running. Happens more frequently on high acceleration/velocity movement.

The following are all related:

UZ-SLAMLab/ORB_SLAM3#608 seems to have a number of potential solutions.

@DavidPetkovsek DavidPetkovsek added the bug Something isn't working label Jul 10, 2023
@DavidPetkovsek DavidPetkovsek self-assigned this Jul 10, 2023
@DavidPetkovsek DavidPetkovsek linked a pull request Jul 10, 2023 that will close this issue
@DavidPetkovsek
Copy link
Owner Author

DavidPetkovsek commented Jul 11, 2023

Solved

This issue has been resolved in the Clean slam branch. This will be closed now since the branch is a larger update and will definitely be merged to master.

Other Nan issues that people reported either only exist in their local copy or have been resolved by the other changes made in our fork.

Solution commit: 8b22f88

Solution PR: #16

Problem Summary:

Sim3Solver is a custom implementation of a RANSAC algorithm. Inside of the iterate step of RANSAC, after selecting the points at random, ComputeSim3 figures out the ideal model for the selected points so then later on the inliers can be computed.

The error occurs inside ComputeSim3. It implements the Horn 1987 algorithm which is a closed form mathematical solution to solving overdetermined systems of equations that minimizes the sum of squared error or residuals.

The vec local variable (which represents the imaginary portion of a quaternion) becomes the 0 vector. Which is then used as the denominator in a division and then a check done by sophus catches the resulting Nan and throws an exception crashing the program.

The 0 vector occurs because the randomly selected points may form a mathematical degenerate edge-case. Meaning the points selected at random are either identical or coplanar, or colinear, etc. Making there be no single solution to the system of equations.

Solution Summary:

Since the CompueSim3 is only used in the iteration step inside the while loop we know that it doesn't make a difference if we throw out the one randomly selected points iteration. And since iterate has been built to return a boolean for success it will handle the case where there is no true solution to the RANSAC data.

To achieve this, ComputeSim3 was modified to return a bool. Return true at the end of the function, and return false if vec.norm() is evaluated to exactly 0 before any division or use of vec.norm is used. Then in the two uses in iterate check if the return value is false and if it is continue to the next iteration.

Other Notes

One of the issue branches was close but their implemented solution does not handle the issue properly at all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant