-
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
Fix FCL's EPA implementation, when calling libccd solver. #305
Fix FCL's EPA implementation, when calling libccd solver. #305
Conversation
45adedf
to
dcdb239
Compare
+@SeanCurtis-TRI for feature review please. Review status: 0 of 5 files reviewed at latest revision, all discussions resolved. Comments from Reviewable |
Is it your intent to squash these commits? If so, don't forget to do so. Otherwise, pre-curate your commits. Checkpoints. Reviewed 2 of 5 files at r1. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 725 at r1 (raw file):
BTW Can you change it to "...vector of a triangular face on a polytope." include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 742 at r1 (raw file):
nit: Any worries about a degenerate triangle here? If not, please document it. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 757 at r1 (raw file):
nit: several things:
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 777 at r1 (raw file):
nit: The comment literally repeats the code -- there is no new information in this comment that isn't clearly expressed in the code. You should rework the comment to explain this "trick" because it takes a moment or two to reason through why this is the right operation. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 790 at r1 (raw file):
nit: this would be better named with a verb (e.g., include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 793 at r1 (raw file):
BTW Here you're doing 2 dot products. Other than the fact that ccd makes this more painful to do, it would be cheaper to do a subtraction and a dot product. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 796 at r1 (raw file):
I would advocate a different organization of this code. It should be void floodFillSilhouettte(const ccd_pt_t& polytope, const ccd_pt_face_t& f, const ccd_vec3& test_vertex, ...) {
}
void floodFillSilhouetteRecurse(polytope, f, int edge_index, test_vertex, ..) {
} The first function should include the lines from include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 797 at r1 (raw file):
After reading through all of the documentation and the function, I realize this description is incorrect. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 798 at r1 (raw file):
BTW
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 802 at r1 (raw file):
This being recursive is not part of the API. It's an implementation detail and, as such, doesn't belong in this documentation. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 808 at r1 (raw file):
This description is inconsistent with the description given above -- above, this is the vertex from which visibility is tested, but here, it has become the new vertex for the polytope. This should be addressed in the rephrasing of the documentation. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 809 at r1 (raw file):
This parameter does not exist. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 814 at r1 (raw file):
BTW Why not name it "visible_faces"? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 817 at r1 (raw file):
BTW add include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 819 at r1 (raw file):
You've introduced concepts of "silhouette" and "visible", you should do the following:
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 824 at r1 (raw file):
btw: Ideally, you should confirm that none of the pointers are null. That said, FCL doesn't do that nor provide a uniform mechanism for doing so. Thoughts:
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 828 at r1 (raw file):
It isn't clear to me that this serves the role of "visited faces". What's to prevent me from visiting an occluded face multiple times? In fact, I'm sure I can conceive of a (simple) scenario in which an occluded face would be visited twice. (The simplest example would be a tetrahedron, where the visible silhouette is two triangles -- the other two triangles would each get visited twice.) If you refactor as I suggest above, you can introduce the visited faces as an internal detail that the caller won't even know about. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 829 at r1 (raw file):
BTW You could replace both of these lines with:
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 854 at r1 (raw file):
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 857 at r1 (raw file):
BTW This description of include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 915 at r1 (raw file):
BTW This is unfortunate, we're doing a linear search on the faces for each face in the unordered set. It would be better if we could iterate through the list once and just do lookups in the If this isn't straight-forward to do in this PR, please put a TODO. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 920 at r1 (raw file):
BTW Food for thought in the future. Rather than deleting the edge/face/vertex, it might be worth just removing it from the network and deleting it when the whole polytope gets deleted (rather than making lots of little calls to delete.) It means the data structure gets bloated with "deleted" objects, but we minimize system calls. Alternatively, some internal memory management that keeps the memory but re-uses it would be slick as well. Again, minimizing system calls. Not part of this PR -- just a thought for the future. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 922 at r1 (raw file):
I don't understand this statement. Up above, you talk about deleting vertices (when all of the supporting edges have been deleted), but you're not doing it now. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 928 at r1 (raw file):
nit: This documentation and name seems a bit wrong. Really, what this is is the set of new edges. Each of these edges has the new vertex on one end and a silhouette vertex at the other and and can be looked up via their silhouette vertices. btw: if the silhouette edges were ordered, then you could throw out the the map entirely. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 953 at r1 (raw file):
nit: "sampled" is not the word you want. I'd simply say "support" direction (here and below). include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 954 at r1 (raw file):
BTW This is pedantic, but I'd say either "Minkowski difference A ⊖ B" or "Minkoski sum A ⊕ -B". (And I'd include white space around the operator). include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 958 at r1 (raw file):
BTW "...an interior point on a face, and the sampled direction..." include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 960 at r1 (raw file):
BTW s/polytoped/polytope include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 966 at r1 (raw file):
BTW Look at this! Returning a include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 969 at r1 (raw file):
BTW This function would read better if you started with the line:
Then the madness is isolated to one line and all other lines that reference the squared distance would be clear. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 975 at r1 (raw file):
BTW I'd replace "this function" with the actual function name.
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 979 at r1 (raw file):
nit: include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 980 at r1 (raw file):
Two questions: don't we consider this to be a degenerate case? And can you provide some documentation arguing why picking one arbitrary face direction is the right thing to do? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1011 at r1 (raw file):
If this property applied to the input element, your program would throw an exception. Probably want to document that distinction. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1026 at r1 (raw file):
BTW If we were to apply drake standards, this would be: include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1030 at r1 (raw file):
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1033 at r1 (raw file):
BTW This seems odd to me. This distance merely seems to be the projected distance along the support direction. However, but down below, the distance we consider below is actual Euclidian distance. It seems counter-intuitive. Is there a rational explanation? Or shall we put in a TODO to figure it out and document it? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1408 at r1 (raw file):
You can remove this comment and the include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1418 at r1 (raw file):
BTW Worth noting that we only support up to a 3-simplex. IN this code, that's worth making clear because, generally, we do allow 4-simplices. test/test_fcl_signed_distance.cpp, line 81 at r1 (raw file):
nit: This really needs documenting. The code ends up reading like:
test/test_fcl_signed_distance.cpp, line 82 at r1 (raw file):
nit: Can you change this test to:
test/test_fcl_signed_distance.cpp, line 91 at r1 (raw file):
BTW We so desperately need to include Drakes Comments from Reviewable |
e91f23b
to
6cf6037
Compare
Review status: 1 of 5 files reviewed at latest revision, 12 unresolved discussions. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 725 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 742 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, I ignore the degeneracy case here. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 757 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Good call. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 777 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 790 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 793 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Good point include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 796 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, good point! include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 797 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, I rewrite this part of the documentation. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 798 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. I rewrote this documentation. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 802 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. I rewrote this documentation. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 808 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 809 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 814 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Hmm I was trying to use the same term include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 817 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, good point. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 819 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
That is a good point. I am not so sure about the name include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 824 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Hmm, I think FCL does not use the google style guide, which requires passing const reference, instead of const pointers. If we want to stay consistent with the rest of the code in this file include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 828 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Exactly as you said, we can access a face twice, from two different edges. And I think we need to access the face for twice, so as to determine if its edges are silhouette edges or visible edges. Say we have an occluded face, but both its neightbouring faces are visible, then we need to access the occluded face for twice, each time for one edge that neighbours the visible face. As you said, we can add a "visited face" parameter in the recursive function. I regard that as an optimization of the current implementation. I will optimize the recursive function later, to avoid storing the obsolete face/edges, and to store include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 829 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 854 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 857 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 915 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, add a TODO here. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 920 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Totally agree, when we implement our own polytope representation, we will add a flag include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 922 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Forgot to update the documentation above. A vertex cannot be removed. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 928 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, rename the variable. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 953 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 954 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 958 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 960 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 966 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Should we pass by pointer here? Since it is static size I assume it is OK to return include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 969 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 975 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
In if (el->type == CCD_PT_VERTEX) return -1; so it actually prevents calling include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 979 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Compiler is unhappy when using
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 980 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Why this is degenerate? When the closest point is on an edge, the origin must be on that edge. But in this case the distance from the Minkowski difference boundary to the origin can be non-zero. I add documentation here. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1011 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
It should not throw an exception here, the program terminates with -1, according to the line if (el->type == CCD_PT_VERTEX) return -1; include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1026 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Hmm I think we haven't applied drake standard yet, as the leading letter in each function name is in lower case. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1030 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1033 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
I think that is the EPA algorithm, the projection distance is an upper bound of the distance from the Minkowski difference boundary to the origin, and the actual Euclidean distance is an lower bound. I added some documentation here. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1408 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Good point. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1418 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/test_fcl_signed_distance.cpp, line 81 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, good point. test/test_fcl_signed_distance.cpp, line 82 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. good point. test/test_fcl_signed_distance.cpp, line 91 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Agree, something we can do in a separate PR. Comments from Reviewable |
Checkpoint on main implementation -- moving on to tests. Reviewed 2 of 4 files at r2. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 742 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
You put in a "todo" that doesn't say what is to be done. The indirect implication is that we should stop ignoring the degeneracy. Can you state this more directly? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 793 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I've been leaking drake notation into FCL with links to drake's notation. So, for this one, I'd probably do include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 797 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I've proposed an alternate write-up to the entry-point function. See what you think and modify this one to match (if you like it.) One general note, the function level of documentation shouldn't explain how the function works internally, only what I need to know about invoking it (interpretation of inputs and outputs and requirements on inputs.) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 814 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
See note on entry point function. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 824 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
See note on entry point function. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 828 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I buy that -- and its merely regrettable we compute the normal twice. But, in the future, when the normal is saved with the face, that cost won't exist. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 922 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Good point. Given that the new vertex (and every vertex) is on the boundary of the Minkowski sum, that means every other vertex will inevitably have at least one face that isn't visible to the new vertex. Could you put in a TODO to assert that all vertices are still valid? I can imagine a circumstance where, due to numerical issues, an occluded face is considered visible. This could lead to a vertex no longer referenced by any faces/edges and having a debug check on that might expose problems in the future. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 966 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I think this is a great deviation from what has been done in FCL (based on libccd). I'd strongly advocate for this kind of thing. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 979 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
It's because of constness. You'd have to cast it to include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 980 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Thanks for the docs. There's a part of my soul that is dissatisfied by this. Since the origin is inside the polytope, there is no voronoi region for the edge. So, saying the closest feature is an edge feels a bit of a lie. In other words, if the origin is on the edge, it's also on a face. Furthermore, numerically, for the origin to lie on the edge (and not a face), it has to be right on the edge when considered from either adjacent face. That seems highly unlikely. Still, I'll mark myself as satisfied based on the added documentation. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1033 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Thanks include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 851 at r2 (raw file):
I've taken the liberty of writing up what I think the documentation should be. This is the documentation for the "main entry point function" I indicated above. /** Defines the "visible" patch on the given convex `polytope` (with respect to
the given `query_vertex`).
A patch is characterized by:
- a contiguous set of visible faces
- internal edges (the edges for which *both* adjacent faces are in the patch)
- border edges (edges for which only *one* adjacent face is in the patch)
A face `f` (with vertices `(v₀, v₁, v₂)` and outward pointing normal `n̂`) is
"visible" and included in the patch if, for query vertex `q`:
`n̂ ⋅ (q - v₀) > 0`
@param polytope The polytope to evaluate.
@param f A face known to be visible to the query point.
@param query_point The point from which visibility is evaluated.
@param[out] border_edges The collection of patch border edges.
@param[out] visible_faces The collection of patch faces.
@param[out] internal_edges The collection of internal edges.
@pre The `polytope` is convex.
@pre The face `f` is visible from `query_point`.
@pre Output parameters are non-null.
**/
static void ComputeVisiblePatch(
const ccd_pt_t& polytope, ccd_pt_face_t& f,
const ccd_vec3_t& query_point,
std::unordered_set<ccd_pt_edge_t*>* border_edges,
std::unordered_set<ccd_pt_face_t*>* visible_faces,
std::unordered_set<ccd_pt_edge_t*>* internal_edges) This addresses several issues
BTW I'd also support creating a include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 856 at r2 (raw file):
btw s/ouside/outside include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 869 at r2 (raw file):
I'm not sure what the first sentence means. Why not store in a set? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 871 at r2 (raw file):
btw s/occuluded/occluded include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 903 at r2 (raw file):
See my note below about the feature being an edge. But, if the visibility of an edge is defined by the visibility of its neighboring face, then one has to wonder why isn't include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 912 at r2 (raw file):
BTW If you go with my
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 929 at r2 (raw file):
BTW Is this what the other TODO refers to about getting rid of the set? If you do that, then my "ComputeVisiblePatch" would become "DeleteVisiblePatch" and simply return the border edges. :) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 930 at r2 (raw file):
BTW s/travering/traversing include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 966 at r2 (raw file):
BTW I hate include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1019 at r2 (raw file):
BTW ", when v is not the origin," (no article "the"). include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1019 at r2 (raw file):
BTW Also, this paragraph is really an implementation detail. The function takes the polytope and the nearest point and gives the support vector for the next iteration. The fact that it handles the nearest point in special and tricky ways is an internal detail. It's good information, but it documents the implementation and not the interface. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1039 at r2 (raw file):
BTW When referencing function names, you should add a terminal () to emphasize a function call. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1045 at r2 (raw file):
BTW s/implementatin/implementation include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1079 at r2 (raw file):
BTW "the program converges" doesn't feel quite right. This function doesn't know about "the program". This function basically says, "I can/can't compute a meaningful next support vector." So, if it returns 0, the support vector in include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1104 at r2 (raw file):
BTW "...from the feature include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1505 at r2 (raw file):
To the best of my knowledge, this condition will never evaluate to true. This is the equivalent of a BTW: also prefer That also turns your return value into something less meaningful -- you'll never return -1. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1530 at r2 (raw file):
BTW Leftover comment here. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1536 at r2 (raw file):
BTW "...or a face." (and no newline in the exception message). Comments from Reviewable |
test_epa checkpoint Reviewed 1 of 4 files at r2. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 2 at r2 (raw file):
I'd recommend renaming this file:
We'll have a bunch of different gtest files that test functions in test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 37 at r2 (raw file):
BTW Might be worth spelling out EPA in this first comment. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 79 at r2 (raw file):
BTW Return a const reference unless test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 89 at r2 (raw file):
This delete seems very surprising. I'd assume test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 100 at r2 (raw file):
This test is incomplete. Each face on the tetrahedron represents a single, potential test. However, three of the tests are fundamentally redundant (and leaves some code paths untested).
Faces 1-3 invoke the test that the projection is negative and the direction needs to be flipped. Face 0 tests projection = 0. However, since there's only one vertex off the plane (and it is farther than 1 cm), it exercises the the branch that leaves the vector alone. What is not being tested:
test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 108 at r2 (raw file):
BTW Interesting tolerance I'd recommend: test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 116 at r2 (raw file):
You could wrap these three up in a test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 143 at r2 (raw file):
Missing some tests:
test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 162 at r2 (raw file):
BTW I'd recommend the following: const bool expect_inside = false;
const bool expect_outside = true;
CheckPointOutsidePolytopeFace(0, 0, 0.1, 1, expect_inside);
... The code would be more readable. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 200 at r2 (raw file):
BTW This documentation might flow better if you labeled the vertices in your diagram above and then just referenced the labels. Also, a comment that defining them in this order facilitates defining the connecting edges between the top/bottom triangles. Also, some comment about the winding of the face definitions so that readers don't have to deduce it. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 307 at r2 (raw file):
The only thing that test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 328 at r2 (raw file):
BTW Can you have a better name? E.g., test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 390 at r2 (raw file):
"Position difference" is vague. Could you simple call it "distance"? test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 429 at r2 (raw file):
This test can be fooled if test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 460 at r2 (raw file):
This test passes if they have the same number of unique features. You should document this. That the feature lists may include duplicates, but they must have the same number of unique features. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 475 at r2 (raw file):
Can this test fail if test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 532 at r2 (raw file):
This should be gtest EXPECT and not a throw. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 535 at r2 (raw file):
BTW This debug cout should probably not be committed. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 556 at r2 (raw file):
Same comment on names "expandPolytopN" with more descriptive names. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 556 at r2 (raw file):
BTW These are very cool tests and justify all of the work done above. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 736 at r2 (raw file):
BTW same comment on names. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 751 at r2 (raw file):
test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 757 at r2 (raw file):
Edge 0 is axis aligned, yes? This would be more interesting if it were not so. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 788 at r2 (raw file):
MUCH lower tolerance! See previous note. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 794 at r2 (raw file):
Same note on axis-aligned feature. Comments from Reviewable |
Woo hoo! I got all the way through. Reviewed 1 of 4 files at r2. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 158 at r2 (raw file):
test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 179 at r2 (raw file):
I strongly recommend you redefine this test w.r.t. to a reference frame test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 185 at r2 (raw file):
"horizontal" - other than parallel with the z = 0 plane, can you make any strong statement? test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 192 at r2 (raw file):
I think test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 207 at r2 (raw file):
BTW I have a redflag when I see that this doesn't account for
test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 218 at r2 (raw file):
I need some documentation on these last four expects. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 227 at r2 (raw file):
BTW A lambda that captures another lambda? It's lambdas all the way down. :) test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 236 at r2 (raw file):
Why particularly edge-face contact and not face-face or vertex-face? test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl.cpp, line 240 at r2 (raw file):
The why of these apparently orthogonal shifts should be documented. It's not immediately obvious to me. Comments from Reviewable |
f79ec52
to
ca09f07
Compare
I will address the comments in Review status: 2 of 5 files reviewed, 27 unresolved discussions (waiting on @SeanCurtis-TRI and @hongkai-dai) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 742 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 793 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Sure, I will make your happier. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 797 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 814 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 824 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 922 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, add a TODO here. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 979 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 980 at r1 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
I think I actually have a case that the origin is on an edge, in my test case. I agree that conceptually when the closest point is on an edge, it is also on a face, and it makes little sense to differentiate them. But that is how include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 851 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Thanks! This is great. I copied your documentation and function signature. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 856 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 869 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 871 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 903 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Add more explanation here, do you think it makes sense now? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 912 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 929 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
That is right, the TODO is to get rid of the set on include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 930 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 966 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Good point, I inherit that variable name from previous implementation in FCL (which copies the code from LIBCCD) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1019 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1019 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. I moved the documentation inside the function implementation. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1039 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1045 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1079 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1104 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1505 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1530 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Good catch. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1536 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 2 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Good point. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 37 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 79 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Hmm, I think we do not want to make it const reference here, since we will remove and add features into the polytope, and the existing vertices/edges/faces will be changed. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 89 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 100 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Thanks a lot! That is super helpful. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 108 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
For some reasons test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 116 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 143 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Good point. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 162 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done, good call. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 200 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 307 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 328 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Hmm, we have another test that only a single face is visible, and other faces that multiple faces are visible. I hope the documentation at the beginning of the test is clear about the intention of the test? test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 390 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 429 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Add the check test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 460 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Good call, I add the assertion that the features should be distinct. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 475 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
I think the 1-to-1 is handled in this line. Since we already have onto, and the size of test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 532 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 535 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 556 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Hmm, I hope the documentation at the beginning of the test is informative enough? test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 556 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Thanks! test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 751 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 757 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 788 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 794 at r2 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Comments from Reviewable |
Checkpoint Reviewed 2 of 3 files at r3, 1 of 3 files at r4. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 980 at r1 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Per our f2f, you are completely right and I was just fixating on the wrong thing. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 903 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
It seems that this could provide the elaboration you gave me -- if the feature is an edge, then the origin must lie on that edge. That seems like a sufficiently strong result that should be documented. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1530 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I'm sure the break isn't necessary: No switch, no while, and no for. What am I missing? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 814 at r3 (raw file):
BTW Add terminal "()" to these function names. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 827 at r3 (raw file):
BTW I somehow missed this on the previous pass, but:
include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 881 at r3 (raw file):
test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 77 at r4 (raw file):
Now that you've explicitly defined the ordering of the edges, I'd recommend further documentation. Specifically, I'd explain the designed properties of the tetrahedron: /**
Simple equilateral tetrahedron.
Geometrically, its edge lengths are the given length (default to unit length). Its "bottom" face is parallel with the z = 0 plane. It's default configuration places the bottom face *on* the z = 0 plane with the origin contained in the bottom face.
In representation, the edge ordering is arbitrary (i.e., an edge can be defined as (vᵢ, vⱼ) or (vⱼ, vᵢ). However, given an arbitrary definition of edges, the *faces* have been defined to have a specific winding which causes e₀ × e₁ to point inwards or outwards for that face. This allows us to explicitly fully exercise the functionality for computing an outward normal.
- face 0: points outward
- face 1: points inward (requires flipping)
- face 2: points inward (requires flipping)
- face 3: points outward
All property accessors are *mutable*.
*/ Please confirm these directions. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 115 at r4 (raw file):
This needs some documentation. The significance of each test should be captured. Here's my take as near as I can tell: p1-p4: The tetrahedron is positioned so that the origin is placed on each face (some requiring flipping, some not) I think you should have a variation of p6 where the origin lies on a side face. Also, is it worth testing it where the origin is one of the vertices? If not, you should test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 125 at r4 (raw file):
Typo: p4 is not tested, p3 is tested twice. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 154 at r4 (raw file):
FYI BLECH! Mac! Can you put a TODO on this? As soon as we resolve #291 this should be cranked up. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 167 at r4 (raw file):
BTW Should I be surprised that these values changed? It's particularly interesting because the tetrahedron definition didn't change, but the solution did. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 346 at r4 (raw file):
BTW If you take the suggestion of the If you choose not to do that, I'd swap test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 349 at r4 (raw file):
The significance of the test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 370 at r4 (raw file):
test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 397 at r4 (raw file):
I really don't like these two tests. Same polytope, same face, same point, but different output results...all because of the hard to grok test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 512 at r4 (raw file):
BTW s/distince/distinct Also, I don't fully understand the note. Is it that the features in each list must be unique? test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 830 at r4 (raw file):
BTW
test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 79 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
FYI This kind of confuses me -- if you're going to remove/add features into the polytope, then it's not still tetrahedron. :) That said, here's what I'd softly suggest that all of these "getters" return non-const references. Returning a pointer that you know can't be null sends mixed messages. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 89 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
As is turns out, I'm not big fan of how this turned out. New recommendation:
How's that sound? test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 108 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Did you try test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 200 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Face winding? test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 307 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I'll accept it -- I simply doubt the value of the granularity in this particular context compared with the complexity of the testing code. One of the problems I have with this test design is how much the full function is being exercised compared to the recursive function. The recursive function has branches and conditions and should be exercised in many different ways. The main function is completely deterministic. It has one purpose, initialize the recursive function (making sure the initial face ends up in the patch). One test should be sufficient for that purpose. As long as it does that, then its correctness can depends 100% on the recursive function. So, I believe you can be more strategic about these tests. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 328 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I guess its alright -- I just hate looking at the gtest output report that "Test1" failed. The failure report provides little info in that case. test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 475 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I disagree...feature1 contains the keys. This test confirms that you have as many keys in the map as you had in the provided feature 1 list. It doesn't guarantee that every entry in feature 2 is mapped to. And the first question: are there as many keys as entries in feature1, is satisfied by test/narrowphase/detail/convexity_based_algorithm/test_epa.cpp, line 751 at r2 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I don't see it. Comments from Reviewable |
dd242f1
to
757feca
Compare
Is this ready for another review? I know there was a fair amount of churn due to more bugs being found. Review status: 1 of 7 files reviewed, 17 unresolved discussions (waiting on @SeanCurtis-TRI and @hongkai-dai) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 609 at r5 (raw file):
Is there a rationale for picking the most distant? If so, it should be documented. If not, I'd say just pick one. Comments from Reviewable |
… simplex is an edge.
… and the un-normalized support direction.
Review status: 3 of 5 files reviewed, all discussions resolved (waiting on @SeanCurtis-TRI) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 561 at r8 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 1100 at r8 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 1106 at r8 (raw file): Previously, SeanCurtis-TRI (Sean Curtis) wrote…
Done. Comments from Reviewable |
Reviewed 2 of 2 files at r9. Comments from Reviewable |
+@sherm1 for platform review please. Review status: complete! all files reviewed, all discussions resolved Comments from Reviewable |
Review status: all files reviewed, 1 unresolved discussion (waiting on @hongkai-dai) test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_signed_distance.cpp, line 311 at r9 (raw file):
This doesn't compile on Windows because M_PI is not part of the C++ standard. Instead used Comments from Reviewable |
Review status: 4 of 5 files reviewed, 1 unresolved discussion (waiting on @SeanCurtis-TRI and @sherm1) test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_signed_distance.cpp, line 311 at r9 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. Comments from Reviewable |
Reviewed 1 of 1 files at r10. Comments from Reviewable |
Checkpoint. Review status: all files reviewed, 18 unresolved discussions (waiting on @sherm1 and @hongkai-dai) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 740 at r9 (raw file):
Minor: I believe this method is returning the unnormalized face normal. A reader might assume the normal is normalized (since that is so common) so it would be good to be explicit here. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 570 at r10 (raw file):
Minor: from the code it looks as though you are expecting Also, do you want to clarify that the returned polytope has the origin on its face rather than the interior? On first reading I assume the polytope would be constructed with the origin inside. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 570 at r10 (raw file):
Minor: consider calling this "polytope" rather than "pt" as you did in faceNormalPointingOutward() below. I kept reading "pt" as "point". include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 577 at r10 (raw file):
Minor: (META) Per f2f I think we should stick to FCL's informal style of initialLowerCaseLetter() function names. (Would be good to establish a formal style guide but not as part of this PR!) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 590 at r10 (raw file):
Minor: can you conveniently assert that the provided simplex is a triangle, and that the supplied polytope is empty? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 690 at r10 (raw file):
Minor: Should these be mutually exclusive cases? Currently even when it finds the origin in one of the faces it keeps checking the other faces. Is that necessary? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 745 at r10 (raw file):
Minor: here it says "unit length normal vector" but I don't see that in the code? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 747 at r10 (raw file):
Minor: unit vector or not? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 778 at r10 (raw file):
Minor: do we know that lengths in FCL are always in meters (we do have that rule in Drake)? If not, better call this ".01" length units rather than "cm". (And below) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 828 at r10 (raw file):
Nit: in ComputeVisiblePatch() you used backticks for parameter names but here you used include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 829 at r10 (raw file):
Nit: if -> is include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 831 at r10 (raw file):
Minor: here include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 864 at r10 (raw file):
Nit: I always find count()==1 hard to read correctly. It looks like you are checking for exactly one internal edge, but actually this is boilerplate for include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 921 at r10 (raw file):
Minor: you don't need an "else" here since the "if" returns unconditionally. The method would be easier to read since the rest of the code could be un-indented. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 935 at r10 (raw file):
Nit: age -> edge include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 942 at r10 (raw file):
Minor: consider saying here that the query_vertex is assumed to be outside the polytope. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 986 at r10 (raw file):
Minor: not obvious here that you are iterating over edges. Consider a comment and/or renaming the counter from Comments from Reviewable |
Review status: 3 of 5 files reviewed, 2 unresolved discussions (waiting on @SeanCurtis-TRI, @sherm1, and @hongkai-dai) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 740 at r9 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 570 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 570 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. Good call. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 577 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 590 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 690 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Very likely they are mutually exclusive. But I haven't touched this function include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 745 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. Good catch. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 747 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 778 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 828 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 829 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 831 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done, use include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 864 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 921 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 935 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 942 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 986 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. Comments from Reviewable |
Checkpoint: made it through gjk_libccd-inl.h! Just a note: much of this code is not templatized so could be in a .cpp file rather than a header. This would require some build system modifications which I am not proposing for this PR! Reviewed 1 of 2 files at r11. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 590 at r10 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
I don't see the asserts? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 690 at r10 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
How about adding a TODO here? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 828 at r10 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Still an include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 595 at r11 (raw file):
Nit: face -> faces include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 770 at r11 (raw file):
Nit: " include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 893 at r11 (raw file):
Nit: Sinve -> Since include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1024 at r11 (raw file):
Nit: here you have an initial Also there is both include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1031 at r11 (raw file):
Minor: from the code it looks like point features are not allowed. So this should say that el is "a face or edge". include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1037 at r11 (raw file):
Minor: I found the last two sentences confusing. Are they modifying the case where the feature is an edge, or is this a property that every include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1079 at r11 (raw file):
Minor: consider starting this message with "FCL expandPolytope(): " or something like that so that there will be some hint of where it came from (FCL is often buried in some larger application like Gazebo so it wouldn't necessarily be obvious that this is an FCL problem). include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1147 at r11 (raw file):
Minor: this seems misleading -- I believe this parameter is a feature not a point. Could you call it include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1167 at r11 (raw file):
Nit: logic_error. Also consider starting the message with "FCL supportEPADirection(): " include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1198 at r11 (raw file):
Minor: this relies on sqrt(dist) actually being the right normal, which really should be asserted. Consider instead just computing ccdVec3Normalize(&dir) for all cases in which case you could move that to the bottom just before the return and only do it once in the function. It doesn't seem like there would be much cost since you have to do the expensive operations sqrt and divide here anyway. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1210 at r11 (raw file):
Minor: this is a feature, not a point. Maybe "The polytope boundary feature that contains the point nearest the origin." ? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1213 at r11 (raw file):
Nit: newxt -> next include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1747 at r11 (raw file):
Minor: again this is a feature not a point. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1749 at r11 (raw file):
Minor: how are these points measured & expressed? p1 from Ao expressed in A and p2 from Bo expressed in B? Or are they points in the world frame? include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1791 at r11 (raw file):
Minor: point -> feature. Also, consider starting this message with "FCL penEPAPosClosest(): ". include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1802 at r11 (raw file):
Nit: could the above three lines be replaced with just Comments from Reviewable |
Wow! test_gjk_libccd-inl_epq.cpp is the most elaborate set of unit tests I've every seen! Thanks so much for doing that, Hongkai. pending a few minor comments (and check that CI fail is just the expected one). Reviewed 1 of 4 files at r2, 1 of 3 files at r8, 1 of 1 files at r10, 1 of 2 files at r11. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 618 at r11 (raw file):
Minor: consider: GTEST_FAIL() << "There should be only one element in feature2_list that matches "
"with an element in feature1_list."; test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 1249 at r11 (raw file):
Minor: just checking -- is 1e-3 really all we can expect here? Comments from Reviewable |
cd1a21c
to
64c9285
Compare
Review status: 3 of 5 files reviewed, 3 unresolved discussions (waiting on @sherm1 and @hongkai-dai) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 590 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
I put it in line 606 and line 607 https://github.com/hongkai-dai/fcl/blob/box_box_test/include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h#L606~L607 include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 690 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 828 at r10 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 595 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 770 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 893 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1024 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. I changed the documentation to to start with include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1031 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1037 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1079 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1147 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1167 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1210 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1213 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1747 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1749 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1791 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1802 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
I guess not, the type of test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 618 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. test/narrowphase/detail/convexity_based_algorithm/test_gjk_libccd-inl_epa.cpp, line 1249 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
You are right, we can get better accuracy. Comments from Reviewable |
Reviewed 2 of 2 files at r12. include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 590 at r10 (raw file): Previously, hongkai-dai (Hongkai Dai) wrote…
Oh, apparently I'm blind! Comments from Reviewable |
Review status: 4 of 5 files reviewed, all discussions resolved (waiting on @sherm1) include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h, line 1198 at r11 (raw file): Previously, sherm1 (Michael Sherman) wrote…
Done. Comments from Reviewable |
Reviewed 1 of 1 files at r13. Comments from Reviewable |
…ollision-library#305) Rewrite FCL's EPA implementation and add many unit tests.
} else if (isOutsidePolytopeFace(polytope, f[1], &newv->v)) { | ||
start_face = f[1]; | ||
} else { | ||
throw std::logic_error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hongkai-dai Is this really not meant to happen? I just got this error on a long running optimisation job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you send me the code to reproduce the bug?
I think if the starting polytope is non-degenerate (namely it does not have two neighbouring faces being co-planar), this case should not happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am exclusively using shape primitives (boxes, cylinders, spheres). The case that throws this error is a box vs cylinder (radius 0.18, length 0.18). I will open a new issue with more information on how to reproduce.
This PR aims at computing the signed distance function with option
solver_type == GST_LIBCCD
, which is the only solver in FCL that can compute the nearest points when the objects penetrate.Prior to this PR, the implementation in FCL has several flaws.
This PR also adds unit tests to the EPA implementation.
This change is