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