@@ -728,7 +728,7 @@ public float SlipDerivationPercentpS
728728 }
729729
730730 double integratorError ;
731- int waitBeforeSpeedingUp ;
731+ int waitBeforeIntegreationRate ;
732732
733733 /// <summary>
734734 /// Read/Write relative slip speed warning threshold value, in percent of maximal effective slip
@@ -908,26 +908,38 @@ void Integrate(float elapsedClockSeconds)
908908 var AdhesGrad = ( ( upperLimit - lowerLimit ) / ( WheelSlipThresholdMpS - 0 ) ) ;
909909 var targetNumOfSubstepsPS = Math . Abs ( ( AdhesGrad * SlipSpeedMpS ) + lowerLimit ) ;
910910 if ( float . IsNaN ( ( float ) targetNumOfSubstepsPS ) ) targetNumOfSubstepsPS = 1 ;
911+
912+ if ( SlipSpeedMpS > WheelSlipThresholdMpS ) // if in wheel slip then maximise the substeps
913+ {
914+ targetNumOfSubstepsPS = 130 ;
915+ }
916+
911917 // Trace.TraceInformation("Grad - {0} AdhesGrad {1} SlipSpeedMps {2} Threshold {3}", temp, AdhesGrad, SlipSpeedMpS, WheelSlipThresholdMpS);
912918
913- // if (targetNumOfSubstepsPS > NumOfSubstepsPS && Math.Abs(integratorError) > Math.Max((Math.Abs(SlipSpeedMpS) - 1) * 0.01, 0.001)) // increase substeps
914- if ( targetNumOfSubstepsPS > NumOfSubstepsPS && Math . Abs ( integratorError ) > Math . Max ( ( Math . Abs ( SlipSpeedMpS ) - 1 ) * 0.01 , 0.001 ) ) // increase substeps
919+ if ( Math . Abs ( integratorError ) < 0.000277 && ! IsWheelSlip && ! IsWheelSlipWarning && SlipSpeedMpS < 0.4 * WheelSlipThresholdMpS )
915920 {
916- if ( -- waitBeforeSpeedingUp <= 0 ) //wait for a while before speeding up the integration
921+ if ( -- waitBeforeIntegreationRate <= 0 ) //wait for a while before changing the integration rate
917922 {
918- NumOfSubstepsPS += 5 ;
919- waitBeforeSpeedingUp = 5 ; //not so fast ;)
923+ NumOfSubstepsPS -= 2 ;
924+ waitBeforeIntegreationRate = 20 ;
920925 }
921926 }
922- else if ( targetNumOfSubstepsPS < NumOfSubstepsPS ) // decrease sub steps
927+ // else if (targetNumOfSubstepsPS > NumOfSubstepsPS && Math.Abs(integratorError) > Math.Max((Math.Abs(SlipSpeedMpS) - 1) * 0.01, 0.001)) // increase substeps
928+ else if ( targetNumOfSubstepsPS > NumOfSubstepsPS ) // increase substeps
923929 {
924- NumOfSubstepsPS -= 5 ;
925- waitBeforeSpeedingUp = 5 ;
930+ if ( -- waitBeforeIntegreationRate <= 0 ) //wait for a while before changing the integration rate
931+ {
932+ NumOfSubstepsPS += 5 ;
933+ waitBeforeIntegreationRate = 30 ; //not so fast ;)
934+ }
926935 }
927- else if ( Math . Abs ( integratorError ) < 0.000277 )
936+ else if ( targetNumOfSubstepsPS < NumOfSubstepsPS ) // decrease sub steps
928937 {
929- NumOfSubstepsPS -= 2 ;
930- waitBeforeSpeedingUp = 5 ;
938+ if ( -- waitBeforeIntegreationRate <= 0 ) //wait for a while before changing the integration rate
939+ {
940+ NumOfSubstepsPS -= 5 ;
941+ waitBeforeIntegreationRate = 20 ;
942+ }
931943 }
932944
933945 if ( NumOfSubstepsPS < lowerLimit )
0 commit comments