Real Car Physic

This topic is 2055 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi everyone,

I want to make a car simulator long time ago, and the first step is the car's physic.
I'm not so good at physic so I need your helps.

The first thing that I'd like to implement is the velocity and braking. I want a realistic physic and I want customizable cars, so the datas which are known:
- engine: power (in Kw or Hp) (...?)
- gear: ratios
- other things that are necessary

So I want that I control only the gas-pedal from the code. I give a little gas, the engine gives power, the gear and differential reduce / increment the power / RPM(?), etc. and the wheels start turning which moves the car forward (or just spinning)

I know that I know nothing so I hope someone could help me.

Share on other sites
Well, the torque of the engine is a function of the gas pedal position the current revs and the gear. The acceleration of the car is proportional to the torque. You could also consider the torque of inertia of the wheels and the friction of the wheels on the ground.

Share on other sites
I've started searching and I've found some basic forces:
- forceSum = 0
- the car's air resistance:
 cDrag = 0.5f * frictionCoiffient * frontalArea * AIR_DENSITY; fDrag = -velocity * speed * cDrag; AddForce(fDrag); 
- the car's rolling resistance:
 cRR = cDrag * 30.0f; fRResistance = -velocity * cRR; AddForce(fRResistance); 

Now I'll get the engine's force by the torque. My first idea is:
- Because the RPM/Torque curve isn't linear, I'll create an approximation: I'll pick some pairs: RPM - Torque, and I'll interpolate between this values.
- I'll multiply the engine's force (torque) by the gear and differential ratio, so I'll get the front wheels' torque

Yet, I don't know what I can do with these values (compute the wheels' speed from the torque, or the force which effects to the ground, ...).

Share on other sites

- the car's rolling resistance:
 cRR = cDrag * 30.0f; 

ouch.. rolling resistance 30x air drag? Somebody must have put sticky glue on your tyres
That can't be right, RR is a tiny fraction of air drag... recheck your sources.

Also in your air drag formula there is "speed" and "velocity".. I assume you are working in 1D right now so, what's the difference between the 2?

Share on other sites
if you divide the torque by the radius of the wheels you get the force driving the car.

but i do not understand why you calculate the rolling with the cDrag constant. It is rather dependent on the weight of the car, the wheel radius and the material. It also should be independent of the velocity.

edit: Ah i get it, the velocity is the direction and the speed the absolute value, right? Edited by Inferiarum

Share on other sites
I used this tutorial: http://regedit.i365.pl/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html
and some formula from the Physic of Racing series

The velocity is a vector-value, so it has a direction. The speed is the length of the velocity.

The force of drag is: http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=ccs&attach_id=3917
and the rolling resistance is: http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=ccs&attach_id=3920
but in the first tutorial, he writes that the rolling resistance is the drag resistances times 30.

Share on other sites
In the wiki article the rolling resistance is assumed to be constant with respect to the velocity, but well, i guess that is not that important an can be tested later on.

To simulate the car I would calculate the resulting forces for every wheel and with that the resulting change in velocity and angular momentum of the car

Share on other sites
ya you are right, I thought it was multiplying the fDrag but it is not, my bad.
Still that RR calculation doesnt make any sense, RR is function of load on the tyre, velocity and slip... no relationship at all with air drag.

Share on other sites

ya you are right, I thought it was multiplying the fDrag but it is not, my bad.
Still that RR calculation doesnt make any sense, RR is function of load on the tyre, velocity and slip... no relationship at all with air drag.

In the tutorial he mentioned it is just used as a rough estimate. I mean you have to use some number.

Share on other sites
Yes, the cRR is a rough estimate But okay, I'll read more about the rolling resistance.

Suppose that I computed the air resistance (like now) and for each wheel the rolling resistance, slipping and the most important: forces (from the wheel's torque didided by the radius, Like Inferiarum wrote). Then should I have to compute a world matrix from the 4 wheels values? So I know the CG (Center of Gravity) and the position and forces of wheels, then compute a world matrix? Because I have to render the model which needs a world matrix. But if I use only the forces of wheels, where comes on the gravity and the other forces?

I've learnt (long time ago in a galaxy far far away ) that the resultant (force) is the sum of the forces, so the velocity + gravity + etc. But if the car is drifting, the rear wheels are sliding and if I sum the forces, I'll have a "translation", not a "rotation". Or I don't know how I should write my problem

EDIT:
Oh, and thanks for your replies. Edited by csisy

Share on other sites
I would probably first consider a planar problem where gravity is not important.

Ok, this is how I would do it.

The car is a rigid rectangle and the wheels are at the corners. The car has a certain translational and angular momentum, resulting in a certain velocity of the rectangle corners. Depending on the direction of the wheels and the velocity of those corners forces can be calculated which change the momenta.

Now repeat this every simulation step.

Share on other sites
Okay, and generally:
Every object have a CG point, and when I want to apply a force, I have to define a point also where the force "begins". Then I compute the distance between this point and the CG.
- If the distance is zero or the "ray" of the force intersects the CG then the transform is a translation.
- Else, I create a torque from the distance and the force (?) then compute the angular velocity from a formula, and create a rotation transform with CG center
?

It can't be true, because if I turn the front wheels for example right, the rear of the car won't turn left. So could my idea be true for a rigid body and can't I create a general physic object?

Share on other sites

Okay, and generally:
Every object have a CG point, and when I want to apply a force, I have to define a point also where the force "begins". Then I compute the distance between this point and the CG.
- If the distance is zero or the "ray" of the force intersects the CG then the transform is a translation.
- Else, I create a torque from the distance and the force (?) then compute the angular velocity from a formula, and create a rotation transform with CG center
?

It can't be true, because if I turn the front wheels for example right, the rear of the car won't turn left. So could my idea be true for a rigid body and can't I create a general physic object?

You have to split the forces at the wheels in two components, one pointing away from the CG and one orthogonal to that. The first will change the translational momentum the second will change the angular momentum.

if you turn the front wheels right and the rear wheels are on ice, i.e., have no friction, they will turn left. But there is a force of friction working against that.