-
Notifications
You must be signed in to change notification settings - Fork 417
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
__ccdGJK in narrowphase has bugs #366
Comments
For the roadmap, I would propose that we verify the correctness of For better readability, can we change the return code of enum class DoSimplexStatus {
kIntersecting, // Origin is in the simplex, hence A and B intersects
kSeparated, // When building the simplex, we find a plane that separates the origin from the Minkowski difference A ⊖ B. Hence A and B are separated.
kUnknown,
}; |
Thanks, @hongkai-dai ! Assigned to @DamrongGuoy and @SeanCurtis-TRI while we figure out who does what. |
cc @avalenzu |
Just to confirm, EPA will work if called for touching contact? Or will we need to have an additional test before calling EPA? |
We have much higher confidence in the current EPA algorithm. Hongkai has done sterling work there (although there are still a couple of TODOs. BUt, at the very least, it's well tested. |
On another note: This may be the opportunity to disentangle ccd from this GJK implementation. The C-style interface for all of the ccd types obfuscates the math and code. We might want to investigate the viability of removing those structs from the core math. The code becomes easier to read which increases the odds of being correct. |
Good call. That could be a very big project. Maybe we should open a separate issue? It would be good if we can create an API design doc before we start to code, so that we agree what the new types will look like. Currently we use a lot of ccd simplex ( |
In principle, doSimplex*() is a point-location problem. It could be useful in other applications. Please let me give an example in tetrahedron mesh refinement. Given a new point to insert into a tetrahedron mesh, we need to check whether the new point is strictly inside an edge, or strictly inside a triangle, or strictly inside a tetrahedron. This way we avoid creating new zero-volume tetrahedrons when we connect the new point to surrounding elements. (The wrong classification will make us connect the new point to form zero-area triangles or zero-volume tetrahedrons with other points). enum class SimplexLocation {
kInside, // The point is strictly inside the simplex.
kBoundary, // The point is on the boundary of the simplex.
kOutside // The point is strictly outside the simplex.
} The code will first check the point p against a volumetric tetrahedron V. If p is on the boundary of V, then the code checks p against triangular faces F of V. If p is on the boundary of F, the code checks p against the edges E of F. (If p is on the boundary of E, then p co-locates with an existing point, and we abort the point insertion.) I'm not suggesting that we use My idea is |
I meant C static function inside gjk_libccd-inl.h. namespace fcl {
namespace detail {
namespace libccd_extension {
static int doSimplex*(...)
}}} |
I finally feel prepared to respond to @DamrongGuoy's interesting point. Initially, I agreed with your assessment: that these are general functions that could/should be made more generally available. However, after working with These functions live in the context of the full GJK ecosystem. Each simplex has particular properties that can be exploited to simplify the work being done. (See PR #367 for details.) It would be irresponsible to not exploit these properties in the GJK context and these properties disqualify the functions from being general point-location problems. |
Problem
When computing the signed distance in the narrow phase convexity based algorithm, FCL first calls
__ccdGJK
function to determine if the object A and B are separated. This code has several bugsOn the other hand, there are only two return values of this function.
Hence the FCL code doesn't differentiate between separating and iterations limit. We should improve the return values to make that difference.
__ccdGJK
lies when it returns "no intersection" in the following linesfcl/include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h
Lines 1396 to 1398 in 9082fd2
|dir| = 0
, sincedir = -v
(wherev
is the point that is closest to the origin in the simplex), this means thatv = 0
, and hence the origin is within the simplex, hence the origin is within A ⊖ B. This means A and B are intersecting. FCL returns the wrong code.doSimplex2
to compute the closest point within the new simplex (line segmentAB
) to the originO
, FCL also checks if the origin is on the line segmentAB
. The check it does isfcl/include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h
Lines 245 to 252 in 9082fd2
AB x AO = 0
andAB.dot(AO) > 0
, then the code thinks thatO
is on the line segmentAB
. I think this check is wrong. It could be that O is on the ray shooting from A to B, but is beyond B. Hence thisO
satisfies the check in FCL, but it is not on the line segmentAB
.ccdIsZero(dist)
, wheredist
is actually the squared distance. WhatccdIsZero(dist)
checks isabs(dist) < eps
. But this means that the distance < 1E-8 will be regarded as 0. This tolerance is too loose. We should compare the squared distance with the squared machine epsilon.Proposed fix
__ccdGJK
to fix problem 1 and 2. I have a dev branch trying to tackle the problem. I renamed the function__ccdGJK
toseparatingAxisGJK
. Also I created an enum class as the return valuedoSimplex2
, with proper unit tests (@SeanCurtis-TRI) (Reworking gjk_libccd doSimplex2() #367)doSimplex3
anddoSimplex4
yet. I suspect there can be bugs. At least we should add unit tests for these functions.cc @SeanCurtis-TRI @sherm1 @DamrongGuoy
The text was updated successfully, but these errors were encountered: