Jump to content

  • Log In with Google      Sign In   
  • Create Account

bmarci

Member Since 05 Jul 2002
Offline Last Active Oct 09 2014 12:15 AM

#5127424 Invalid internal pointers after startup

Posted by bmarci on 30 January 2014 - 04:23 AM

Sorry, my bad unsure.png

 

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




#5117819 [Car physics] Force feedback and such enjoyment

Posted by bmarci 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 bmarci 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 bmarci 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:

tyres[i]->load = tyres[i]->deflection * tyres[i]->spring;

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


#4980823 Car Simulation Headaches Part_#2

Posted by bmarci 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.


#4979663 Car Simulation Headaches Part_#2

Posted by bmarci 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.


#4978895 Car Simulation Headaches Part_#2

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