Page 1 of 1

strange capsule behaviour

Posted: Thu Jul 30, 2009 10:47 am
by shogun
Hi,

is this behaviour of the capsule shape normal? -> http://www.youtube.com/watch?v=Loy-TiOo-_Q

I didn't change the center of the mass or the collision margins.

Regards,
shogun

Re: strange capsule behaviour

Posted: Thu Jul 30, 2009 3:04 pm
by Ellon
Hi,

Which type of capsule do you use?
We have used btCapsuleShapeZ before and suffered from similar problem..

Now we use btMultiSphereShape composed of 2 sphere with same radius and problem is gone. (its debug draw was horrible but now fixed on recent commit :P )

Moreover, our character got more realistic knock-down rolling without a full-featured ragdoll with a single multisphere composed of one big sphere (head) and two small sphere (legs) just adding on the fly.

Thanks

p.s. I think that rendering quality on the video is awesome. May I ask which engine do you use?

Posted: Thu Jul 30, 2009 4:15 pm
by shogun
Hallo!

Well, I use the normal btCapsuleShape, but I will try the multipsphere approach.

I use OGRE. But the bad quality of the video is my own fault. ;)

Regards,
shogun

Re: strange capsule behaviour

Posted: Thu Jul 30, 2009 7:37 pm
by shogun
I changed the capsule to multi sphere ...
Ellon wrote:Now we use btMultiSphereShape composed of 2 sphere with same radius and problem is gone.
Not in my case. The behaviour is pretty much the same. :(

EDIT: I just tested the whole thing again, this time with cylinders. The do exactly the same strange tumbling. Hm.

Re: strange capsule behaviour

Posted: Fri Jul 31, 2009 12:11 pm
by RBD
Looks like the center of mass is on one side (not in the center :wink: ).

Re: strange capsule behaviour

Posted: Fri Jul 31, 2009 12:13 pm
by shogun
Yes, it looks like that. But as I said, the center of mass IS in the center.

Re: strange capsule behaviour

Posted: Fri Jul 31, 2009 12:17 pm
by RBD
Oh, sorry, but you wrote that you didn't change the center of mass... I'm thinking maybe you should try changing it?

Re: strange capsule behaviour

Posted: Fri Jul 31, 2009 1:37 pm
by shogun
The thing is, to move an object's center of mass in Bullet you have to create a compound object. I don't know if this is a good solution, especially as I don't know where my current "virtual center of mass" is.

Re: strange capsule behaviour

Posted: Fri Jul 31, 2009 2:29 pm
by DannyChapman
It's behaving like this because when a capsule is rolling on its end like in your video, it spins much faster than a cylinder would for the same linear velocity, so it behaves strongly as a gyroscope. Rather than the non-contacting end falling down, the capsule rolls in a circle (to the left in your case).

It should be doing this to some extent - as to whether it's doing it more than it should be in Bullet - perhaps you should check that the inertia is being calculated correctly.

Remember also that you probably don't have much real-world experience with how objects like this behave - when was the last time you played with a 1.5m (?) high capsule?!

Re: strange capsule behaviour

Posted: Fri Jul 31, 2009 3:24 pm
by shogun
DannyChapman wrote:It's behaving like this because when a capsule is rolling on its end like in your video, it spins much faster than a cylinder would for the same linear velocity, so it behaves strongly as a gyroscope. Rather than the non-contacting end falling down, the capsule rolls in a circle (to the left in your case).
I could live with that ... but I tested the cylinder and it behaved exactly like the capsule.
It should be doing this to some extent - as to whether it's doing it more than it should be in Bullet - perhaps you should check that the inertia is being calculated correctly.
It's calculated just like in the demos.

Thanks for your reply!

Re: strange capsule behaviour

Posted: Fri Jul 31, 2009 3:34 pm
by Dirk Gregorius
I think it is exactly as Danny pointed out. Bullet as many other engines drop the coriolies term from the force computation because of stability issues. To test whether your problem is related to this you can add the torque yourself. For an explanation look here:

http://en.wikipedia.org/wiki/Newton%E2% ... _equations

The issues you notice is because of the (w x I * w) being dropped. If you add this term the whole system might get unstable and explode though. In this case you have to choose a smaller timestep.

Re: strange capsule behaviour

Posted: Mon Aug 03, 2009 1:49 am
by Ellon
Checking my code again, I found that I adjusted friction and dampings addition to changing shape.
In my case I'm using 2.0m capsule and tried to reproduce your case, applied following:

Code: Select all

body->setLinearVelocity(btVector3(5,5,0));
body->setAngularVelocity(btVector3(0,0,5));
On plane ground, this spins exactly like yours (doesn't fall down *naturally* and looks like gyro)

I think Danny and Dirk suggests is the correct explanation of this phenomenum. But before going to have hard time to implementing coriolies term, how about to try this:

Code: Select all

// numbers should be tested
body->setDamping(0.3, 0.5); 
body->setFriction(0.1);
This reduced the gyro-like spinning alot and looks much natural on my case.

I'm sorry for not being helpful..

Re: strange capsule behaviour

Posted: Mon Aug 03, 2009 2:10 pm
by shogun
Well, you're very helpful. (You all are.)
I will try to tweak the damping.

The strange behaviour of capsules/cylinders isn't a big problem for me - I just wondered if it was "just me" or expected.

Regards,
shogun

Re: strange capsule behaviour

Posted: Mon Aug 03, 2009 6:30 pm
by Dirk Gregorius
To try the gyroscopiv term you could maybe quickly try this:

btVector3 tau = cross( body->getAngularVelocity(), body->getGlobalInertia() * body->getAngularVelocity() );
body->applyTorque( tau );

The force needs to be applied each frame.


Cheers,
-Dirk