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

Started by
36 comments, last by bmarci 11 years, 4 months ago
well if you can't or don't was use 3rd parties physics library that doesn't mean you shouldn't try to learn something from them ;)

Having a solid and well tested RigidBody class with addForce, addForceAtPos, addLocalForceAtPos, addLocalForceAtLocalPos and so on, member functions should be the first step in your simulator development ;)

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

Advertisement

well if you can't or don't was use 3rd parties physics library that doesn't mean you shouldn't try to learn something from them ;)

I used ODE many years ago and tried Bullet recently. Simply it's not a simulator project I'm working with, not even a game, so I don't want to "mess" the codebase, I just use it as a sandbox :)
So as soon as I have "serious" results, a new project prbably with Bullet will be the first thing.


Having a solid and well tested RigidBody class with addForce, addForceAtPos, addLocalForceAtPos, addLocalForceAtLocalPos and so on, member functions should be the first step in your simulator development ;)

Accomplished :P
About suspension and weight transfer, i don't know if the solution i used can help any of you guys.
It is just a simplification of the concept, but honestly, i got pretty decent result and my simulation got better.

As kunos said, i use physX as my physics engine, with 5 rigid body connected with joints.
Basically i calculate the spring compression based on the distance of center of my wheel to the distance of my spring attached to the body of the car.
You can decide about the spring distance free height. I set mine to 0.36 meters.
That mean, if the car body is 0 kg the spring should not be compressed and give you 0.36 meters.

Then i just do some calculation of the distance. Vector3 of the center of the wheel, Vector3 of the joint position.
I then make calculation to get a result between 0 and 1.

0 mean that the spring is stretched to the max and give 0 grip. (spring free height)
1 mean that the spring is compressed to the max and give 100 % of grip.

once you made that, calculate the total force that your tire should provide and multiply it by the result of the spring compression.

Works decently for me and was really simple to implement.
But of course, this technique is valuable only if you use a 3d physics engine as mentioned.

I don't know what kunos think about this way of doing though..

At this level, it's all about game and fun with an acceptable level of physical accuracy, and thus as everything in game programming it's all about cheating as much as possible. So there ARE miracle recipes as long as you are not a professional in aero dynamics or in suspension geometry setups.
Later when we work out everything about differentials and tyre simulation those magical solutions will disappear.

I am not even talking about realistic simulation, i am talking about something really simple, the basics.
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.
And gamedev forum should be there to help you to answer question on a particular point that you don't understand for example.
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 easy and enjoyable to read IMO.


Anyhow.. you seem to want to complicate things a lot .. they are REALLY simple:

Having a solid and well tested RigidBody class with addForce, addForceAtPos, addLocalForceAtPos, addLocalForceAtLocalPos and so on, member functions should be the first step in your simulator development ;)


That's exactly my ongoing work: nailing down the basics of vehicle simulation in a way that could be easily understood and used by anyone. Yes, there are really simple ways of doing pretty realistic vehicle simulation. Yes, there are "miracle" recipes, but they are not so miracle, they are just some simple formulas combined in the proper way. And YES, working on differentials, tire simulation, etc could still be simple and comprehensive.

Hopefully a good tutorial should be the result of this work (unless I'm proven terribly wrong tongue.png)


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).


No calculation: you set up a vehicle as a rigid body mass suspended on 4 damped springs. If you drop that vehicle from 1m on a surface, it will fall down and when the springs make contact with the surface, they will compress and expand while supporting the mass of the vehicle. Eventually, the damped springs will absorb all the energy and the vehicle will stand still. At this point, the physics engine has done everything for you, you haven't had to code anything yet.

The physics engine allows you to access the 4 contact points with the surface, as well as all related information on each one. This includes the position, normal vector of the surface and the downforce, that is, the force supported by each spring at any time.

Now we start to code. You instruct the physic engine to apply a force to the rigid body of your vehicle in the positions of the contact points (AddForceAtPos). The engine will then simulate the effect of that force at that rigidbody, and what happens when you apply an off-center force on a rigid body? It causes rotation! (torque). The engine will take care of the calculations for simulating that behavior. So imagine that the force you've just applied is located at the contact point of one of the rear springs ("wheel") and is pointing forward. It will cause the rigid body to want to rotate backwards. But the rear springs will counter act this trend by compressing (and thus exerting more force). At the same time, because of the rotation the front springs will expand (exerting less force). Here you have your weight transfer, and all you've done is "AddForceAtPos".

The physics engine gives the downforce on each contact point. So you can use this value for calculating the magnitude of the force you will pass to "AddForceAtPos".


+1. We need some real life values with a known-setup car to help us.


Here are some gems from Kunos (of course ;) ). These real world data are really valuable as they give us a reference of the values we should use and expect to see in the results. Maybe they should go to the first post?

[quote name='kunos']
I found a ratio of 1.1 (Fx=Fy * 1.1) is a good starting point.
..
For tyres you are looking into the 200,000 N/m spring rate and a 400 N/ms for damping.
..
It depends a lot.. a typical road tyre will give you 1.0 - 1.1 G.. with load sensitivity and all you should get close to 1.0G on a skidpad. A normal road car with 1.0G lateral acc is considered VERY good (ie. the BMW Mini scores a tad less than 1.0G and is considered a very good handling car).
..
Continuing the grip references, for a high performance road tyre (high end supercars) you see 1.2 - 1.3
Racing slick tyres range from 1.4 to 1.9 depending on compound.
..
The more load on the tyre the more the friction coefficient goes down. A tyre that can do 1.2 at 1000N, might give you 1.1 at 2000N . That is why the loaded tyre will be the first one to "break" grip.
[/quote]
Hi again,
My hobby car project is going fine, I stepped into the wonderful world of 3d physics :)
Suspension/tire spring/anti-rollbar are complete and seem to work, at least they look good.
The new tire model is not implemented yet, so the car is skating on ice.
Here is a reference video:

No force is applied to the body, only the gravity is acting, the wheels are reacting nicely to banks and the the underlying geometry.
The weight distribution is also fine, the sum of measured suspension forces equal to the mass of the car (in steady state)

Now, I have a concern about the jacking forces.
There are two formulas, Milliken uses the Instant Center and others use Roll Center, but probably the results are the same.

Using a roll center that is below ground a right turn (Fy+) would generate a force acting downward at the left tire, and upward at the right.
If the roll center is above ground the whole thing works the opposite way.

I don't know what to do with that force;
1. Apply it on the car body at the suspension attachment point, so it would push down the chasis at the outside corner, adding more load
2. Add this force to the suspension spring force ???

I just drawn a small figure:
jacking.jpg

I hope it's self explainary, the length of arrows are not relevant :)

So where does the Fjacking act? (A/B/C ?) or other?
Another confusion about roll centers, and applied torques:

I though I should have applid forces generated at the contact patch using the car's CG.
But recently I found a couple of writings about roll centers, and the usage of RC instead of CG.

What do I mean, you may ask:
Normaly I calculate body torque using T=BodyRelPos [cross] BodyRelForce
I also found in Racer that Ruud calculates some components of the torque with regard to Roll Center instead of CG.
Lateral jacking?

I'm still far from being clever enough :)
I believe that suspension geometries go far beyond "where this force applies". As far as I can figure out, all forces act on the rigid body at the point they are applied (C in this case, with respect to CG). However, the "intermediate path" and its consequences (i.e. suspension, roll center, etc.) are not easy to calculate. I think it's something related with solving inverse kinematics, unless you are using a physics engine allowing "hard" joints and constraints. In this case you would just apply the force to the wheel's attachment point and the engine would properly propagate it to the rigid body. Again, these are my thoughts, I have no real experience with this.
Thanks Edy,
I tought of C too, but whatever I do, without adding this jacking force everything seems buch better, so I just abandon it for now.
The biggest problem is my "good" old instability problem came back, namely it's hard to take a corner over 50-60km/h.
Too much understeer, maybe I have a crappy steering and that causes the tires to loose traction.

This topic is closed to new replies.

Advertisement