Another one of my questions with regards to vehicle physics. This is more of a theorethical question and less about implementation details. So I'm looking at implementing an vehicle engine, driveshaft and wheels into the simulation.
The engine spins at a given RPM, produces torque which is then applied onto the driveshaft through the transmission (gear ratio) which is then applied onto the wheels via the differential. (differential ratio.)
So the calculation (from the engine RPM to the wheels) looks like this:
float engineRPM = ... //current RPM
//engine stats
float gearRatio = 2.3f;
float differentialRatio = 1.5f;
float finalDriveRatio = 1.7f;
float transmissionEfficiency = 0.7f;
float wheelRadius = 0.3f;
float engineTorque = lookupCurve(engineRPM) * throttle;//lookup torque of engine to the given RPM
float wheelTorque = engineTorque * gearRatio * differentialRatio * finalDriveRatio * transmissionEfficiency;
I'm specifically talking about this line here:
//direction: engine > driveshaft > wheel
float wheelTorque = engineTorque * gearRatio * differentialRatio * finalDriveRatio * transmissionEfficiency;
by going from the engine through the transmission, driveshaft and differential to the wheel we multiply the given ratios with the engine torque.
Now, because those components are a closed loop system, the engine RPM (float engineRPM = ... //current RPM
from the first codeblock) depends on the wheels angular velocity (which got accelerated by the engines torque).
The angular velocity can be calculated by dividing the torque by the wheels inertia:
float wheelInertia = 1;//for simplicity purposes
float wheelAngularVelocity = wheelTorque / wheelInertia;
//convert angular velocity from radians/s to rpm for later use
float wheelRPM = wheelAngularVelocity*60.0f/2.0f*pi; //from angular velocity to revolutions per minute
So far so good. Here comes the part that i don't understand.
We now want to use wheelRPM (which is essentially the angular velocity) an input for the engine RPM from the first codeblock. (float engineRPM = ... //current RPM
)
According to this source: https://asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html as well as a reply i've found on this site: https://gamedev.net/forums/topic/677344-engine-rpm-and-wheel-angular-velocity/5283248/?page=1
The RPMs have to be calculated by multiplying the wheelRPM with the ratios (again).
//from wheelRPM to engineRPM
float engineRPM = wheelRPM * gearRatio * differentialRatio * finalDriveRatio;
But shouldn't the reverse be the case? Instead of multiplying the wheel with the rations shouldn't we perform a division like this: ?
//from wheelRPM to engineRPM (?)
float engineRPM = wheelRPM / gearRatio / differentialRatio / finalDriveRatio;
My thinking is that (for a very simple example) if we have an engine spinning at 1000 RPM with a gearRatio of 2 and attach this directly to the wheels then the wheels will spin twice as fast (2000 RPM). So if we want to calculate the engine RPM from the wheelRPM (going through the transmission) we should basically reverse the equation and perform a division instead of multiplication?
So in the end the closed loop would look something like this:
float wheelInertia = 1;//for simplicity purposes
float wheelAngularVelocity = wheelTorque / wheelInertia;
float wheelRPM = wheelAngularVelocity*60.0f/2.0f*pi;
float engineRPM = wheelRPM / gearRatio / differentialRatio / finalDriveRatio;
//or? float engineRPM = wheelRPM * gearRatio * differentialRatio * finalDriveRatio;
//engine stats
float gearRatio = 2.3f;
float differentialRatio = 1.5f;
float finalDriveRatio = 1.7f;
float transmissionEfficiency = 0.7f;
float wheelRadius = 0.3f;
float engineTorque = lookupCurve(engineRPM) * throttle;//lookup torque of engine to the given RPM
wheelTorque = engineTorque * gearRatio * differentialRatio * finalDriveRatio * transmissionEfficiency;
//wheelTorque is then used at the top of the codeblock as an input
I'm probably overlooking something crucial here so any insight would be greatly appreciated.