Beginner help request on constraints

Post Reply
cc9cii
Posts: 7
Joined: Sat Dec 24, 2016 9:24 am

Beginner help request on constraints

Post by cc9cii »

I've run into a strange behaviour that I can't figure out and would like some help please - since I'm new to Bullet I'm certain I've done something wrong, but where to start investigating?

What I have is a static box and a number of capsules (chain) and another box (lamp) - basically a ragdoll. These are made using btRigidBody with btMotionState and constraints (tried both p2p and 6Dof).

If I set the mass of the dynamic objects (chain capsules and lamp box) to zero, then the objects are placed correctly. See the pic below:

Image

So the starting world transforms set in btMotionState must be ok. But of course the objects won't move with their mass set to zero. Now, if I set the mass values correctly (the capsules are 0.5 each and the lamp box is 2.0) then they float up through the ceiling (so it seems). I have a video that shows this. The first video is when m_localInertia are set to zero - the lamp responds to and "swings", except upside down. But why upside down? I've made no change to the code other than set the mass values between the pic and video.

https://youtu.be/a_rrhoA1EpU

The second video shows when m_localInertia is set using shape->calculateLocalInertia(mass, localInertia). This time the linked objects break apart! Again, no change other than setting the local inertia non-zero between the first video and the second video.

https://youtu.be/lfCFTaFNyrA

Obviously I've messed up, but I have no idea where. Any help here would be much appreciated.
cc9cii
Posts: 7
Joined: Sat Dec 24, 2016 9:24 am

Re: Beginner help request on constraints

Post by cc9cii »

EDIT: Changed the joint pivot points after I posted below, works better now (made them further apart). I've updated the code below, so the behaviour shown in the video won't occur with below code

EDIT2: removed the code from below since it is no longer relevant (or correct)

Created the same object for the Example Browser. Interestingly it doesn't work here, either (still "floats" as if there is no gravity, even though the ragdolls fall down without any problems).

https://youtu.be/5GUI4yw4x_4

The code was more or less copied directly from the RagDoll example; the instance created in BenchmarkDemo::createTest3() by:

CathedralCryptLight02 *light = new CathedralCryptLight02(m_dynamicsWorld, pos, 1.f);

(If you are looking at the code, please ignore "*7" everywhere - that's just how the model is defined in NIF files and I wanted to preserve it for now.)

<snip example code>
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Beginner help request on constraints

Post by drleviathan »

Idea 1: Try using longer links in the middle and fewer of them.

Idea 2: Long chains of constraints can go unstable, especially when there is a wide range of relative masses and inertia tensors: that is, when the smallest mass/inertia is much much smaller than the biggest. Try artificially increasing the mass and inertia tensor of the middle links: double the mass and quadruple the inertia tensor and see what happens.
Post Reply