# Rapha

Member

15

158 Neutral

• Rank
Member

2. ## [Car Physics] Proper driveline simulation

Hello again [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] (i know i have a lot of things to answer in the other topic, but i'm not finished analyzing and trying all suggestions yet !) This subject is very interesting, as i am willing to modelize a proper engine transmission too, eventually. My main concerns are : inertia of components (varying with gear), inner friction and the differential. I am very busy right now working on the purely handling part, so i cant try anything / do suggestions for the moment, but i can give you this link, which is very informative on the subject : [url="http://hpwizard.com/rotational-inertia.html"]http://hpwizard.com/...al-inertia.html[/url] Other cool links on this website : [url="http://hpwizard.com/index.html"]http://hpwizard.com/index.html[/url] But it is quite possible you already have this link in your bookmarks ! Good luck working on that driveline ! I stay tuned.

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

Hi ! Thanks for your answer[u]s[/u] ! Well, indeed it doesn't help that much ^^ Instead of focusing on fun, i know at least a part of the posting people seems to want to have the basic physics right. So knowing if a typical car launched at X velocity should more or less stop in 1 sec or 100 sec might help future beginners to start implementing physics. I know i really had a hard time to get the basics right, and the lack of reference values was a great pain. AFAIK, most of 2D simulations simulates a part of inner 3D (eg : weight transfer), and as long as you consider driving on a flat surface, things are quite similar. For a beginner starting right away with 3D terrain and car model might be a good thing to make stupid mistakes. A few weeks ago i asked if a lateral pacejka force should be applied lateraly to wheel body or to car model, and response was not clear to everyone. A LOT of basics things are not well understood by beginners, and we have a few people here who have successfully created full racing games. So again, i think it might be a good idea to have some shareable and stored knowledge on the subject. As for the "what is fun" part, i guess you are right. But again AFAIK, getting controled drifts and natural car behaviour is kind of what every carsim dev wants,no ?(independant of arcadish/simu considerations) I haven't been able to find very simple and important car setup parameters, so why not trying at least to share those somewhere ? My max_steer function comes from a 3D game and it works well for my 2D sim ;) I really think we can try to bring light to some dark places, instead of always creating topics to ask something precise and then realize a few answers laters that we have missed other things or that we just didn't think of a key feature. Almost all car related topics end like that. And the only tutorials are the one from marco, gamedev and unity, which i personnaly think are really vague on a lot of key subjects like proper car inputs management or how pacejka works. And PHORs is way too complicated for most readers to implement it i guess. I know i do not want to implement the Maths, altough the reading helped me to understand many things. [quote]Probably a 100Hz or 200Hz physics rate should be enough if the car isn't too stiff[/quote] Well, the 1000Hz value in test/dev purpose allow us to be sure any instability does not come from there. Objective of the thread is to try to enlight newcomers to the subject. For a game in early prototype stage, the computer can handle it well. And everyone is free to adapt the value to its needs later, but for the scientifical accurate part, i think 1000Hz is doable and a simple value. [quote][b]Use wheel distance to CG to calculate weight transfer lateraly and longitudinal. Combine those two[/b]. This is most probably wrong... you don't calculate weight transfer, it should be automatically happening in your rigid body physics[/quote] Sorry, i meaned load transfer and not weight transfer, i offen misuse those two words. My dynamic load transfer happens with acceleration in the car body. So to know the real weight on a body point, i have to find out its distance to CG, and then use long/lat acceleration. As i do not use a physics engine (except for the collision detection part), i code weight transfer as much as simple forces integration. So AFAIK it cannot happen automatically unless i use a real 3D engine and feed him with some values. I get front/lat acceleration depending on current acceleration values, which themselves depends on previous ticks generated forces. The real weight transfer, which happens when the car CG is displaced occurs indeed automatically as a suspension or an other is going up or down. I'll edit my post to use correct terms.

6. ## [Car Physics] - Angular Velocity / Angular Momentum

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. [CODE] Vector3 lateralForce = this.transform.right * pacejkaLateral; this.rigidbody.addForce( lateralForce ); [/CODE] 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. [quote name='kunos' timestamp='1348635065' post='4983882'] 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.[/quote] [b]At the wheel center and not at the wheel contact point[/b] > 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. [b]"right" vector of the tyre isn't the right direction for the lateral force that is generated on the plane of the road[/b] > 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 name='kunos' timestamp='1348635065' post='4983882'] The behavior you explain in your first post is not necessarily wrong , a well balanced car will not spin out... [/quote] 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 [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [quote]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 ^^

11. ## Car Simulation Headaches Part_#2

Hi, That's bad for me because i get much better results applying the lateral force directly to car chassis regardless of steering angle (but i take it in count for slip angle calculation). Maybe i just need to tune pacejka curve to respond to the fact it changes the car behaviour somehow. A little change alway seems dramatic in result at first, but maybe it is the right way to go and i need to adapt my curves which are really trivials for now. [quote]Although i'm no expert, i always understood that a stationary car spinning on the spot with the steering centred produces no longtitude forces from the tires to move the car forwards or backwards. But only lateral forces to slow down the rate of spin.[/quote] 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 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 ? This : [quote]The lateral forces of the four tyres have two results: a net cornering force and a torque around the yaw axis. The cornering force is the force on the CG at a right angle to the car orientation and serves as the centripetal force which is required to describe a circular path. The contribution of the rear wheels to the cornering force is the same as the lateral force. For the front wheels, multiply the lateral force with cos(delta) to allow for the steering angle.[/quote] [CODE] Fcornering = Flat, rear + cos(delta) * Flat, front [/CODE] I'm quite rusted with my trigonometry, so i'm not 100% sure, but i think that will act as if the lateral response IS indeed perpenducular the the wheel, according to steer angle, BUT that he is suggesting to take only the force component that is projected on the car side axis. So if the front wheels are centered, 100% of the force will be applied. But if the wheel is steering at 60°, only 50% of the force is applied to the car. But he is only calculating centripetal force and torque, so i guess only the truly lateral component does it. He may have "forget" the sin(dela)*Flat, front which is supposed to slow down the car as it is cornering, but maybe it is not that important for the car behaviour ? If i release the gaz pedal, it may slow down the car by a similar amount. If i'm right, that would mean, that i just should try to have better steerAngle/steerSpeed/lateralCurves constants instead of looking at the maths. --- One other question as i'm experimenting if i may : 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. By the way, it feels a bit strange to me that only weight transfer due to +/- acceleration affects cornering capacity in curves. Am i missing something here or again, should i just tune weight transfer speed to get something smoother to drive ? [b]EDIT [/b]: after re-reading closely PHORS articles, it seems only acceleration/weight transfer affects available traction and it is supposed to scale linearly with weight load, indefinitely. http://phors.locost7.info/phors07.htm --- Thanks for your help and sharing your experience ! You say you are not expert, but given the quality of your racing game, i'll take your advices very seriously ! It's exactly the kind of feeling i want, only more arcade-ish.
12. ## Car Simulation Headaches Part_#2

Oh, and i have one more question that has haunted me those past days. Knowing that marcos slipAngle formula is made to be used with car coordinates (that's why it takes angular vel, and so) to determine the lateral force the tire produce, it makes sense that this lateral force should be applied to the car directly perpendicular at wheel position. But, i use a formula where the front/lat velocities are the real ones of the wheel. So, simply using this formula should work to determine slip angle : [CODE] var alpha = -Math.atan2(wheelRealSideVelocity, Math.abs(wheelRealFrontVelocity)); [/CODE] But when it comes to applying that lateral force... Case 1 : Should i apply the given force perpendicular to wheel, with steering producing an oriented lateral force, which will slow down the car ? Case 2 : Or instead should i apply it perpencular to wheel attach point, regardless of steering, and then it will only make the car turn, but never slow it down ? Case 1 example : [img]http://img546.imageshack.us/img546/1576/lateralforceappliedonti.jpg[/img] Case 2 example : [img]http://img267.imageshack.us/img267/1834/lateralforceappliedonbo.jpg[/img] Everyone use its own formula and coordinate system in the examples i have found, so it is not clear to me. For Slip Ratio, it is more obvious as we look at patch speed (wheel angular velocity) and ground speed in the direction the wheel is heading, it seems logical to have that vector acting in the wheel space, thus respecting steering angle. But using a simplified formula with examples were it is used to apply a force directly perpendicular to car makes me have some doubts...
13. ## Car Simulation Headaches Part_#2

Hello to both of you ! Thanks for your detailed answers. As always, i really appreciate it. I worked very hard those past days on the simulation, and made some progress. @K_J_M & @bmarci [quote]If you look at the issue with regards to local car coordinates then each wheel has 0 longtitude velocity and (N) Lateral velocity if the car is spinning on the spot.[/quote] That is right, but when i look at a point in a system, i use my pointVelocity method which takes angVel in account like you said [quote]But in regards to a stationary car spinning on it's axis the lateral wheel velocity is derived from the car angular velocity.[/quote] So, theorically, when spinning on itself, any point velocity depends on angular velocity of the car. That velocity will be tangent to rotation circle and depends on distance to CG. The wikipedia page illustrates this very well : [url="http://upload.wikimedia.org/wikipedia/commons/2/2f/Velocity-acceleration.PNG"]http://upload.wikime...cceleration.PNG[/url] So i have something like that : [img]http://img837.imageshack.us/img837/6290/pointvelocity.jpg[/img] So, now, what bmarci said is exactly what i'm doing : [quote]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[/quote] That's exactly the way i do things. So that means, i am transforming the point velocity of the wheel (the blue vector on the picture) in wheel coordinates, which as we can see it on the picture will result in both lont/lat velocities, and so in a slip angle which is not 90° when the car is spinning on itself. So the conclusion is in contradiction with what KJM stated above, but i can't see what is failing in my reasonment. Am i right to not find 90° for a wheel which belongs to the right place on a car spinning on itself ? The point velocity seems good, so if i am supposed to get only lateral velocity, i need a sort of hack, or maybe stay in car coordinates instead of going into wheel system ? The thing is, i am almost sure i am right on this and that my slip angles are good, because the wheel produce good damping forces to annihilate car angular velocity when spinning on itself. If tires produce 90° slip angles when the car is spinning the car is slowing down of 99% and not 100%. If my slip angles are good, that would mean that my car problems during cornering lies somewhere else. As i said i have obtained a better result, but i am not sure if my base calculations in slip angles are OK. So i cannot really try to tune pacejka or other things like wheel velocity and weight transfer if the underlying system is not good. Actually the result i have is very close to the Java source example you can download on marco's website. It seems ok as i have deactivated everything else : weight transfer, decreasing pacejka curve, no more real engine/wheel transmission / rotation. I needed to have a clean working table, sort of. But when i try the car on my game track it is far from playable. If i use an always increasing, producing high cornering forces curve for lateral pacej, then the car turns very sharply, and i can have somme controled oversteer, but the car will eventually stop in the turning curve instead of keeping some speed. If i use a realistic pacejka curve, then the car is understeering at high speed, which is good, because i can do high speed turns in a comfortable way. But, if i want to produce oversteer and drift for a sharper curve, it just doesn't happen. So, what do you think ? Problem in base system calculation ? Pacejka curve tuning ? Maybe i should reactivate some critical feature or system ? I will try to cast a video of the car later to show try to show you, if interested. Thanks for your help, my game really needs it [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Sorry for the long posts by the way... EDIT : the main thing here, might be this "the car will eventually stop in the turning curve instead of keeping some speed". I have the feeling that when i take a sharp turn, even if a great part of the initial velocity will be killed by the lateral forces, and even without pushing throttle, the car should keep more front velocity to come out of the curve. Instead it just stops there with very small to none forward velocity. If i could have this, and manage somehow to mix the best of the 2 results i have with my different pacejka, the game would start to be fun i think. EDIT2 : those results were obtained with a dummy traction circle (allowing 2*weightLoad traction max), applied only on lateral force for testing purpose.
14. ## Car Simulation Headaches Part_#2

Hi, K_J_M ! Thank you for your answer ! I already downloaded your top down racing game, but haven't had many time to play it yet ! It seemed a little hard to me at first sight [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] If i understand you, then a static but spinning car would generate velocities for tires that would be with 0 longitude, and some value in x depending on the direction of rotation. Something like that : [url="http://en.wikipedia.org/wiki/Uniform_circular_motion"]http://en.wikipedia....circular_motion[/url] I found it to be true if the tire is aligned with the radius of the circle. As the wheels are not centered, but rather on the side of the car, when they are not steering, then the radius from wheel attach point to car CG will not be perpendicular to the wheel heading. If you draw a path following the front right wheel positions, it is indeed a perfect circle, and the velocity of that point (blue vector) is indeed tangent to circle. But as my wheel is not aligned with the radius, the projection of the velocity according to steering (wich is 0), will give me both lateral and frontal velocities, wich in turn will give me a slip angle not equal to +/- 90°. The only case i have such results is if : a) There is only 1 front wheel, centered on the chassis (like a bike, or tricycle) b) The wheel is aligned with the radius coming from CG c) The car is sliding lateraly [img]http://img834.imageshack.us/img834/8581/circulatpath.jpg[/img] That is a little confusing to me, so i am wondering if :[list=1] [*]I should have 0 longitidunal velocities as long as the tire is describing a circular path, regardless of wheel steering. The steering would then be "used" in slip angle calculation like the formula from marco suggest it : [CODE] slip = Atan(latVel / |frontVel|) - signOf(frontVel) * steerAngle [/CODE] [*]I should have a longitudinal & lateral velocities (excepted for previous a,b,c cases) and my calculations are OK until there (the wheel front/lat velocities are the green and red vectors on the picture). [/list] I am suspecting it is not the only thing that goes wrong with my simulation but it would really helped me to know which way is the right one [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] And again, thanks for your help, it is much appreciated !