Advertisement

Vehicle simulation shenanigans: My car slides uncontrollably and I have no idea why…

Started by March 14, 2023 01:08 AM
3 comments, last by bmarci 1 year, 7 months ago

So, I have all of this cool, fancy vehicle physics stuff which are forced to stay in my Excel sheets, because the basis of my simulation is wrong somewhere, the cars oversteer in every corner and are very twitchy in general. I kept throwing complexity at it, thinking the too simple simulation is the problem. Well, it wasn’t…

I use Pacejka’s formulas for tyre modelling. Currently the simplified model is in use. The code should be right (?):

  • get the contact velocity of the wheel transform or the ray cast hit point
  • convert it into local space
  • separate the vector into VCx(lon) and VCy(lat), Pacejka naming
  • calculate the angular velocity of the wheel
  • calculate the slip velocities VSx(from angular velocity, radius and lon contact velocity) and VSy(which is the same as lat contact velocity)
  • using your standard slip ratio and angle formulas
  • clamp the SR +/-1 and SA to +/- whatever 90deg in radians is, or convert them to whatever the tyre model needs
  • Fz is the suspension force for now
  • calculate pre-combination Fx/Fy
  • then calculate feedback torque from Fx, apply it to the angular velocity calculation

I used the coefficient from Edy’s site among others, but none of them really worked, I even tried curves that have basically no falloff and produce peak force after a set slip.

As for combined forces, I have Beckman’s formulas, although I also have MF6.x model as well.

I thought maybe the setup of the car was wrong, I tried super stiff front swaybars, stiff suspensions, low CGs etc. even though I had the “real” values

Honestly, I’m lost… I’ve spent a lot of time trying stuff, but none of them really worked, or were completely unrealistic. Maybe I have wrong values somewhere, if you could provide some from your project, I’d be glad. Maybe the local velocity needs some extra vector math magic, or I’m not using the correct axis system or I got the formulas wrong, although I double checked them a lot of times.

SiriusT987 said:
. I kept throwing complexity at it, thinking the too simple simulation is the problem.

Simplicity is never a problem. Actually a simple tire model with 2 parameters (slope and force cap) can produce convincing result.

Some ideas/questions:

  • do you have a differential in place?
  • what is your simulation frequency?
  • using your own physics or known engine, or any hybrid solution?
  • what are your spring and anti-rollbar stiffness?
  • the coordinate frames can trick you. calculate the forces in tire local, but apply them in vehicle local space.
  • instability in the driveline simulation can cause “traction loss”
Advertisement

Hi there, thank you for your response.

bmarci said:
do you have a differential in place?

I do split the input torque from the engine into two equal parts, but that’s it, no locked or limited slip diffs implemented yet, I need more research on them and I don’t really have enough data either.

bmarci said:
what is your simulation frequency?

I run everything at 1000Hz, but I haven’t really seen weird stuff at Unity’s default 50Hz either. No jittering at low or high speeds, at least not visibly.

bmarci said:
using your own physics or known engine, or any hybrid solution?

I use basic Unity, so PhysX.

bmarci said:
what are your spring and anti-rollbar stiffness?

For the suspension my base values 0.2m spring length, 50000N/m spring stiffness and 2500Ns/m dampers for a 1000kg car, 50/50 weight distribution. Now, I got rid of everything that's not necessary, but before that I used values from rFactor and AC mods for testing.

bmarci said:
the coordinate frames can trick you. calculate the forces in tire local, but apply them in vehicle local space.

I’ve seen this in Racer as well, but I’m not entirely sure what it means. As I said, I take the velocity of the raycast hit or the wheels transform, do an InverseTransformDirection to convert it to local space and I use the longitudinal and lateral velocities for the slip angle/ratio, then I multiply the forces with a transform.forward/right, which is in world space. The wheels are parented to the rigidbody, so I think that I apply the forces in vehicle local space? I must be, because I tried to convert the force application points as well as the transform.forward/right vectors in every way possible, which ended up making things infinitely worse, including car with no steering and the car having a seizure.

bmarci said:
instability in the driveline simulation can cause “traction loss”

Well, there’s no driveline anymore so I doubt it’s that. I just apply constant torque to the rear wheels, like an EV.

Of course, I apply the throttle, brakes and steering smoothly. As a matter of fact, it turned out that a lot of the oversteer was due me being an idiot and setting up boat steering for an AE86. Basically, I wasn’t able to countersteer fast enough. Sadly, I don't have a wheel so I can only use controller and keyboard inputs, but that shouldn't be a huge issue, given that none of the inputs are on/off switches anymore.

The problem, while not as severe now, is still there. I smoothly apply full throttle/ part throttle on corner exit or in some cases no throttle at all and the back end keeps getting loose instead of understeering, which wouldn’t be a bad thing... IF it wasn’t a car with only 150Nm engine in 3rd gear and I wasn’t limiting slip ratio to 0.1 already(as far as I know this is what TCS does, but I skipped the braking part). Yeah, sure do that at 500Nm, but even then you can control it with small throttle inputs and keep the car on the track…

I think that there is a problem with the way I get the vehicle speed for the slips or the way that I apply the forces or both.

Currently I'm in the process of rewriting the whole thing for the 6489896421th time, adding in some more stuff, like proper clutch, instead of an on/off switch, downforce, brake torque depending on disc size etc. and when I'm done, probably tomorrow, I will make some videos or GIFs, so you can see what's going on, maybe find something in the telemetry that I don't see. In the telemetry I have VSx, VCx, VCy, slip ratio, slip angle, lon, lat forces and Fz per wheel as well as throttle and brakes, plus a speedometer and probably a tach and clutch as well by then, should I add anything else?

By the way, how “simulator” is your simulator? I've gone down the rabbit hole and plan to include a lot of stupid stuff, like wind effects, full suspension geometry, chassis stiffness, component wear and efficiency based on temperatures etc. would I be able to and more importantly would you be willing to chat about this stuff?

SiriusT987 said:
do split the input torque from the engine into two equal parts, but that’s it,

So, that's a locked differential ?
Your suspension values seem ok, but the damping could be higher, and don't forget that stiff rear suspension causes oversteer.
Also it's worth considering to separate the bump/rebound damping. The rebound can be the double or more.

Your slip calculations may be a bit off. I don't remember if physx had helper functions to calculate the velocity of a given point in a rigid body.
Thus you could get the CP's world space velocity (that also considers the car's yaw velocity), and then you'd transform it back to the wheel's local space to calculate the slips.
It's been a while when I did this, but was very important to get it right (inspired from Racer as well). Hard to give references as I have my own rigid body sim, and it's a bit different from physx :(

Anyway, I'd suggest that you should validate if your coordinate frame conversions are correct. This is very-very-very-very…. important ? Lots of formulas are given in their own reference frame, so you'll have to convert them.

SiriusT987 said:
Well, there’s no driveline anymore so I doubt it’s that. I just apply constant torque to the rear wheels, like an EV.

That will be a fun part, I couldn't nail it for years, so I made a fake one, and used it for almost 2 years. Just like yours (apply constant torque). You can get quite far with such solution.
The fixed axle that you have in place is good for drifting. I'm not a big drifter, but I remember I read something about welding the diff to get better oversteer.

SiriusT987 said:
Currently I'm in the process of rewriting the whole thing for the 6489896421th time, adding in some more stuff, like proper clutch, instead of an on/off switch, downforce, brake torque depending on disc size etc.

Downforce and aero drag are quite easy to add, and play important role at high speed.

Yes, some video/telemetry would be nice! ?

SiriusT987 said:
By the way, how “simulator” is your simulator? I've gone down the rabbit hole and plan to include a lot of stupid stuff, like wind effects, full suspension geometry, chassis stiffness, component wear and efficiency based on temperatures etc.

My “simulator” is just a wannabe. Few years ago I realized that without proper data your sim will not be any better than a simple approximated/cheated solution.
For example, you can go for a proper kinematic simulation of the suspension arms, but how will you get the arm length, attachment positions, weight and spring inclination…etc of your favorite Ferrari? You can measure it if you have one ?
And tweaking those values can be painful, especially if your anti-pitch or lateral-jacking characteristics doesn't work out.
I'm already in the rabbit hole, but I have a lots of “educated guesses" instead of real-world approach.
There is no chance you can get real tire wear/grip or temperature/wear combo sheets.

This topic is closed to new replies.

Advertisement