Precision of getClosestPoints calculation ?

Post Reply
jeffq
Posts: 1
Joined: Thu Aug 16, 2018 3:38 am

Precision of getClosestPoints calculation ?

Post by jeffq »

I want to use bullet physics to measure the min distance between convex objects(btConvexTriangleMeshShape) and use the GjkPairDetector with the VoronoiSimplexSolver and the GjkEpaPenetrationDepthSolver. I met a problem : the result of m_pointInWorld is within shape sometimes,but not within shape other times.

The code is below:
Image

The precision error pic is below:
Image

Is there any way to reduce the error such that getClosestPoints returns m_pointInWorld within the shape?
Any help would be appreciated!
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Precision of getClosestPoints calculation ?

Post by drleviathan »

I want to use bullet physics to measure the min distance between convex objects(btConvexTriangleMeshShape)
That statement does not agree with the image you supplied: some of the objects in the image do not render as convex.

Also, you talk about whether "point is within shape" but your image has text about "point is not within model". Are you aware that there would tend to be a difference between the convex shape approximation of a concave model? Perhaps you should use better approximate shapes, like a really tight btCompoundShape around all of the convex parts of your concave model.

btConvexTriangleMeshShape derives from btConvexShape which introduces the set/getMargin() API. I haven't looked at the code but it is possible there is a default collision margin at play for btConvexTriangleMeshShape and the "nearest approach" algorithms may be supplying points on the surface with margin. Dunno if this is the case, just saying it is a possibility that you might want to verify.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Precision of getClosestPoints calculation ?

Post by Erwin Coumans »

Using an extremely small margin and changing the setEqualVertexThreshold is not supported. Also, make sure to use the double precision version.

Also, I made some fix in the btGjkPairDetector.cpp related to degenerate cases here.

You may want to share a small reproduction case based on a modified example in the Bullet ExampleBrowser so someone can easily look at it (without requiring other projects/dependencies etc). Alternatively, simply use PyBullet to reproduce it, with an OBJ and URDF file.
Post Reply