-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[sample_consensus] Inconsistent sample validation in SampleConsensusModelLine, SampleConsensusModelStick, and SampleConsensusModelCylinder #5268
Comments
Thank you for the very nice and detailed issue description! |
Just out of curiosity I also had a look at Regarding how to work on from these observations: One could argue that the "interface documentation" in |
You are right, there is often a trade-off between safety and performance. I am not aware of any official PCL policy on this. Here I would rather keep the checks in |
There also seem to be some inconsistencies between models using three points that must not be collinear:
I guess something like |
are you sure about that? Remember that |
Pretty much. I even wrote a test for this to be sure, so I can say: doesn't work for me 😉 But it's great to see this "anecdotal evidence" supported by some references to the standard. My suggestion would be that I push the changes for Circle2D and the tests I wrote for that model and we then discuss if these tests should also be implemented as such or in a similar fashion for Circle3D and Plane or if we just stick with the fixed check based on the cross-product there. |
Something for Plane is now up in the PR. For Circle3D I would propose |
Sounds good. Let's change the test to |
Describe the bug
The sample validation in
isSampleGood(...)
ofSampleConsensusModelLine
has some strong similarity to the validation block incomputeModelCoefficients(...)
(lines 84 - 86). The piece of code incomputeModelCoefficients(...)
was likely introduced as a workaround to a bug that was fixed in #2488 and also contradicts to the changes introduced in 36c2bd6.SampleConsensusModelStick
is very similar toSampleConsensusModelLine
(but broken as detailed #2452 since I still haven't figured out what to do with the radius model parameter there 😓 🤦♂️) but hasn't received the changes of 36c2bd6.SampleConsensusModelCylinder
on the other hand doesn't do that kind of point dissimilarity validation inisSamplesGood(...)
at all and leaves it up tocomputeModelCoefficients(...)
. The implementation incomputeModelCoefficients(...)
then is virtually identical to that ofSampleConsensusModelLine
.If I managed to track down the usage of those functions correctly, they are used in
computeModel(...)
(isSampleGood(...)
indirectly throughgetSamples(...)
) of the various classes derived fromSampleConsensus
(e.g.RandomSampleConsensus
) so for "practical" cases where those points really come from a sensor, there should not be much difference in the actual outcome. In some edge cases the log messages will likely differ since the validation fails in different portions of the algorithm.Context
Real-time point cloud segmentation using RANSAC and the models above.
Expected behavior
Since these three models have quite some similarity, I would expect similar behavior of them.
Current Behavior
See description.
To Reproduce
Since this is a bug found by code analysis, you have to look at the code to reproduce my journey 😉
Screenshots/Code snippets
Links to some of the relevant code pieces are included in the description.
Your Environment (please complete the following information):
Possible Solution
If there is a consensus which of the validations (i.e.
abs
vs.!=
,&&
vs.||
) is "the right one" and where it should live (isSampleGood
vs.computeModelCoefficients
), I think I could contribute a PR. My gut feeling goes towards something likein
isSampeGood(...)
.std::abs
feels "more correct" than!=
for floating points, but is more expensive to compute.Additional context
-/-
The text was updated successfully, but these errors were encountered: