Jump to content

  • Log In with Google      Sign In   
  • Create Account


PochyPoch

Member Since 09 Sep 2012
Offline Last Active Nov 21 2012 07:41 AM

Posts I've Made

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

03 October 2012 - 07:22 PM

Hi to all beloved co-posters !

Bmarci, thanks a lot for saying what i was going to say ^^

More precisely, i would say, yes, this is going to fail, as almost any other car topic on the forum. Of course there are a lot of errors in my (very) simple explanation. The whole purpose was to get people to say "hey this is not the way you should do that !", or even more valuable "hey there is a faster/easier way to do that !". So if i had all knowledge already, i would finish my game and make a real tutorial instead of a "general car ways of doing things" topic Posted Image

My goal is ultimately to explain everything we learned on the first topic, and maybe if i estime myself enough give some advices (like do not believe marcos tutorial will give you a nice car ^^). I have a LOT of litterature on the subject i will post, etc. But right now, i feel like trying to make a "reference" first post is kind of a waste of time as there is too much things to discuss, and making it look "good" won't make it good for real. The idea is to get people to understand this is an open debate and ideas/tips sharing topics, which i hope will let us gather enough intel to be able to provide a few good advices on the first post.

As i see it, all kinds of handy formulas, links, tips, and even different "ways" of doing things will be explained in the first post. Bu right now, this thread is highly unrecommandable, especially for newcomers, there are better places to start, like marcos monster, phors or the tutorial on gamedev, which are all good reads.

And, finally yes, i think all noobies car devs are going the same way those times, and maybe a fresher starting point would be necessary.

Beside the fact that marco monster is 10 years old, it cover everything so well, its just the best way to start in my opinion.

Oh yeah, +1k to that. And maybe even before that getting familiar with driver knowledge before going into physics. The value of the first post when completed would not be to do what marcos did, but instead, starting where it stopped. So let's say you have implemented everything he said, and even a few more things, but you are very disappointed because your car is not feeling right. I already learned very valuable things (like role of differentials and so), that i think are worth explaining in the first post, in time, when i'll have implemented and understood them myself. And finally having a few videos demos, data sets and reference values would be a great contributions for people coming from marcos tutorial or trying to implement it.

Of course, its always interesting to see some reading on car physics, a subject that passionate all of us, but the fact of melting all kind of question and answer together make it really confusing and not that enjoyable to read IMO.

The fact is, we (i) have so many questions, i feel like creating topics for all of them would result in terrible forum flooding. So the idea is to ask things as they are coming, and when i figure out enough of them i'll summarize the first post well Posted Image And then it would be a great time for constructive feedback, as we are thinking towards future readers and explaining things correctly.

---

That being said, let's go back to main topic : car science alchemy !

---

EDIT : Wow i just realized there are very interesting things being said in the previous car topics ! Maybe some of my questions have been answered there. If that is don't bother linking the other topics, i'm reading them right now Posted Image

A few words on the differential topic i started : i was just talking of a flat multiplier in my sim actually : engineTorque * gearRatio * diff * throttleInput. Very dumb thing, compared to how advanced a real differential is. I personnaly do not use an axle, instead i add torque to the drive wheels directly, and so, they get individually slowed/accelerated in a corner. If cornering without throttle, the inner wheels is going slower than outer wheel (normal), but if cornering with throttle, that's the opposite. Actually wihtout differential, the inner wheel has to slide on itself, which works but is far from good. And must have an influence on cornering.

Anyway i just deactivated slip ratios, engine torque and all things related to concentrate on drifting and cornering behaviour. No traction circle either for now. So i'm not on power drifting, but more on braking->more weight to front->oversteer drifts.

I think i'll code real suspesions/springs and enhance my mastery of steering_input_control / general lateral forces manipulations before i get more into combined lateral and longitudinal grips. Step by step !

---

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.


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.


No calculations... does not work for me, sorry ^^ You mean the physical engine does it for you ? You mean, the spring/wheel will compress because of car accel, and the final force on each tyre will be way more reasonnable than in a vehicle without suspension ? I still have a doubt if you're suggesting NOT even consider car acceleration, or just don't use it AS IS because it is very stupid (which is obvious ! As you pointed it, even a tire is a kind of suspension on itself).

If that is what you mean, then we agree ! Either way, please explain further, the "no calculation" thing.

As all front/lateral forces get eventually multiplied by the wheel load, we can say getting the wheel load right is maybe as much or even more important than getting the initial values right. I had much trouble with that, and honestly for this particular subject i kind of miss examples. When i look at a big pickup truck i can see the springs getting highly compressed. Marcos state something like "xxx acceleration > formula > xxx Fz on back wheels, so you accelerate faster". The fact he didn't talked about car suspesions made me think :
  • It is not a very important part of the simulation (VERY wrong i think, now)
  • Suspension or no, i CAN get the force he is talking about, eventually, and maybe suspensions will just make the weight shift process a little slower (i guess it is really wrong too).

Here is a problem i still have : if weight transfer is more than a FEW percents, car can spin very easily or behave odd. When i see the raw acceleration weight transfer outputs, i find it hard to beleive spring/dampers can convert a totally incontrolable car in something smooth. So i looked elsewhere.... For a too long time. I mean, will i go from 15% weight transfer to 1% ? Or more from 15% to 12% ?

What is a typical cornering car weight transfer values ? On something like a lambo, and a drift car (to have extremes), if i decelerate from 200Km/H to 150Km/H, what can be the front/rear weight repartition at corner entry ? middle ? end ? Is it ok to have almost all cars to spin if the transfered weight ratio from back to front is more than 10% during serious cornering ? (i know you miss the steering and lateral tyres forces intel, but i'm just asking to have an idea of the effect of suspensions).

Actually i get pretty good results with 1% ~ 5% maximum weight transfer amount. It all depends of steering and lateral forces, wich varies from one car to an other.

---

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


I generally have this behaviour too. Slip angle is initially higher at front, it makes the car oversteer (with or without weight transfer). If accelerating, the cornering radius is getting higher very fast (understeering). Even more noticeable if you have an arcade front velocity directly coming from throttle instead of SR/torque. I think (hope) Kunos is right and a differential would help to create a front acceleration vector which has a small angle instead of 0. Thus helping in cornering. I was not confident trying to implement this for now, but i'm looking toward formulas and tips helping to create a diff. Unless the formulas are pure magic, i guess it is very hard to do this quickly.

---

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

+1. We need some real life values with a known-setup car to help us. Do you have the name of a book wich specifically has real examples ? Physics of racing maybe ?

---

A few questions :
  • What is a reasonably good lateral deceleration a tire can produce ? I mean, if i am at 50 meters/second front and want to turn right at 90° without making a huge drift, how much lateral G are realistic ? Or in other words what can be the cornering radius ? Reason i am asking this : my game is currently top down, and to see curves, they have to fit on the screen. So, i know my driving environment is far from realistic, and thus i need VERY good tires to turn. So let's say you kick a car lateraly so the Fy speed get instantaneously to 50 meters/s. What would be a reasonable stopping time ? 1s ? 5s ? I have done some research and it seems, F1 car do something like 5G of lateral acceleration, while a regular car is closer to 1G. But no one is trying to take a 90° corner with a regular car at 150 Km/H. I guess if it a crossover it is not even doable even if drifting ?
    If i have a 1500Kg car, with inertia of 3000 and a pacejka curve like this : peak@4° = 1.2, value@90°=1.0 my car handling is credible, but totally catastrophic, i cannot take any decent corner above 50KmH. I have to go to 20 or more in the 90° to make the car turn ok.
  • Do you see the peak of the long/lat curves as the maximum radius of the traction ellipse in that direction ?
  • Is there a formula to create an ellipse knowing the X/Y radiuses ?
  • If a front pacejka curve is not matching the lateral one : let's say i draw curves by hand and i am modifying them separatly as i try things. Is there a point at wich it is stupid to hope anything because those are so closely related (with SR/SA, traction circles) that everything has to be in perfect harmony (ie: lateral forces physically accurate regarding to front ones). That means i cannot let the player upgrade its front grip without having lateral grip to increase as well ?
  • In most car simulations, when the car starts to slide, it acts as it keeps sliding, like if a slide situation was more able to create a slide situation in the next tick. Or like if when sliding has started, the friction forces are modified. That make sense if you consider static/dynamic friction, but afaik, a tire cannot bo seen from this simple perspective. If i am cornering at 150Km/H, i guess everything is sliding here and there a little, and there no such thing as : "static friction, everything is alright"--> "sliding, so i have lost traction and cannot do much about it". But i don't know, we always read the patch is kind of "not moving" at a given time, so maybe even when cornering at high speed, i should consider the patch as static ? And then i would need to find out if it is in static or dynamic friction mode ? No idea if it is a legitimate question, and even less idea on how to determine that. Funny that jujunosuke had the same hope than me on this ^^ Anyway the response of Kunos is absolutly no static friction.
And finally, last but not least, something very important to me i am still not sure :
  • It is said the more acceleration, the more weight on the tire, and the more weight on the tire, the more grip. So why during intensive cornering, the outer wheels (which are the most loaded) are always the first to slide ? My guess ares :
a) It only happens when the lateral speed gets too high. So something related to static/dynamic friction like i am asking above. And lateral speed would be higher on outside side of the car ? Or even more crazy : in fact all wheels are sliding at the same time, the outside wheels are not always the first to slide in those situations.
b) Somehow the slip angles of the outside wheels are getting too high, the curve is getting down and slipping occurs ?
c) At some point, more weight means less force ??? I know the weight has diminushing returns on generated forces, it is not entirely linear. But when i looked at the values, even if not neglectible, it does not makes sense that the outer wheels slide first.
d) Only happens because of differentials + driver pushing throttle. So outside wheels are slipping, traction circle is outranged and increased weight is not important enough to counter the loss of magnitude of the "raw" lateral friction.
e) It is something else, maybe related to camber, or the fact that the car is simply not well balanced with too much weight on one side which means... too strong lateral forces ?

In Topic: [Car Physics] Proper driveline simulation

03 October 2012 - 04:47 PM

Hello again Posted Image

(i know i have a lot of things to answer in the other topic, but i'm not finished analyzing and trying all suggestions yet !)

This subject is very interesting, as i am willing to modelize a proper engine transmission too, eventually.

My main concerns are : inertia of components (varying with gear), inner friction and the differential.

I am very busy right now working on the purely handling part, so i cant try anything / do suggestions for the moment, but i can give you this link, which is very informative on the subject : http://hpwizard.com/...al-inertia.html

Other cool links on this website : http://hpwizard.com/index.html

But it is quite possible you already have this link in your bookmarks !

Good luck working on that driveline ! I stay tuned.

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

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.

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

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.

In Topic: [Car Physics] - Angular Velocity / Angular Momentum

26 September 2012 - 07:35 PM

Hi everyone. I have read this very closely as i have my issues with my own car sim. (So now we are at least 3 guys needing help ^^)

I agree with kunos, you can have the same behaviour with different parameters. For example you can have oversteer if you accelerate during cornering and outrange the traction circle on rear wheels. But the weight transfer created by the acceleration can add more weight to the back of the car and thus, produce understeer. Depends of settings i guess, or maybe i missed something again.

Vector3 lateralForce = this.transform.right * pacejkaLateral;
this.rigidbody.addForce( lateralForce );
If the body is the wheel, i do the exact same thing. My sim is not perfect (far) but it seemed ok for basical handling.

For sure I see a problem in your code, you are adding the lateral force at the wheel center and not at the wheel contact point, this is clearly wrong, and one of the effect would be to reduce lateral weight transfer left/right. Also the "right" vector of the tyre isn't the right direction for the lateral force that is generated on the plane of the road.. if you add it like that, the force will start to point "up" as the car rolls, this is wrong and will reduce load, thus grip.


At the wheel center and not at the wheel contact point > I know you're talking about 3D sim, but mine is 2D. So lateral force is just lateral force, applied at the wheel attach point, as it cannot more on ground than on wheel center, and i already have a LOT of lateral weight transfer, i have to limit it. My lateral transfer is calculated by me using lateral acceleration provided by total lateral forces on the body. I don't really understand the implications of that phrase for a 2D sim.

"right" vector of the tyre isn't the right direction for the lateral force that is generated on the plane of the road > Again i have trouble to understand what you mean. You mean if the contact patch is at some inclination, the lateral force should respect this patch position ? If it is it, again in 2D, i am not concerned directly.

The behavior you explain in your first post is not necessarily wrong , a well balanced car will not spin out...

Well it makes me think, probably none of us has a really good model of a "well balanced" car. At least i have read nowhere : "this is the data of a fun drift car", and "this is the data of some nice stable car".

If jujunosuke & bmarci agree with that idea, maybe we could start to share a model with preset parameters which could help us to understand what we are doing right, and what we are doing wrong Posted Image

Also, i forgot to mention that there is no weight transfer in my simulation, the load on the tire is always the same.
That may explain also some issue i have.

I would say yes. I can do some extremely fast spins with weight transfer activated (front/rear). I suggest you try to activate it and see if braking + steering allows for a fast car spin. If it is extremely fast and uncontrolable drifts, well you might have reached the same point as bmarci and me ^^

PARTNERS