Skip to content

Commit 1f7af77

Browse files
committed
Workaround to avoid oscillations due to SlipPercent
1 parent e0dbb20 commit 1f7af77

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,7 +2766,7 @@ protected virtual void UpdateTractiveForce(float elapsedClockSeconds)
27662766
{
27672767
if (axle.DriveForceN != 0 && (AdvancedAdhesionModel || !AntiSlip))
27682768
{
2769-
if (axle.SlipPercent > axle.SlipWarningTresholdPercent) SlipControlActive[i] = true;
2769+
if (axle.HuDIsWheelSlipWarning) SlipControlActive[i] = true;
27702770
}
27712771
else
27722772
{
@@ -2776,18 +2776,22 @@ protected virtual void UpdateTractiveForce(float elapsedClockSeconds)
27762776
{
27772777
float absForceN = Math.Abs(axle.DriveForceN);
27782778
float newForceN;
2779-
if (axle.SlipPercent < axle.SlipWarningTresholdPercent * 0.9f)
2779+
if (!axle.HuDIsWheelSlipWarning)
27802780
{
27812781
// If well below slip threshold, restore full power in 10 seconds
27822782
newForceN = Math.Min(Math.Abs(prevForceN) + absForceN * elapsedClockSeconds / 10, absForceN);
27832783

27842784
// If full force is restored, disengage slip control
27852785
if (newForceN / absForceN > 0.95f) SlipControlActive[i] = false;
27862786
}
2787-
else
2787+
else if (axle.IsWheelSlipWarning)
27882788
{
27892789
newForceN = Math.Max(Math.Abs(prevForceN) - absForceN * elapsedClockSeconds / 3, 0);
27902790
}
2791+
else
2792+
{
2793+
newForceN = absForceN;
2794+
}
27912795
if (axle.DriveForceN > 0 && prevForceN >= 0) axle.DriveForceN = newForceN;
27922796
else if (axle.DriveForceN < 0 && prevForceN <= 0) axle.DriveForceN = -newForceN;
27932797
}

0 commit comments

Comments
 (0)