rec.autos.simulators

Car Physics : Constant Timestep

alex

Car Physics : Constant Timestep

by alex » Tue, 01 Jan 2002 10:56:27




>> I understand what you're taking is the step of the differential net
>> (not sure I am giving correct translation of the term, that's a method
>> of approximation of continuous process with discrete one) and not
>> periodicity of updates.

> Umm... possibly, but I'm not sure I understand what you're saying here.
> :-)
>> If you're capable of resolving your model
>> analytically, you won't have inaccuracies at all (except caused
>> by floating point calculations).

> True, but I can't think of any part of the equations of motion of a
> rigid body that could be solved analytically under randomly varying
> forces, so numerical integration would seem to be necessary.

>> Stability is only applicable to approximate methods and has
>> nothing to do with the frequence of updates.

> All the numerical integration methods I know of (euler, midstep,
> 4th-order runge-kutta, etc.) depend on a sufficiently small timestep
> for stability. If I have a tire in my simulation that has a vertical
> stiffness of 500,000 N/m, it'll very easily start to oscillate and
> eventually fly all the way to Jupiter and back, if the timestep doesn't
> stay sufficiently small, so stability definitely has everything to do
> with how often I update the physics! Or maybe I'm misunderstanding what
> you're saying.

>> What you are more interested in is convergence and precision.
>> The faster your approximate methods converge, faster you will get your
>> update made.

> Are you saying there's some sort of iterative way to integrate the
> equations of motion? Does that have something to do with implicit
> integration? That's something I'll have to look into, I guess.

>> I start to believe that you actually trying to use approximation
>> method based on discretisation(spelling?) of time and synchronize the
>> step of the net with the other components of the program.

> Could be, but I'm still not sure I understand what you mean by the
> "net" in this context. :-)

>> Let's say we're considering only one car driven by human. To display
>> current state to the driver you need to update physics first to
>> learn this state. Drawing will take some time and as long as you
>> can calculate next car state from the previous one you don't need to
>> know intermediate states.

> The problem is, how do I calculate the next car state from the previous
> one without those intermediate states, without inducing instability?
> Right now I calculate the physics at a fixed 500 Hz - if there really
> is some way to calculate the physics at rates as low as 30 Hz so that
> it remains stable, I definitely want to learn it! :-)

>> One reason why you may need another thread is to collect driver input
>> while you're updating physics and drawing screen. I am not sure
>> how noticable is it, but if for example, driver presses throttle
>> smoothly or abruptly, it should be taken into account by your
>> simulation, which may not happen if you're reading controllers only
>> once per update.

> Hmm. I guess that could be an issue.

> Petri Blomqvist

Let's say you have continuos implicitly defined function F(X,t) on
the [x0;x1]x[t0;t1]. For example, by equation G(F(X,t),X,t) = 0 where G is
too complex to find F explicitly. X does not have to be a scalar, but for
simplicity let's assume it is.

In this case one of the main numeric methods
is to define a "net" (sorry, english is not my first language, I don't
know the right term) as a set of "nodes" (x(i),t(j)) where i=0,N, j=0,M
Usually x(0)=x0, x(N)=x1, t(0)=t0, t(M)=t1.

x(i+1)-x(i) and t(j+1)-t(j) do not have to be a constant, but if they're
the next has fixed step.

There're many numeric methods that allow to calculate F(i,j) which
approximate F(X(i),t(j)) from the original equation.
Steps (of the "net") in this case
do not affect stability, by they're just points where you want to find
the value of F. The more iterations you do the better is approximation
(however this is not related to the timestep).

Instability may arise is your function is defined as something like
G(F(X,t),F(Y,t-dt))=0. Then if you calculated F(Y,t-dt) approximately
your error may grow. You could avoid it by saving all input and
recalculating from the starting point instead of previous state,
however implementation of that would face problems of memory requirement
to store input as well as performance issues.

AFAIK there're some methods to deal with this case. I don't know this
area well, but idea is that they use past states, but not the very
beginning. Each of the past states participate with a weight selected
some complex criteria that will ensure convergence. This way you
have more calculations to do to get every next step, however this
amount is fixed and is not growing, instead you can afford bigger
error in your approximation because it doesn't accumulate thus saving
some time.

With your original idea, you will still get error accumulation, no
matter how small is your step and you still need some kind of feedback
to prevent simulation from breaking down.

As I understant you're looking at this simulation from the point of
view of physics, mechanics and math analysis, but you need more to
make it work well. I am sorry I can not point to any particular place to
look for answers, but here're some directions. There's a part of
Applied Math that studies numerical solution for physics/mechanic
equations. There's another area of Applied Math that studies control
of the technical systems. At some point they overlap with each other,
and this one is a good area to look into. Now I am trying to guess
correct terms. They might be something like difference/differential
nets or grids or schemes, stability stuff have terms like feedback
and after-effect.

The problem is that those methods might be difficult to get into
unless you specialize in Math.

Concering rigid body simulation, I think I've heard about some
research done, so probably you can find ready to use methods.

Alex.

Petri Blomqvis

Car Physics : Constant Timestep

by Petri Blomqvis » Wed, 02 Jan 2002 03:56:13


If the frame rate is bad, your lightning-fast steering reflexes won't do
much good anyway because all you'll see is a slideshow, so what's the point
of reading the controller more often? (it's not exactly a fast operation,
and neither is updating sound, as far as I know, so it would seem to be best
to keep those updates at a sufficient minimum). I could be wrong, of course.
:-)

Well, if you need interrupts generated then you'd obviously use the
multimedia timer. If not, as is the case with my sim, the performance
counter would seem to be a better choice.

True. :-) The only reason I'm using the methods that I am is because the
others I tried didn't work and these do. If it turns out some other method
will work better, I'll switch to it without hesitation. :-)

Petri Blomqvist

Petri Blomqvis

Car Physics : Constant Timestep

by Petri Blomqvis » Wed, 02 Jan 2002 04:07:11


Thanks for the explanation, Alex! Will have to investigate that method. :-)

Petri Blomqvist

Ruud van Ga

Car Physics : Constant Timestep

by Ruud van Ga » Fri, 04 Jan 2002 03:15:21

On Mon, 31 Dec 2001 00:55:07 -0000, "Paul Laidlaw"


>> > It needs to coincide with realtime when you read the controller.

>> I read the controller once per animation frame, and I update sound once
>per
>> animation frame, so that's not a problem.

>And if your frame rate is bad? or variable?

You can do the same what you do with graphics to the controller
reading. Get a fixed timestep for the controller reads, and put an
extra
'if(curSimTime>=nextControllerReadTime)ReadControllers(),nextControllerReadTime+=0.01'
in there.

I believe GPL does this.

BTW I use the same swingy method; update controllers and sound just
every gfx frame. Seems ok.

Ruud van Gaal
Free car sim  : http://www.marketgraph.nl/gallery/racer/
Pencil art    : http://www.marketgraph.nl/gallery/

J. Todd Wass

Car Physics : Constant Timestep

by J. Todd Wass » Thu, 10 Jan 2002 08:57:54

  I think I tried something like this awhile back when trying to stabilize my
tires' rotation without decreasing the integration time step.  I averaged the
last 10 or so time steps' slip ratios together, then averaged that value with
the current calculated value, and used that for the slip ratio (it worked a
little like using relaxation lengths).  Is this at least a very basic example
of what you're talking about here, or am I misunderstanding the idea?
Actually, I think I allowed the current calculated value to have as much effect
as the previous 10 (or something like that), before averaging them and using
this final value (weighting?).

Todd Wasson
---
Performance Simulations
Drag Racing and Top Speed Prediction
Software
http://PerformanceSimulations.Com

My little car sim screenshots:
http://performancesimulations.com/scnshot4.htm

alex

Car Physics : Constant Timestep

by alex » Thu, 10 Jan 2002 14:34:08



In principle yes, though usually those methods are
much more complicated. Your method adds a lot of damping,
but I am not really familiar with tire rotation modelling,
so I can't comment on this particular usage. Essentially
you approximate function slip_ratio(t) with some function
constant on [t0;t1).

Alex.

Ruud van Ga

Car Physics : Constant Timestep

by Ruud van Ga » Thu, 10 Jan 2002 22:18:37





>>   I think I tried something like this awhile back when trying to
>>   stabilize my
>> tires' rotation without decreasing the integration time step. I
>> averaged the last 10 or so time steps' slip ratios together,
...
>In principle yes, though usually those methods are
>much more complicated. Your method adds a lot of damping,

Which is normally the thing to go for, at low speed. As long as you
turn it off when the thing starts rotating.
And that's fortunately what racing's all about. :)

It seems a more regular filter where there's some kind of inertia
attached to the changing of the value may be simpler and effective
enough for most car simulations (handling at low speed is generally of
lesser importance there).

Ruud van Gaal
Free car sim  : http://www.marketgraph.nl/gallery/racer/
Pencil art    : http://www.marketgraph.nl/gallery/

Matthew V. Jessic

Car Physics : Constant Timestep

by Matthew V. Jessic » Sat, 12 Jan 2002 11:24:42


> >Instability may arise is your function is defined as something like
> >G(F(X,t),F(Y,t-dt))=0. Then if you calculated F(Y,t-dt) approximately
> >your error may grow. You could avoid it by saving all input and
> >recalculating from the starting point instead of previous state,
> >however implementation of that would face problems of memory requirement
> >to store input as well as performance issues.

> >AFAIK there're some methods to deal with this case. I don't know this
> >area well, but idea is that they use past states, but not the very
> >beginning. Each of the past states participate with a weight selected
> >some complex criteria that will ensure convergence. This way you
> >have more calculations to do to get every next step, however this
> >amount is fixed and is not growing, instead you can afford bigger
> >error in your approximation because it doesn't accumulate thus saving
> >some time.

>   I think I tried something like this awhile back when trying to stabilize my
> tires' rotation without decreasing the integration time step.  I averaged the
> last 10 or so time steps' slip ratios together, then averaged that value with
> the current calculated value, and used that for the slip ratio (it worked a
> little like using relaxation lengths).  Is this at least a very basic example
> of what you're talking about here, or am I misunderstanding the idea?
> Actually, I think I allowed the current calculated value to have as much effect
> as the previous 10 (or something like that), before averaging them and using
> this final value (weighting?).

An averaging filter like that will have very high variations
in frequency response at different frame rates also.

At the high frame rates you are using it the change
won't be significant, but at normal PC game frame
rates it could be very serious.
I saw someone using that for a joystick filter once
which would be very bad.

- Matt

J. Todd Wass

Car Physics : Constant Timestep

by J. Todd Wass » Mon, 14 Jan 2002 09:51:35

  Ok, at least I'm following the basic idea. High level math isn't my best area
:0)  Stuff like this makes no sense to me:

  Huh??  lol  

Todd Wasson
---
Performance Simulations
Drag Racing and Top Speed Prediction
Software
http://PerformanceSimulations.Com

My little car sim screenshots:
http://performancesimulations.com/scnshot4.htm

J. Todd Wass

Car Physics : Constant Timestep

by J. Todd Wass » Mon, 14 Jan 2002 09:54:25

  I'm mostly just curious for stability reasons and to make sure the car stops
properly.  My low speed torsion spring model works pretty well for this, but
it's tough to adjust properly.  My little 4WD radio controlled cars can have
exploding drivetrains rather quickly, and that's with the center diff locked...
 Was curious about other approaches (as always.)

Todd Wasson
---
Performance Simulations
Drag Racing and Top Speed Prediction
Software
http://PerformanceSimulations.Com

My little car sim screenshots:
http://performancesimulations.com/scnshot4.htm

J. Todd Wass

Car Physics : Constant Timestep

by J. Todd Wass » Mon, 14 Jan 2002 10:00:53

  Oh, ok..  Will keep an eye out for that.  I'm not using the filter now, this
was before the low speed torsion spring was put in..
Todd Wasson
---
Performance Simulations
Drag Racing and Top Speed Prediction
Software
http://PerformanceSimulations.Com

My little car sim screenshots:
http://performancesimulations.com/scnshot4.htm


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.