How modular drive train works
Each component of the modular drive train needs to implement “DriveTrainModuleComm” interface which has 4 methods:
- DTUpdateFromSourceToApplication
- DTUpdateFromApplicationToSource
- DTReceiveDataFromSourceSide
- DTReceiveDataFromApplicationSide
“Source” means side of the drive train with the engine and “Application” means side with wheels/tracks.
The idea is that on each Tick (or physics sub-step Tick) each component is “updated” twice and each “update” ends with sending resulting data to next component up (or down) the chain:
So if engine is connected to a clutch and clutch is connected with gearbox. We start with updating engine using “DTUpdateFromSourceToApplication” function call, which sends data to the clutch using “DTReceiveDataFromSourceSide” function at the end of the update.
Now as clutch received data from the engine, it does it’s own update in “DTUpdateFromSourceToApplication” and sends data to gearbox. In this example, gearbox is the last component and there is no data to send further. As we reached the end of the chain, we start to update components in the backwards direction - gearbox->clutch->engine. For this we use “DTUpdateFromApplicationToSource” functions and “DTReceiveDataFromApplicationSide” to pass data.
This way each drive train component can do it’s own calculations as a “black box” and the rest don’t need to know anything about it. For example, engine doesn’t need to know if clutch is locked or not. When clutch is unlocked (completely released and not slipping) clutch will just pass back the same angular velocity to the engine as it received from the engine. When clutch is completely locked (not slipping) it will pass angular velocity received from the engine to the next component, which decides on it’s own what should be done with it.
The only other consideration is regarding components that can integrate velocity, meaning that they apply torque to change angular velocity on their update. Such components are engine, clutch, gearbox and track sprocket or wheel hub. Not all of them integrate velocity all the time, only when their logic requires to do so. For example, engine integrates velocity on every tick as final engine torque changes with RPM and throttle position. Clutch integrates velocity only when not completely locked as clutch plates will produce friction force. Gearbox integrates velocity when you shift gears and synchro produces friction force to match velocity of lay and drive shafts. Wheels or tracks, integrate velocity from the reaction force as the result of friction with the ground. The pattern is pretty clear: each component that creates or receives torque from outside of the drive train or can “disconnect” drive train - will integrate angular velocity.
When components “disconnect” drive train, such as clutch or gear box, they integrate velocity on their “application” side of the shaft. The “source” shaft is considered as responsibility of the component previously in the chain.
In feature posts I’ll describe each of the implemented components.