Skip to content

Commit

Permalink
Automatic merge of T1.4-446-gbdb0429f1 and 14 pull requests
Browse files Browse the repository at this point in the history
- Pull request #525 at 614b222: TCS extensions
- Pull request #613 at 39fb000: fix: Use properly FPS-independent smoothing function
- Pull request #616 at 1b168a0: Improvements in graduated/full release braking
- Pull request #617 at 99c6474: 02m: Removed menu option Debrief Evaluation. Now always available.
- Pull request #619 at ea10bfc: Adjust HuD to display relevant parameters for DM locomotive
- Pull request #620 at 67c67f1: Adjust kinietic friction calculations
- Pull request #622 at c01c4a6: Bug fix for https://bugs.launchpad.net/or/+bug/1965311. TDI: The vacuum brake value is misaligned.
- Pull request #624 at 01231e1: Menu option04 - invert controls
- Pull request #627 at 14c0a12: Improve advanced adhesion model
- Pull request #629 at 34abd9c: Refined label for downloading Testing Version
- Pull request #630 at 688d0cd: Sky Color Fix (Addresses Trello Roadmap Card #367 for More accurate sunrise and sunset)
- Pull request #631 at 443fc13: Get correct signal id if signal ahead is in same Track Circuit
- Pull request #635 at b731488: Minor steam locomotive issues.
- Pull request #637 at b24ab3d: Bug fix for http://www.elvastower.com/forums/index.php?/topic/36129-player-trainlead-locomotive-must-be-player-locomotive-crash/
  • Loading branch information
openrails-bot committed Apr 6, 2022
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public float GetSpeedVariation(float axleSpeedMpS)
float totalAxleForceN = motiveAxleForceN - Math.Sign(axleSpeedMpS) * frictionalForceN;
if (Math.Abs(axleSpeedMpS) < 0.01f)
{
if (Math.Abs(TrainSpeedMpS) < 0.01f) frictionalForceN += frictionN; // Set a starting friction to avoid oscillations at standstill. Maybe Davis A should go here?
if (Math.Abs(TrainSpeedMpS) < 0.01f) frictionalForceN += frictionN; // Set a starting friction to avoid oscillations
if (motiveAxleForceN > frictionalForceN) totalAxleForceN = motiveAxleForceN - frictionalForceN;
else if (motiveAxleForceN < -frictionalForceN) totalAxleForceN = motiveAxleForceN + frictionalForceN;
else
Expand All @@ -600,8 +600,19 @@ public float GetSpeedVariation(float axleSpeedMpS)
frictionalForceN -= Math.Abs(motiveAxleForceN);
}
}
avgAxleForce += axleForceN;
times++;
// Assuming Runge-Kutta 4 integration
// Average force computed weighting the four function calls for each iteration
int c = times % 6;
if (c > 0 && c < 5)
{
avgAxleForce += 2*axleForceN;
times += 2;
}
else
{
avgAxleForce += axleForceN;
times++;
}
return totalAxleForceN * axleDiameterM * axleDiameterM / 4 / totalInertiaKgm2;
}

Expand All @@ -617,13 +628,13 @@ public virtual void Update(float timeSpan)
float prevSpeedMpS = axleSpeedMpS;
times = 0;
avgAxleForce = 0;
axleSpeedMpS = AxleRevolutionsInt.Integrate(timeSpan, GetSpeedVariation);
axleSpeedMpS = AxleRevolutionsInt.Integrate(timeSpan, GetSpeedVariation); //GetSpeedVariation(axleSpeedMpS) * timeSpan;
if (times > 0) axleForceN = avgAxleForce / times;
// TODO: around zero wheel speed calculations become unstable
// Near-zero regime will probably need further corrections
if ((prevSpeedMpS > 0 && axleSpeedMpS <= 0) || (prevSpeedMpS < 0 && axleSpeedMpS >= 0))
{
Reset();
if (Math.Max(brakeRetardForceN, frictionN) > Math.Abs(driveForceN-axleForceN)) Reset();
}
// TODO: We should calculate brake force here
// Adding and substracting the brake force is correct for normal operation,
Expand All @@ -632,9 +643,7 @@ public virtual void Update(float timeSpan)
// And thus there is a duplication of the braking effect in OR. To compensate for this, after the slip characteristics have been calculated, the output of the axle module
// has the brake force "added" back in to give the appropriate motive force output for the locomotive. Braking force is handled separately.
// Hence CompensatedAxleForce is the actual output force on the axle.
if (TrainSpeedMpS > 0.01f) CompensatedAxleForceN = axleForceN + brakeRetardForceN;
else if (TrainSpeedMpS < -0.01f) CompensatedAxleForceN = axleForceN - brakeRetardForceN;
else CompensatedAxleForceN = axleForceN;
CompensatedAxleForceN = axleForceN + Math.Sign(TrainSpeedMpS) * brakeRetardForceN;

if (driveType == AxleDriveType.MotorDriven)
{
Expand Down

0 comments on commit 02c09f7

Please sign in to comment.