This is what I currently have after reading articles regarding the issue. It works a little bit, except it still sinks a small distance and when dropped from a height it will add too much force and bounce the rigid body really high.
//Calculate wheel base ratio, using distance of front/rear tire base length,
// and current tire base to center of mass along the wheel base line
float flWheelBaseLength = 20.0;
float flWheelBaseCenter = 10.0;
float flWheelBaseRatio = (flWheelBaseCenter / flWheelBaseLength) * 0.5; //halved for single tire
//Calculate depth ratio from 0.0 to 1.0, 1.0 being center of tire
float flRadius = 6.0;
float flGroundDistance = 5.0;
float flDepth = (flRadius - flGroundDistance) / flRadius;
//Extract velocity along ground normal
Vector vDownVelocity = DotProduct( vVelocityAtTire, vGroundNormal ) * vGroundNormal;
//Point it upward.
Vector vUpVelocity = vDownVelocity * -1;
Hiya OneEyed. I know a fair bit about vehicle simulation so maybe I can help you out. Your calculations aren't making much sense viewed out of context though. Could you give a higher level overview of how you are handling your vehicle simulation and where these calculations fit in to that scheme?
Hiya OneEyed. I know a fair bit about vehicle simulation so maybe I can help you out. Your calculations aren't making much sense viewed out of context though. Could you give a higher level overview of how you are handling your vehicle simulation and where these calculations fit in to that scheme?
I'm working on the Source engine that uses the Havok Physics Engine.
I get the velocity at the tire base of the rigid body, and at the end of the calculation I add the new force to the tire base offset of the rigid body.
The problem lies when the angle between velocity and plane normal are within 90 degrees, there is no force pushing into the plane. This causes the tires to sink a bit.
The normal force exerted by the ground plane is independent of the car's velocity. However, it may affect the resulting velocity of the car, but not the other way around.
FN = mg cos(a)
Where, a is the slope angle of the surface.
Working with vectors, normal force vector is basically the weight force multiplied by the normal vector N at the contact point. When working with wheels, the weight force must be distributed at each wheel using a mass ratio, zm.
FN = zm mg N
You need to feed that back into the integrator. We are assuming the vehicle is resting or, continually in contact with the surface. If the vehicle is separated from the surface, you will need to apply impulse physics when the tyre patch collides with the surface.
In a nutshell, you always add the weight force onto the car (to make it fall down). If the car is not in contact with the surface, you test when the collision occurs and apply some kind of an impulse response to the system when the collision occurs. Once the contact patch is continually touching the surface, you apply the normal force onto the body as outlined above. This should counteract the constant weight force the car is experiencing. If the car is on a slope, depending on frictional forces the car should slide down.
The vehicle velocity plays a big role in longitudinal and lateral tyre dynamics - i.e. slip and traction on the surface, aka the frictional force.
Working with vectors, normal force vector is basically the weight force multiplied by the normal vector N at the contact point. When working with wheels, the weight force must be distributed at each wheel using a mass ratio, zm.
FN = zm mg N
The mass ratio. Is that ratio of the wheel bases to center of mass?
You need to feed that back into the integrator. We are assuming the vehicle is resting or, continually in contact with the surface. If the vehicle is separated from the surface, you will need to apply impulse physics when the tyre patch collides with the surface.
In a nutshell, you always add the weight force onto the car (to make it fall down). If the car is not in contact with the surface, you test when the collision occurs and apply some kind of an impulse response to the system when the collision occurs. Once the contact patch is continually touching the surface, you apply the normal force onto the body as outlined above. This should counteract the constant weight force the car is experiencing. If the car is on a slope, depending on frictional forces the car should slide down.
The vehicle velocity plays a big role in longitudinal and lateral tyre dynamics - i.e. slip and traction on the surface, aka the frictional force.
The problem is when the vehicle is in motion. Let's say the car is moving towards an incline, on first contact with the ramp the tires will experience a force greater than gravity. What your saying is that this collision needs to be calculated separately?
The tire up force comes from the collision. The deeper the collision, the bigger the force. So if you hit a ramp, due to the mass and inertia of the car, the collision depth will be bigger on the first wheels (since the car tries to move in a straight line, and does so in the simulation). So: you have your shock like force.
Take a look at the tank simulator in my youtube channel (signature). The tire up force is calculated from the collision depth (like spring force), and a dumping force. This damping force is proportional to the collision velocity (ratio is smaller than one, thus the force always tries to slow the motion down).
Those are the two components of the "tire force". I'm not calculating any constant force like the others have suggested. The force only comes from the collision. The gravity pulls the tank down, so the collision depth increases. This means the tire up forces will increase too, untill equlibrium is reached (more precisely it will oscillate around the equilibrium with decreasing amplitude due to the damping force).
And I can say that the tank's behaviour looks pretty good in the demo...(note, that I'm using springs instead of tires, and the wheels are just placed to touch the ground).