I am trying to model my tyres as springs / dampers, but I am having big
problems with stability :( I have upped my frequency to 1000Hz, but still
no difference.
Here is what I do: -
1. Add a force to the car at its CoG representing the weight
2. Allow the car to sink into the ground
3. Calculate the upward force based on the distance the tyre has squashed
(i.e. how far it has sank into the ground)
4. Calculate a damping force based on the vertical velocity of the tyre.
I am using a Spring value of 60000 and a damping value of 6000
When I turn a corner it starts bouncing terribly and soon goes out of
control. If you want to see what happens have a look at
http://www.racesimcentral.net/~ashley.mcconnell/demo/demo011.zip (use q/a/o/p
and 1/2 to change gear). WARNING - it aint pretty, and there are some
horrible keyboard issues to be resolved :)
Here is the code in question (horribly formatted in the pasting process) : -
void CTyre::CalcFz()
{
groundReaction = Vector3(0.0f,0.0f,0.0f);
Vector3 groundReactionTYRE;
//Get the distance that the tyre has sunk into the ground
height = GetDistanceFromPatchToGround();
//Check if our force has made the sign change (it shouldnt)
if ((lastTyreVel) && (velTyreTyre.y<0)) {
velTyreTyre.y = 0;
}
if ((!lastTyreVel) && (velTyreTyre.y>0)) {
velTyreTyre.y = 0;
}
if (velTyreTyre.y>0) {
lastTyreVel = true;
}
else {
lastTyreVel = false;
}
//Reset the tyre force to zero
tyreForceTYRE.z = 0.0f;
if (height<0){
groundReaction.y = (tyrestiffness * -height);
//Do a little damping
groundReaction.y += (velTyreTyre.y * -tyredamper);
tmpDampingForce = (velTyreTyre.y *-tyredamper);
}
else {
//We are off the ground
groundReaction.y = 0.0f;
tmpDampingForce = 0.0f;
}
tyreForceTYRE.add(groundReactionTYRE);
FzKN = tyreForceTYRE.z / 1000.0f;
Can anyone see anything obvious that I am doing wrong?
Ash
http://www.racesimcentral.net/