• Create Account

# bmarci

Member Since 05 Jul 2002
Offline Last Active Yesterday, 01:18 PM

### #5315596Systems of gears (Car simulation)

Posted by on 17 October 2016 - 04:22 PM

Hi,

I remember this was the most mysterious part in my sim. I couldn't find any usefull info on the topic, not even here, only foggy and misleading docs everywhere, like it had been the most difficult problem of life, or something. It was very frustrating.

I also remember trying what you did, just spinning the rear wheels (fake it) and managed to achieve quite believable result.

And finally I god enlighted by myself

I strpiped down the problem to a simple acceleration test in 2d (side view) having only one wheel. It was much easier to follow what the heck is going on.

First forget about the differentials, they make your problem even more difficult to get it right. Do a fixed axle for first.

So, in a nutshell;

You have to differentiate two major cases, when the clutch is locked and when it's "slipping".

1. When locked, the whole stuffs rotates together and can be handled together.
You can indeed derive the rpm from speed, but instead of using linear speed use the wheels angular velocity.
Calculate the torque from the engine, through the gearbox to the wheels and accelerate only the wheel usng (torque_drive + torque_road) / effective_inertia
As you accelerate the wheel calculate the rotation speed of gearbox and engine back from the wheel rotation. Pretty simple.
2. When the clucth is not locked, you have to separate the engine and the rest of the driveline.
Use the engine torque to accelerate the engine only, and do the same as in (1) to the gearbox to wheel acceleration with the difference of using a portion of engine torque. The "portion" is the amount that the clutch can transfer depending on the pedal position.
Here is an extra torque created by the clutch that accelerates and decelerates these two to synchronize their speed.
And the same as above calculate the gearbox rotation speed from wheel speed (the engine is calculated separately)
3. And you are done. The only thing you have to take care of is when to open and close the clutch, and its only a relation between the pedal position and the amount of torque going through it.

I hope it was clear somehow.

You'll need this: http://www.racer.nl/tech/effinertia.htm to calculate the inertia of the whole driveline or just part of it.

Regarding transmission efficiency, I didn't have an idea where to "put" it, so I just left it out. It looked cool without it, though.

My guess would be, it's enough to use the efficiency "loss" once, when the torque is calculated that accelerates the wheel. The reaction is handled at the wheel too, it's "not going back" to the engine that way.

### #5287913Engine RPM and wheel angular velocity

Posted by on 21 April 2016 - 01:44 AM

I start to understand some of the things, but it's still difficult for me to compile data from text. I'd be really thankful for some sort of chart or something that gives a nice overview of this topic. Huge thanks already for the help so far! ;)

unfortunatelly some of these things are beyond math or physics. you have to learn how things work and figure out some logic that mimics the real thing. you can write accurate simulation, but many times it's just overkill and no visible difference anyway.

apart from some basic math there are no universal equations that fit all sims. this is why it's difficult, and this is why we like it

you may already found this site: http://www.racer.nl

lots of technical info and the source of an early version is still available.

you may also want to check out the rec.autos.simulators google group. around 2000-2003 search for [car physics]
you'll find posts from people who later made test drive unlimited, assetto corsa and such games

### #5284445Best way to simulate weight distribution between car wheels

Posted by on 31 March 2016 - 02:43 AM

Are you sure that bullet has the weight transfer?

sure, every physics lib that handles forces and torques has it

the weight transfer is a derived figure that you can calculate from the simulation, and not something that you have to do yourself. it's like the engine power (horsepowers)

### #5284364Best way to simulate weight distribution between car wheels

Posted by on 30 March 2016 - 05:11 PM

In weight transfer, the best thing is that you don't need to calculate it at all, as Edy wrote

Simply just calculate the forces that act on the car:

- wheel, from your tire formula

- aero dynamics, from whatever formula

- gravity

- suspension (from previous iteration)

- etc

As you apply the forces, the car's body will start pitching/turning. If you measure the distance from the suspension attachement point to the ground you get the compression/expansion amount of the springs, so you instantly know the force that pushes the wheels down and pushes the chasis up (don't forget to add this force to the car body)

However this is not the best method, but good for starting.

Later you'll want to calculate with the wheel's mass too and handle it as a separate rigid body, and use the tire's compression instead of the suspension's.

### #5284359Engine RPM and wheel angular velocity

Posted by on 30 March 2016 - 04:50 PM

Hi, I remember, this part was the most difficult for me to get it right.

The Marco Monster's tutorial is great for getting the idea.

In fact the engine-clutch-wheel rpm mayhem has 3 situations.

1. The clutch is engaged, the whole driveline turns as one assembly, as mentioned above

2. The clutch is disengaged, the engine is turning on its own and so does the rest of the driveline (or standing still in your case)

3. In between, when you start engaging the clutch this will move the engine and wheel's angular velocity to the "same" speed, this is why the engine rpm drops when the wheel starts turning.

This sounds easy, but first I'd suggest making a one-wheel car to see it in action (a simple 2d app where you see a single wheel turning, no fancy thing)

First don't bother with differentials, they just screw everyhing up

Also a very important thing is the inertia of each component, in all 3 of the above cases you'll need different inertias.

This is a great article for this: http://www.racer.nl/tech/effinertia.htm

For you the #3 case is interesting.

The clutch has a maximum torque that it can transmit to the gearbox, as you depress the pedal, it increases from 0 to this max value.

A simple example: your engine produces 200Nm torque, and the clutch is 90% down and it can handle,let's say 80Nm. In this case only 80Nm is going to the transmission that accelerates the wheels

You can imagine as the torques "circulate"

1. it starts from the engine

2. some of the engine torque goes to the transmission

3. the gearbox multiplies this by the gear ratio

4. through the diff it arrives to the wheel

5. the wheel start rolling, and from your tire formula you get the road resistance torque (the same that pushes the car forward)

6. this resistance torque goes back to the transmission trough the diff, and gets divided by the gear ratios

7. according to the clutch position some of it arrives to the engine and slows it down

...and repeat this in every simulation step.

I hope I gave you some idea.

### #5127424Invalid internal pointers after startup

Posted by on 30 January 2014 - 04:23 AM

the "body" and "obj" are the same pointer and freed before remove.

### #5117819[Car physics] Force feedback and such enjoyment

Posted by on 18 December 2013 - 06:22 AM

Hi,

I started playing with force feedback wheels, and as I noticed this is the point where most people had already given up or it's just simply out of their interest.

Anyway, I'm having a hard time finding good writings about decent force feedback "simulation", so I have to take the hard way, figuring it out.

Hopefuly some of you are also into this topic

Here are some notices and questions that arose:

- There is a strange behavior even if driving straight, the steering wheel wants to "go slalom", I noticed the same effect with some AAA driving game, but not with Gran Turismo. Maybe it's the toe-in or camber that generates some torque, which are not equal for both wheels and "magnifies" with speed. My quick solution is to have a dead-zone and some damping at the center, so I can release the wheel at 300km/h and not hitting the wall

But it feels there is no grip around the center. It builds up as I turn but not instantly.

- I'm using the good old Pacejka to get the aligning moment, but it not incorporates the caster angle, is that an important factor, or can that be neglected? Also, where should the Mz curve's peak be? At the peak of Fy's? Or should it go back to zero at Max Fy?

- Road surface feedback is what I did yesterday. I'm using constant force for aligning moment, so it seemed obvoius that I should add some "noise" to the current FF force depending on the surface, but it just doesn't make that rumble effect that I expected. Am I on the good way or should I turn my attention to custom FF effects?

That's all I can remember now, and thanks for every help, ideas and opinions...ect.

By the way, this is where I'm now:

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

Posted by on 04 October 2012 - 04:32 AM

One more thought on suspensions (for dummies (mostly myself) ) through an example.

For the simplicity I'd represent a car with a box with 4 corners for each wheel attachment point, and 4 points for the wheels' contact points.
The 4 points are constrained to the 4 corners of the car with a spring/damper.
To make our life more difficult let our wheels have their own mass.

The spring/damper has the following parameters:
k = spring rate
b = damping rate
L0 = restlength (is it the measured length of the spring if I put it on my table???, no forces acting on it)
Lmin, Lmax = minimum/maximum extensions (how much can it be compressed or stretched)

Given the spring formula; F=-kx-bv
where,
x = spring compression (difference between spring current length and restlength)
v = velocity difference between the two ends of the spring (if a wheel is attached this is the vertical speed of the wheel)

In the simulation step;
1. Suppose we have a working dynamics, our car starts freefalling at the first step.
2. The 4 wheels' contact points sink into the ground, so the "x" gets a nonzero value, thus one can calculate the current load on the tyre W=kx
3. Since x is nonzero a spring force is generated (F) that is applied to the contact point and the corresponding corner of the box.
4. If the wheel is touching the ground all spring force (F) is applied on the box corner, otherwise it's divided between the wheel and the body;
5. Applying that force back on the car body, changes its linear and angular velocity, and the vertical movement of the wheel
6. Now we can calculate the new x and v for damping in the next step. The Lmin and Lmax can be used to limit these values.

^^^ Could this work????

Couple of things to clarify;
1. Does the amount of weight transfer depend on the stiffness of the spring?
Or, is the same weight transferred with a 200kN/m spring as one with 50kN/m but much faster?
2. The value x is almost always nonzero, so the spring is never reaches the restlength and oscillates forever.
3. Maybe not relevant, but if the suspension has double springs (like all my lego cars) can it be handled as one, just summing the spring and demper rates?

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

Posted by on 04 October 2012 - 03:17 AM

2) "Sim" multibody approach. Here each tyre is a separated rigid body connected to the car body either with a joint, more joints, or more rigid bodies.
In this situation the tyre is a spring too, when it collide with the ground it will "sink" into it, this "deflection" is used as a compressed spring, it pushes tyre up at it represent your load. So simply:

For tyres you are looking into the 200,000 N/m spring rate and a 400 N/ms for damping.

This is what I always had hard time to imagine
Using the spring/damper formula:

F = -kx - bv

where:
k is the spring rate, 200000 in your example
x is the deflection

So the load is simply kx?

Also, in a multibody situation, suppose the wheels are made of steel, so only one spring is there.
The spring would act on both the wheel and on the body. This becomes more obvious when the car lifts off the ground, so the spring pushes the wheel down and the body up.
In this case the applied spring force is divided between the wheel and body in the ratio of their masses. Is that correct?

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

Posted by on 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

### #4983162[Car Physics] - Angular Velocity / Angular Momentum

Posted by on 24 September 2012 - 03:45 AM

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.

Posted by on 17 September 2012 - 03:30 AM

were the same as yours, i haven't really looked into this issue, so right now i use some simple dots. Oh and the 1164N output force (peak) for a small 1N load input confused me too. But i still can inspire of the general shape.

The Pacejka MF, takes KILO NEWTONS as input load, so your 1N is actually 1000N!

I was twiddling with stability and controlled drifting and such in the weekend and realized that the weight transfer has significant importance in cornering and control, which makes sense, but also confuses me why anti-roll bars help stabilizing in corners.

Without weight transfer my car was incredibly unstable at high speed (>100km/h), even with a very small (2-3°) steering angle it spun around instantly.
Adding some load transfer helped, but it was still oversteer without throttle. With throttle it was just understeer, but no inbetween... So I cannot play with brakes and throttle to control drifting.

My weigth transfer formula is:

W=m*GRAVITY
Wf=(c/L)*W-(h/L)*Fx
Wr=(b/L)*W+(h/L)*Fx

For 4 wheel weight transfer, I'm not sure if this is the right thing to do:
Just transfer along axles based on lateral acceleration.

Fz_front_left=0.5*Wf+(h/Track)*Fy
Fz_front_right=0.5*Wf-(h/Track)*Fy
...the same for the rear wheels...

Fx, Fy - Forces acting on the car's body in car space
c/b = Axle distance from the CG
h = Height of CG from ground
L = wheelbase
m = Car mass
Wf, Wr = weight on front/rear axle
Track = Distance of wheels on the same axle

Adding some jacking force helps a bit, but still not the result I expected.

F_jack=Fy*h_roll_center/(Track/2)
Fz_front_left-=F_jack
Fz_front_right+=F_jack

h_roll_center = roll center height from ground

Maybe I'm mixing up things, or should I implement a proper suspension model, where all spring and dumping forces do all the weight transfer and the formula above is not needed at all?

I was also playing with car settings, and it seems a front engine car (60:40 weight balance to the front) is more controllable than a mid-engined (40:60) which should not be.

Posted by on 13 September 2012 - 04:59 AM

As i understand it, when wheels are centered, the lateral response will be perpendicular to wheels, and will then slow down car rotation, but it will not introduce longitudinal force. The longitudinal force component present on the wheel during spinning will just introduce a diffrent slip angle result.

I would argue with that. In your post #6, the blue arrow IS the real velocity of the tyre, which is perpendicular to the vector from CG to wheel pos, but not to the wheel's heading.
So it WILL generate both long/lat forces. If you do the same calculations for the remaining 3 wheels the sum of all Fx's will be zero if the CG is at the center of the car, so that's why there is no movement of the car body.

I re-checked marcos page for the steering section. He claims, after determining lateral force using pacejka curve, that they have to be applied to the car body. He will apply both lateral forces directly to car body, and then use them separatly to calculate torque and finally introduce some yaw. Fine for me, but what does he have to say about the lateral component of the front wheels ?

Since Marco is using only two wheels (front/back) his lateral forces are always tangential to "yawing circle", with centered wheels. If you are thinking in more wheels, this is mostly not the case.

What worked for me is:
1. Calculate long/lat forces for each wheel and create a force vector of them, VForce = {lat_force , long_force} in WHEEL space
2. Transform VForce to the WORLD space (as an ordinary 2d verctor) and add them together for all wheels (so you have a total 2D force vector acting on the car body)
3. Using the Car's mass you will get the acceleration and thus the velocity in WORLD space. acc=ForceTotal/Mass
4. For rotation, transform the VForce to CAR space, and -here comes the tricky part- split the VForce_InCarSpace vector into 2 components. One is perpendicular to the (CG->WHEEL) vector and the other one is parallel
5. You'll need the one that is perpendicular, get some idea from here: http://en.wikipedia.org/wiki/Vector_projection
6. Multiply the resulting force component by the wheel distance from CG and you get the torque that the wheel aplies to the body around the CG
7. Sum all torques and with ang_acc=TorqueTotal/BodyInertia you get the yaw angle acceleration of the car body

Do you know if traction circle should be applied before or after taking count of weight load ? Because when i slow down the car in/before curves, so much weight get transfered to the front that the lateral force increase happens way too fast and the car can make an half-turn really easily. I feel like traction circle should be capped at some maximum load or maybe my weight transfer needs a real spring instead of a simplistic time integration of the weight transfer.

The weight load is an input parameter to the tyre model as well as slip ratio and slip angle, if you want to cap the result to the limit you have two options (I've found so far)
1. The most typical way is to cut down the resulting forces (Fx/Fy), you can perform single vector scaling or prefer one over the other (eg: use all the long_force and use as much from lateral as much remained in the traction budget)
2. The other one that works me the best is to cut down the input parameters (slip angle/slip ratio) See chapter 24/25 of PHORS.

Posted by on 11 September 2012 - 08:25 AM

Hi PochyPoch,

Here are some remarks that helped me to get it, if not even right, but an acceptable result
1. Create transform functions between coordinate systems (World, Car, Wheel) and double check if they produce the wanted results.
2. Calculate everything in its own coordinates, eg: wheel forces in wheel space, car forces in car space...etc
3. Forget about steering angle in slip angle/ratio calculations. If you have the right transform functions, that will take care of steering angles.
4. Check the result of the ATAN(lat/long), especialy when dividing by long=0!!! The result should be +-PI/2

This is my transform from WORLD to WHEEL, in case of velocity:

angle = -car_yaw_angle-wheel_steer_angle
sn = sin(angle)
cs = cos(angle)
vel_x = cs*world_vel_x + sn*world_vel_y
vel_y = cs*world_vel_y - sn*world_vel_x

(X+ right, Y+ forward/up)

In the last video of your original post (around 0:20) I see something like: timestep = 50/1000
Be careful with this large timesteps, it can cause stability problems with integrating.

I hope I didn't confuse you too much

PARTNERS