Trying to stabilize the ragdoll

Oozie

20-02-2007 20:34:11

I'm trying to get the ragdoll simulation to be more stable. Right now the ragdolls experience a lot of shaking, and they jitter in a unrealistic fashion.

I'm going through the Ode manual to get information about the parameters which I should modify... I've also heard that there is a alternative, more slow but accurate physics solver available in ode...

If you have any tips, or you have tried this before, I would appreciate your information!

One problem which puzzles me, is the fact that the collision objects of the ragdoll are detached, especially the box objects, which make up the stomach, chest and head. The deformed zombie model seems to behave well despite this problem. Does anyone know why this happens? Here's a picture about the strongly detached collision box objects (rendered with green outlines):

rewb0rn

21-02-2007 07:23:56

I havent worked with ragdolls so much yet, but maybe the boxes are just defined wrong in the ogreode file?
I found out its generally a better way to work with ode if you have fixed timesteps. Try out something like this in your time calculation:
while (GetRoot()->getTimer()->getMilliseconds() < 20) Sleep(1);

TimePassed = double(GetRoot()->getTimer()->getMilliseconds()) / 1000.0;
GetRoot()->getTimer()->reset();


To get an accurater simulation check out the different steppers that come with ogreode.

Ill stay tuned to the detached boxes, im interested in it as well.

Oozie

23-02-2007 15:13:32

Thank you rew0rn for your idea! I'll look into that, if I run into more problems.

I was able to stabilize the ragdoll significantly through my own tweaking! Here's how:

Original CFM in SimpleScenesApplication.cpp is 10e-5. Replace it with:
//_world->setCFM(10e-5); -->
_world->setCFM(100e-5);


The value of 100e-5 is the max in my opinion, the shaking is not a big problem anymore, but now the objects go through each other (softness). To make the CFM with the floor collisions hard, we must add a new command into SimpleScenes::collision function in SimpleScenes.cpp (insert it after the if sentence for example):
contact->setSoftness(0.8, 10e-5);

To reduce the shaking even further, we must also set manually the joint CFM values in the Ragdoll::createBoneBody function in OgreOdeRagdoll.cpp.

In the beginning of OgreOdeRagdoll.cpp I have this definition:
#define JOINT_CFM 500e-5

Inside the function Ragdoll::createBoneBody is the following if-clause:

if ((physical_bone->_parent_bone)
&& (physical_bone->_parent_bone->_body)
&& (physical_bone->_body))
{


Inside this clause there are many if-clauses like this:
if (settings._joint_type == Joint::Type_BallJoint)

In each of these if-clauses (with many different joint types), insert this:
physical_bone->_joint->setParameter(Joint::Parameter_CFM, JOINT_CFM, 1);
physical_bone->_joint->setParameter(Joint::Parameter_StopCFM, JOINT_CFM, 1);


The ragdolls shaking disappears almost completely. The downside is that with these parameters the ragdolls are very elastic, so their legs and arms seem rubber like. More parameter tweaking needed.

Changing the stepper didn't give any significant accuracy, it only made the FPS choppy with 15+ ragdolls in one pile :-)

I hope this is useful to someone.

tuan kuranes

24-02-2007 11:30:53

Could you provide a patch so that it becomes OgreOde official demos behaviour ?

Oozie

27-02-2007 00:06:39

I can't send any tested source files right now, because I modified the originals too much. I could unzip the original source files, modify the three files and send them to you WITHOUT checking if it compiles (I don't want to ruin my current modified project).

Anyone should be able to implement these changes themselves, and see the results. The instructions are in my previous reply.

If no one has done so in 3 months (when my current project ends), then I can send you the modified and tested OgreOdeRagdoll.cpp, SimpleScenesApplication.cpp and SimpleScenes.cpp.

rewb0rn

27-02-2007 07:47:13

I think itd be generally a better way if some1 writes getter and setter for the changed values, so that nothing is hardcoded (the initialization of course can be like yours or tuans), thatd make the ragdolls class much more dynamic and usable.

btw have u found out something about the detached boxes?

Oozie

27-02-2007 21:17:12

I haven't found anything new about the detached boxes, but as you pointed out in this thread "Rag Doll exported from Blender not working in OgreODE", there seems to be a bug with the box class.

But I have made other discovery: When I view the collision bodies (E toggles this mode on and off in the demo), they seem to be move smoothly, but only the animated mesh inside them does the shaking! I could minimize this shaking with my modifications, but it still is visible with some zombies, if I go really close.

This is very clearly seen in the OgreOde zombie demo. Does anyone know what is causing this?

tuan kuranes

28-02-2007 13:43:42

I could unzip the original source files, modify the three files and send them to you WITHOUT checking if it compiles (I don't want to ruin my current modified project).
That would help indeed.

Does anyone know what is causing this?
some vertex inside the ragdoll may be not associated correctly with bones ?

Oozie

01-03-2007 21:09:15

Ok, I sent the files to you with email