   Simplified Pacejka Magic Formula
  Hi,Lately I've been looking into the Pacejka "Magic Formula" for the car simulation I'm doing. I've found two simplified, approximations of the formula that work for both the lateral and longitudinal force here: http://www.apatira.net/portfolio/mftk/ and here: http://phors.locost7.info/phors29.htmMy question is, what do the A, B, and P values actually mean? I might want to mess with these, since my car simulations may or my not be used for realistic simulations. Will I be able to play around with the stiffness and dampening with the Pacejka formula? I'm mainly interested in the lateral force, and not so much the longitudinal force.Thanks!   
  It's difficult to assign them physical properties. They're simply nondimensional parameters that fit the model nicely.You can get a feel for how they affect the model by seeing what happens when you change them:B is a linear factor in the numerator, so it is a direct measure of the force. Scale B by a given factor and you'll scale the resulting force by the same. That's the easy one. A is a measure of how steeply the curve changes near α=0; the higher, the sharper. P has an effect on how quickly the curve returns to a flat shape after the initial linear phase. (0, 1 + a bit) tilts the gentle curves as given in the article. Large values above 2 cause the curve to overshoot a lot before returning to equilibrium (as |α| increases). If you have any curve-plotting software, you should fire it up and play around for a bit.Admiral   ;  Ahh, thanks a lot :)   ;  I would reccomend using the standard pacejka formula.It just so happens that the Racer free open project has already coded it in C++ and has made the source code available for all.I have included a pacejka section, with source code + coeficients (long and lateral versions) and the racer web pages in a car physics resource download on my website.I have succesfully ported the Pacejka code and is used my game Auto Cross Racing, also available on my website atMy Websitehttp://www.kjmsoftware.co.uk/And the Racer websitehttp://www.racer.nl/KJM;  I used the simplified version and it worked great.   ;  If i remember correctly, the Physics of racing series pacejka aproximation had an error in the equations.I e-mailed brian beckman about this, but didn't recieve a reply.I can't remember if it was the long or lat version which had the error.  I'd be interested to hear if anyone has had similar problems with his equations.  Or just me.KJM;  Thanks guys. I've actually decided to go with actual formula. I've got some question on how to actually use the forces once calculated.1.) I have also been calculating a wheel torque for each wheel from the engine/motor torque. My question is, can this still be used? I was thinking about converting the longitudinal force to a torque, add to the wheel torque, then turn the result of that back into force. I would use it then like this:CarRigidBody.AddForceAtPosition( theForceFromWheelTorqueAndLongitudinalTorque, wheelPosition );In case you were wondering, this is how I calculated the wheel torque:private float CalcMotorTorque( float motorRPM ){// Could try this insteadfloat x = (2*(motorRPM/maxMotorRPM)-1);float torqueCurve = 0.5f*(-x*x+2);return Berp( minMotorTorque, maxMotorTorque, torqueCurve );// My first attempt/*float lerpValue = Mathf.Sin( motorRPM/maxMotorRPM );return Mathf.Lerp( minMotorTorque, maxMotorTorque, lerpValue );*//*float berpValue = motorRPM/maxMotorRPM;float torque = Berp( minMotorTorque, maxMotorTorque, berpValue );return torque;*/}private float CalcWheelRPM(){float wheelRPM = 0.0f;foreach( WheelControl w in wheels ){wheelRPM += w.wheelCollider.rpm;}wheelRPM *= 0.25f;return wheelRPM;//Mathf.Abs(wheelRPM);}public float CalcMotorRPM( float wheelRPM ){float engineRPM = wheelRPM * gearRatio * diffirentialRatio;if( engineRPM > maxMotorRPM ) engineRPM = maxMotorRPM;//engineRPM = Mathf.Max( engineRPM, minMotorRPM ); // IS THIS NEEDED?return engineRPM;}private float CalcWheelTorque( float accelPedalInput ){float motorRPM = Mathf.Abs(CalcWheelRPM());motorRPM = CalcMotorRPM( motorRPM );float motorTorque = CalcMotorTorque( motorRPM ) * accelPedalInput;return motorTorque / gearRatio / diffirentialRatio * transmissionEfficiency;//return motorTorque * gearRatio * diffirentialRatio * transmissionEfficiency;}// Taken from UnifyCommunity Mathfxpublic float Berp(float start, float end, float value){value = Mathf.Clamp01(value);value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value)));return start + (end - start) * value;}2.) Can I treat the longitudinal force and lateral force separetly? IE, do something like this[source lang = "c#"] // calc the lateral force and longitudinal force and what notCarRigidBody.AddForceAtPosition( theForceFromWheelTorqueAndLongitudinalTorque, wheelPosition );CarRigidBody.AddForceAtPosition( lateralForce, wheelPosition );3.) If my presumption in question one is wrong and I can't use the wheel torque, how do I initially get the car moving since the slipRatio would all ways equal 0? The input I get from the user (from the up and down keys) is a values between or equal to 1.0 and 0.0 (this is why the wheeltorque idea seems to be reasonable to me.).Thanks![/source]   ;  Bump(?)I'd really appreciate some insight :)   ;  The main input needed for lateral pacejka is the slip angle of the wheel / tire, along with camber and load.You can keep the camber and load as constants, while your getting your code to work.  Later on, you can work out the load on each tire as the weight of the car shifts about under breaking and acceleration ectThe slip angle of the wheel / tire is the difference between the longtitude velocity of the wheel and its lateral velocity, in wheel / tire frame of reference, not world frame reference.So, to get the tire frame of reference, you would need to transform the tire / wheels world velocities by it's -yaw angle.slipangle = atan2(longtitude wheel speed, lateral wheel speed)might be other way round, (lat, long) since i'm writing from memory, sorry.The output from pacejka is the force on that wheel at that particular slip angle.This force is used as an opposing force to the angular yaw velocity of the wheel ( not to be confused with its rolling forward speed ).  The force should slow down the angular yaw velocity of the wheel and also act as a turning yaw force on the direction of travel for the tire / wheel.It's much easier to visualise when you think of the car body as a single wheel.Slip angle caluclated from atan2(lontitude velocity of car body , latitude velocity of car body)in car frame coordinates and not world frame.call pacejka function with the slipangle inputand use the returned force to slow down the angular yaw rotation of the car body, and to change the direction of travel of the car ( world frame reference).  ie, rotate the direction of travel vector for the car, by some yaw angle calculated from the pacejka output force.The most noticable thing about using the pacejka formula, is that as the slip angle increases, 0 to 90 degrees say, the force returned is not a linear increase.  But instead, a tire defined by it's pacejka coeficients has a maximum slip angle with which it returns a maximum force.  This may be, say at 25 degrees slip.  With a slip angle greater than this, the force returned starts to decrease.You could alternatively, use a linear tire model, and use the slipangle as the force.  This actually gives quite good results but does mean spinning a car beyond 90 degrees gets very difficult.  But you could do a simple test for slipangle greater than 75 degreees for instance, and then decrease the force to overcome this.The point being, that pacejka magic formula, models a tire quite accurately, but for games this level of accuracy isn't that important.  So long as the game plays well.Hope that helpskjm[Edited by - K_J_M on September 14, 2007 4:27:57 AM];  Bump