update attempt

This commit is contained in:
Ivan Grachyov
2025-05-11 01:58:58 +03:00
parent 14ab069846
commit ae5133bd87
4 changed files with 75 additions and 27 deletions

View File

@@ -23,8 +23,10 @@ function Wheel:initialize(config)
self.forwardFriction = Friction:new(config.ForwardFriction)
self.sideFriction = Friction:new(config.SideFriction)
self.frictionPreset = FrictionPreset:new(config.FrictionPreset)
self.satFrictionPreset = FrictionPreset:new()
self.lateralFrictionPreset = FrictionPreset:new(config.LateralFrictionPreset)
self.longitudinalFrictionPreset = FrictionPreset:new(config.LongitudinalFrictionPreset)
self.aligningFrictionPreset = FrictionPreset:new(config.AligningFrictionPreset)
self.motorTorque = 0
self.brakeTorque = 0
@@ -107,7 +109,7 @@ function Wheel:stepLongitudinal(Tm, Tb, Vx, W, Lc, R, I, kFx, kSx)
Tb = math.clamp(Tb, -TbCap, TbCap)
W = W + Tb / I * TICK_INTERVAL
local maxTorque = self.frictionPreset:evaluate(math.abs(Sx)) * Lc * kFx * R
local maxTorque = self.longitudinalFrictionPreset:evaluate(math.abs(Sx)) * Lc * kFx * R
local errorTorque = (W - Vx / R) * I / TICK_INTERVAL
local surfaceTorque = math.clamp(errorTorque, -maxTorque, maxTorque)
@@ -143,7 +145,7 @@ function Wheel:stepLateral(Vx, Vy, Lc, kFy, kSy)
Sy = Sy * kSy * 0.95
Sy = math.clamp(Sy, -1, 1)
local slipSign = Sy < 0 and -1 or 1
local Fy = -slipSign * self.frictionPreset:evaluate(math.abs(Sy)) * Lc * kFy
local Fy = -slipSign * self.lateralFrictionPreset:evaluate(math.abs(Sy)) * Lc * kFy
if Lc < 0.0001 then
Sy = 0
@@ -178,10 +180,10 @@ function Wheel:selfAligningTorque(Sy, load)
return 0
end
local B = self.satFrictionPreset.B
local C = self.satFrictionPreset.C
local D = self.satFrictionPreset.D
local E = self.satFrictionPreset.E
local B = self.aligningFrictionPreset.B
local C = self.aligningFrictionPreset.C
local D = self.aligningFrictionPreset.D
local E = self.aligningFrictionPreset.E
local loadScale = load * 1000
local mechanicalTrail = 0.15