Added direction option to wheel config
This commit is contained in:
parent
d432b3220a
commit
ca83cc2515
@ -24,7 +24,7 @@ function Differential:initialize(config, order)
|
|||||||
CalculateInertia = true
|
CalculateInertia = true
|
||||||
}
|
}
|
||||||
self.outputA = Wheel:new(wheelConfig, prefix .. 'Left')
|
self.outputA = Wheel:new(wheelConfig, prefix .. 'Left')
|
||||||
self.outputB = Wheel:new(wheelConfig, prefix .. 'Right')
|
self.outputB = Wheel:new(table.merge(wheelConfig, { Direction = -1 }), prefix .. 'Right')
|
||||||
|
|
||||||
table.merge(self.wireInputs, self.outputA.wireInputs)
|
table.merge(self.wireInputs, self.outputA.wireInputs)
|
||||||
table.merge(self.wireInputs, self.outputB.wireInputs)
|
table.merge(self.wireInputs, self.outputB.wireInputs)
|
||||||
|
|||||||
@ -12,12 +12,13 @@ function Wheel:initialize(config, prefix)
|
|||||||
PowertrainComponent.initialize(self)
|
PowertrainComponent.initialize(self)
|
||||||
|
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
|
self.direction = config.Direction or 1
|
||||||
|
|
||||||
self.wireInputs = {
|
self.wireInputs = {
|
||||||
[prefix .. 'Wheel'] = 'entity'
|
[prefix .. 'Wheel'] = 'entity'
|
||||||
}
|
}
|
||||||
self.wireOutputs = {
|
self.wireOutputs = {
|
||||||
[prefix .. 'RPM'] = 'number'
|
[prefix .. 'WheelRPM'] = 'number'
|
||||||
}
|
}
|
||||||
|
|
||||||
self.entity = NULL_ENTITY
|
self.entity = NULL_ENTITY
|
||||||
@ -41,7 +42,7 @@ function Wheel:initialize(config, prefix)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Wheel:updateWireOutputs()
|
function Wheel:updateWireOutputs()
|
||||||
wire.ports[self.prefix .. 'RPM'] = self:selfRPM()
|
wire.ports[self.prefix .. 'WheelRPM'] = self:getRPM()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Wheel:queryAngularVelocity()
|
function Wheel:queryAngularVelocity()
|
||||||
@ -54,8 +55,8 @@ function Wheel:forwardStep(torque, inertia)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--self.entity:setInertia(self.entity:getInertia():setY(inertia))
|
--self.entity:setInertia(self.entity:getInertia():setY(inertia))
|
||||||
self.entity:applyTorque(torque * self.entity:getRight())
|
self.entity:applyTorque(torque * self.direction * self.entity:getRight())
|
||||||
self.angularVelocity = self.entity:getAngleVelocity().y
|
self.angularVelocity = self.entity:getAngleVelocity().y * self.direction * TICK_INTERVAL
|
||||||
|
|
||||||
return self.angularVelocity * self.inertia
|
return self.angularVelocity * self.inertia
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user