rec.autos.simulators

Car physics

Andreas Ekstran

Car physics

by Andreas Ekstran » Mon, 30 Jul 2001 02:44:08

Hi there!

I've noticed that there are plenty of people who knows a great deal about
car physics in this newsgroup. So, I will try my luck with a couple of
questions for you. Bear with me if my post gets a bit loooong, but please
read it through.

I'm trying to develop my own little car simulator and so far I have just
implemented acceleration forces and weight transfer, i.e. my car can't brake
or turn.

I have one problem with my simulation and I was hoping that someone would
perhaps give me some answers. When I try to run the simulation at higher
frequencies, e.g. 60Hz, my car doesn't get anywhere. The reason is that
after the first frame, my engine speed drops to about 26 rpm. I start with
an engine speed of 2000 rpm and after one frame I calculate the new engine
speed according to the speed the car has reached in this frame. Something
like this:

wheelAngularSpeed = carSpeed / wheelRadius
engineSpeed = 60 * 1/2pi * wheelAngularSpeed * totalRatio

Is this a correct calculation do you think?

The rev drop decreases the acceleration force too much to overcome the
rolling resistance, which is about 130N. Maybe this resistance is too high?
I used Zuvich's approximation formula RX = 0.01(1 + V/100) * W, where V is
the speed in mph and W is the weight of the car in Newton. I have put a
restriction on the acceleration force so that it doesn't decrease below 0.
Otherwise, the car would go backwards in this simulation. Now it just goes
forward with the frightening speed of 0.23 km/h...

At lower frequencies, e.g. 10Hz, this is not a problem, since the linear
interpolation makes the speed rise to 0.78 km/h at the first frame, which
means that the rev drops down to 90 rpm. This makes a acceleration force of
145N which overcomes the rolling resistance force of 130N.

The following is some prints from my simulation at 60Hz:
Ntf is the combined gear and final ratio.
ntf is the total efficiency.
r is the wheel radius.
RX is the rolling resistance.
DA is the drag.
Tractive force is torque * Ntf * ntf / r
Facc is the acceleration force = torque * Ntf * ntf / r - RX - DA

0 km/h, 2000 rpm at 0 seconds
Torque at 2000 rpm: 163
Ntf: 12.8142
ntf: 0.7
r: 0.293
RX: 0
DA: 0
Tractive force: 4990.1
Facc: 4990.1

0.226823 km/h, 26.3136 rpm at 0.0166667 seconds
Torque at 26.3136 rpm: 2.63136
Ntf: 12.8142
ntf: 0.7
r: 0.293
RX: 129.807
DA: 0.00151679
Tractive force: 80.5567
Facc: 0

0.226823 km/h, 26.3136 rpm at 0.0333333 seconds
Torque at 26.3136 rpm: 2.63136
Ntf: 12.8142
ntf: 0.7
r: 0.293
RX: 129.807
DA: 0.00151679
Tractive force: 80.5567
Facc: 0

I hope someone could find the time to read this loooong post through and
answer some of my questions. If I was unclear in any part, please ask me to
explain it better.

Thanks in advance,
Andreas Ekstrand

Ruud van Ga

Car physics

by Ruud van Ga » Tue, 31 Jul 2001 22:37:23

On Sat, 28 Jul 2001 17:44:08 GMT, "Andreas Ekstrand"


>I'm trying to develop my own little car simulator and so far I have just
>implemented acceleration forces and weight transfer, i.e. my car can't brake
>or turn.

Welcome to the club. :)

No, sounds ok. Sounds like you either do something bad with the time,
multiplying something with 'dt' where you shouldn't, or you are not
caculating engine torque correctly. That last one is my first bet. Do
you have an engine torque that drives the wheels? If this torque
exceeds the 130N at the wheel's contact patch, it should be ok. And as
an engine might easily produce 200Nm, that would mean about
3x4x200=2400Nm at the wheel (3 and 4 are gear rations). As T=F*r, you
get F=T/r, so 2400Nm/0.33 (radius of wheel) ~ 7200N at the wheel's
contact patch. And 7200N >> 130N.
Somewhere in all this it goes wrong for you I think.

Good luck,

Ruud van Gaal, GPL Rank +53.25
Pencil art    : http://www.marketgraph.nl/gallery/
Free car sim  : http://www.marketgraph.nl/gallery/racer/

Matthew V. Jessic

Car physics

by Matthew V. Jessic » Wed, 01 Aug 2001 09:22:41


> I'm trying to develop my own little car simulator and so far I have just
> implemented acceleration forces and weight transfer, i.e. my car can't brake
> or turn.

> I have one problem with my simulation and I was hoping that someone would
> perhaps give me some answers. When I try to run the simulation at higher
> frequencies, e.g. 60Hz, my car doesn't get anywhere. The reason is that
> after the first frame, my engine speed drops to about 26 rpm. I start with
> an engine speed of 2000 rpm and after one frame I calculate the new engine
> speed according to the speed the car has reached in this frame. Something
> like this:

> wheelAngularSpeed = carSpeed / wheelRadius
> engineSpeed = 60 * 1/2pi * wheelAngularSpeed * totalRatio

> Is this a correct calculation do you think?

> The rev drop decreases the acceleration force too much to overcome the
> rolling resistance, which is about 130N.

engineSpeed = 60 * 1/2pi * wheelAngularSpeed * totalRatio

I assume wheelAngularSpeed is radians per second.
(This assumes that carSpeed and wheelRadius are in units of length/second
and  length. That is, make sure you aren't using kph or something for carSpeed.)

Once wheelAngularSpeed is in radians / second,
then I think your conversion from radians per sec to revolutions per minute
may be wrong.   It is   (60 / (2 * PI)) or about 9.55.
This may indeed be what you meant by your equation, but be wary
you use enough parentheses for your programming language ;)

Finally, setting engine speed like this means you have no engine dynamics.
The engine speed appropriate to a near zero speed at startup may indeed
be so slow as to stall the engine. What happens in real life is the driver
either declutches to reduce the torque dragging down the engine speed
or revs the engine prior to clutching or engaging first gear.
To make this work properly you need a lot more dynamics for the engine
and cluch.

One quick patch you could make is to filter the engineSpeed.
This will slow the engines response to gear / clutch changes
like your step down at starting and get you past this type of
problem for awhile. (This is actually a simplified version of
what adding all the dynamics mentioned above
would result in anyway ;)

The easiest filter to use may be a "first order low pass filter"
because you can use it in situations where the frame rate varies.
In the pseudo code below, "//" is a comment to end of line

engineSpeed_raw = (60 / (2 pi)) * wheelAngularSpeed * totalRatio

// constant for your application
// try 1.0 to 0.1 cycles per second or lower.
// higher values are more smoothing,
// lower is quicker response (less smothing)
cutoffFrequency = 0.5

// filter:
timeStep = time - time_previous     // this is in seconds
filterCoefficientA = exp(-TWO_PI * cutoffFrequency * timeStep)
filterCoefficientB = 1 - filterCoefficientA

engineSpeed = engineSpeed_previous * filterCoefficientA +
                        engineSpeed_raw * filterCoefficientB

engineSpeed_previous = engineSpeed

Whenever you add a filter, you should add code to "reset" the filter
whenever you do a step change to the filter state.
(For instance, if you have a "Reset" command that
starts the car back at starting states, the filter reset
would be:  engineSpeed_previous = engineSpeed )

Otherwise the filter will smooth in the step change you wanted to
take place instantly.

The filter coefficient equation above is exact and will automatically
correct for changing frame rates and maintain the same lag characteristics
for all. You can approximate the desired coefficient various ways
if you don't want to do the exponential each frame.

- Matt

Jim Seamu

Car physics

by Jim Seamu » Wed, 01 Aug 2001 09:22:48

Erm, it looks like your car is effectively stalling (I don't think internal
combustion engines work very well at 26 rpm...)

If everything "feels good" when you try it with a 5 mph rolling start then
maybe you might want to look at your clutch code and try to get underway
without being quite so brutal to your engine.

I'm no programmer but this is the way it looks to me :0)

Cheerio
Jim S


Jim Seamu

Car physics

by Jim Seamu » Wed, 01 Aug 2001 09:32:54

I've been drinking tonight but helpfully this will clarify my previous post,
I've no idea if either make sense, except to me :0)

This equation looks to be fine, but it does make several assumptions, such
as zero wheelspin, no skidding, car isn't airborne, car isn't cornering
(where carSpeed won't necessarily equal wheelSpeed) etc.

Another assumption is that the clutch isn't slipping. Some amount of clutch
slip (or alternatively wheelspin!) is necessary when moving off from a
standstill or you'll stall the engine. This is what's happening in your
sim - the clutch isn't modelled so the car stalls when you slam it into
first gear. I think. :0)

Hope that helps
Jim

Andreas Ekstran

Car physics

by Andreas Ekstran » Thu, 02 Aug 2001 06:12:47

Yep, that's exactly what I meant - the following is what I wrote in the real
code:
rpm = (60.0/(2.0*M_PI) * vx_/r) * Ntf;
vx_ is the speed in the x direction, r is the wheel radius and Ntf is the
total ratio.

Yes, I realize that. I thought I could omit the clutch for now though, and
get a fairly realistic behavior anyway. So now I have cheated a bit and
assumes that the engine delivers torque even at 0 rpm. What do you think
about that approximation?

Thanks a lot for the filtering function! I will try it out as soon as I find
the time to hack away again.

/Andreas

Andreas Ekstran

Car physics

by Andreas Ekstran » Thu, 02 Aug 2001 06:33:14

Yes, I know. I haven't modelled cornering yet. Neither have I given it any
thought about the differential, which is the reason why carSpeed won't
always be the same as wheelSpeed, I guess? My plan is to refine the model
gradually. But dont' get me wront, I really appreciate these thoughts! They
really help to think about every aspect of this complicated task. I heard
someone say that developing a car simulator is twice as hard compared to
developing a flight simulator. Well, I guess that's not entirely
exaggerated... :-)

Yes...so maybe I'll just have to model the clutch? Can you see any way to
make the behaviour fairly realistic without this, until I find the energy to
implement the clutch?

Thanks!
/Andreas

Jim Seamu

Car physics

by Jim Seamu » Thu, 02 Aug 2001 09:28:35


Just start your test at 5 mph? That way you can avoid the awkward "getting
going" bit which won't really work without a clutch I don't think... Ruud,
Gregor, Ash, Todd and a whole bunch of others are really the best people to
ask :0)

Cheers
Jim

Gregor Vebl

Car physics

by Gregor Vebl » Thu, 02 Aug 2001 15:34:48


> Yes, I know. I haven't modelled cornering yet. Neither have I given it any
> thought about the differential, which is the reason why carSpeed won't
> always be the same as wheelSpeed, I guess? My plan is to refine the model
> gradually. But dont' get me wront, I really appreciate these thoughts! They
> really help to think about every aspect of this complicated task. I heard
> someone say that developing a car simulator is twice as hard compared to
> developing a flight simulator. Well, I guess that's not entirely
> exaggerated... :-)

Indeed, that should be true. In a flight sim the application of forces
is straightforward, as they all just act in a very numerically stable
way (they go to 0 with velocity), so it's much easier. That's if you
fudge the taxiing behaviour of course, which effectively makes it a car
sim :).

To do it properly you do need a clutch. However, if purely for gameplay
reasons, as clutches aren't that common on wheels these days, just make
the available torque nonzero for 0 RPM. It's a fudge practically all
sims out there make, so why can't we as well :)?

-Gregor

Ruud van Ga

Car physics

by Ruud van Ga » Thu, 02 Aug 2001 19:47:19

On Wed, 01 Aug 2001 08:34:48 +0200, Gregor Veble


>To do it properly you do need a clutch. However, if purely for gameplay
>reasons, as clutches aren't that common on wheels these days, just make
>the available torque nonzero for 0 RPM. It's a fudge practically all
>sims out there make, so why can't we as well :)?

Well, WSC will probably stall as one of the few sims. :)
I just ordered a fullblown Force RS wheel with RS Shifter and clutch
pedal thingy. Couldn't find it up until today, and even then I was
lucky when there was this checkmark stating 'you want a clutch pedal
with that?'. :)
Will take a month probably to arrive, but hm, the fun starts! Or at
least, the programming, to get the Act Labs shifter and clutch pedal
to work (when I have it, I surely have to get it working right).

Ruud van Gaal, GPL Rank +53.25
Pencil art    : http://www.marketgraph.nl/gallery/
Free car sim  : http://www.marketgraph.nl/gallery/racer/

J. Todd Wass

Car physics

by J. Todd Wass » Fri, 03 Aug 2001 08:59:26

  That's a good way to do it.  Let the engine deliver torque even at 0 rpm.
What I did (before I did a clutch model) was seperate the "displayed" engine
speed from the true engine speed.  They'd be equal unless the true engine speed
dropped below 1500 rpm or whatever.  Then, the displayed rpm would stick there.
 If you've got sound in yet, then run the sound off the displayed engine speed.
 It works just like a clutch then, you can't tell much difference.
Todd Wasson
---
Performance Simulations
Drag Racing and Top Speed Prediction
Software
http://PerformanceSimulations.Com

Uwe Schuerka

Car physics

by Uwe Schuerka » Sat, 27 Oct 2001 22:32:30



>> I'm trying to develop my own little car simulator and so far I have just
>> implemented acceleration forces and weight transfer, i.e. my car can't brake
>> or turn.

Sorry to follow up on such an ancient post, but with so many
creative, talented developers in this group why don't you concentrate
your efforts on one product, so that re-inventing the wheel can
be prevented? I think "Racer" by Ruud van Gaal is the most advanced
free car sim out there, so it would be cool if people would pour
their energy into this one, write extensions, converters, AI and
what not.

What's everybody's take on this? I cannot imagine the rifts between
sim authors being as deep as the "emacs vs. vi" crowd, for instance,
so there should be a way for all to get along, no?

cheers,

uwe

Ashley McConnel

Car physics

by Ashley McConnel » Sat, 27 Oct 2001 22:04:48

Hi Uwe,

I am trying to develop a sim of my own.  I love what Ruud has done, it is
awesome in such a small amount of time too,  I am sure it will develop into
one of the great sims of all time.  Ruud has helped me a number of times
with physics questions and I have helped him a few times (i hope).  The
reason I don't really want to combine efforts with anyone else (yet?) is
that I am doing this as much for the learning experience as anything else.
I guess its kind of selfish to some extent, but I would like to learn enough
myself so that I could set up a small company some time in the future and
develop racing sims full time.

All the "physics" guys have been great to one another when anyone has needed
help.  I think that having people doing different race-sims is ultimately
great for the sim-racing community, and the fact that we call call upon each
other's knowledge as it grows will increase the quality for everyone :).

Sometimes reinventing the wheel leads to a better wheel :)  or at least a
better tyre model <G>

All the best,
Ash - who must start some hard work on his sim again and stop farting about
with his new***pit :)

|
| Sorry to follow up on such an ancient post, but with so many
| creative, talented developers in this group why don't you concentrate
| your efforts on one product, so that re-inventing the wheel can
| be prevented? I think "Racer" by Ruud van Gaal is the most advanced
| free car sim out there, so it would be cool if people would pour
| their energy into this one, write extensions, converters, AI and
| what not.
|
| What's everybody's take on this? I cannot imagine the rifts between
| sim authors being as deep as the "emacs vs. vi" crowd, for instance,
| so there should be a way for all to get along, no?
|
| cheers,
|
| uwe

Carol Bekke

Car physics

by Carol Bekke » Sat, 27 Oct 2001 23:21:53

I think you will find that currently Ruud isnt actually looking for people
to take the code away and add to it, its still a personal project from Ruud
but one that we can join in by creating assets for it in the way of cars and
tracks. Its a learning process for Ruud as it is for the other chaps
developing sims in here, and I think ras is a nice place for them to trade
thoughts and ideas, without giving up the fun they are having in creating
their own sims.





> >> I'm trying to develop my own little car simulator and so far I have
just
> >> implemented acceleration forces and weight transfer, i.e. my car can't
brake
> >> or turn.

> Sorry to follow up on such an ancient post, but with so many
> creative, talented developers in this group why don't you concentrate
> your efforts on one product, so that re-inventing the wheel can
> be prevented? I think "Racer" by Ruud van Gaal is the most advanced
> free car sim out there, so it would be cool if people would pour
> their energy into this one, write extensions, converters, AI and
> what not.

> What's everybody's take on this? I cannot imagine the rifts between
> sim authors being as deep as the "emacs vs. vi" crowd, for instance,
> so there should be a way for all to get along, no?

> cheers,

> uwe

Sebastien Tixie

Car physics

by Sebastien Tixie » Sun, 28 Oct 2001 00:30:19

hi,

i'm also doing my own car simulators ;o)

I doing it for me , it's not a project developed to do a game, and released it, i'm
doing it just because i like programming physics stuff to develop my knowledge on
the subject.

So use other people code doesn't interrested me.

regards,

--
Sebastien TIXIER - Game Developer
Dynamics and Car Physics
http://www.eden-studios.fr
GPLRank Normal:-44.24 Monster:-124.44


rec.autos.simulators is a usenet newsgroup formed in December, 1993. As this group was always unmoderated there may be some spam or off topic articles included. Some links do point back to racesimcentral.net as we could not validate the original address. Please report any pages that you believe warrant deletion from this archive (include the link in your email). RaceSimCentral.net is in no way responsible and does not endorse any of the content herein.