   Engine Torque
  I want to make a fairly accurate car sim, but I don''t really know how the engines work.  In fact, I don''t know anything about engines.Basically, I''ve been reading this tutorial.  But, I don''t really get it, all the varaibles like RPM and engine torque depend on eachother, and I don''t know how it''s possible to calculate one or the other.Anyway, should I make the engine RPM depend on user input (when he pushes the up button or whatever, it increases the throttle and the engine RPMs?)  If I did that, then how would I store the torque curve?  There are about 4 gears each with their own torque curve, and I don''t know how to store the values off these curves, or if I should just make keep a few key points in the car''s file, and then interpolate between them.Really, I hardly have much of an idea of what I''m doing, any suggestions on how to work out these values and stuff would be great.  Thanks a lot. 
  The engine will be at some RPM at the moment you press the throttle. Then the throttle will modulate the corresponding torque or that RPM. this will in turn, generate a force on the car, pushing it forward. The angular velocity of the tyre will then also increase with the speed of the car. the angular velocity of the typre will then trickle back to the car engine through the drive shaft and gears, and change the RPMs of the car. so it's throttle -> Torque output (at the current RPM of the engine) -> Torque Multiplier (gears) -> Force on car -> car forward speed -> tyre angular speed -> velocity multiplier (gears) -> engine RPM. example : float throttle = Inputs.PositiveYAxis();float EngineTorque = Engine.GetTorque(Engine.GetRPM()) * throttle;float GearTorque = EngineTorque * Gear.GetCurrentRatio();float DriveTorque = GearTorque * DriveTrain.GetFinalRatio();Car.AddRearTyreForce(DriveTorque / Tyres.Radius());Car.Update(dt);float TyreAngularVelocity = Car.GetForwardVelocity() / Tyre.Radius();float EngineRPM = TyreAngularVelocity * DriveTrain.GetFinalRatio() * Gear.GetCurrentRatio();Engine.SetRPM(EngineRPM);that's for a simple model. Now with slip and friction, you do the same, but the tyre might have a different velocity than the car (wheelspin), but still, the tyre always dictates the RPM of the engine, wheelspin or not. The engine and tyres are directly connected through gears, and their RPM is inter-dependent. Only the clutch stands in the way, but you should not have to worry about that. [edited by - oliii on February 6, 2004 4:58:34 AM] [edited by - oliii on February 6, 2004 4:58:58 AM];  I see, that clears it up a bit, but there''s still one thing I''m not getting very well.  What''s the RPM in the first place?  Do you just set it at the minimum RPM the engine can take without stalling?  Then, if your wheels aren''t moving, the RPM would be calculated as zero, but you set it to 1000 anyway, or something like that?  Then on the other end of the spectrum, once the RPM gets over a certain "redline," you shift up to the next gear?  (Or explode, if you are in the last gear )Anyway, thanks a ton for the help! ;quote:Original post by Samith  I see, that clears it up a bit, but there''s still one thing I''m not getting very well.  What''s the RPM in the first place?  Do you just set it at the minimum RPM the engine can take without stalling?  Then, if your wheels aren''t moving, the RPM would be calculated as zero, but you set it to 1000 anyway, or something like that?  Then on the other end of the spectrum, once the RPM gets over a certain "redline," you shift up to the next gear?  (Or explode, if you are in the last gear )Anyway, thanks a ton for the help!   you forget that cars have clutches. So yeah, in general, if RPM < minRPM, then set RPM to minRPM.When you are over the redline, the torque curve will dip sharply (down to 0), so in theory, the car should stop accelerating once the engine gets over a given RPM (the end of the red line). Due to air friction and other friction forces, the torque given by the car at the peak RPM will not be sufficient to push the car. But doing too much peak RPM for too long kills the engine. The temperature goes though the roof, and the engine gets damaged, or even blows up. So in theory again, the highest gear ratio is tuned so that the car achieves maximum speed at maximum throttle and at the start of the redline, where the internal frictions are not too tiresome for the engine, but the engine is still capable to push the car efficiently. however, at a lower gear, the car is capable of overshooting the redline (remember, the RPM is a product of car linear speed times the gera ratio). So, imagine you are cruising at top speed in 5th gear, and suddenly drop into 4th gear, the RPM will go way over the redline, and the engine will blow up (maybe not instantenously, but say, after a second).the highest gear is safe, but it''s very easy to get to insanely high revs in low gears, so you have to be careful. Try to limit the revs to an absolute maximum, higher than the maximum revs, just in case. ;  btw, simulating a car in neutral can be fun. It''s especially useful for jump starts. To get the maximum torque from a stop-start, you obviously rev the car high, where the power/torque is maximum, and drop the clutch. But as you can see, the model presented is very innacurate for things like that. In the case of a proper burnout, the tyre would wheelspin, thus the RPM of the engine could be kept to peak RPM, while the speed of the car remains very low and the car won''t get anywhere. to properly model this, you either hack it in some ways, or use a proper complicated physical model for your engine, drive train and clutch.  ;  I was thinking about modelling a car in neutral, but decided against it for now.  Right now I''ve got another problem about torque, about modelling the power curve.  I don''t really know anything about power curves, I mean, what''s the limit for the power?  By that I mean, what''s keeping me from having a powercurve that''s way up at 300 kW over the entire thing?  I want to model power curves somewhat accuratly, but I think it might be good enough to just have a sort of "power bank" and I take power from that "power bank" and put it on the curve, if you know what I mean.Again, thanks for all your help. ;  Now, assuming the tires don''t slip at all, when I apply the drive torque on the rear wheels, the road exerts an equal torque in the opposite direction, which moves the car forward, but this is what confuses me.  If that happens, then how do the wheels ever rotate?  There isn''t any net torque, so they wouldn''t rotate at all, so then when you go to calculate the rpm using your non-rotating wheels you get zero, now you can''t move at all!Sorry if I''m really a newbie or something, I''m pretty new at this.Anyway, I tried using your method to calculate the rpms too, where you divide the speed by the tire radius, but my rpms would go up pretty fast and the highest speed I could get my car to go was about 5 meters a second (including air resistance, without it was maybe around 10 meters a second.)  Obviously this is really slow and I don''t really know why it was going so slow, so I tried to calculate the angular velocity of the wheels in a different way. ;  say, car travels at roughly 10 meters/s. that''s rougly 20 miles/hour, or 32 km/hour.the wheel as a radius of .35 meters. so the wheel angular velocity is 10 / 0.35 = 28 rad/s28 rad/s = 28 * 60 / (2 * Pi) = 260 RPM (revolutions per MINUTES).the final drive ratio is usually about 3, 3.5, the gear ratio, for 20 miles / hours is usually second gear, so rougly 2.5so you get 260 * 3.5 * 2.5 = 2300 RPM. Which sounds about right.about the net torque, the force exerted from the wheel onto the floor is indeed re-transmitted back to the car. the car goes forward, a force is exerted on the axle of the wheel, pushing it forward, the contact point on the wheel gain velocity, which generate a friction force on the floor, which in turn, turns the wheel if the car was obstructed, the netforce will indeed be canceled by the obstruction pushing the car back, the car will not gain any speed, the wheel axle will not move forward, and it will not generate a friction force. If the engine force then exceeds the slip, then there would be an exceedent of force, and would make the wheel turn on the spot (wheelspin).I know, it''s confusing, and I probably got it wrong, but hey, I gave it a try. About power curves, you should not model it by yourself, it''s hardcore physics (fluid dynamics, and other mind bending physics). Instead, I''d get one as an example, off the net, from real cars. If you''re lucky, you will even get all other sorts of useful informations, like weight, car dimensions (for inertia), weight balance, suspension parameters, gear ration, final ratio, drive train efficiency, drag coefficients, turning radius, ect... ;  I know how to calculate the rpms based on angular velocity of the wheels, but it''s just not working.  I''m getting like 6000 rpm in the 5th gear (0.6 gear ratio, with a 3.42 differential ratio) and my car is going like 10 m/s.now, 6000 / (.6 * 3.42) = 2923 rpm for the rear wheels.2923 = (velocity / wheel_radius) * 60/2pi2923 = (velocity / 0.35) * 60/2pivelocity = 2923 * 2pi/60 * .35velocity = 107 m/s107m/s is ten times as large as what I''m getting.  I don''t get it either, as far as I know, I''m doing exactly what all the car physics tutorials I''ve read have told me to do but it''s still not working. engine_torque = GetTorque(rpm) * throttle;drive_torque = engine_torque * gear_ratio[current_gear] * diff_ratio * engine_efficiency;local_force.x = drive_torque / wheel_radius;local_force.x -= drag_constant * local_velocity.magnitude() * local_velocity.magnitude();local_force.x -= local_velocity.x * rolling_resistance;local_acceleration = local_force / mass;local_velocity.x += local_acceleration.x * deltaTime;ang_velocity_wheel = local_velocity.x / wheel_radius;rpm = ang_velocity_wheel * gear_ratio[current_gear] * diff_ratio * (60.0f / 2.0f * 3.14159265f);That''s my source so far.  Again, thanks for your help! ;  you''re doing diff_ratio * (60.0f / 2.0f * 3.14159265f);when you should dodiff_ratio * (60.0f / (2.0f * 3.14159265f));hence, the 10x ratio. I get 600 rpm, which seems right