Looking for good transmission calculations

Hi! I am looking for a good transmission calculations based on speed.
I have following variables:


speed = current car speed
maxSpeed = maximum speed car can achieve
gears = the count of gears aviable for car, usually it is 5 or 6
rpms = maximum possible RPM car can achieve before setting next gear(usually 6000-9000)

Thanks everybody for help!:slight_smile:

Truth is, physics behind engines is immensely complicated.

For example:

  • A real engine has a torque-speed curve. It does not output a constant torque at any speed, but it varies hugely. For instance, see this: link

You’ll notice that each gear has a different torque-speed curve, but they are all just different scalings of the same shape. So we can just have a single engine-speed-torque function, and scale it based on gear.

If you want to be accurate (as you seem to be), you’ll have to model that here’s how I would structure it:


engine_rpm = getEngineSpeed(carVelocity, gear)     #Simple linear relationship with gear as a factor
engine_torque = getTorque(engine_rpm)           #Either a crazy math equation or a lookup table 
wheel_torque = getWheelTorque(engine_torque, gear)    #Simple linear relationship with gear as a factor.
applyWheelTorque(wheel_torque)

Assuming you have drag set up on your car sensibly (not damping, but mathematically modelled in (such as rolling resistance, wind resistance etc.), simply apply the torque to the wheels and your car will find a maximum speed where the output power is equal to the friction power.

Well, I use simple vehicle wrapper for my car. In your example I am more interested in calculations under theese definitions.

“speed = current car speed”
This is the forward coordinate of the linear velocity. You can directly read it from there.

“maxSpeed = maximum speed car can achieve
gears = the count of gears aviable for car, usually it is 5 or 6
rpms = maximum possible RPM car can achieve before setting next gear(usually 6000-9000)”

These are settings. They do not belong to the physics model as … it is no car, just a wire-frame cage with some rays.

You can use them as configuration for your car model (model = what you think your car should be). So you can use that to calculate the forces you want to apply to the vehicle wrapper (applyEngineForce() per wheel).

The typical implementation in this forum is to apply constant forces when a key is pressed. You do not need to do this. You can add forces dependent on the current speed, or whatever condition you like.

For example your car model (not the mesh object) could have a “moment of force” or “torque”. Usually there is a fluent transition in changing it’s values. e.g when braking it will not suddenly stop, it will strongly decrease down to zero because of the feedback of the wheels. The opposite is similar, when you give power it will not suddenly have a million rpm. There is a transition dependent on the current moment, and the forces involved. The gear will influence the forces.

You could implement some formulas that calculate the forces (per wheel).


def calculateForce(gear, momentum, power):
   if gear == 1:
      return momentum + power # whatever formula you want
   if gear == 2
      return momentum  + power*0.2 # whatever formula you want

The formulas are totally up to you.

I am more thinking of how to get a good looking RPM system. I don’t know how to correctly calculate RPM…

lol nobody knows. That’s why you can invent whatever you want.

I suggest to orient on the expectations.

As less momentum you currently have as less power you get from the engine (to result in a force -> acceleration).
At a certain momentum the the power has it’s maximum and will decrease with more momentum

You can “scale” the curve with different gears (that is why they are there).

The time to switch gears is when the curves crosses.
Are the curves real? No. They might even be bullshit Can anybody tell? No.

So use curves as you like. I suggest to use different curves for different car types. The spike can be at different places. The curves can be wider, smaller whatever.

Do them in a way you think a car should behave.

OK! Sounds quite good, but I have never written curve calculations, I will have curve math this year(class 9), but haven’t had it before. I don’t know how to struct a curve.

OK! What I’ve got is:


import bgefrom bge import logic
from gamesystem import gaudges


def gearbox(cont):
    own = cont.owner
    
    speed = gaudges.speed
    maxSpeed = own["maxSpeed"]
    gearcount = own["gears"]
    rpms = own["rpms"]
    
    div = maxSpeed / gearcount
    gear = ((speed - 1) / div) + 1 # a common way, I will use something better later
    
    gaudges.gear = gear
    gaudges.rpm = #WHAT TO DO HERE!?
    
    own["Gear"] = gaudges.gear
    own["RPM"] = gaudges.rpm

Now I need to have 7000 RPM(rpms = 7000) when having 50 km/h, 100 km/h or any other maximum km/h at any gear(because maxSpeed = 250, gearcount is 5 in my example). SO what to do in gaudges.rpm to make sure that 0 km/h = 0 RPM, 1-50 km/h ir 1000-7000(approximately) RPM, 51-100 km/h = 1000-7000 km/h(approximately) or something like that? What equation to write?

Hey - is the


applyEngineForce()

taking in account a unit that is equal to the torque used to spin the wheels?

They might even be bullshit Can anybody tell? No.

I like this response

What answer and where?

I think I just confused you (and me). The above curves are not the how to convert from rpm of an engine to speed of a wheel. They are more the speed increase on different rpm (momentum).

The relation between engine angular speed and wheel angular speed is due to the mechanics … linear. The only flaxible part is the gear which adds a scale.

This makes the formula pretty simple:


TRANSMISSION_FACTOR = 1/100 # up to the gear box = whatever you want
...
def calculateWheelSpeed(engineSpeed, gear):
    return engineSpeed * TRANSMISSION_FACTOR * gear 

This can result in such values:


    0:      1      2      3      4      5      6
-------------------------------------------------
    0:      0      0      0      0      0      0
  300:      3      6      9     12     15     18
  600:      6     12     18     24     30     36
  900:      9     18     27     36     45     54
 1200:     12     24     36     48     60     72
 1500:     15     30     45     60     75     90
 1800:     18     36     54     72     90    108
 2100:     21     42     63     84    105    126
 2400:     24     48     72     96    120    144
 2700:     27     54     81    108    135    162
 3000:     30     60     90    120    150    180
 3300:     33     66     99    132    165    198
 3600:     36     72    108    144    180    216
 3900:     39     78    117    156    195    234
 4200:     42     84    126    168    210    252
 4500:     45     90    135    180    225    270
 4800:     48     96    144    192    240    288
 5100:     51    102    153    204    255    306
 5400:     54    108    162    216    270    324
 5700:     57    114    171    228    285    342
 6000:     60    120    180    240    300    360
 6300:     63    126    189    252    315    378
 6600:     66    132    198    264    330    396
 6900:     69    138    207    276    345    414

Interpretation:
in gear 1 you get in normal range (2100 rpm) 21 km/h in gear 6 you get 126 km/h

While this sounds like you can “simply” switch to gear 6 and power your engine with 6900 rpm to get 414 km/h -> this does not consider the forces you need to increase the engine speed.

That is where the above curves come into play. In a normal car the highest forces are in the range around 2000-3000 rpm. This means if you provide full gas it results in most power. Outside this range the same gas results in less power.

Less power means it takes longer to increase the rpm (and the speed) by a constant value (e.g. 1 rpm) . More power means it is faster to increase the power.

There are additional forces the counters the engine force e.g. the air resistance. The air resistance gets stronger as faster the car is driving.

All of that results in a limit. That means regardless how much gas you provide the engine will not be able to increase the speed anymore, because the counter forces will nullify any additional force from the engine.

I do not have a formula yet that helps you calculating the forces or the speed increase from gas to rpm or wheel speed.

OK! Here is what I made with a bit more complex setup, but it is wrong yet:
https://drive.google.com/file/d/0B_3-3pjFYDzaZ0RYU0ZpS25RdlU/view?usp=sharing

I used this:

In the way of simulation mode.
However, the end part more looks like that it is not such easy when using it in the vehicle wrapper.


I briefly explained what exactly I am looking for in here!