@@ -904,15 +904,16 @@ void Integrate(float elapsedClockSeconds)
904904 // Points are 1 = (0, upperLimit) and 2 = (threshold, lowerLimit)
905905
906906 var upperLimit = 130 ;
907- var lowerLimit = 10 ;
907+ var lowerLimit = 1 ;
908908 var AdhesGrad = ( ( upperLimit - lowerLimit ) / ( WheelSlipThresholdMpS - 0 ) ) ;
909909 var targetNumOfSubstepsPS = Math . Abs ( ( AdhesGrad * SlipSpeedMpS ) + lowerLimit ) ;
910910 if ( float . IsNaN ( ( float ) targetNumOfSubstepsPS ) ) targetNumOfSubstepsPS = 1 ;
911911 // Trace.TraceInformation("Grad - {0} AdhesGrad {1} SlipSpeedMps {2} Threshold {3}", temp, AdhesGrad, SlipSpeedMpS, WheelSlipThresholdMpS);
912912
913- if ( targetNumOfSubstepsPS > NumOfSubstepsPS ) // increase substeps
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
914915 {
915- if ( -- waitBeforeSpeedingUp <= 0 ) //wait for a while before speeding up the integration
916+ if ( -- waitBeforeSpeedingUp <= 0 ) //wait for a while before speeding up the integration
916917 {
917918 NumOfSubstepsPS += 5 ;
918919 waitBeforeSpeedingUp = 5 ; //not so fast ;)
@@ -923,14 +924,19 @@ void Integrate(float elapsedClockSeconds)
923924 NumOfSubstepsPS -= 5 ;
924925 waitBeforeSpeedingUp = 5 ;
925926 }
927+ else if ( Math . Abs ( integratorError ) < 0.005 )
928+ {
929+ NumOfSubstepsPS -= 2 ;
930+ waitBeforeSpeedingUp = 5 ;
931+ }
926932
927933 if ( NumOfSubstepsPS < lowerLimit )
928934 NumOfSubstepsPS = lowerLimit ;
929935
930936 if ( NumOfSubstepsPS > upperLimit )
931937 NumOfSubstepsPS = upperLimit ;
932938
933- // Trace.TraceInformation("Grad - {0} AdhesGrad {1} SlipSpeedMps {2} Threshold {3} NumStepsPS {4}", targetNumOfSubstepsPS, AdhesGrad, SlipSpeedMpS, WheelSlipThresholdMpS, NumOfSubstepsPS);
939+ // Trace.TraceInformation("Grad - {0} AdhesGrad {1} SlipSpeedMps {2} Threshold {3} NumStepsPS {4} Error {5} ", targetNumOfSubstepsPS, AdhesGrad, SlipSpeedMpS, WheelSlipThresholdMpS, NumOfSubstepsPS, integratorError );
934940
935941 double dt = elapsedClockSeconds / NumOfSubstepsPS ;
936942 double hdt = dt / 2 ;
0 commit comments