Tank simulation

DanielH

08-04-2008 16:11:46

Hey, I've got my terrain up and running now.

I have also created a "tank-like" vehicle with six wheels that is locked in a fixed steering angle.

However I does not move as I want it to. To steer i put a braking torque on the wheels on one side while applying the torque from the engine on the wheels on the other side. From the beginning this cause a very jagged motion . It kind of looked like the wheels lost and regained contact over and over, making it jump back and forth, which also make it bounce up and down until it flipped over :D

Since then I have changed the settings for the springs so that the wheels have better contact with the ground. But that didn't really solve the problem. What made things better is when I lowered the lateral stiffness. This makes the movement pretty decent, except for one thing, the tank now slides around on the terrain as if it was made of ice :(

Here is the code I've used to setup the tank.


NxOgre::Material* mat = m_scene->createMaterial("TankMat");
mat->setRestitution(0);
mat->setDynamicFriction(0.9f);
mat->setStaticFriction(0.9);

// Setup ShapeParams
NxOgre::ShapeParams sp;
sp.setToDefault();
sp.mFlags |= NX_SF_VISUALIZATION;
sp.mMass = 50000;
sp.mMaterial = mat->getMaterialIndex();

NxOgre::ActorParams ap;
ap.setToDefault();
ap.mMass = 50000;

// Create tank body
m_body = m_scene->createBody("Tank", new Cube(4, 1.5f, 8, sp), NxOgre::Pose(Vector3(50, 50, 50)), nrp, ap);
m_body->setSleepEnergyThreshold(0.0);
m_body->setCMassOffsetLocalPosition(Vector3(0,-2.0f,0));

NxTireFunctionDesc lngTFD;
lngTFD.extremumSlip = 0.01f;
lngTFD.extremumValue = 1.0f;
lngTFD.asymptoteSlip = 0.04f;
lngTFD.asymptoteValue = 0.6f;
lngTFD.stiffnessFactor = 100000000.0f;

NxTireFunctionDesc latTFD;
latTFD.extremumSlip = 0.01f;
latTFD.extremumValue = 1.0f;
latTFD.asymptoteSlip = 0.04f;
latTFD.asymptoteValue = 0.6f;
latTFD.stiffnessFactor = 5000000.0f;

NxSpringDesc sd;
sd.damper = 15000.0;
sd.spring = 50000.0f;
sd.targetValue = 0.05f;

NxOgre::WheelParams wp;
wp.setToDefault();
wp.mSuspension = sd;
wp.mMaterial = mat->getMaterialIndex();
wp.mSuspensionTravel = 1.5f;
wp.mLateralTireForceFunction = latTFD;
wp.mLongitudalTireForceFunction = lngTFD;

wp.mMass = 60;
wp.mInverseWheelMass = 1.0f / wp.mMass;

solaris1912

08-04-2008 22:43:20

the tank now slides around on the terrain as if it was made of ice

This problem can be solved by updating lateral and longitudal tire force functions in each frame. What I do is something like this.

On every frame



NxTireFunctionDesc tireFunc, tireFunc2;

tireFunc.stiffnessFactor = 10000000 / abs(mWheelset.backLeft->getNxWheelShape()->getAxleSpeed()) ;
mWheelset.backLeft->getNxWheelShape()->setLateralTireForceFunction(tireFunc);

tireFunc2.stiffnessFactor = 1000000 / abs(mWheelset.backLeft->getNxWheelShape()->getAxleSpeed()) ;
mWheelset.backLeft->getNxWheelShape()->setLongitudalTireForceFunction(tireFunc2);

// do this for other 3 wheels...