update
This commit is contained in:
@@ -3,10 +3,10 @@ local FrictionPreset = class('FrictionPreset')
|
||||
function FrictionPreset:initialize(config)
|
||||
config = config or {}
|
||||
|
||||
self.B = config.B or 10.86
|
||||
self.C = config.C or 2.15
|
||||
self.D = config.D or 0.933
|
||||
self.E = config.E or 0.992
|
||||
self.B = config.B or 11
|
||||
self.C = config.C or 1.15
|
||||
self.D = config.D or 1.03
|
||||
self.E = config.E or -10
|
||||
end
|
||||
|
||||
function FrictionPreset:evaluate(slip)
|
||||
|
||||
@@ -18,11 +18,13 @@ function Wheel:initialize(config)
|
||||
self.squat = config.Squat or 0.1
|
||||
self.slipCircleShape = config.SlipCircleShape or 1.05
|
||||
self.casterAngle = math.rad(config.CasterAngle or 0)
|
||||
self.camberAngle = math.rad(config.CamberAngle or 0)
|
||||
self.toeAngle = math.rad(config.ToeAngle or 0)
|
||||
|
||||
self.forwardFriction = Friction:new(config.ForwardFriction)
|
||||
self.sideFriction = Friction:new(config.SideFriction)
|
||||
self.frictionPreset = FrictionPreset:new(config.FrictionPreset)
|
||||
self.satFrictionPreset = FrictionPreset:new({ B = 13, C = 2.4, D = 1, E = 0.48 })
|
||||
self.satFrictionPreset = FrictionPreset:new()
|
||||
|
||||
self.motorTorque = 0
|
||||
self.brakeTorque = 0
|
||||
@@ -60,6 +62,7 @@ end
|
||||
|
||||
function Wheel:setInertia(inertia)
|
||||
if isValid(self.physObj) then
|
||||
print(inertia)
|
||||
self.physObj:setInertia(Vector(inertia))
|
||||
self.inertia = inertia
|
||||
end
|
||||
@@ -186,12 +189,28 @@ function Wheel:selfAligningTorque(Sy, load)
|
||||
local effectiveTrail = mechanicalTrail + casterEffect * self.radius
|
||||
local D_scaled = D * loadScale * effectiveTrail
|
||||
|
||||
local camberEffect = 1 + 0.5 * math.abs(self.camberAngle)
|
||||
local toeEffect = 1 + 0.3 * math.abs(self.toeAngle)
|
||||
|
||||
local term = B * Sy - E * (B * Sy - math.atan(B * Sy))
|
||||
local Mz = D_scaled * math.sin(C * math.atan(term))
|
||||
local Mz = D_scaled * camberEffect * toeEffect * math.sin(C * math.atan(term))
|
||||
|
||||
return Mz
|
||||
end
|
||||
|
||||
function Wheel:rotateVector(vector)
|
||||
local ang = self.entity:getAngles()
|
||||
local baseForward = ang:getForward()
|
||||
local baseUp = ang:getUp()
|
||||
local baseRight = -ang:getRight()
|
||||
|
||||
local steerRotated = vector:rotateAroundAxis(baseUp, nil, math.rad(-self.steerAngle) + self.toeAngle)
|
||||
local camberRotated = steerRotated:rotateAroundAxis(baseForward, nil, -self.camberAngle)
|
||||
local casterRotated = camberRotated:rotateAroundAxis(baseRight, nil, -self.casterAngle)
|
||||
|
||||
return casterRotated:getNormalized()
|
||||
end
|
||||
|
||||
function Wheel:update()
|
||||
if not isValid(self.entity) or not isValid(self.physObj) then
|
||||
return
|
||||
@@ -206,27 +225,14 @@ function Wheel:update()
|
||||
self.longitudinalLoadCoefficient = self:getLongitudinalLoadCoefficient(self.load * 1000)
|
||||
self.lateralLoadCoefficient = self:getLateralLoadCoefficient(self.load * 1000)
|
||||
|
||||
local baseForward = self.entity:getForward()
|
||||
local baseUp = self.entity:getUp()
|
||||
local baseRight = self.entity:getRight()
|
||||
|
||||
local steerRotatedForward = baseForward:rotateAroundAxis(baseUp, -self.steerAngle)
|
||||
local finalForward = steerRotatedForward:rotateAroundAxis(baseRight, nil, self.casterAngle)
|
||||
|
||||
self.forward = finalForward:getNormalized()
|
||||
self.right = baseUp:cross(self.forward):getNormalized()
|
||||
self.up = self.forward:cross(self.right):getNormalized()
|
||||
|
||||
|
||||
-- local steerRotated = self.entity:getForward():rotateAroundAxis(self.entity:getUp(), -self.steerAngle)
|
||||
-- self.forward = steerRotated:rotateAroundAxis(self.entity:getRight(), self.casterAngle)
|
||||
|
||||
local ang = self.entity:getAngles()
|
||||
local baseForward = ang:getForward()
|
||||
local baseUp = ang:getUp()
|
||||
local baseRight = -ang:getRight()
|
||||
|
||||
-- local steerRotatedRight = self.entity:getRight():rotateAroundAxis(self.entity:getUp(), -self.steerAngle)
|
||||
-- self.right = steerRotatedRight:rotateAroundAxis(self.entity:getRight(), self.casterAngle)
|
||||
|
||||
-- self.forward = self.entity:getForward():rotateAroundAxis(self.entity:getUp(), -self.steerAngle)
|
||||
-- self.right = self.entity:getRight():rotateAroundAxis(self.entity:getUp(), -self.steerAngle)
|
||||
self.forward = self:rotateVector(baseForward)
|
||||
self.right = self:rotateVector(baseRight)
|
||||
self.up = self:rotateVector(baseUp)
|
||||
|
||||
local forwardSpeed = 0
|
||||
local sideSpeed = 0
|
||||
|
||||
Reference in New Issue
Block a user