vehicles speed- what does newton do for you?

unclepauly

23-09-2006 20:06:37

i am working through both stunt playground code and the well-known car physics tutorial: http://www.etse.urv.es/EngInf/assig/si2/cardynamics.pdf . I am wondering what Newton does for you and what you have to code yourself.

For example, the first section of the tutorial discusses straight line physics, and the forces at play - F[traction] + F[air-drag] + F[rolling-resistance]. From this, it shows how one can calculate aceleration, then velocity. In Stunt Playground, i can't see any code to calculate these forces - does Newton do it for you?

The second section of the tutorial discusses weight transfer. again, i can't see any code to change the centre of mass as the vehicle accelerates/decelerates. i can see a call to m_chassis->setCentreOfMass() when the vehicle is first initialsed - is this all that is needed and does Newton do the rest?

walaber

23-09-2006 20:26:25

basically yes. what you need to do, is create a chassis with a realistic center of mass (which you can change in realtime if you really want to, but it not necessary), set realistic suspension parameters, and provide the torque and steering angles to the tires.

unclepauly

23-09-2006 20:45:43

so basically i need to do this (psudeo code stolen from Stunt Playground):

getOmega
rpm = omega * gear_ratio * diff_ratio * (60 /2 * pi)
use rpm to find engine torque (using torque curve)
use engine torque to find wheel torque -> throttle * engine_torque * gear_ratio * diff_ratio * transmission_efficiency
determine gear based on rpm and change if necessary.

i think this is right - thanks!

walaber

23-09-2006 22:46:05

yup. you will see that is almost exactly what Stunt Playground does.

unclepauly

23-09-2006 23:51:41

also, i see in SP you have a member variable in the vehicle class - mDragCoefficient. But this doesn't seem to do anything! the value is parsed from the .car file and stored in the variable but no funtion uses it (if i search the project for it i only get 3 results, the declaration and the parsing).

to me, drag coefficient is the coeffiecient of friction in the constant C[drag], but as you have already said, i don't need to bother with this as Newton does it for you? However, this value does depend on the size of the car, so is there actually a way to set it via OgreNewt?

Game_Ender

24-09-2006 05:46:14

I don't know anything about Newton, but my guess is that you would have to calculate what the drag force would be and then just apply it as a force. Other wise Newton would have to do some complicated aerodynamic analysis to guess this for you.

walaber

24-09-2006 06:35:07

sorry, Newton (and OgreNewt) don't calculate drag for you. that was something I wanted to add, but never got around to adding into Stunt Playground.

Newton does however support buoyancy, which can probably be used to simulate drag pretty realistically.

unclepauly

25-09-2006 14:59:37

so i am guessing that its not really mega-important, if SP does not implement this. however, if the net force is

F[traction] + f[air-drag] + F[rolling-resistance]

and Newton does not calculate air-drag, then it MUST calculate rolling resistance, otherwise there would be no opposing forces and the car would keep accelerating forever ?

because i will quote form the tutorial:


with these 3 forces we can simulate car acceleration pretty accurately....There is no need to put a maximum speed anywhere in the code, its just something that follows from the equations. This is because the equations form a kind of negative feedback loop. If the traction force exceeds all the other forces, the car accelerates. This means the velocity increases which causes the resistance forces to increase. The net force descreases and therefore the acceleration decreases. At some point the resistance forces and the engine force cancel each other out and the car has reached its top speed for that engine power.

walaber

25-09-2006 17:09:17

i implemented rolling resistance myself, and also protected against ever increasing speed by having the engine lose torque at high rpms.