From a0f705292af03e2fca5e980a63feb65512116770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=B3lik=20Uszasty?= Date: Tue, 5 Sep 2017 20:14:58 +0200 Subject: [PATCH] New formula for adhesion, fixed some bugs in calculation of wheels' rotation --- Driver.cpp | 2 +- McZapkie/Mover.cpp | 52 ++++++++++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Driver.cpp b/Driver.cpp index 42d3c222..12af005a 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -4821,7 +4821,7 @@ bool TController::UpdateSituation(double dt) else mvControlling->AntiSlippingButton(); ++iDriverFailCount; - mvControlling->SlippingWheels = false; // flaga już wykorzystana + //mvControlling->SlippingWheels = false; // flaga już wykorzystana } if (iDriverFailCount > maxdriverfails) { diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 1a371675..ba9b03f1 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -3648,6 +3648,7 @@ double TMoverParameters::ComputeMass(void) void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer) { int b; + double Fwheels = 0.0; if (PhysicActivation) { @@ -3707,19 +3708,35 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer) else FTrain = 0; Fb = BrakeForce(RunningTrack); + Fwheels = FTrain - Fb * Sign(V); if( ( Vel > 0.001 ) // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test - && ( std::max( std::abs( FTrain ), Fb ) > TotalMassxg * Adhesive( RunningTrack.friction ) ) ) // poslizg + && ( std::abs(Fwheels) > TotalMassxg * Adhesive( RunningTrack.friction ) ) ) // poslizg { SlippingWheels = true; } if( true == SlippingWheels ) { // TrainForce:=TrainForce-Fb; - nrot = ComputeRotatingWheel((FTrain - Fb * Sign(V) - FStand) / NAxles - + double temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrot * M_PI * WheelDiameter - V) * - Adhesive(RunningTrack.friction) * TotalMass, + Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrot); - FTrain = Sign(FTrain) * TotalMassxg * Adhesive(RunningTrack.friction); - Fb = std::min(Fb, TotalMassxg * Adhesive(RunningTrack.friction)); + Fwheels = Sign(nrot * M_PI * WheelDiameter - V) * TotalMassxg * Adhesive(RunningTrack.friction); + if (Fwheels*Sign(V)>0) + { + FTrain = Fwheels - Fb; + } + else + { + Fb = FTrain - Fwheels; + } + if (Sign(nrot * M_PI * WheelDiameter - V)*Sign(temp_nrot * M_PI * WheelDiameter - V) < 0) + { + SlippingWheels = false; + temp_nrot = V / M_PI / WheelDiameter; + } + + + nrot = temp_nrot; } // else SlippingWheels:=false; // FStand:=0; @@ -3728,7 +3745,7 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer) (Couplers[b].CouplerType<>Articulated)*/ { // doliczenie sił z innych pojazdów Couplers[b].CForce = CouplerForce(b, dt); - FTrain += Couplers[b].CForce; + FTrain += Couplers[b].CForce; } else Couplers[b].CForce = 0; @@ -3862,16 +3879,6 @@ double TMoverParameters::BrakeForce(const TTrackParam &Track) } else UnitBrakeForce = K * 1000.0; - if (((double)NBpA * UnitBrakeForce > TotalMassxg * Adhesive(RunningTrack.friction) / NAxles) && - (abs(V) > 0.001)) - // poslizg - { - // Fb = Adhesive(Track.friction) * Mass * g; - SlippingWheels = true; - } - //{ else - // begin - //{ SlippingWheels:=false;} // if (LocalBrake=ManualBrake)or(MBrake=true)) and (BrakePress<0.3) then // Fb:=UnitBrakeForce*NBpA {ham. reczny dziala na jedna os} // else //yB: to nie do konca ma sens, ponieważ ręczny w wagonie działa na jeden cylinder @@ -3907,7 +3914,10 @@ double TMoverParameters::FrictionForce(double R, int TDamage) // ************************************************************************************************* double TMoverParameters::Adhesive(double staticfriction) { - double adhesion; + double adhesion = 0.0; + const double adh_factor = 0.25; //współczynnik określający, jak bardzo spada tarcie przy poślizgu + const double slipfactor = 0.33; //współczynnik określający, jak szybko spada tarcie przy poślizgu + const double sandfactor = 1.25; //współczynnik określający, jak mocno pomaga piasek /* // ABu: male przerobki, tylko czy to da jakikolwiek skutek w FPS? // w kazdym razie zaciemni kod na pewno :) @@ -3930,6 +3940,7 @@ double TMoverParameters::Adhesive(double staticfriction) // WriteLog(FloatToStr(adhesive)); // tutaj jest na poziomie 0.2 - 0.3 return adhesion; */ + /* //wersja druga if( true == SlippingWheels ) { if( true == SandDose ) { adhesion = 0.48; } @@ -3940,7 +3951,12 @@ double TMoverParameters::Adhesive(double staticfriction) if( true == SandDose ) { adhesion = std::max( staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ) * 1.1, 0.48 ); } else { adhesion = staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ); } } - adhesion *= ( 11.0 - 2 * Random() ) / 10.0; + adhesion *= ( 11.0 - 2 * Random() ) / 10.0; */ + //wersja3 by youBy - uwzględnia naturalne mikropoślizgi i wpływ piasecznicy, usuwa losowość z pojazdu + double Vwheels = nrot * M_PI * WheelDiameter; // predkosc liniowa koła wynikająca z obrotowej + double deltaV = V - Vwheels; //poślizg - różnica prędkości w punkcie styku koła i szyny + deltaV = std::max(0.0, std::abs(deltaV) - 0.25); //mikropoślizgi do ok. 0,25 m/s nie zrywają przyczepności + adhesion = staticfriction * (28 + Vwheels) / (14 + Vwheels) * ((SandDose? sandfactor : 1) - (1 - adh_factor)*(deltaV / (deltaV + slipfactor))); return adhesion; }