added type configuration for differential
This commit is contained in:
parent
d1c446b598
commit
a81aa450dc
@ -2,9 +2,10 @@
|
||||
--@author Koptilnya
|
||||
--@server
|
||||
--@include /koptilnya/engine_remastered/vehicle.txt
|
||||
--@include /koptilnya/engine_remastered/powertrain/differential.txt
|
||||
|
||||
local Vehicle, POWERTRAIN_COMPONENT = unpack(require('/koptilnya/engine_remastered/vehicle.txt'))
|
||||
|
||||
local Differential = require('/koptilnya/engine_remastered/powertrain/differential.txt')
|
||||
|
||||
local WheelConfig = {
|
||||
BrakePower = 800,
|
||||
@ -62,6 +63,7 @@ Vehicle:new({
|
||||
Input = 'Gearbox',
|
||||
Type = POWERTRAIN_COMPONENT.Differential,
|
||||
Config = {
|
||||
Type = Differential.TYPES.HLSD,
|
||||
FinalDrive = 3.392,
|
||||
Inertia = 0.01,
|
||||
BiasAB = 0.5,
|
||||
|
||||
@ -9,6 +9,10 @@ require('/koptilnya/libs/constants.txt')
|
||||
|
||||
local Differential = class('Differential', PowertrainComponent)
|
||||
|
||||
function Differential.getSplitStrategy(type)
|
||||
return SPLIT_STRATEGIES[type] or SPLIT_STRATEGIES[Differential.TYPES.Open]
|
||||
end
|
||||
|
||||
function Differential:initialize(vehicle, name, config)
|
||||
PowertrainComponent.initialize(self, vehicle, name, config)
|
||||
|
||||
@ -24,6 +28,7 @@ function Differential:initialize(vehicle, name, config)
|
||||
self.preload = config.Preload or 10
|
||||
self.stiffness = config.Stiffness or 0.1
|
||||
self.slipTorque = config.SlipTorque or 1000
|
||||
self.splitStrategy = Differential.getSplitStrategy(config.Type or Differential.TYPES.Open)
|
||||
end
|
||||
|
||||
function Differential:linkComponent(component)
|
||||
@ -85,7 +90,7 @@ function Differential:forwardStep(torque, inertia)
|
||||
|
||||
self.torque = torque * self.finalDrive
|
||||
|
||||
local tqA, tqB = self:_openDiffTorqueSplit(
|
||||
local tqA, tqB = self:splitStrategy(
|
||||
self.torque,
|
||||
aW,
|
||||
bW,
|
||||
@ -156,4 +161,18 @@ function Differential:_HLSDTorqueSplit(tq, aW, bW, aI, bI, biasAB, preload, stif
|
||||
return tq * (1 - biasAB) - dTq, tq * biasAB + dTq
|
||||
end
|
||||
|
||||
Differential.TYPES = {
|
||||
Open = 'Open',
|
||||
Locking = 'Locking',
|
||||
VLSD = 'VLSD',
|
||||
HLSD = 'HLSD',
|
||||
}
|
||||
|
||||
SPLIT_STRATEGIES = {
|
||||
[Differential.TYPES.Open] = Differential._openDiffTorqueSplit,
|
||||
[Differential.TYPES.Locking] = Differential._lockingDiffTorqueSplit,
|
||||
[Differential.TYPES.VLSD] = Differential._VLSDTorqueSplit,
|
||||
[Differential.TYPES.HLSD] = Differential._HLSDTorqueSplit,
|
||||
}
|
||||
|
||||
return Differential
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user