16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 16:19:19 +02:00

build 190430. ai braking logic tweaks

This commit is contained in:
tmj-fstate
2019-05-01 03:44:53 +02:00
parent fbe570950d
commit 57f7ac27da
5 changed files with 62 additions and 35 deletions

View File

@@ -1476,7 +1476,8 @@ TController::braking_distance_multiplier( float const Targetvelocity ) const {
if( ( mvOccupied->TrainType == dt_DMU ) if( ( mvOccupied->TrainType == dt_DMU )
&& ( mvOccupied->Vel < 40.0 ) && ( mvOccupied->Vel < 40.0 )
&& ( Targetvelocity == 0.f ) ) { && ( Targetvelocity == 0.f ) ) {
return interpolate( 2.f, 1.f, static_cast<float>( mvOccupied->Vel / 40.0 ) ); auto const multiplier { clamp( 1.f + iVehicles * 0.5f, 2.f, 4.f ) };
return interpolate( multiplier, 1.f, static_cast<float>( mvOccupied->Vel / 40.0 ) );
} }
// HACK: cargo trains or trains going downhill with high braking threshold need more distance to come to a full stop // HACK: cargo trains or trains going downhill with high braking threshold need more distance to come to a full stop
if( ( fBrake_a0[ 1 ] > 0.2 ) if( ( fBrake_a0[ 1 ] > 0.2 )
@@ -2014,7 +2015,7 @@ void TController::AutoRewident()
fBrakeReaction = 0.25; fBrakeReaction = 0.25;
} }
else if( mvOccupied->TrainType == dt_DMU ) { else if( mvOccupied->TrainType == dt_DMU ) {
fNominalAccThreshold = std::max( -0.45, -fBrake_a0[ BrakeAccTableSize ] - 8 * fBrake_a1[ BrakeAccTableSize ] ); fNominalAccThreshold = std::max( -0.75, -fBrake_a0[ BrakeAccTableSize ] - 8 * fBrake_a1[ BrakeAccTableSize ] );
fBrakeReaction = 0.25; fBrakeReaction = 0.25;
} }
else if (ustaw > 16) { else if (ustaw > 16) {
@@ -2374,7 +2375,7 @@ double TController::BrakeAccFactor() const
} }
/* /*
if (mvOccupied->TrainType == dt_DMU && mvOccupied->Vel > 40 && VelNext<40) if (mvOccupied->TrainType == dt_DMU && mvOccupied->Vel > 40 && VelNext<40)
Factor *= 1 + ( (1600 - VelNext * VelNext) / (mvOccupied->Vel * mvOccupied->Vel) ); Factor *= 1 + 0.25 * ( (1600 - VelNext * VelNext) / (mvOccupied->Vel * mvOccupied->Vel) );
*/ */
return Factor; return Factor;
} }
@@ -2780,17 +2781,15 @@ bool TController::IncBrake()
{ {
if( /*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.1 ) { if( /*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.1 ) {
OK = /*mvOccupied->*/BrakeLevelAdd( BrakingInitialLevel ); //GBH OK = /*mvOccupied->*/BrakeLevelAdd( BrakingInitialLevel ); //GBH
/*
// HACK: stronger braking to overcome SA134 engine behaviour // HACK: stronger braking to overcome SA134 engine behaviour
if( ( mvOccupied->TrainType == dt_DMU ) if( ( mvOccupied->TrainType == dt_DMU )
&& ( VelNext == 0.0 ) && ( VelNext == 0.0 )
&& ( fBrakeDist < 200.0 ) ) { && ( fBrakeDist < 200.0 ) ) {
mvOccupied->BrakeLevelAdd( BrakeLevelAdd(
fBrakeDist / ActualProximityDist < 0.8 ? fBrakeDist / ActualProximityDist < 0.8 ?
1.0 : 0.5 :
3.0 ); 1.0 );
} }
*/
} }
else else
{ {
@@ -2811,8 +2810,10 @@ bool TController::IncBrake()
} }
} }
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition > 0 ) { if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition > 0 ) {
if( mvOccupied->Hamulec->Releaser() ) {
mvOccupied->BrakeReleaser( 0 ); mvOccupied->BrakeReleaser( 0 );
} }
}
break; break;
} }
case TBrakeSystem::ElectroPneumatic: { case TBrakeSystem::ElectroPneumatic: {
@@ -2865,7 +2866,8 @@ bool TController::IncBrakeEIM()
bool TController::DecBrake() bool TController::DecBrake()
{ // zmniejszenie siły hamowania { // zmniejszenie siły hamowania
bool OK = false; bool OK = false;
double deltaAcc = 0; double deltaAcc = -1.0;
double pos_diff = 1.0;
switch (mvOccupied->BrakeSystem) switch (mvOccupied->BrakeSystem)
{ {
case TBrakeSystem::Individual: case TBrakeSystem::Individual:
@@ -2875,7 +2877,12 @@ bool TController::DecBrake()
OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired))); OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
break; break;
case TBrakeSystem::Pneumatic: case TBrakeSystem::Pneumatic:
deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition -1.0)*fBrake_a1[0]); if( ( fBrake_a0[ 0 ] != 0.0 )
|| ( fBrake_a1[ 0 ] != 0.0 ) ) {
if( mvOccupied->TrainType == dt_DMU )
pos_diff = 0.25;
deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition - pos_diff)*fBrake_a1[0]);
}
if (deltaAcc < 0) if (deltaAcc < 0)
{ {
if (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition > 0) if (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition > 0)
@@ -2894,8 +2901,11 @@ bool TController::DecBrake()
if (!OK) { if (!OK) {
OK = DecBrakeEIM(); OK = DecBrakeEIM();
} }
/*
// NOTE: disabled, duplicate of AI's behaviour in UpdateSituation()
if (mvOccupied->PipePress < 3.0) if (mvOccupied->PipePress < 3.0)
Need_BrakeRelease = true; Need_BrakeRelease = true;
*/
break; break;
case TBrakeSystem::ElectroPneumatic: case TBrakeSystem::ElectroPneumatic:
if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor) { if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor) {
@@ -5712,26 +5722,44 @@ TController::UpdateSituation(double dt) {
ReactionTime = 0.25; ReactionTime = 0.25;
} }
} }
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) // napełnianie uderzeniowe if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) {
if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P // napełnianie uderzeniowe
|| mvOccupied->BrakeHandle == TBrakeHandle::M394) if( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a )
{ || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P )
|| ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) ) {
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == -2 ) { if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == -2 ) {
/*mvOccupied->*/BrakeLevelSet( gbh_RP ); /*mvOccupied->*/BrakeLevelSet( gbh_RP );
} }
if( ( mvOccupied->PipePress < 3.0 )
&& ( AccDesired > -0.03 ) ) { // TODO: combine all releaser handling in single decision tree instead of having bits all over the place
if( ( AccDesired > -0.03 )
&& ( false == mvOccupied->Hamulec->Releaser() ) ) {
if( mvOccupied->PipePress < 3.0 ) {
mvOccupied->BrakeReleaser( 1 ); mvOccupied->BrakeReleaser( 1 );
} }
if( ( mvOccupied->BrakePress > 0.4 )
&& ( mvOccupied->Hamulec->GetCRP() > 4.9 ) ) {
// wyluzuj lokomotywę, to szybciej ruszymy
mvOccupied->BrakeReleaser( 1 );
}
}
if( ( mvOccupied->PipePress > 3.0 )
&& ( mvOccupied->Hamulec->Releaser() ) ) {
// don't overcharge train brake pipe
mvOccupied->BrakeReleaser( 0 );
}
if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 ) if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 )
&& ( AbsAccS < 0.03 ) && ( AbsAccS < 0.03 )
&& ( AccDesired > -0.03 ) && ( AccDesired > -0.03 )
&& ( VelDesired - mvOccupied->Vel > 2.0 ) ) { && ( VelDesired - mvOccupied->Vel > 2.0 ) ) {
if( ( mvOccupied->EqvtPipePress < 4.95 ) if( ( mvOccupied->EqvtPipePress < 4.5 )
&& ( fReady > 0.35 ) && ( fReady > 0.35 )
&& ( BrakeChargingCooldown >= 0.0 ) ) { && ( BrakeChargingCooldown >= 0.0 )
&& ( ( ActualProximityDist > 100.0 ) // don't charge if we're about to be braking soon
|| ( min_speed( mvOccupied->Vel, VelNext ) == mvOccupied->Vel ) ) ) {
if( ( iDrivigFlags & moveOerlikons ) if( ( iDrivigFlags & moveOerlikons )
|| ( true == IsCargoTrain ) ) { || ( true == IsCargoTrain ) ) {
@@ -5742,10 +5770,13 @@ TController::UpdateSituation(double dt) {
BrakeChargingCooldown = -120.0; BrakeChargingCooldown = -120.0;
} }
} }
/*
// NOTE: disabled, duplicate of release activation in #5732
else if( Need_BrakeRelease ) { else if( Need_BrakeRelease ) {
Need_BrakeRelease = false; Need_BrakeRelease = false;
mvOccupied->BrakeReleaser( 1 ); mvOccupied->BrakeReleaser( 1 );
} }
*/
} }
if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition < 0 ) if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition < 0 )
@@ -5754,6 +5785,7 @@ TController::UpdateSituation(double dt) {
BrakeLevelSet( gbh_RP ); BrakeLevelSet( gbh_RP );
} }
} }
}
#if LOGVELOCITY #if LOGVELOCITY
WriteLog("Dist=" + FloatToStrF(ActualProximityDist, ffFixed, 7, 1) + WriteLog("Dist=" + FloatToStrF(ActualProximityDist, ffFixed, 7, 1) +
", VelDesired=" + FloatToStrF(VelDesired, ffFixed, 7, 1) + ", VelDesired=" + FloatToStrF(VelDesired, ffFixed, 7, 1) +
@@ -5792,17 +5824,6 @@ TController::UpdateSituation(double dt) {
AccDesired > 0.0 ) ) { AccDesired > 0.0 ) ) {
// on slopes disengage the brakes only if you actually intend to accelerate // on slopes disengage the brakes only if you actually intend to accelerate
while( true == DecBrake() ) { ; } // jeśli przyspieszamy, to nie hamujemy while( true == DecBrake() ) { ; } // jeśli przyspieszamy, to nie hamujemy
if( ( mvOccupied->BrakePress > 0.4 )
&& ( mvOccupied->Hamulec->GetCRP() > 4.9 ) ) {
// wyluzuj lokomotywę, to szybciej ruszymy
mvOccupied->BrakeReleaser( 1 );
}
else {
if( mvOccupied->PipePress >= 3.0 ) {
// TODO: combine all releaser handling in single decision tree instead of having bits all over the place
mvOccupied->BrakeReleaser( 0 );
}
}
} }
} }
} }

View File

@@ -280,7 +280,7 @@ private:
int iCoupler = 0; // maska sprzęgu, jaką należy użyć przy łączeniu (po osiągnięciu trybu Connect), 0 gdy jazda bez łączenia int iCoupler = 0; // maska sprzęgu, jaką należy użyć przy łączeniu (po osiągnięciu trybu Connect), 0 gdy jazda bez łączenia
int iDriverFailCount = 0; // licznik błędów AI int iDriverFailCount = 0; // licznik błędów AI
bool Need_TryAgain = false; // true, jeśli druga pozycja w elektryku nie załapała bool Need_TryAgain = false; // true, jeśli druga pozycja w elektryku nie załapała
bool Need_BrakeRelease = true; // bool Need_BrakeRelease = true;
bool IsAtPassengerStop{ false }; // true if the consist is within acceptable range of w4 post bool IsAtPassengerStop{ false }; // true if the consist is within acceptable range of w4 post
double fMinProximityDist = 30.0; // stawanie między 30 a 60 m przed przeszkodą // minimalna oległość do przeszkody, jaką należy zachować double fMinProximityDist = 30.0; // stawanie między 30 a 60 m przed przeszkodą // minimalna oległość do przeszkody, jaką należy zachować
double fOverhead1 = 3000.0; // informacja o napięciu w sieci trakcyjnej (0=brak drutu, zatrzymaj!) double fOverhead1 = 3000.0; // informacja o napięciu w sieci trakcyjnej (0=brak drutu, zatrzymaj!)

View File

@@ -385,6 +385,11 @@ void TBrake::Releaser( int const state )
BrakeStatus = (BrakeStatus & ~b_rls) | ( state * b_rls ); BrakeStatus = (BrakeStatus & ~b_rls) | ( state * b_rls );
} }
bool TBrake::Releaser() const {
return ( ( BrakeStatus & b_rls ) == b_rls );
}
void TBrake::SetEPS( double const nEPS ) void TBrake::SetEPS( double const nEPS )
{ {
} }

View File

@@ -203,6 +203,7 @@ class TBrake {
virtual double GetCRP(); //cisnienie zbiornika sterujacego virtual double GetCRP(); //cisnienie zbiornika sterujacego
bool SetBDF( int const nBDF ); //nastawiacz GPRM bool SetBDF( int const nBDF ); //nastawiacz GPRM
void Releaser( int const state ); //odluzniacz void Releaser( int const state ); //odluzniacz
bool Releaser() const;
virtual void SetEPS( double const nEPS ); //hamulec EP virtual void SetEPS( double const nEPS ); //hamulec EP
virtual void SetRM( double const RMR ) {}; //ustalenie przelozenia rapida virtual void SetRM( double const RMR ) {}; //ustalenie przelozenia rapida
virtual void SetRV( double const RVR) {}; //ustalenie przelozenia rapida virtual void SetRV( double const RVR) {}; //ustalenie przelozenia rapida

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 19 #define VERSION_MAJOR 19
#define VERSION_MINOR 419 #define VERSION_MINOR 430
#define VERSION_REVISION 0 #define VERSION_REVISION 0