Jump to content
  • Advertisement
Sign in to follow this  
jujunosuke

[Car Physics] - Angular Velocity / Angular Momentum

This topic is 2210 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone,

I actually use a physics engine for my racing game (physX) with a some rigid bodies.
Basically, i have 4 wheels that have a rigidbody on it and these wheels are connected to the body of the car via a spring.

I use Pacejka typical curves to simulate the tire model.
I have no problem so far regarding the basic move of the car, it work pretty well i would say.

But recently, i have played some nice racing game simulation and some car crash videos on youtube and noticed that something important was missing to my car simulation.

The Angular Velocity / Momentum !

In fact, my car behavior act like there is no angular momentum at all.. I mean, the weight of the car doesn't feel right..

For example, if i turn on the right at medium speed, and then counter steer, my car will NOT spin and loose control, the angular speed is immediately stopped..

But i don't think its like my car have too much lateral grip, its something different i think...

Something must be wrong on my rigid body settings..

My 4 wheels rigid body are about 40 kg each, and the car body is around 1400 kg.
I have tested with more weight on wheels and less on car body but, it doesn't fix the problem, actually its getting a little bit worst.
The best results i have so far is around 30 - 50 kg for each wheels.

Do you guys have any suggestions on this ?
How can i have a stronger angular velocity ?

i would like my car to spin!

Any suggestions are very welcome.
Thank you for reading.
Please forgive my bad English.

Share this post


Link to post
Share on other sites
Advertisement
Hi,
Does the PhysX calculate with friction between your wheel geometry and ground?
If so, it could add damping force to your pacejka forces. Try to ignore lateral forces first (set Fy=0) and see if you can turn the car.
Also you can try modifying the lateral pacejka curve. If it generates too much grip your car won't spin.

Share this post


Link to post
Share on other sites
You also need to set the inertia tensor for the rigid bodies. IIRC PhysX calculates it for you if you attach shapes to the rigid body, but for a car simulator it's much better if you get in control of these things. You might have your angular inertia very low.

Also make sure you get the terms right, angular momentum, velocity and inertia are very different things. It's impossible you "don't have angular velocity" if that was true, your car wouldn't rotate at all (ie. won't turn). Angular inertia is the rotational equivalent of mass. Edited by kunos

Share this post


Link to post
Share on other sites
Hi bmarci, hi kunos.
Thank you very much for your input.

Does the PhysX calculate with friction between your wheel geometry and ground?[/quote]
I am not using the usual friction for my wheels, i set everything to zero. (Like its on ice).
That way i am sure to control the friction myself with the pacejka curves.
If i lower the lateral curve it work better but its still not enough.. And if i lower the lateral force too much, it become less realistic in my simulation.. :(


You also need to set the inertia tensor for the rigid bodies. IIRC PhysX calculates it for you if you attach shapes to the rigid body, but for a car simulator it's much better if you get in control of these things. You might have your angular inertia very low.[/quote]

Thank you kunos for this great input !
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-inertiaTensor.html

You was right !
I will try to set the inertia tensor myself, play with it and see if it help me to get the desired result.
I'll give feedback very soon.

Also sorry about using not correct terms. its been confusing to me. I will make additional researches.

Share this post


Link to post
Share on other sites
Arf.. I tried to play with the inertia tensor, but sadly, that does not solve my issue..
I guess the problem should be somewhere else.

First i would like to confirm how i apply the lateral force on tires.

Basically, i get the tire slip angle, then, the slip angle is used as input to get the pacejka latera output force.
Then, i apply the lateral force like this :


Vector3 lateralForce = this.transform.right * pacejkaLateral;
this.rigidbody.addForce( lateralForce );


That may explain why the angular velocity of the car is stopped so fast in my sim ?

Share this post


Link to post
Share on other sites
as your simulator grow more complex you will see that it is impossibile to blame a single thing for something... just as a real car it all becomes a game of balance and deep understanding of car dynamics becomes essential.

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.

The behavior you explain in your first post is not necessarily wrong , a well balanced car will not spin out.. but anyway the situation can be explained by a HUGE number of factors.. some examples?

- Too much grip from the tyres.
- Wrong units fed to pacejka formulas (this is VERY common)
- Wrong parameters to pacejka (this is also VERY VERY common, cut & paste won't do, to properly use pacejka it is essential to deeply understand both tyre dynamics and how that formula is trying to approach and model the problem.)
- Angular inertia too low (tyres can stop angular velocity too quickly)
- Angular inertial too high (tyres can't unbalance angular velocity enough.. see what I did there? tongue.png )
- Rear tyre grip too high compared to front tyres (car will always autobalance itself)
- Wrong lateral and longitudinal force combination.. if there is a combination at all
- Wrong weight transfer calculations ... too much weight at the back

as you can see, there is a huge number of possible explanations, but the morale is, if you want to do a car simulator you NEED to get yourself very comfortable with car dynamics, tyre modeling and the concept that "everything influences everything else".. there is no shortucut for it. Edited by kunos

Share this post


Link to post
Share on other sites
Kunos, thank you very much for your very valuable input.

I know that its all about balance, and sometimes changing a simple parameter will after the whole driving feel and car behavior.
Basically, i am pretty sure of the output i got from pacejka, in fact i do not use the pacejka formula in itself, but i create the curve with a bunch of Math formulas.

The part that i have been actively looking is the force combination, i have already experimented few of them, that allow me to do some donuts and cool power-slides.

Anyway, that's just another issue.
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 will investigate furthermore..

Share this post


Link to post
Share on other sites
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 smile.png

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.[/quote]
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 ^^

Share this post


Link to post
Share on other sites
"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.[/quote]
Yes, your are not concerned by this as its for 3d sims only.



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 ^^
[/quote]
Yep, i will try to implement this as well.

After reading some more documentation about the subject, i have found something interesting.

First the vocabulary i used was confusing. (angular momentum, velocity and inertia).

What i wished to say is "Rotational Inertia"
My car is missing Rotational Inertia.

After a violent turn in relatively high speed, my car should continue to rotate in the direction i turned, because rotational inertia of a car could not be stopped that easily.
(Because of the weight of the car body).
So, after making some more researches i found this :

When i reduced tyre longitudinal and lateral force of the tire, i noticed that the rotational inertia of my car was much more believable.
But unfortunately, the handling ability of my car became really weak.
In the contrary, with stronger force, the turn and acceleration felt really good, but the inertia of the car is really weak.

So, i conclude this has probably something to do with static and dynamic friction of the tire.
What do you think ?

In my sim, this notion is not implemented yet.


Here are few questions :

If i go straight at a steady 100 kmh, my tires are still in static friction ?
Is there any simple way to determinate when my tire friction change state ? ( static -> dynamic) and (dynamic -> static) ?

Should i decide few constants ?

Any help would be greatly appreciated.
Best regards. Edited by jujunosuke

Share this post


Link to post
Share on other sites
static friction only applies at velocity = 0 , so forget about that :)

As for "drift", it took me about 13 years to come up with a global model that allows my physics implementer to do a "drift" car... it really is that hard :), and the more your model is complicated the harder it gets.

My suggestion is to start as simple as possible, neutral car, weight balance 50% front, same tyres front and rear... again, do not underestimate the role of differential modeling.. drift needs limited slip differentials, an open diff won't drift, and a spool won't drift.

Also, as I've said in other threads, calculating tyre load from lateral forces is fundamentally wrong, it'll disregard and destroy every action from the suspensions and tyres as springs.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!