-
Notifications
You must be signed in to change notification settings - Fork 421
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
extractClosestPoints() from simplex made more robust to degenerate simplex #296
extractClosestPoints() from simplex made more robust to degenerate simplex #296
Conversation
@tongtybj Please take a look at this solution. Sorry for the lag in getting this PR in. Robustly solving the problem took some more rigor. |
Review status: 0 of 4 files reviewed at latest revision, all discussions resolved. Comments from Reviewable |
Hold off on review; I've broken CI. Review status: 0 of 4 files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
79a5205
to
9df0b23
Compare
Thank you for your kind commit. I carefully read your improvement. LGTM. |
9df0b23
to
390f318
Compare
If the simplex is degenerate, it can lead to divide-by-zero errors. This test is drawn from the real world and exposes such a problem - nearest points are returned as NaN. See flexible-collision-library#293 for the discussion
390f318
to
8f3da74
Compare
There was a mac CI bug due to the known issue of linking against a single-precision libccd on mac (#291). This most recent modification should address that issue. Review status: 2 of 4 files reviewed at latest revision, all discussions resolved. Comments from Reviewable |
8f3da74
to
e7a9dde
Compare
@sherm1 CI is all clear. Can you merge for me. Review status: 1 of 4 files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
+@hongkai-dai -@sherm1 (per f2f) Review status: 1 of 4 files reviewed, all discussions resolved (waiting on @tongtybj and @sherm1) Comments from Reviewable |
Reviewed 2 of 3 files at r3. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1017 at r3 (raw file):
Should it be include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1026 at r3 (raw file):
It might be worthwhile to put the computation of for (int i = 0; i < 3; ++i) {
const ccd_real_t scale = max({ccd_real_t{1.0}, abs(p.v[i]), abs(q.v[i])}) * eps
const ccd_real_t delta = abs(p.v[i] - q.v[i]);
if (delta > scale) return false;
}
return true; include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1047 at r3 (raw file):
Maybe also check include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1219 at r3 (raw file):
What is test/test_fcl_distance.cpp, line 313 at r3 (raw file):
s/an/a test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 216 at r3 (raw file):
One should be θₑ + δ test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 229 at r3 (raw file):
Pick a vector test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 231 at r3 (raw file):
I am not sure if this is a correct statement. Whether ∠C test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 254 at r3 (raw file):
const Vector3d test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 305 at r3 (raw file):
Better to rename test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 558 at r3 (raw file):
I do not think this gives a co-linear configuration. For co-linear configuration, it should be v2 = s * v0 + (1-s) * v1, namely the coefficients of v0 and v1 sum up to 1. Comments from Reviewable |
Reviewed 1 of 3 files at r3. Comments from Reviewable |
e7a9dde
to
1361646
Compare
Thanks @hongkai-dai. Comments addressed. PTAL Review status: 1 of 4 files reviewed, 11 unresolved discussions (waiting on @hongkai-dai and @SeanCurtis-TRI) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1017 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Done include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1026 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Done include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1047 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I'm going to make a counter argument. It is cheaper when b and c are co-linear. However, if we expect that it's a rare case, we are now paying the extra cost every time. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1219 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Added. test/test_fcl_distance.cpp, line 313 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Done test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 216 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Done test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 229 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Done test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 231 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I believe making it test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 254 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Done test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 305 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Or change the documentation so I can stay zero-indexed. :) test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_extractClosestPoints.cpp, line 558 at r3 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
So, I've updated the intent described in the documentation and corrected the math. PTAL. Comments from Reviewable |
1361646
to
55be221
Compare
For simplex of size n, if the simplex is degenerate, extracts from a simplex of size n - 1 (to prevent returning NaN). 1. Refactor point extraction into independently callable methods. 2. At each level, add method for downgrading the simplex. 3. Add unit tests on the local methods. 4. Add integration test with motivating example. 5. Update documentation of this implementation.
55be221
to
8a656c6
Compare
Reviewed 1 of 4 files at r2, 3 of 3 files at r4. Comments from Reviewable |
@sherm1 It looks like it's ready for merging. I've double checked the CI failure and it's the known failure. Review status: 2 of 4 files reviewed, all discussions resolved (waiting on @hongkai-dai) Comments from Reviewable |
Wow! Looks great. Awesome tests! Reviewed 1 of 4 files at r2, 1 of 3 files at r4, 2 of 2 files at r5. Comments from Reviewable |
…mplex (flexible-collision-library#296) * Expose numerical errors in gjk_libccd-inl.h extractClosestPoints() If the simplex is degenerate, it can lead to divide-by-zero errors. This test is drawn from the real world and exposes such a problem - nearest points are returned as NaN. See flexible-collision-library#293 for the discussion * Make extractClosestPoints more robust For simplex of size n, if the simplex is degenerate, extracts from a simplex of size n - 1 (to prevent returning NaN). 1. Refactor point extraction into independently callable methods. 2. At each level, add method for downgrading the simplex. 3. Add unit tests on the local methods. 4. Add integration test with motivating example. 5. Update documentation of this implementation.
Issue #293 shows a case where the result of the GJK between two separated object is a degenerate simplex. Specifically, a 3-simplex consisting of co-linear vertices. This leads to zero dividing zero which causes NaN to propagate everywhere.
This PR has two curated commits:
Resolves #293
replaces #295
This change is