Jump to content

  • Log In with Google      Sign In   
  • Create Account


[Car Physics] Sharing work, ideas, formulas and car parameters


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
37 replies to this topic

#1 PochyPoch   Members   -  Reputation: 155

Like
0Likes
Like

Posted 26 September 2012 - 08:01 PM

Hi again to everyone

I noticed we are now at least 3 on this forum, trying to create a proper car simulation. It seems everyones main goal is to create something fun (drifts...), based on realistic physics, but not too hard for the player. So closer to something like GRID than Forza.

I think i am right when i say this : we all want the kind of fun we can find in games like NFS. If a game like NFS or GRID (or even the Steam racing casual games) can only be achieved by using some cheats or specific player input tweaking, i suppose we all want to know what they are.

What i propose here is :
  • Share the fundamental basics every car simulation based on newton physics should have. eg : weight transfer, pacejka-like curves for getting output of SR/SA....
  • Share one or two basics car models and parameters to be sure we are talking about the same thing.
  • Share some reference values/behaviours in predetermined situations, so that everyone can compare their own values with some reference to know if things are going right or wrong.
  • Share math/physics formula, tips & tricks, or cheats & shortcuts that would allow us to make the game more fun. Because we must not forget, it is all about fun in the end.
I would try to maintain the first post as updated as possible as people bring their contributions. So if this thing is going well, it could be a very good starting point in the future for programmers wanting to create their own car simulation.

I'll start to fill the blanks, and i hope the car experts will bring their knowledge to be sure future readers won't be misleaded by the things listed here.

One of the goals here is to cover 2D and 3D games, as the car behaviour will be similar in both situations.

Part 1 - What should i absolutly do to make this a fun game with drifts, skids and such things ?

Let's make an exhaustive list of things needed to achieve a drifting behaviour on a racing car.
  • Get basic newton physics right : forces, acceleration, torque, integration. You can use a physics engine for this, like box2d or PhysX.
  • At first use a 1ms timestep to update the simulation at a decent rate and avoid bad approximations.
  • Create 4 wheels and attach them to the body.
  • Use wheel distance to CG to calculate weight transfer lateraly and longitudinal. Combine those two.
  • Use real car suspension/springs/anti roll bars, or the weight transfer will just be instantaneous and make the car highly unstable.
    Subsidiary question : is it vital to have proper car suspensions ?
  • Use some "soft" player inputs, and try to limit steer angle at high speed to get good lateral forces, or the car might be totally uncontrolable. Or use realistic driving accessories.
  • Find out velocity for each wheel contact patch, transformed in the wheel space. So if the wheel is heading 45° and the car going straight, the front wheels will have both X/Y velocities, as rear wheels will only have Y (if Y is front).
  • Use the powered wheels velocity to determine motor RPMs. Based on player throttle input, and engine torque curve, generate a torque force for powered wheels.
  • Apply torque on wheel so it increase their angular velocity.
  • Calculate wheel slip angles and slip ratios.
  • Use a plotted pacejka curve, or a real formula to find out the normalized force the tire must produce front/lat.
    Subsidiary question : is it vital to have the original formula instead of a simple pre-plotted curve ?
    Subsidiary question : is it vital for nice drifting to have combined lateral/front formula ?
    Subsidiary question : is it vital for nice drifting to feed directly the real load to the formula ? If i multiply the normalized 1N value by the wheel Fz result is supposed identical right ?
  • Create a vector for front/lat forces, and check this vector on friction circle/ellipse. Cut any part which is not inside the circle.
    Subsidiary question : should ellipse max values be the same as pacejka normalized max values ?
  • You can now multiply the remaining vector by the wheel weight (Fz)
  • For the longitudinal component of the force, reintegrate it in the wheel (with the radius), so it decrease their angular velocity. That part is what makes the wheel angular velocity adapt to the car speed.
  • Apply the resulting forces to the body, at the attach point of the wheel, or directly the contact patch in 3D, and calculate resulting torque/acceleration on the body.
  • When 4 wheels have generated torque/forces for the car body, integrate those values in the physical engine to produce velocity and move the car.
  • Apply damping forces (rolling friction, air drag). It is not supposed to be vital to car behaviour, but it might help a little. It will mostly influence acceleration time and maximum speed.


That should be all what is needed to get a car simulation right. At least theorically. I think i have forgotten nothing.

Part 2 - The reference car(s)

The goal of this part is to have reference values for a classic car, so we can compare our values and behaviours.

The classic car inspired from some Corvette C5 values and other frequent values seen here and there. Let's call it X-Car-1
Spoiler


To be honest i must say this reference values don't make a nice car. I'll post a general handling video soon.

Here are some parameters taken from Edys Car Vehicle Physics for the Red Pickup you can try in the demo. Some of the values can be monitored with B and the SHIFT+B in the demo. I post it here to give some elements to discuss about as a part of those values are not present above, and for some i just dont know what they mean. Any idea / insight would be appreciated.
Spoiler


Part 3 - Reference handling and values

The goal of this part is to put the car in a typical situation with controlled environment, and to look at what happens. Game may be written in Java, .NET, Unity or whatever, if you have taken control of the physics, and if you have the right car parameters, the values should look like these.

X-Car-1_T01 : apply 100% throttle for 10.00 seconds
Coming soon...

X-Car-1_T02 : launching directly the car with a front velocity of 50 meters/s
Coming soon...

X-Car-1_T03 : launching directly the car with a side velocity of 50 meters/s
Coming soon...

X-Car-1_T04 : launching directly the car with an angular velocity of 10 radians/s
Coming soon...

X-Car-1_T05 : launching directly the car with a combined front/lateral velocity : 50m/s in each direction
Coming soon...

X-Car-1_T06 : launching directly the car with a combined front/lateral velocity : 50m/s in each direction and a 10 radians/s angular velocity
Coming soon...

X-Car-1_T07 : apply 100% throttle for 10.00 seconds, then without releasing throttle, press the right key for the next 10.00 seconds (right + full throttle)
Coming soon...

X-Car-1_T08 : apply 100% throttle for 10.00 seconds, then release throttle, and press the right key for the next 10.00 seconds (right + free roll)
Coming soon...

X-Car-1_T09 : apply 100% throttle for 10.00 seconds, then apply brake, and press the right key for the next 10.00 seconds (right + brake)
Coming soon...

X-Car-1_T10 : a controled drift situation (still have to find a reference test)
Coming soon...


Part 4 - Tips & tricks

This part is still R&D, and i am more open to debate and wanting to collect ideas and tests than trying to explain to do this or not. I do not have the solution for doing most of those things anyway.

List of "legit" tricks :
  • Limit maximum steer angle according to speed & max grip peak SA
  • Same for throttle/brakes with peak slip ratio output
  • Decrease gently (or not) steer angle after input release
  • Be aware (you, programmer) of when a drift situation occurs and change car control inputs to help player have more fun
  • Instead of modelizing a complex combined front/lat grip formula, just determine how much percent of lateral grip you lose in function of the slip ratio

Cheap tricks or cheats :
  • If player apply throttle, just directly add front Y velocity to car
  • Disable real front/rear weight calculations. Just decide of a prefixed weight change on acceleration/braking situations
  • Gently decrease forces near/after traction circle max value, instead of just cutting it
  • Rotate directly car velocity vector by a very small percent of the front wheels slip angle
  • Use a linear slipAngleInRadians * someConstant formula for lateral pacejka output

Part 5 - Reference formulas and ressources

More content to come...

Reference physics formulas, tutorials and references...

Part 6 - Questions, FAQ, things we don't know

Questions :
  • What is the formula to have a friction ellipse instead of a circle ?
  • Where can we find a simple formula for combined long/lat grip ?
  • Should we apply a static friction force or something like that or just pacejka ?

FAQ :
  • Should i apply forces lateraly to car body or to the wheel ?
    To the wheel.
  • More classic question and answers to come...
  • What value can i use to decide if i must draw lateral drift skidmarks ?
  • What value can i use to decide if i must draw burnout skidmarks ?
I am a little bit tired, but i will update with more basics.

I'm looking forward to read your answers and contributions, if anyone interested !

Edited by PochyPoch, 26 September 2012 - 09:51 PM.


Sponsor:

#2 jujunosuke   Members   -  Reputation: 188

Like
0Likes
Like

Posted 27 September 2012 - 04:20 AM

Dude, sorry if my post won't help you, but i don't understand the point of your new thread.
As far as i understand, you are doing a 2D car sim right ?

The problem that you face in a 2D car sim are really different from any 3D car sim so it make your thread evern harder to understand.
Also, we are not just 3 but maybe hundred of people on this forum are trying to get car Physics right.

Also, to be honest, everyone have its own vision about what is fun car physics, what is realistic car physics and what is arcade style car physics.
So there is no easy way to share stuff on it in my opinion.

#3 kunos   Crossbones+   -  Reputation: 2187

Like
0Likes
Like

Posted 27 September 2012 - 04:51 AM

wow.. huge post.. it'll take me ages to go through it all.
All I can say straight away is that 1ms deltaT is waaaaaaay more than what you would need for a simple racing game, >=1000Hz and you are in the realm of professional simulators and, starting to get in trouble with 32 bit floating point accuracy.

Probably a 100Hz or 200Hz physics rate should be enough if the car isn't too stiff.

EDIT: More notes..

Use wheel distance to CG to calculate weight transfer lateraly and longitudinal. Combine those two.

This is most probably wrong... you don't calculate weight transfer, it should be automatically happening in your rigid body physics

Subsidiary question : is it vital to have proper car suspensions ?

For a simple racing game you can get away with a simple "slider" suspension only going up and down. For a proper sim, you'll need a much more complex and realistic movements but that will also require engineering skills to set it up in the sim and lots of tools to understand where it goes wrong.

Use the powered wheels velocity to determine motor RPMs. Based on player throttle input, and engine torque curve, generate a torque force for powered wheel

You can get away with it, but again, this is backwards thinking, torque goes from engine to wheels, wheel speed is a result, not an input. Once you stick a differential in the mix things get really complicated, proper differential modeling is tricky... but essential for "on the limit and over" driving styles.

Edited by kunos, 27 September 2012 - 04:59 AM.

Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#4 PochyPoch   Members   -  Reputation: 155

Like
0Likes
Like

Posted 27 September 2012 - 04:55 AM

Hi !

Thanks for your answers !

Well, indeed it doesn't help that much ^^ Instead of focusing on fun, i know at least a part of the posting people seems to want to have the basic physics right. So knowing if a typical car launched at X velocity should more or less stop in 1 sec or 100 sec might help future beginners to start implementing physics. I know i really had a hard time to get the basics right, and the lack of reference values was a great pain.

AFAIK, most of 2D simulations simulates a part of inner 3D (eg : weight transfer), and as long as you consider driving on a flat surface, things are quite similar. For a beginner starting right away with 3D terrain and car model might be a good thing to make stupid mistakes.

A few weeks ago i asked if a lateral pacejka force should be applied lateraly to wheel body or to car model, and response was not clear to everyone. A LOT of basics things are not well understood by beginners, and we have a few people here who have successfully created full racing games. So again, i think it might be a good idea to have some shareable and stored knowledge on the subject.

As for the "what is fun" part, i guess you are right. But again AFAIK, getting controled drifts and natural car behaviour is kind of what every carsim dev wants,no ?(independant of arcadish/simu considerations)

I haven't been able to find very simple and important car setup parameters, so why not trying at least to share those somewhere ? My max_steer function comes from a 3D game and it works well for my 2D sim ;) I really think we can try to bring light to some dark places, instead of always creating topics to ask something precise and then realize a few answers laters that we have missed other things or that we just didn't think of a key feature. Almost all car related topics end like that. And the only tutorials are the one from marco, gamedev and unity, which i personnaly think are really vague on a lot of key subjects like proper car inputs management or how pacejka works. And PHORs is way too complicated for most readers to implement it i guess. I know i do not want to implement the Maths, altough the reading helped me to understand many things.

Probably a 100Hz or 200Hz physics rate should be enough if the car isn't too stiff

Well, the 1000Hz value in test/dev purpose allow us to be sure any instability does not come from there. Objective of the thread is to try to enlight newcomers to the subject. For a game in early prototype stage, the computer can handle it well. And everyone is free to adapt the value to its needs later, but for the scientifical accurate part, i think 1000Hz is doable and a simple value.

Use wheel distance to CG to calculate weight transfer lateraly and longitudinal. Combine those two.
This is most probably wrong... you don't calculate weight transfer, it should be automatically happening in your rigid body physics

Sorry, i meaned load transfer and not weight transfer, i offen misuse those two words. My dynamic load transfer happens with acceleration in the car body. So to know the real weight on a body point, i have to find out its distance to CG, and then use long/lat acceleration. As i do not use a physics engine (except for the collision detection part), i code weight transfer as much as simple forces integration. So AFAIK it cannot happen automatically unless i use a real 3D engine and feed him with some values. I get front/lat acceleration depending on current acceleration values, which themselves depends on previous ticks generated forces.
The real weight transfer, which happens when the car CG is displaced occurs indeed automatically as a suspension or an other is going up or down. I'll edit my post to use correct terms.

Edited by PochyPoch, 27 September 2012 - 08:49 AM.


#5 Edy   Members   -  Reputation: 134

Like
0Likes
Like

Posted 27 September 2012 - 09:14 AM

I believe that by best contribution to this thread is my article about the pacejka formulas, including the interesting debate at the bottom comments:

Facts and myths on the Pacejka curves


In summary, you need these kind of formulas only when developing high-end ultra-realistic vehicle simulation with real tire sets (think on netKar Pro, rFactor, etc). But you are not required at all to use these approaches for developing realistic vehicle physics. These methods are inherited from the automotive industry and it's quite difficult to implement them properly in video games.

In my tests I was able to develop a very fun and realistic vehicle simulation using basic vector math only, with the vehicle reacting properly to burnouts, drifting, brake locks... everything in a few lines and running at 50 Hz.

Forget those numbers and quantities on Edy's Vehicle Physics. That system was developed as workaround for the bad implementation of the wheel component in PhysX 2.8 (nxWheel, used by Unity as WheelCollider). As one of the nVidia developers confirmed me recently, that implementation was cheap and easily tuned for specific applications. My Vehicle Physics package makes the wheel component behave in a barely acceptable realistic way, but none of its parameters has to do with real vehicle dynamics.

I'm now developing a new tire simulation model designed form scratch specifically for video games. It provides a complete tire simulation that reacts realistically on almost all possible situations of the wheel, including static friction and wheel spin. I expect it to be completed by the end of this year.

About the 1ms deltaT subject: in my opinion the problem with this is that the traditional methods are way too dependent of the deltaT. In a regular implementation of slip ratio, the resulting force exerted by the tire could double if deltaT is doubled. So you could find that your simulation works exactly as expected at a specific deltaT only. This is why I'm developing a method that doesn't depend directly on the deltaT. A small deltaT (< 20ms) helps avoiding instabilities at certain extreme situations, but the resulting force doesn't depend directly on it.

Edited by Edy, 27 September 2012 - 09:15 AM.


#6 kunos   Crossbones+   -  Reputation: 2187

Like
0Likes
Like

Posted 27 September 2012 - 09:19 AM

Use wheel distance to CG to calculate weight transfer lateraly and longitudinal. Combine those two.
This is most probably wrong... you don't calculate weight transfer, it should be automatically happening in your rigid body physics

Sorry, i meaned load transfer and not weight transfer, i offen misuse those two words. My dynamic load transfer happens with acceleration in the car body. So to know the real weight on a body point, i have to find out its distance to CG, and then use long/lat acceleration. As i do not use a physics engine (except for the collision detection part), i code weight transfer as much as simple forces integration. So AFAIK it cannot happen automatically unless i use a real 3D engine and feed him with some values. I get front/lat acceleration depending on current acceleration values, which themselves depends on previous ticks generated forces.
The real weight transfer, which happens when the car CG is displaced occurs indeed automatically as a suspension or an other is going up or down. I'll edit my post to use correct terms.


actually the two terms are almost equivalent and, as I said, using body acceleration to calculate load transfer is the wrong way of doing it:)

intuition should suggest you that load on a tyre should be influenced by the movement of the tyre, not from the movement of the car body.
Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#7 kunos   Crossbones+   -  Reputation: 2187

Like
0Likes
Like

Posted 27 September 2012 - 09:27 AM

In a regular implementation of slip ratio, the resulting force exerted by the tire could double if deltaT is doubled


that doesn't make sense at all. deltaT doesnt even appear in a slip ratio definition how can it influence it? There is no reason for a sim to change behaviour if dT is changed, the ENTIRE point of having a dT in the first place is to make things indipendent of time :)
Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#8 PochyPoch   Members   -  Reputation: 155

Like
0Likes
Like

Posted 27 September 2012 - 01:16 PM

Well, thanks everybody for the answers, as always, i am still learning interesting things.

Edy, i am really glad to see you participating in here, your experience is very valuable. Actually i bought Edy's Car Physics for unity, just to be able to look at car setup parameters and to have a better understanding of some of the mechanics. But with the system based on Unity WheelColliders how it really works is kind of hidden + i have trouble reading spanish comments ^^ Too bad my game is javascript and not Unity ^^

Anyway i have read all of your articles and the interesting comments too. Helpful, but it didn't gave me a real alternative to pacejka curves. To be clear i am working with simple curves plotted for 1N i am scaling afterward. I never messed with those complicated parameters and as pacejka just produce some value, it seems clear it is a very small part of a proper driving game.

that doesn't make sense at all. deltaT doesnt even appear in a slip ratio definition how can it influence it? There is no reason for a sim to change behaviour if dT is changed, the ENTIRE point of having a dT in the first place is to make things indipendent of time

Well, it makes a lot of sense to me, actually a lot of articles explain this. Basically if you have 200% slip ratio, and produce 5kN of force for a 50ms timestep, you are stuck with the same force applying for 50ms. With smaller timestep, physics engine actually has a chance to see that slip ratio may have go down to 100% around 25ms, and for the remaining 25ms you will produce a different amount of force for example. You seem to have some experience in car physics (with 2010 posts !), so i guess you already know this and maybe we are not talking about the same thing Posted Image Or you have eliminated any numerical instability issue in your simulation and just have forgot about it ^^ Anyway it is not that hard to emulate some equivalent to SR with similar results, but improved stability. My lateral forces are quite stable too at 50Hz, the difference is not really noticeable with 1000Hz.

In summary, you need these kind of formulas only when developing high-end ultra-realistic vehicle simulation with real tire sets (think on netKar Pro, rFactor, etc). But you are not required at all to use these approaches for developing realistic vehicle physics. These methods are inherited from the automotive industry and it's quite difficult to implement them properly in video games.

Really ? oO i just learned it. I had the feeling a lot of games (like GTA, or even more arcade games) use the curve approach, even if they tweak it rather than directly implementing the formula. Your framework doesnt seems too much realistic to me, and it's using it right ? I was just plotting simple curves scaled by weight load, and (re)discovered today, that forces do not linearly increase with Fz, thus making proper use of the formula important to me, or at least it is what i was thinking until i read this.

In my tests I was able to develop a very fun and realistic vehicle simulation using basic vector math only, with the vehicle reacting properly to burnouts, drifting, brake locks... everything in a few lines and running at 50 Hz.

Oh man, you just blowed up my entire world ^^ just kidding. I know we can have stable behaviours at 50Hz, but having controled/fun drifts over/under steer with really simple maths, without getting into wheel angular vels or SA/SR, and weight-dependant curves seems quite hard to me without recreating this entire logic out of nothing with math hacks or such things. I'd really love to have a look or even be able to buy such a piece of code Posted Image (seriously). Right now, my best hope to control the drifts without having a naturally oversteering car is to have better load transfer calculations and to stop to apply Fz linearly after normalized pacejka output. Maybe i am once again very wrong to hope that it will greatly improve car handling and capabilities... :'(

I have the intuition without a little of weight transfer and some dumb but credible suspension and traction circle or at least combined slips you can't have the driving feeling of your red pickup for example : if i brake enough in a corner i am able to produce controled oversteer to turn sharply at 100Kmh in your 90° curves in the city demo.

The best i can do to have "fun" physics with very little code is to directly rotate car and to let the lateral forces of the tire do the rest of the job. Not good enough if i want my player to have car parts and i guess you are suggesting something more sophisticated than this.

actually the two terms are almost equivalent and, as I said, using body acceleration to calculate load transfer is the wrong way of doing it:)
intuition should suggest you that load on a tyre should be influenced by the movement of the tyre, not from the movement of the car body.

Wow, that is really confusing me. What do you mean by tyre movement ? As in the tire going up and down (spring/suspesion) ? Unless there is a bump in the road, AFAIK, acceleration is responsible for load transfer.
Wikipedia is quite clear on this :

In wheeled vehicles, load transfer is the measurable change of load borne by different wheels during acceleration (both longitudinal and lateral). This includes braking, and deceleration (which is an acceleration at a negative rate).[6] No motion of the center of mass relative to the wheels is necessary, and so load transfer may be experienced by vehicles with no suspension at all. Load transfer is a crucial concept in understanding vehicle dynamics. The same is true in bikes, though only longitudinally.

Again, when i read what you say and compare it with my "knowledge" of the subject, i can't stop me of thinking i have clearly messed up something... Please enlight me Posted Image

I'm now developing a new tire simulation model designed form scratch specifically for video games. It provides a complete tire simulation that reacts realistically on almost all possible situations of the wheel, including static friction and wheel spin. I expect it to be completed by the end of this year.

I'm looking forward to it, but sadly i'd like to have my game runing in alpha stage before that time. And anyway i would still have to rewrite the entire thing in javascript, which i would not be able to do without a lot of detailed english comments everywhere ^^

Actually in my sim everything is fine, except i cannot really combine different behaviours, and it really seem to me everything is VERY weightload related. If i cut a vector using friction circle, it usually makes the car spin very fast. Same goes if too much weight goes to one of the outside front wheels. So have i missed really important things, or am i going the wrong way trying to get more reasonnable load transfer ?
I mean if you can achieve credible drifts behaviours without load transfer or lateral pacejka... I'd really like to know where to look to do it Posted Image

As always, really looking forward to your answers ! i have spent 6 months reading a lot of docs and trying many things, but i still need to learn A LOT. Main problem is to when you get the basics "right" and it still not fun, is to find out what to try to move forward.

I have seen in a lot of threads, a lot of people trying the same things, learning slowly the hard way, to finally give up or be unsatisfied with their car handling. If i get better understanding of the problems and manage to get my car simulation running fine (failure is not option, the rest of the game is going very well), i would be very happy if sharing that knowledge helps future racing developers.

Edited by PochyPoch, 27 September 2012 - 01:24 PM.


#9 Edy   Members   -  Reputation: 134

Like
0Likes
Like

Posted 27 September 2012 - 05:38 PM


In a regular implementation of slip ratio, the resulting force exerted by the tire could double if deltaT is doubled


that doesn't make sense at all. deltaT doesnt even appear in a slip ratio definition how can it influence it? There is no reason for a sim to change behaviour if dT is changed, the ENTIRE point of having a dT in the first place is to make things indipendent of time Posted Image


Posted Image

The problem arises when calculating w (angular velocity). If the wheel is in the air, applying torque at the axle results in an angular acceleration a = Torque / Inertia. Then w = a · dT. Thus, doubling dT means double w. Everything is fine to this point: applying a constant torque during twice the time produces twice the angular velocity.

But if the tire is grounded, applying the same Torque at the axle requires calculating the slip ratio and looking up the value in the friction curve in order to get the final force at the tire. And here is it: how to calculate w now? All I was able to find over there is that one must simply calculate w as if the wheel was unloaded, then use the ground speed V and the slip ratio definition to get it. Thus, double dT means more slip ratio. Locking up the friction curve returns a different force at the wheel depending on dT. Of course, the smaller dT, the smaller are the difference among results. This is why many people recommends a minimum of 500Hz for these calculations.

Of course, this is all I was able to find and deduct from the information and source code available over there. Surely there are other methods, but they are either a secret available only for gurus of vehicle simulation, or so complicated that I just didn't recognize them ("not my war, I want it simple"). So I'd really love to hear your point on this specific issue Posted Image

#10 kunos   Crossbones+   -  Reputation: 2187

Like
1Likes
Like

Posted 27 September 2012 - 11:02 PM

But if the tire is grounded, applying the same Torque at the axle requires calculating the slip ratio and looking up the value in the friction curve in order to get the final force at the tire. And here is it: how to calculate w now? All I was able to find over there is that one must simply calculate w as if the wheel was unloaded, then use the ground speed V and the slip ratio definition to get it. Thus, double dT means more slip ratio. Locking up the friction curve returns a different force at the wheel depending on dT. Of course, the smaller dT, the smaller are the difference among results. This is why many people recommends a minimum of 500Hz for these calculations.


That makes even less sense.. I read what you wrote several times and it really doesn't :P wherever you found these info they are just wrong all the way. Your wheel angular speed should be a function of all the torques (and forces transformed to torque) acting on the entire transmission system, from the engine to the wheels. All these are integrated with the same formulas and, unless they are wrong, deltaT won't change the result in any tangible way. You should make sure to double check your sources because the big risk here is you claiming to have a solution to a problem that never existed in the first place but it's just a result of your fantasy.

@PochyPoch .. what you are talking about has nothing to do with slip ratio, it's a "problem" common to every physical simulation integrated in discrete steps..of course a bigger integration time will lead to a bigger error.. it's obvious and it isn't what we were talking about.
Regarding the weight transfer, you are perfectly right.. on a vehicle with no suspension, (100% rigid body and 100% rigid steel tyres) load at one corner is EXACTLY the load transfer calculated analytically from the body's acceleration.. but there is no such a a vehicle.. even for a kart you'll have at the very least consider flexible tyres.. which are actually acting like a suspension.
Even worse with a car, where you have your tyres' springs and then your suspension springs.. so those analytically calculated load are only valid in steady state (ie. NEVER :P ) .. in every other situation load is a function of all those springs... the easiest and more common way of getting load is to treat the tyre as a spring and get the load from that spring compression... no calculation needed.
Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#11 Edy   Members   -  Reputation: 134

Like
0Likes
Like

Posted 28 September 2012 - 02:44 AM

That makes even less sense.. I read what you wrote several times and it really doesn't wherever you found these info they are just wrong all the way. Your wheel angular speed should be a function of all the torques (and forces transformed to torque) acting on the entire transmission system, from the engine to the wheels. All these are integrated with the same formulas and, unless they are wrong, deltaT won't change the result in any tangible way. You should make sure to double check your sources because the big risk here is you claiming to have a solution to a problem that never existed in the first place but it's just a result of your fantasy.


Ok, imagine the simplest scenario. An electric motor which delivers a constant amount of torque directly to a wheel. In order to calculate the force at the tire, you need to calculate the slip ratio first, so you could look it up in the friction curve and get the force. Calculating the slip ratio requires to calculate w (angular velocity) first. How to calculate w, then? What am I missing?

#12 kunos   Crossbones+   -  Reputation: 2187

Like
1Likes
Like

Posted 28 September 2012 - 03:15 AM


That makes even less sense.. I read what you wrote several times and it really doesn't wherever you found these info they are just wrong all the way. Your wheel angular speed should be a function of all the torques (and forces transformed to torque) acting on the entire transmission system, from the engine to the wheels. All these are integrated with the same formulas and, unless they are wrong, deltaT won't change the result in any tangible way. You should make sure to double check your sources because the big risk here is you claiming to have a solution to a problem that never existed in the first place but it's just a result of your fantasy.


Ok, imagine the simplest scenario. An electric motor which delivers a constant amount of torque directly to a wheel. In order to calculate the force at the tire, you need to calculate the slip ratio first, so you could look it up in the friction curve and get the force. Calculating the slip ratio requires to calculate w (angular velocity) first. How to calculate w, then? What am I missing?


you don't calculate w.. it's a status. You have your status at t0 and you are calculating your new status at t1. Wheel angular velocity is part of the status t0.

once you calculate all the forces on the system you integrate it and w is part of your result, that becomes the input status for your next iteration.
Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#13 bmarci   Members   -  Reputation: 369

Like
1Likes
Like

Posted 28 September 2012 - 07:26 AM

The problem that you face in a 2D car sim are really different from any 3D car sim so it make your thread evern harder to understand.
Also, we are not just 3 but maybe hundred of people on this forum are trying to get car Physics right.


I'm not sure about that. I'm also planning a 3D car game, but first I'll make a 2D version to make sure I understand all the fundamental parts that I need.
In 2D everyting is more simple but the physics is more or less the same, eg: use only anular velocity (scalar) instead of a vector, or inertia value instead of tensors, but the principle is the same.

At the current sate I'm in the same situation as PochyPoch. I have a decent working car, only having problem with high speed cornering and stability.
As Kukos seems to be one of the guys from the old RAS discussions I'd aim a couple of questions for you directly (if you don't mind) :)

Just a couple of symptoms and confusions:

Symptoms:
1. The car behaves fine with low speed (the wheels are jerky, but no low speed relaxation, so that's ok for now)
2. Up to 40/60 km/h everything is fine, but over this limit the car becomes very hard to control, especialy with no throttle.
3. Around 80/100 km/h, understeer with throttle, and oversteer without it.
4. I tried to adjust the pacejka curve to have more lateral forces at the rear tyres, so it became mor controllable after a while (no oversteer, but more understeer), and thus the rear end becames more sticky and couldn't spin the car not even with locked rear tyres.
5. I tried modifying weight balance, and smaller body inertia value, but didn't help too much.
6. When the car starts skidding the situation becomes very "slippery", like driving on ice.
7. I tried straight Fx/Fy calcuations like: (Fx=SR*1.0*Fz) and (Fy=SA*0.8*Fz) but didn't help too much.


Confusions:
1. For SA/SR calculations do I need the velocity of the contact pacth or the wheel hub wrt the ground?
In most docs I found the wheel velocity is made up from Car's linear velocity and the Car's angular veloicty at the wheel pos.
But, the CP is moving backward as the wheel is rolling (in case of moving forward), is it an important term, or should I just forget it?
I tried this and get "better" lateral forces, so more stability, but it screws up the SR, the wheels spin slower than expected.
Also should I cap SR, eg: betweeh -1..10 ?

2. I have doubts about the afore mentioned straigh engine RPM calculation. Could that affect cornering stability?
I'm thinking in this model: Engine torque accelerates the whole drivetrain (flywheel/transmission/wheel) (clutch/diff ommitted for simplicity)
The final wheel rotation gives a slip ratio that helps to calculate the reaction torque. And apply this reaction torque back to the whole drivetrain (wheel/transmission/flywheel)
BUT, if i'm thinking right, the two calculations need different inertia values (wheel side/engine side). Is that correct?

3. I noticed some oscillation in SR when not pushing the throttle, only engine brake and drag. SR jumping between (0.03% and -0.08%) is that normal?

4. much more that I don't remember now :)

#14 kunos   Crossbones+   -  Reputation: 2187

Like
2Likes
Like

Posted 28 September 2012 - 07:54 AM

Hi, all these points might be simply a symptom of a bug in the code... which could be anywhere, I'll try to approach it from a car dynamics point of view, assuming basic physics code is correct.


Symptoms:
1. The car behaves fine with low speed (the wheels are jerky, but no low speed relaxation, so that's ok for now)
2. Up to 40/60 km/h everything is fine, but over this limit the car becomes very hard to control, especialy with no throttle.

Unless you have explicitly coded a speed sensitivity ( I doubt that because it's a fairly new development and it is usually neglected in literature) in the car, this is usually the sign of a bug.. a well balanced car (ie, right tyre grip distribution, suspension and anti roll bar setup, aero balance) should get more stable as speed increase.

3. Around 80/100 km/h, understeer with throttle, and oversteer without it.

Could be CG too high, too much "coast" torque.. wrong or missing implementation of a proper differential

4. I tried to adjust the pacejka curve to have more lateral forces at the rear tyres, so it became mor controllable after a while (no oversteer, but more understeer), and thus the rear end becames more sticky and couldn't spin the car not even with locked rear tyres.

That's the fascination of car development, to get a car that is drivable and well behaved in real life is VERY hard.. should it be any different in a simulator? ;) You need to hit a sweet spot that usually comes with experience, real world values and study of car dynamics and setup. Of course wrong tyre modeling or differential modeling could produce bad behaving sims.

5. I tried modifying weight balance, and smaller body inertia value, but didn't help too much.

Usually smaller rotational inertia makes the car more twitchy.

6. When the car starts skidding the situation becomes very "slippery", like driving on ice.

This is usually a sign of blindly trusting some common found pacejka sets, they do a good job in reproducing the "grip" side of the curve but a piss poor job in reproduction the sliding side of the curve. You're pretty much by yourself in this., as there is no reliable way to measure tyre behavior after the grip peak it all comes to the developer driving experience and creativity... so, start spending time on a real car on the limit and try to figure out why and how to reproduce that behavior in the sim... this is currently the most active part in PC driving sim research and most simulator have abandoned the pacejka approach because it just doesn't work.

7. I tried straight Fx/Fy calcuations like: (Fx=SR*1.0*Fz) and (Fy=SA*0.8*Fz) but didn't help too much.

How can they work? It's virtually infinite grip there, they only can give you an idea about what's called the "terminal behavior" of the car.. but that's old theory and is pretty much worthless.

Confusions:
1. For SA/SR calculations do I need the velocity of the contact pacth or the wheel hub wrt the ground?
In most docs I found the wheel velocity is made up from Car's linear velocity and the Car's angular veloicty at the wheel pos.
But, the CP is moving backward as the wheel is rolling (in case of moving forward), is it an important term, or should I just forget it?
I tried this and get "better" lateral forces, so more stability, but it screws up the SR, the wheels spin slower than expected.
Also should I cap SR, eg: betweeh -1..10 ?

You want to use the velocity of the contact point but without the angular velocity component. So if you have a rigid body for the suspension hub you'd call a function such as getVelocityAtWorldPos , or transform the point into hub's frame and call something like getVelocityAtLocalPos .

2. I have doubts about the afore mentioned straigh engine RPM calculation. Could that affect cornering stability?
I'm thinking in this model: Engine torque accelerates the whole drivetrain (flywheel/transmission/wheel) (clutch/diff ommitted for simplicity)
The final wheel rotation gives a slip ratio that helps to calculate the reaction torque. And apply this reaction torque back to the whole drivetrain (wheel/transmission/flywheel)
BUT, if i'm thinking right, the two calculations need different inertia values (wheel side/engine side). Is that correct?

that is correct, because ratio influences inertia. There is a nice document written by Ruud Van Gaal at racer.nl that explain how to calculate "effective inertia" as seen from different sides of the drivetrain.

3. I noticed some oscillation in SR when not pushing the throttle, only engine brake and drag. SR jumping between (0.03% and -0.08%) is that normal?

With the car in movement on a flat road no, that isn't normal... it might be a wheel angular inertia too low wrt to the forces and the deltaT.
Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#15 bmarci   Members   -  Reputation: 369

Like
0Likes
Like

Posted 28 September 2012 - 09:11 AM

Unless you have explicitly coded a speed sensitivity ( I doubt that because it's a fairly new development and it is usually neglected in literature) in the car, this is usually the sign of a bug.. a well balanced car (ie, right tyre grip distribution, suspension and anti roll bar setup, aero balance) should get more stable as speed increase.

The only speed sensitive parts are aero drag and rolling resistance for now, but I was wondering how aero downforce works as speed increases. Is the front/rear balance constant or changing as the car moves (probably not constant, but is the change significant?)

Could be CG too high, too much "coast" torque.. wrong or missing implementation of a proper differential

h=0.5m, L=2.55, track=1.9
It shouldn't be high, but there is no differential at all. First I'll try how the rear wheels behave if I disconnect them from the engine at turning.

This is usually a sign of blindly trusting some common found pacejka sets, they do a good job in reproducing the "grip" side of the curve but a piss poor job in reproduction the sliding side of the curve. You're pretty much by yourself in this., as there is no reliable way to measure tyre behavior after the grip peak it all comes to the developer driving experience and creativity... so, start spending time on a real car on the limit and try to figure out why and how to reproduce that behavior in the sim... this is currently the most active part in PC driving sim research and most simulator have abandoned the pacejka approach because it just doesn't work.

You might be right :) But I found those values at the same place, maybe PHORS or Genta's ferrari. So you say, my curves can be right but they don't belong to the same tyre?

In "the sliding side of the curve", you mean over the slip limit?
I read somewhere, it is a common misbelief, that the curve falls off over the slip limit drastically. So a linear appriximation with caping at the limit could give "close enogh" result. If not considering load sensitivity.

Also it would be nice to see some real values, not curves, just sample values eg: (SR=0.01, Fz=3500N, Fx=???) and the same for Fy, just to see if we even have reasonable results.
Is there any "healthy" ratio between Fx and Fy (at peak). I just checked, and my FxMax is greater than FyMax.
Are these values reasonable for a 255/50ZR16 tyre:
Fx: Load=3KN, PeakSR=0.11, MaxFx=3240N, InputSR=0.03, Fx=2211N
Fy: Load=3KN, PeakSA=8.6°, MaxFy=2834N, InputSA=4°. Fy=2519N


that is correct, because ratio influences inertia. There is a nice document written by Ruud Van Gaal at racer.nl that explain how to calculate "effective inertia" as seen from different sides of the drivetrain.

Yes, got that :)

3. I noticed some oscillation in SR when not pushing the throttle, only engine brake and drag. SR jumping between (0.03% and -0.08%) is that normal?
With the car in movement on a flat road no, that isn't normal... it might be a wheel angular inertia too low wrt to the forces and the deltaT.

DeltaT is 1ms, Wheel mass=15kg, Radius=0.33, Inertia=0.81 In case of free rolling wheel.
Is it worth using the relaxation length method at high speed to smooth the SA/SR values?

#16 kunos   Crossbones+   -  Reputation: 2187

Like
1Likes
Like

Posted 28 September 2012 - 11:37 PM

The only speed sensitive parts are aero drag and rolling resistance for now, but I was wondering how aero downforce works as speed increases. Is the front/rear balance constant or changing as the car moves (probably not constant, but is the change significant?)


Surely the levels of downforce go up as the car speeds up because as the car get closer to the ground it will increase aero efficiency. The forward/aft movement of the aero center of pressure varies a lot, older cars suffered from this a lot, newer cars are less prone to move it around a lot, but it's just a trend, not a automatic fact.

h=0.5m, L=2.55, track=1.9
It shouldn't be high, but there is no differential at all. First I'll try how the rear wheels behave if I disconnect them from the engine at turning.


It's not crazy high. Differentials are one of the key element to tune the car behavior and can really change the way the car is behaving at corner entry, apex and exit. It's really important to get those right... in my games most key improvements came from diffs and not from tyres.


You might be right Posted Image But I found those values at the same place, maybe PHORS or Genta's ferrari. So you say, my curves can be right but they don't belong to the same tyre?


Sadly, to be a good car simulator developer you need to invest lots of money trying to acquire every available book and paper on the matter. I have a huge library with references to interesting graphs and formulas all collected so I can easily find what I need when I need it. Once you start seeing tyre curves from different sources you start to see patterns and things like tyre models just become tools for you to reproduce those patterns. I don't think those tyres pacejka sets commonly found on the internet are a good starting point to develop a sim at all. I strongly suggest you to start your journey getting the Tyre Dynamics book from Mr. Pacejka himlself.. at least you'll understand what kind of trip you have ahead of you :) (and get good data to start with).


In "the sliding side of the curve", you mean over the slip limit?
I read somewhere, it is a common misbelief, that the curve falls off over the slip limit drastically. So a linear appriximation with caping at the limit could give "close enogh" result. If not considering load sensitivity.

Yep, I would say that is generally true. I would suggest to start with a "Brush Model" instead of a pacejjka, it does have a touch of "floaty" feel to it, but, being a physical based model it's easier to understand and easier to improve, while with pacejka you are starting from nothing every time you have to work on a new tyre.

Also it would be nice to see some real values, not curves, just sample values eg: (SR=0.01, Fz=3500N, Fx=???) and the same for Fy, just to see if we even have reasonable results.
Is there any "healthy" ratio between Fx and Fy (at peak). I just checked, and my FxMax is greater than FyMax.
Are these values reasonable for a 255/50ZR16 tyre:
Fx: Load=3KN, PeakSR=0.11, MaxFx=3240N, InputSR=0.03, Fx=2211N
Fy: Load=3KN, PeakSA=8.6°, MaxFy=2834N, InputSA=4°. Fy=2519N


As I've said, you can find some of those on books.. and, if you get in touch with teams, see some data straight from tyre manufacturer. Fx to Fy ratio varies a lot, I found a ratio of 1.1 (Fx=Fy * 1.1) is a good starting point. In your example I would say Fy is quite low for a 255 tyre.


DeltaT is 1ms, Wheel mass=15kg, Radius=0.33, Inertia=0.81 In case of free rolling wheel.
Is it worth using the relaxation length method at high speed to smooth the SA/SR values?


Relaxation length is needed at low speed not at high speeds. Although 0.8 seems a bit low for a 0.33m radius tyre the time step should be enough to handle that.. I am more inclined to say it's a bug.
Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#17 bmarci   Members   -  Reputation: 369

Like
0Likes
Like

Posted 30 September 2012 - 12:27 PM

Sadly, to be a good car simulator developer you need to invest lots of money trying to acquire every available book and paper on the matter. I have a huge library with references to interesting graphs and formulas all collected so I can easily find what I need when I need it. Once you start seeing tyre curves from different sources you start to see patterns and things like tyre models just become tools for you to reproduce those patterns. I don't think those tyres pacejka sets commonly found on the internet are a good starting point to develop a sim at all. I strongly suggest you to start your journey getting the Tyre Dynamics book from Mr. Pacejka himlself.. at least you'll understand what kind of trip you have ahead of you (and get good data to start with).

Yes, I've already started spending money :) and was reading about a lot of interesting new things. And whatever new formula I just find seems to greatly affect the final "experience" :)
I've already collected a bunch of sample curves, but until I implement all neccesary components, I cannot be sure if the problem is with the tyre or with some missing part.

As I've said, you can find some of those on books.. and, if you get in touch with teams, see some data straight from tyre manufacturer. Fx to Fy ratio varies a lot, I found a ratio of 1.1 (Fx=Fy * 1.1) is a good starting point. In your example I would say Fy is quite low for a 255 tyre.

Ok, I try with a better curve, twice as many forces? What do you think? :)

Relaxation length is needed at low speed not at high speeds. Although 0.8 seems a bit low for a 0.33m radius tyre the time step should be enough to handle that.. I am more inclined to say it's a bug.

Maybe I use a wrong formula for wheel inertia: (not considering drivetrain inertia, only free rolling wheels)

V1: (one component, cylinder)

I = (m * r^2) /2
I = (15 * 0.33^2) /2
I = 0.81

V2: (two components, tyre + rim)

I = (m1 * r1^2)/2 + (m2*(r2^2 - r1^2)) /2
I = (8 * 0.2^2) /2 + (7 * (0.33^2 - 0.2^2) /2
I = 0.16 + 0.24
I = 0.4

Even worse, do I miss something?

#18 Edy   Members   -  Reputation: 134

Like
0Likes
Like

Posted 01 October 2012 - 04:36 AM

you don't calculate w.. it's a status. You have your status at t0 and you are calculating your new status at t1. Wheel angular velocity is part of the status t0.
once you calculate all the forces on the system you integrate it and w is part of your result, that becomes the input status for your next iteration.


Okay... this may sound silly but that simple paragraph supposes a lot of clarification to me. I'm using Unity 3D, so I'm constrained to a subset of the physics engine (PhysX). No access to the integrator at all - only rigidbody dynamics that just work and the ability of applying forces to it (rigidbody.AddForceAtPosition).

But it doesn't mean that I'm trying to solve a nonexistent problem. Now I have a much better picture of the problem I'm working on, and it has to do with another of your replies:

Sadly, to be a good car simulator developer you need to invest lots of money trying to acquire every available book and paper on the matter. I have a huge library with references to interesting graphs and formulas all collected so I can easily find what I need when I need it. Once you start seeing tyre curves from different sources you start to see patterns and things like tyre models just become tools for you to reproduce those patterns. I don't think those tyres pacejka sets commonly found on the internet are a good starting point to develop a sim at all. I strongly suggest you to start your journey getting the Tyre Dynamics book from Mr. Pacejka himlself.. at least you'll understand what kind of trip you have ahead of you (and get good data to start with).


My goal is to develop the most realistic vehicle simulation that could be achieved only with the minimum (and simplest) math involved. Of course, it wouldn't be comparable to the high-end solutions, but it will provide developers a rather simple method that could be easily understood, implemented, and tuned for each specific project. Thus, developers with limited physics knowledge (as me) could still develop good vehicles that would be realistic enough for most projects.

Edited by Edy, 01 October 2012 - 09:40 AM.


#19 Edy   Members   -  Reputation: 134

Like
0Likes
Like

Posted 01 October 2012 - 04:57 AM

In summary, you need these kind of formulas only when developing high-end ultra-realistic vehicle simulation with real tire sets (think on netKar Pro, rFactor, etc). But you are not required at all to use these approaches for developing realistic vehicle physics. These methods are inherited from the automotive industry and it's quite difficult to implement them properly in video games.
Really ? oO i just learned it. I had the feeling a lot of games (like GTA, or even more arcade games) use the curve approach, even if they tweak it rather than directly implementing the formula. Your framework doesnt seems too much realistic to me, and it's using it right ? I was just plotting simple curves scaled by weight load, and (re)discovered today, that forces do not linearly increase with Fz, thus making proper use of the formula important to me, or at least it is what i was thinking until i read this.


Yes, you can use a curve approach, but not necessarily a pacejka one. As Kunos pointed out in another of his replies, once you see the pattern of the real friction curves you can use any method for reproducing them. That framework uses those patterns as you can see at the demo (press B, then shift-B to see the curves). However, that framework is based on a workaround to the standard wheel component of the physics engine (no real-world physics on the tire). So things like lateral-longitudinal force combination are roughly calculated, and the method is targeted for gameplay instead of realism.

> Use wheel distance to CG to calculate weight transfer lateraly and longitudinal. Combine those two.
This is most probably wrong... you don't calculate weight transfer, it should be automatically happening in your rigid body physics


That's right, you don't need to calculate this. In my case (Unity 3D) I have rigid body physics that just work. So my vehicle is constructed simply as a rigid body with 4 contact points and a simple suspension on each one (spring + damper). If I put this "vehicle" over a terrain it will behave as if it is sliding on ice (no friction) but suspension, weight transfer and weight load at each contact point will just work.

What my tire simulation does is simply applying the appropriate force at each contact point according to the vertical load on that point. If the forces are calculated and applied properly, then the rigid body will behave as a vehicle by itself, which actually does in my work-in-progress framework.

Edited by Edy, 01 October 2012 - 05:05 AM.


#20 jujunosuke   Members   -  Reputation: 188

Like
0Likes
Like

Posted 01 October 2012 - 10:52 PM

Again, i am sorry but i think this thread is confusing.
When i look at the first post and the evolution of the thread, i can't find anything related.
Its like everyone is talking about his problem and mix everything.

I will be difficult for someone who have a specific issue to find answers by looking at this thread..

Part 1 - What should i absolutly do to make this a fun game with drifts, skids and such things ?

This title only is just nonsense...
There is no miracle recipe to make fun game or drift game.

First the random guy who have no knowledge about car physics should be oriented to some reading first.
The famous Marco monster tutorial is i guess a good start :
http://www.asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html

Also, the way you explain things is hard for a newcomer to understand.
The advice order is completely wrong, and doing thing that way is total nonsense.

Again no offense, you want to help people and help yourself, thats a great idea, but you should at least do it seriously..

Basically separating Car physics in multiple categories would have been a better approach...
Tires, Transmissions, Engine, Gear Ratios, Weight Transfer etc...
Again marco's monster tutorial do that better than you do.

Use the powered wheels velocity to determine motor RPMs. Based on player throttle input, and engine torque curve, generate a torque force for powered wheels.

Another exemple, how did you came to this conclusion ? Looks like a copy and paste.
As kunos mentioned this is backward thinking, and not very logical to me.
Of course i know that this approach is valuable because i already deal with it by seeing some car physics tutorial on the net.
But for a new-comer, it will be difficult to understand anything...

Anyway..




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS