slomal bahui

This commit is contained in:
Никита Круглицкий
2025-05-14 18:57:41 +06:00
parent 6a128f470b
commit 138d91b9f9
12 changed files with 233 additions and 86 deletions

View File

@@ -14,9 +14,9 @@ function Gearbox:initialize(vehicle, name, config)
Downshift = 'number'
}
self.wireOutputs = {
Gearbox_RPM = 'number',
Gearbox_Torque = 'number',
Gearbox_Ratio = 'number'
[string.format('%s_RPM', self.name)] = 'number',
[string.format('%s_Torque', self.name)] = 'number',
[string.format('%s_Ratio', self.name)] = 'number'
}
self.type = config.Type or 'MANUAL'
@@ -28,9 +28,9 @@ end
function Gearbox:updateWireOutputs()
PowertrainComponent.updateWireOutputs(self)
wire.ports.Gearbox_RPM = self:getRPM()
wire.ports.Gearbox_Torque = self.torque
wire.ports.Gearbox_Ratio = self.ratio
wire.ports[string.format('%s_RPM', self.name)] = self:getRPM()
wire.ports[string.format('%s_Torque', self.name)] = self.torque
wire.ports[string.format('%s_Ratio', self.name)] = self.ratio
end
function Gearbox:queryInertia()
@@ -52,18 +52,18 @@ function Gearbox:queryAngularVelocity(angularVelocity)
end
function Gearbox:forwardStep(torque, inertia)
self.torque = torque * self.ratio
if self.output == nil then
return torque
end
if self.ratio == 0 then
self.output:forwardStep(0, self.inertia)
self.output:forwardStep(0, self.inertia * 0.5)
return torque
end
self.torque = torque * self.ratio
return self.output:forwardStep(self.torque, (inertia + self.inertia) * math.pow(self.ratio, 2)) / self.ratio
end