'Bouncy' Joints

tengil

04-01-2007 18:44:08

Hi!

I have a small question about the joints. Perhaps somebody can help me...

Whatever I try the joints behave like they aren't 'strong' enough... The Bodies bouncing around.

Some test runs (different densities):

http://freenet-homepage.de/tengil001/number1.avi
http://freenet-homepage.de/tengil001/number2.avi
http://freenet-homepage.de/tengil001/number3.avi
http://freenet-homepage.de/tengil001/number4.avi
http://freenet-homepage.de/tengil001/number5.avi


It seems not to be the bounce variable:


mScene->findBody("1st")->mShape[0]->mMaterial->setBounce(0);
mScene->findBody("2nd")->mShape[0]->mMaterial->setBounce(0);
mScene->findBody("3rd")->mShape[0]->mMaterial->setBounce(0);
mScene->findBody("4th")->mShape[0]->mMaterial->setBounce(0);



...but I can not find such a bounce variable for the joints???

Does anybody know how to 'strengthen' the joints?

best regards
Tengil





world::getSingleton().setDebug(world::DEBUG_VISUAL_EVERYTHING, true);

material *aMaterial = mScene->createMaterial("a",0.5,0.5,0.0);

mScene->createBody(
"1st",
"cube.1m.mesh",
new nxOgre::cubeShape(Vector3(4.0f,1.0f,2.0f), Vector3(0, 0, 0), aMaterial),
100.0f,
Vector3(0.0f,0.5f,0.0f)
);
mScene->findBody("1st")->mNode->scale(4.0f,1.0f,2.0f);
mScene->findBody("1st")->setAngularDamping(0.0f);
mScene->findBody("1st")->setLinearDamping(0.0f);
mScene->findBody("1st")->mShape[0]->mMaterial->setBounce(0);

mScene->createBody(
"2nd",
"cube.1m.mesh",
new nxOgre::cubeShape(Vector3(1.0, 0.1, 1.0), Vector3(0, 0, 0), aMaterial),
100.0f,
Vector3(1.5f,2.052f,0.0f)
);
mScene->findBody("2nd")->mNode->scale(1.0,0.1,1.0);
mScene->findBody("2nd")->setAngularDamping(0.0f);
mScene->findBody("2nd")->setLinearDamping(0.0f);
mScene->findBody("2nd")->mShape[0]->mMaterial->setBounce(0);

mJointLeftRight = mScene->createMotorisedJoint(
mScene->findBody("1st"),
mScene->findBody("2nd"),
Vector3(1.5f,2.051f,0),
Vector3(0,1,0),
true);
mJointLeftRight->setVelocityTarget(0.0);

mScene->createBody(
"3rd",
"cube.1m.mesh",
new nxOgre::cubeShape(Vector3(4.0f,0.5f,2.0f), Vector3(0, 0, 0), aMaterial),
100.0f,
Vector3(0.0f,2.352f,0)
);
mScene->findBody("3rd")->mNode->scale(4.0f,0.5f,2.0f);
mScene->findBody("3rd")->setAngularDamping(0.0f);
mScene->findBody("3rd")->setLinearDamping(0.0f);
mScene->findBody("3rd")->mShape[0]->mMaterial->setBounce(0);

mJointUpDown = mScene->createMotorisedJoint(
mScene->findBody("2nd"),
mScene->findBody("3rd"),
Vector3(1.5f,2.351f,0),
Vector3(0,0,-1),
false);
mJointUpDown->setVelocityTarget(0.0);
mJointUpDown->setFreeSpin(true);

mScene->createBody(
"4th",
"cube.1m.mesh",
new nxOgre::cubeShape(Vector3(4.0f,0.4f,1.9f), Vector3(0, 0, 0), aMaterial),
100.0f,
//Vector3(0.0f,2.367f,0)
Vector3(-1.0f,2.367f,0)
);
mScene->findBody("4th")->mNode->scale(4.0f,0.4f,1.9f);
mScene->findBody("4th")->setAngularDamping(0.0f);
mScene->findBody("4th")->setLinearDamping(0.0f);
mScene->findBody("4th")->mShape[0]->mMaterial->setBounce(0);

mJointInOut = mScene->createJoint(
new nxOgre::cylindricalJoint(
mScene->findBody("3rd"),
mScene->findBody("4th"),
Vector3(1.5f,2.351f,0),
Vector3(1,0,0))
);


mJointUpDown->setMaxForce(10000000000000000000000000000000000000.0);

mJointUpDown->setVelocityTarget(-0.5);

std::cout << "\n############################# DEBUG ############################\n\n";
std::cout << "Mass 1st: ";
std::cout << mScene->findBody("1st")->getMass();
std::cout << "\n";
std::cout << "Mass 2nd: ";
std::cout << mScene->findBody("2nd")->getMass();
std::cout << "\n";
std::cout << "Mass 3rd: ";
std::cout << mScene->findBody("3rd")->getMass();
std::cout << "\n";
std::cout << "Mass 4th: ";
std::cout << mScene->findBody("4th")->getMass();
std::cout << "\n";

betajaen

04-01-2007 19:41:55

Hmm. Interesting, Have you tried adjusting the damping to max?

tengil

05-01-2007 13:04:33

Hi!

First I don't know how to get the JointDesc out of the MotorisedJoint to change the damping, so I edited the NxOgre\source\nxOgre_joint.cpp (only for testing). Still the same behavior... Any other idea?

best regards
Tengil




motorisedJoint::motorisedJoint(body *_first, body *_second, Ogre::Vector3 _anchor, Ogre::Vector3 _axis, bool _collisions) : joint(joint::MOTORISED_JOINT,_first,_second) {
NxRevoluteJointDesc mJointDesc;
mJointDesc.actor[0] = mFirst->mActor;
mJointDesc.actor[1] = mSecond->mActor;

mJointDesc.setGlobalAnchor(NxTools::convert(_anchor));
mJointDesc.setGlobalAxis(NxTools::convert(_axis));

if (_collisions) {
mJointDesc.jointFlags |= NX_JF_COLLISION_ENABLED;
}

mJointDesc.motor.maxForce = 1000;
mJointDesc.motor.velTarget = 0.15;
mJointDesc.flags |= NX_RJF_MOTOR_ENABLED;

// MY TEST... BEGIN
mJointDesc.spring.damper = NX_MAX_REAL;
// MY TEST... END

mJoint = static_cast<NxRevoluteJoint*>(mFirst->owner->mScene->createJoint(mJointDesc));
mJoint->userData = this;
}


motorisedJoint::motorisedJoint(body *_first, Ogre::Vector3 _anchor, Ogre::Vector3 _axis) : joint(joint::MOTORISED_JOINT,_first) {

NxRevoluteJointDesc mJointDesc;
mJointDesc.actor[0] = mFirst->mActor;
mJointDesc.actor[1] = NULL;

mJointDesc.setGlobalAnchor(NxTools::convert(_anchor));
mJointDesc.setGlobalAxis(NxTools::convert(_axis));


mJointDesc.motor.maxForce = 1000;
mJointDesc.motor.velTarget = 0.15;
mJointDesc.flags |= NX_RJF_MOTOR_ENABLED;

// MY TEST... BEGIN
mJointDesc.spring.damper = NX_MAX_REAL;
// MY TEST... END

mJoint = static_cast<NxRevoluteJoint*>(mFirst->owner->mScene->createJoint(mJointDesc));
mJoint->userData = this;
}

tengil

05-01-2007 13:20:21

This code also does not work (only slower)...


mScene->findBody("1st")->setAngularDamping(NX_MAX_REAL);
mScene->findBody("2nd")->setAngularDamping(NX_MAX_REAL);
mScene->findBody("3rd")->setAngularDamping(NX_MAX_REAL);
mScene->findBody("4th")->setAngularDamping(NX_MAX_REAL);

mScene->findBody("1st")->setLinearDamping(NX_MAX_REAL);
mScene->findBody("2nd")->setLinearDamping(NX_MAX_REAL);
mScene->findBody("3rd")->setLinearDamping(NX_MAX_REAL);
mScene->findBody("4th")->setLinearDamping(NX_MAX_REAL);

betajaen

05-01-2007 14:04:44

Hmm. At this point it seems to be a PhysX problem or misunderstanding of the SDK. Try asking on the Ageia's forum and see if they can help you.

tengil

06-01-2007 14:58:58

Thnx, i will do so.

tengil

06-01-2007 16:00:31

Hi!

It seems to be a known problem...

http://devsupport.ageia.com/ics/forum/Client/Common/ContentView.aspx?contentID=45759&PageNo=1&tmp=tmp#Content46344

Spring-like joint behaviour
This is even occuring when you simply chain 2 joints with just one DOF. It is just a matter of the mass relationship of the actors attached to the joints how big this "pull apart effect" will be. This issue is already on the todo list (at least it was at 2.6.0).
As it is now, real mechanics can't be simulated with real physical values and will therefore never act realistic, just almost hopefully. I also read about another user wanting to simulate a 6 axis industrial robot. In such an app this would help.
This is not unusual with an iterative solver, if you apply a sufficiently large impulse to part of the jointed object it can take a while for the impulse to propogate. Due to the solver not converging fast enough.

Possible solutions:

* Increasing the iteration count.

* Decreasing the mass/density of the walls.

* Turning on joint projection.

* Decreasing the impulse/spreading it across a period of time.

* Changing the topology of the joints, for example it may work better to attach all parts to the floor, rather than in a chain(eg floor=>roof instead of floor=>wall=>roof).

* Attaching the joints close the the center of mass of the parts.


best regards
Tengil