Hi,
I'm investigating using Bullet to add collision detection to SimTK (https://simtk.org/home/simtkcore), a toolkit for physics based simulation of biological structures. Since our target is scientific simulation rather than games, our requirements are a bit different from most users, so I want to find out whether it would really be suitable. (Note that we would only be using it for collision detection, not for dynamics, constraints, etc.)
Here is what I would need it to do: given a set of bodies, I need to be able to specify their positions and get back a list of all contacts between them. For each contact, I need to get the location of the contact, normal vector, and penetration depth. When working with concave objects, it's possible for two objects to have multiple contacts at once. I would need to be able to get the above information separately for each contact.
We also need to support conforming contacts where the contact may occur over an extended area, not just at a small point. (Think of a foot resting on the floor.) Given two meshes that are overlapping, I need to be able to get a list of all vertices on each mesh that are inside the other one. And for any point on one mesh, I need to be able to get the penetration depth at that point (if it's inside the other body) or distance to the other body (if it's outside), along with the local contact normal.
I'm also hoping that it can be extended to support new types of geometry. We'll only provide out-of-the-box support for a few primitive types (spheres, planes, triangle meshes, etc.), but users may want to add new types. For example, we have one user who works with trimmed NURBS, and it should be possible for him to implement support for that.
Is it possible to do these things with Bullet? If the answer is, "Yes, but you'll need to modify it," that's fine. I don't mind making changes to the code, as long as it's architected in a way that allows the necessary features to be added in a clean way.
Thanks for your input!
Peter
Bullet for scientific simulation
-
peastman
- Posts: 5
- Joined: Sat Aug 16, 2008 12:17 am
Re: Bullet for scientific simulation
Based on the lack of response, should I conclude that what I want to do is not possible? Or just that no one has had time to reply yet?
Peter
Peter
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Bullet for scientific simulation
We just returned from the SIGGRAPH conference and still catch up with developments.
Hope this helps,
Erwin
Yes, you can use the btCollisionWorld for this. Bullet will accumulate several contact points after each call to btCollisionWorld::performDiscreteCollisionDetection. Contact points are only recorded if there is a penetration (negative distance) or very small positive distance. Each contact point keeps the position (location), normal and depth. See Demos\CollisionInterfaceDemo\CollisionInterfaceDemo.cpp for one example how to iterate over contact points (there are other ways to achieve the same).Here is what I would need it to do: given a set of bodies, I need to be able to specify their positions and get back a list of all contacts between them. For each contact, I need to get the location of the contact, normal vector, and penetration depth. When working with concave objects, it's possible for two objects to have multiple contacts at once. I would need to be able to get the above information separately for each contact.
This query for meshes might be available somewhere in the codebase, but not exposed as a userfriendly API. Note that Bullet doesn't assume meshes.We also need to support conforming contacts where the contact may occur over an extended area, not just at a small point. (Think of a foot resting on the floor.) Given two meshes that are overlapping, I need to be able to get a list of all vertices on each mesh that are inside the other one. And for any point on one mesh, I need to be able to get the penetration depth at that point (if it's inside the other body) or distance to the other body (if it's outside), along with the local contact normal. You might want to check out Bullet/Extras/GIMPACT for these queries, or Bullet/src/BulletSoftBody/*.
Bullet is very modular and extensible, so adding other collision shapes is definately possible. The interactions with the new shapes can be registered, see btDefaultCollisionConfiguration or btSoftBodyRigidBodyCollisionConfiguration.I'm also hoping that it can be extended to support new types of geometry. We'll only provide out-of-the-box support for a few primitive types (spheres, planes, triangle meshes, etc.), but users may want to add new types. For example, we have one user who works with trimmed NURBS, and it should be possible for him to implement support for that.
Hope this helps,
Erwin
-
peastman
- Posts: 5
- Joined: Sat Aug 16, 2008 12:17 am
Re: Bullet for scientific simulation
I hope you had a good time! Thanks for replying.Erwin Coumans wrote:We just returned from the SIGGRAPH conference and still catch up with developments.
I see that this demo (like all the others I've looked at) still assumes that Bullet is in control of the simulation, and you just provide a callback to handle collisions. Are there any demos that show how to do it the other way around - call Bullet to perform a single collision detection from a program that is otherwise independent of it?See Demos\CollisionInterfaceDemo\CollisionInterfaceDemo.cpp for one example how to iterate over contact points (there are other ways to achieve the same).
Understood. Any contact model which depends on the detailed shape of the contacting geometry is necessarily going to be specific to a particular type of surface representation. On the other hand, even a very simplistic contact model will still need an estimate of the overall dimensions of the contact area. Is there a generic way to get that, or do I need to write a separate routine to calculate it for each possible pair of shape classes?Note that Bullet doesn't assume meshes.
Peter
-
peastman
- Posts: 5
- Joined: Sat Aug 16, 2008 12:17 am
Re: Bullet for scientific simulation
Where can I find a description of the algorithm used by GIMPACT to calculate intersections between triangle meshes?
Peter
Peter
-
peastman
- Posts: 5
- Joined: Sat Aug 16, 2008 12:17 am
Re: Bullet for scientific simulation
It's very quiet around here... If anyone could answer these questions, I'd really appreciate it.
Peter
Peter
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Bullet for scientific simulation
Bullet estimates a contact area between two convex shapes, by a collection of several contact points. Contact reduction is performed to reduce the number of contact point, the current Bullet implementation uses a maximum of 4 contact points between two convex shapes.an estimate of the overall dimensions of the contact area
Collision detection between complex shapes, such as compounds or concave triangle meshes happens in two stages: a midphase finds pairs of convex parts, and those convex parts are handled as described above.
Bullet and GIMPACT use AABB trees to perform this midphase culling. The tree traversal detects overlapping nodes, which represent convex parts/triangles.
Hope this helps,
Erwin
-
esingla
- Posts: 8
- Joined: Sat Mar 13, 2010 8:00 am
Re: Bullet for scientific simulation
This discussion surely helped me in clearing a few doubts in my mind. However, two related issues still remain:
As Peter asked, if Bullet is to be used without any callback and not with Simulation way --- but just used by another program which is independent of Bullet and calls it for collision detection between a set of objects (a pair of objects in each call); then how does bullet collects the contact points. I have this confusion as it is told that bullet accumulates multiple contact points in each call of say performDiscreteCollisionDetection, and in my understanding it returns a manifold which provides the set of contact points and the corresponding detail informations. Does it mean that by calling a function between two same objects can provide different contact points? This sounds absurd but with my little knowledge and experience, I cannot understand probably the utility of this. Please clarify me at this issue.
Second issue is about what Erwin replied that a contact is declared if there is a penetration distance or a very small positive distance. May I know what is that tolerance/margin which decides this contact. I need this information for my collision queries and I was trying to find positive distance between two objects and then to decide of it is below the tolerance we give or not. But is this information, about the tolerance for deciding a contact, is already present inside in bullet (surely be), then my work would be nothing.
Really thankful for quick replies, Erwin.
As Peter asked, if Bullet is to be used without any callback and not with Simulation way --- but just used by another program which is independent of Bullet and calls it for collision detection between a set of objects (a pair of objects in each call); then how does bullet collects the contact points. I have this confusion as it is told that bullet accumulates multiple contact points in each call of say performDiscreteCollisionDetection, and in my understanding it returns a manifold which provides the set of contact points and the corresponding detail informations. Does it mean that by calling a function between two same objects can provide different contact points? This sounds absurd but with my little knowledge and experience, I cannot understand probably the utility of this. Please clarify me at this issue.
Second issue is about what Erwin replied that a contact is declared if there is a penetration distance or a very small positive distance. May I know what is that tolerance/margin which decides this contact. I need this information for my collision queries and I was trying to find positive distance between two objects and then to decide of it is below the tolerance we give or not. But is this information, about the tolerance for deciding a contact, is already present inside in bullet (surely be), then my work would be nothing.
Really thankful for quick replies, Erwin.