Fix randomly failing sample consensus test - #6475
Merged
Merged
Conversation
The problem seems to be a lost wakeup: LMedS only does very few iterations (much fewer than the other sac methods) and sac.computeModel() accordingly returns quickly. In rare cases, it seems to be done before the main thread is listening/waiting for the condition_variable notification, so it is missed and the test fails after the timeout. The fix is to add a `bool done` that is set to true after sac.computeModel() is finished, and use the other overload of cv.wait_for() that returns the value of `done` (only true if finished before the timeout).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem seems to be a lost wakeup: LMedS only does very few iterations (much fewer than the other sac methods) and sac.computeModel() accordingly returns quickly. In rare cases, it seems to be done before the main thread is listening/waiting for the condition_variable notification, so it is missed and the test fails after the timeout. The fix is to add a
bool donethat is set to true after sac.computeModel() is finished, and use the other overload of cv.wait_for() that returns the value ofdone(only true if finished before the timeout).Reverts 11ab21b because the verbose output is no longer necessary.
See e.g. https://www.modernescpp.com/index.php/c-core-guidelines-be-aware-of-the-traps-of-condition-variables/