strange capsule behaviour

Post Reply
shogun
Posts: 34
Joined: Tue Mar 04, 2008 3:16 pm

strange capsule behaviour

Post 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
Ellon
Posts: 10
Joined: Wed Jul 29, 2009 4:04 am
Location: Seoul, Korea

Re: strange capsule behaviour

Post 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?
shogun
Posts: 34
Joined: Tue Mar 04, 2008 3:16 pm

Post 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
shogun
Posts: 34
Joined: Tue Mar 04, 2008 3:16 pm

Re: strange capsule behaviour

Post 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.
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: strange capsule behaviour

Post by RBD »

Looks like the center of mass is on one side (not in the center :wink: ).
shogun
Posts: 34
Joined: Tue Mar 04, 2008 3:16 pm

Re: strange capsule behaviour

Post by shogun »

Yes, it looks like that. But as I said, the center of mass IS in the center.
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: strange capsule behaviour

Post 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?
shogun
Posts: 34
Joined: Tue Mar 04, 2008 3:16 pm

Re: strange capsule behaviour

Post 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.
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: strange capsule behaviour

Post 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?!
shogun
Posts: 34
Joined: Tue Mar 04, 2008 3:16 pm

Re: strange capsule behaviour

Post 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!
Last edited by shogun on Fri Jul 31, 2009 3:53 pm, edited 1 time in total.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: strange capsule behaviour

Post 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.
Ellon
Posts: 10
Joined: Wed Jul 29, 2009 4:04 am
Location: Seoul, Korea

Re: strange capsule behaviour

Post 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..
shogun
Posts: 34
Joined: Tue Mar 04, 2008 3:16 pm

Re: strange capsule behaviour

Post 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
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: strange capsule behaviour

Post 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
Post Reply