Repository navigation
Bound rotated geometry by the rotated local AABB - #664
SeanCurtis-TRI merged 3 commits into
Conversation
6e0a865 to
c576b09
Compare
|
Closes #509 The cost of the operation is about ~2x compared to the spherical bound, but it prunes the bvh significantly in downstream Drake's broadphase, cutting the broadphase time (a major bottleneck in Drake simulation with large number of bodies) by ~30%. |
|
+a:@SeanCurtis-TRI for feature review |
SeanCurtis-TRI
left a comment
There was a problem hiding this comment.
@SeanCurtis-TRI reviewed 3 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on xuchen-han).
include/fcl/narrowphase/collision_object-inl.h line 131 at r1 (raw file):
// (Graphics Gems, 1990); see Ericson, Real-Time Collision Detection, // section 4.2.6. const Vector3<S> c_local =
nit: Don't compute c_local, simply use cgeom->aabb_center.
test/test_fcl_collision_object.cpp line 110 at r1 (raw file):
// looser than the looser cube of half-width aabb_radius. template <typename S> void TestBoundIsConservative() {
nit: The name of this method is misleading. The test does two things:
- Confirms the bound is conservative; all of the original box's corners are contained within the bound.
- Confirms the bound is no worse than bounding the bounding sphere.
Is that second case a test on the "conservative" nature of the box? It feels not. Furthermore, this second test doesn't seem to have long-term value as there is no code path where you could choose to get one or the other. This is merely a test to help the feature reviewer get comfortable with the idea that this change is worthwhile (i.e., it creates a tighter bound). Is that worth repeating in CI over and over?
c576b09 to
36d4e7f
Compare
xuchen-han
left a comment
There was a problem hiding this comment.
@xuchen-han made 2 comments and resolved 2 discussions.
Reviewable status: 1 of 3 files reviewed, all discussions resolved (waiting on SeanCurtis-TRI).
include/fcl/narrowphase/collision_object-inl.h line 131 at r1 (raw file):
Previously, SeanCurtis-TRI (Sean Curtis) wrote…
nit: Don't compute
c_local, simply usecgeom->aabb_center.
Done.
test/test_fcl_collision_object.cpp line 110 at r1 (raw file):
Previously, SeanCurtis-TRI (Sean Curtis) wrote…
nit: The name of this method is misleading. The test does two things:
- Confirms the bound is conservative; all of the original box's corners are contained within the bound.
- Confirms the bound is no worse than bounding the bounding sphere.
Is that second case a test on the "conservative" nature of the box? It feels not. Furthermore, this second test doesn't seem to have long-term value as there is no code path where you could choose to get one or the other. This is merely a test to help the feature reviewer get comfortable with the idea that this change is worthwhile (i.e., it creates a tighter bound). Is that worth repeating in CI over and over?
Done. Renamed and removed the second test.
SeanCurtis-TRI
left a comment
There was a problem hiding this comment.
Now I have to figure out what I'm going to do about CI....blech.
@SeanCurtis-TRI reviewed 2 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on xuchen-han).
include/fcl/narrowphase/collision_object-inl.h line 136 at r2 (raw file):
(cgeom->aabb_local.max_ - cgeom->aabb_local.min_) * S(0.5); const Vector3<S> delta = t.linear().cwiseAbs() * h_local; if(delta.allFinite())
BTW Probably worth putting a note on why we only test delta (maximum values for box dimensions getting tipped over the edge by transform). THe same concern doesn't apply to the center.
computeAABB() bounds a rotated geometry by a cube of half-width aabb_radius, the circumscribing sphere of the local AABB. For flat or elongated shapes that box is far looser than the rotated local box, causing inefficiencies in broadphase collision. Bound the rotated local AABB instead, with center X * c and half-widths |R| * h. Since |R| h <= ||h|| = aabb_radius on every axis, the new box is always contained in the old one and still contains the geometry, so broadphase results stay conservative. Half spaces and planes report an unbounded local AABB as extents at the limits of the scalar type, which overflow the half-width and can reach the rotation as 0 * inf; those keep the bound built from aabb_center and aabb_radius.
36d4e7f to
2edd0f4
Compare
SeanCurtis-TRI
left a comment
There was a problem hiding this comment.
@SeanCurtis-TRI reviewed 1 file and all commit messages, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on xuchen-han).
xuchen-han
left a comment
There was a problem hiding this comment.
#665 in case it helps.
@xuchen-han made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on xuchen-han).
SeanCurtis-TRI
left a comment
There was a problem hiding this comment.
Ok...now we'll let CI run through.
@SeanCurtis-TRI reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on xuchen-han).
The old test assumed that the boxes were in one of two discrete states: tightly-fitting in the identity orientation or supremely overinflated in any other orientation. That's no longer true.
SeanCurtis-TRI
left a comment
There was a problem hiding this comment.
I've updated the SaPBroadphase test. It's previous assumptions no longer hold with a more strategically-computed AABB. Now we'll let CI run and see what comes out of it.
@SeanCurtis-TRI made 1 comment.
Reviewable status: 3 of 4 files reviewed, all discussions resolved.
|
Huzzah. Merging. |
708d2e1
into
flexible-collision-library:master
computeAABB() bounds a rotated geometry by a cube of half-width
aabb_radius, the circumscribing sphere of the local AABB. For flat or
elongated shapes that box is far looser than the rotated local box,
causing inefficiencies in broadphase collision.
Bound the rotated local AABB instead, with center X * c and half-widths
|R| * h. Since |R| h <= ||h|| = aabb_radius on every axis, the new box is
always contained in the old one and still contains the geometry, so
broadphase results stay conservative. Half spaces and planes report an
unbounded local AABB as extents at the limits of the scalar type, which
overflow the half-width and can reach the rotation as 0 * inf; those keep
the bound built from aabb_center and aabb_radius.
This change is