Trouble making a rigid joint

chucksspencer
Posts: 35
Joined: Wed Jun 25, 2008 2:52 pm

Trouble making a rigid joint

Post by chucksspencer »

Hi there. We're trying to work out a way to create a fixed joint between two objects. Various user interactions will cause this connection to be created and broken during the simulation. Both shapes are dynamic and can be moved (again, by the user) during the simulation both before and after the connection is made.

Initially we've tried to accomplish this by creating a btGeneric6DofConstraint between the two shapes with all the axes locked. This seems to work reasonably well unless one shape is much larger than the other, in which case the connection acts "springy" in stead of rigid.

I've tried using a limited btHingeConstraint - same result.

Any hints on what might be causing this and how to correct it? Some sort of damping or relaxation threshold either in the joint or globally?

At the moment I'm looking into creating a btCompoundShape as an alternative, but this makes breaking the connection a pain.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Trouble making a rigid joint

Post by Erwin Coumans »

Using a btCompoundShape, and adding extra logic is probably the best way forward, this would give you some kind of fracturing system.

We should modify the Demos/ConvexDecompositionDemo to show how to propagate a collision impulse, and break the btCompoundShape into multiple rigid bodies, with childshape(s) from the btCompoundShape.

Hope this helps,
Erwin
chucksspencer
Posts: 35
Joined: Wed Jun 25, 2008 2:52 pm

Re: Trouble making a rigid joint

Post by chucksspencer »

Not what I'd hoped for but c'est la vive. Thanks for the response.

Is there somewhere that I might find a good example of how to remove a shape from a group? Will I need to create a new btCompoundShape with all the children except the one I'm trying to remove?
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: Trouble making a rigid joint

Post by ola »

Yes that's how to do it for now.

I wrote a patch earlier that makes it possible to remove a shape from a compound, it's on the google code issue list (http://code.google.com/p/bullet/issues/detail?id=51). But it's not yet decided if it is going to be included. At the moment I'm using the same technique as what you describe.

Best regards,
Ola
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Trouble making a rigid joint

Post by Erwin Coumans »

The patch from Ola has finally been applied, thanks!

http://code.google.com/p/bullet/source/detail?r=1185

Removing childshapes from compound shapes will be available in Bullet 2.70
Thanks for the contribution and feedback,
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Trouble making a rigid joint

Post by Erwin Coumans »

Important to note is that it is best to remove the rigid body from the dynamics world, before changing the number of childshapes in a btCompoundShape.
This is required, because some overlapping pairs may cache information of those child shapes.

Another solution is to explicitly clean this cached information of all pairs that involve this compound shape:

Code: Select all

btBroadphaseProxy* bp = rigidbody->getBroadphaseHandle();
dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
Hope this helps,
Erwin
chucksspencer
Posts: 35
Joined: Wed Jun 25, 2008 2:52 pm

Re: Trouble making a rigid joint

Post by chucksspencer »

Erwin Coumans wrote:Important to note is that it is best to remove the rigid body from the dynamics world, before changing the number of childshapes in a btCompoundShape.
This is required, because some overlapping pairs may cache information of those child shapes.

Another solution is to explicitly clean this cached information of all pairs that involve this compound shape:

Code: Select all

btBroadphaseProxy* bp = rigidbody->getBroadphaseHandle();
dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
Hope this helps,
Erwin
Do you mean remove the rigid body of the shape being added/removed or the rigid body that the btCompoundShape is attached to? If you were to force the cache clean would you do it before or after you changed the number of children? Would you do this before or after the change in number of children? Is it necessary to do this when you add to the group or only when you remove from it?

Sorry for all the questions :-D
dekarguy
Posts: 6
Joined: Thu Jul 10, 2008 11:47 pm

Re: Trouble making a rigid joint

Post by dekarguy »

I'm doing something extremely similar to this, and already used the patch for removeChildShape

What I'm wondering is how to apply a force through the first object to apply to the second object.

What I want to do is attach 2 objects with a rigid joint, and let the first one push/pull the other at the spot they attached and the whole shape move about second one's center of mass.

Whats happening right now when I attach the two is the center of mass for the compound shape is staying at the center of mass of the initial object.
chucksspencer
Posts: 35
Joined: Wed Jun 25, 2008 2:52 pm

Re: Trouble making a rigid joint

Post by chucksspencer »

dekarguy wrote:I'm doing something extremely similar to this, and already used the patch for removeChildShape

What I'm wondering is how to apply a force through the first object to apply to the second object.

What I want to do is attach 2 objects with a rigid joint, and let the first one push/pull the other at the spot they attached and the whole shape move about second one's center of mass.

Whats happening right now when I attach the two is the center of mass for the compound shape is staying at the center of mass of the initial object.
There are many smarter people who could do a much better job of answering your question here, but they seem quiet so for now you're stuck with me. :-D

I had the same problem and while I didn't ever actually get around to implementing it I did find a few posts indicating that the solutions is to re-calculate the center of gravity (add up all the relative CG positions of the objects multiplied by their masses, divide by total mass) - use the result to set the compound shape's center of mass (use the btRigidBody method setCenterOfMassTransform) then change the relative transformations of the children to account for the new CG (you may have to remove then re-add them?)

Hope that helps!
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Trouble making a rigid joint

Post by sparkprime »

chucksspencer wrote: There are many smarter people who could do a much better job of answering your question here, but they seem quiet so for now you're stuck with me. :-D
This appears to be the motto of this forum and most bullet users i've spoken to!

Really, documenting bullet's internals should be priority #1 as it's not just driving away users but also people who might contribute.