Sign in to follow this  
csisy

Real Car Physic

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:
- wheels position, radius
- 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 this post


Link to post
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 this post


Link to post
Share on other sites
I've started searching and I've found some basic forces:
- forceSum = 0
- the car's air resistance:
[CODE]
cDrag = 0.5f * frictionCoiffient * frontalArea * AIR_DENSITY;

fDrag = -velocity * speed * cDrag;
AddForce(fDrag);
[/CODE]
- the car's rolling resistance:
[CODE]
cRR = cDrag * 30.0f;

fRResistance = -velocity * cRR;
AddForce(fRResistance);
[/CODE]

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 this post


Link to post
Share on other sites
[quote name='csisy' timestamp='1341942654' post='4957682']
- the car's rolling resistance:
[CODE]
cRR = cDrag * 30.0f;
[/CODE]
[/quote]

ouch.. rolling resistance 30x air drag? :P Somebody must have put sticky glue on your tyres :D
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 this post


Link to post
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 this post


Link to post
Share on other sites
I used this tutorial: [url="http://regedit.i365.pl/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html"]http://regedit.i365.pl/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html[/url]
and some formula from the [url="http://www.gamedev.net/page/resources/_/technical/math-and-physics/the-physics-of-racing-part-9-straights-r1618"]Physic of Racing[/url] 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: [url="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=ccs&attach_id=3917"]http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=ccs&attach_id=3917[/url]
and the rolling resistance is: [url="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=ccs&attach_id=3920"]http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=ccs&attach_id=3920[/url]
but in the first tutorial, he writes that the rolling resistance is the drag resistances times 30.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
[quote name='kunos' timestamp='1341946987' post='4957730']
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.
[/quote]

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

Share this post


Link to post
Share on other sites
Yes, the cRR is a rough estimate [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] 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 [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]) 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 [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]

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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
[quote name='csisy' timestamp='1341985504' post='4957897']
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?
[/quote]

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this