velocity based tangential acceleration calculation, tweaks for relay type 45, 46

This commit is contained in:
tmj-fstate
2018-01-14 19:09:46 +01:00
parent 8e5841d0ec
commit 8d8a533515
8 changed files with 120 additions and 136 deletions

View File

@@ -4563,7 +4563,6 @@ TController::UpdateSituation(double dt) {
AbsAccS /= fMass;
}
AbsAccS_pub = AbsAccS;
AbsAccS_avg = interpolate( AbsAccS_avg, mvOccupied->AccS * iDirection, 0.25 );
#if LOGVELOCITY
// WriteLog("VelDesired="+AnsiString(VelDesired)+",

View File

@@ -209,7 +209,6 @@ public:
double BrakeAccFactor();
double fBrakeReaction = 1.0; //opóźnienie zadziałania hamulca - czas w s / (km/h)
double fAccThreshold = 0.0; // próg opóźnienia dla zadziałania hamulca
double AbsAccS_avg = 0.0; // averaged out directional acceleration
double AbsAccS_pub = 0.0; // próg opóźnienia dla zadziałania hamulca
double fBrake_a0[BrakeAccTableSize+1] = { 0.0 }; // próg opóźnienia dla zadziałania hamulca
double fBrake_a1[BrakeAccTableSize+1] = { 0.0 }; // próg opóźnienia dla zadziałania hamulca

View File

@@ -1749,10 +1749,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
// McZapkie: TypeName musi byc nazwą CHK/MMD pojazdu
if (!MoverParameters->LoadFIZ(asBaseDir))
{ // jak wczytanie CHK się nie uda, to błąd
if (ConversionError == -8)
ErrorLog("Missed file: " + BaseDir + "\\" + Type_Name + ".fiz");
Error("Cannot load dynamic object " + asName + " from:\r\n" + BaseDir + "\\" + Type_Name +
".fiz\r\nError " + to_string(ConversionError));
if (ConversionError == 666)
ErrorLog( "Bad vehicle: failed do locate definition file \"" + BaseDir + "\\" + Type_Name + ".fiz" + "\"" );
else {
ErrorLog( "Bad vehicle: failed to load definition from file \"" + BaseDir + "\\" + Type_Name + ".fiz\" (error " + to_string( ConversionError ) + ")" );
}
return 0.0; // zerowa długość to brak pojazdu
}
bool driveractive = (fVel != 0.0); // jeśli prędkość niezerowa, to aktywujemy ruch
@@ -2964,27 +2965,26 @@ bool TDynamicObject::Update(double dt, double dt1)
}
}
auto axleindex { 0 };
for( auto &axle : m_axlesounds ) {
axle.distance -= dDOMoveLen * Sign( dDOMoveLen );
if( axle.distance < 0 ) {
axle.distance += dRailLength;
/*
// McZapkie-040302
if( i == iAxles - 1 ) {
rsStukot[ 0 ].stop();
MoverParameters->AccV += 0.5 * GetVelocity() / ( 1 + MoverParameters->Vmax );
}
else {
rsStukot[ i + 1 ].stop();
}
if( i == 1 ) {
MoverParameters->AccV -= 0.5 * GetVelocity() / ( 1 + MoverParameters->Vmax );
}
*/
if( MoverParameters->Vel > 2.5 ) {
axle.clatter.gain( volume ).play();
// crude bump simulation, drop down on even axles, move back up on the odd ones
MoverParameters->AccVert +=
interpolate(
0.25, 0.50,
clamp(
GetVelocity() / ( 1 + MoverParameters->Vmax ),
0.0, 1.0 ) )
* ( ( axleindex % 2 ) != 0 ?
1 :
-1 );
}
}
++axleindex;
}
}
}
@@ -3621,9 +3621,9 @@ void TDynamicObject::RenderSounds() {
// don't stop the sound too abruptly
volume = std::max( 0.0, rsPisk.gain() - ( rsPisk.gain() * 2.5 * dt ) );
rsPisk.gain( volume );
if( volume < 0.05 ) {
rsPisk.stop();
}
}
if( volume < 0.05 ) {
rsPisk.stop();
}
// other sounds

View File

@@ -850,8 +850,9 @@ public:
double V = 0.0; //predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
double Vel = 0.0; //moduł prędkości w [km/h], używany przez AI
double AccS = 0.0; //efektywne przyspieszenie styczne w [m/s^2] (wszystkie siły)
double AccN = 0.0; //przyspieszenie normalne w [m/s^2]
double AccV = 0.0;
double AccSVBased {}; // tangential acceleration calculated from velocity change
double AccN = 0.0; // przyspieszenie normalne w [m/s^2]
double AccVert = 0.0; // vertical acceleration
double nrot = 0.0;
double WheelFlat = 0.0;
/*! rotacja kol [obr/s]*/

View File

@@ -1116,7 +1116,6 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
{
const double Vepsilon = 1e-5;
const double Aepsilon = 1e-3; // ASBSpeed=0.8;
double Vprev, AccSprev, d;
// T_MoverParameters::ComputeMovement(dt, dt1, Shape, Track, ElectricTraction, NewLoc, NewRot);
// // najpierw kawalek z funkcji w pliku mover.pas
@@ -1260,12 +1259,13 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
if (dL == 0) // oblicz przesuniecie}
{
Vprev = V;
AccSprev = AccS;
// dt:=ActualTime-LastUpdatedTime; //przyrost czasu
auto const AccSprev { AccS };
// przyspieszenie styczne
AccS = (FTotal / TotalMass + AccSprev) /
2.0; // prawo Newtona ale z wygladzaniem (średnia z poprzednim)
AccS = interpolate(
AccSprev,
FTotal / TotalMass,
0.5 );
// clamp( dt * 3.0, 0.0, 1.0 ) ); // prawo Newtona ale z wygladzaniem (średnia z poprzednim)
if (TestFlag(DamageFlag, dtrain_out))
AccS = -Sign(V) * g * 1; // random(0.0, 0.1)
@@ -1276,7 +1276,29 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
else
AccN = g * Shape.dHrail / TrackW;
// velocity change
auto const Vprev { V };
V += ( 3.0 * AccS - AccSprev ) * dt / 2.0; // przyrost predkosci
if( ( V * Vprev <= 0 )
&& ( std::abs( FStand ) > std::abs( FTrain ) ) ) {
// tlumienie predkosci przy hamowaniu
// zahamowany
V = 0;
}
// tangential acceleration, from velocity change
AccSVBased = interpolate(
AccSVBased,
( V - Vprev ) / dt,
clamp( dt * 3.0, 0.0, 1.0 ) );
// vertical acceleration
AccVert = (
std::abs( AccVert ) < 0.01 ?
0.0 :
AccVert * 0.5 );
// szarpanie
/*
#ifdef EU07_USE_FUZZYLOGIC
if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * Mass * Vel / Vmax, 500000.0, p_accn ) ) {
// Ra: czemu tu masa bez ładunku?
@@ -1288,7 +1310,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
if (AccV > 1.0)
AccN += (7.0 - Random(5)) * (100.0 + Track.DamageFlag / 2.0) * AccV / 2000.0;
*/
// wykolejanie na luku oraz z braku szyn
if (TestFlag(CategoryFlag, 1))
{
@@ -1323,22 +1345,14 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
Mains = false;
DerailReason = 4; // Ra: powód wykolejenia: nieodpowiednia trajektoria
}
V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci
if (TestFlag(DamageFlag, dtrain_out))
if (Vel < 1)
{
V = 0;
AccS = 0;
}
if ((V * Vprev <= 0) && (abs(FStand) > abs(FTrain))) // tlumienie predkosci przy hamowaniu
{ // zahamowany
V = 0;
// AccS:=0; //Ra 2014-03: ale siła grawitacji działa, więc nie może być zerowe
if( ( true == TestFlag( DamageFlag, dtrain_out ) )
&& ( Vel < 1.0 ) ) {
V = 0.0;
AccS = 0.0;
}
// { dL:=(V+AccS*dt/2)*dt; //przyrost dlugosci czyli
// przesuniecie
// dL:=(V+AccS*dt/2)*dt;
// przyrost dlugosci czyli przesuniecie
dL = (3.0 * V - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha}
// ale jesli jest kolizja (zas. zach. pedu) to...}
for (int b = 0; b < 2; b++)
@@ -1350,10 +1364,11 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
if (Power > 1.0) // w rozrządczym nie (jest błąd w FIZ!) - Ra 2014-07: teraz we wszystkich
UpdatePantVolume(dt); // Ra 2014-07: obsługa zbiornika rozrządu oraz pantografów
if (EngineType == WheelsDriven)
d = (double)CabNo * dL; // na chwile dla testu
else
d = dL;
auto const d { (
EngineType == WheelsDriven ?
dL * CabNo : // na chwile dla testu
dL ) };
DistCounter += fabs(dL) / 1000.0;
dL = 0;
@@ -1414,6 +1429,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
// if (Vel>10) and (not DebugmodeFlag) then
if (!DebugModeFlag)
SecuritySystemCheck(dt1);
return d;
};
@@ -1425,7 +1441,6 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
TTrackParam &Track, const TLocation &NewLoc,
TRotation &NewRot)
{
double Vprev, AccSprev, d;
int b;
// T_MoverParameters::FastComputeMovement(dt, Shape, Track, NewLoc, NewRot);
@@ -1437,76 +1452,40 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
if (dL == 0) // oblicz przesuniecie
{
Vprev = V;
AccSprev = AccS;
// dt =ActualTime-LastUpdatedTime; //przyrost czasu
auto const AccSprev { AccS };
// przyspieszenie styczne
AccS = (FTotal / TotalMass + AccSprev) /
2.0; // prawo Newtona ale z wygladzaniem (średnia z poprzednim)
AccS = interpolate(
AccSprev,
FTotal / TotalMass,
0.5 );
// clamp( dt * 3.0, 0.0, 1.0 ) ); // prawo Newtona ale z wygladzaniem (średnia z poprzednim)
if (TestFlag(DamageFlag, dtrain_out))
AccS = -Sign(V) * g * 1; // * random(0.0, 0.1)
// przyspieszenie normalne}
// if Abs(Shape.R)>0.01 then
// AccN:=SQR(V)/Shape.R+g*Shape.dHrail/TrackW
// else AccN:=g*Shape.dHrail/TrackW;
// szarpanie}
#ifdef EU07_USE_FUZZYLOGIC
if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * Mass * Vel / Vmax, 500000.0, p_accn ) ) {
// Ra: czemu tu masa bez ładunku?
AccV /= ( 2.0 * 0.95 + 2.0 * Random() * 0.1 ); // 95-105% of base modifier (2.0)
}
else
#endif
AccV = AccV / 2.0;
// simple mode skips calculation of normal acceleration
if (AccV > 1.0)
AccN += (7.0 - Random(5)) * (100.0 + Track.DamageFlag / 2.0) * AccV / 2000.0;
// {wykolejanie na luku oraz z braku szyn}
// if TestFlag(CategoryFlag,1) then
// begin
// if FuzzyLogic((AccN/g)*(1+0.1*(Track.DamageFlag and
// dtrack_freerail)),TrackW/Dim.H,1)
// or TestFlag(Track.DamageFlag,dtrack_norail) then
// if SetFlag(DamageFlag,dtrain_out) then
// begin
// EventFlag:=true;
// MainS:=false;
// RunningShape.R:=0;
// end;
// {wykolejanie na poszerzeniu toru}
// if FuzzyLogic(Abs(Track.Width-TrackW),TrackW/10,1) then
// if SetFlag(DamageFlag,dtrain_out) then
// begin
// EventFlag:=true;
// MainS:=false;
// RunningShape.R:=0;
// end;
// end;
// {wykolejanie wkutek niezgodnosci kategorii toru i pojazdu}
// if not TestFlag(RunningTrack.CategoryFlag,CategoryFlag) then
// if SetFlag(DamageFlag,dtrain_out) then
// begin
// EventFlag:=true;
// MainS:=false;
// end;
V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci
if (TestFlag(DamageFlag, dtrain_out))
if (Vel < 1)
{
V = 0;
AccS = 0; // Ra 2014-03: ale siła grawitacji działa, więc nie może być zerowe
}
if ((V * Vprev <= 0) && (abs(FStand) > abs(FTrain))) // tlumienie predkosci przy hamowaniu
{ // zahamowany}
// velocity change
auto const Vprev { V };
V += ( 3.0 * AccS - AccSprev ) * dt / 2.0; // przyrost predkosci
if( ( V * Vprev <= 0 )
&& ( std::abs( FStand ) > std::abs( FTrain ) ) ) {
// tlumienie predkosci przy hamowaniu
// zahamowany
V = 0;
AccS = 0;
}
// simple mode skips calculation of tangential acceleration
// simple mode skips calculation of vertical acceleration
AccVert = 0.0;
if( ( true == TestFlag( DamageFlag, dtrain_out ) )
&& ( Vel < 1.0 ) ) {
V = 0.0;
AccS = 0.0;
}
dL = (3.0 * V - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha
// ale jesli jest kolizja (zas. zach. pedu) to...
for (b = 0; b < 2; b++)
@@ -1516,10 +1495,12 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
// QQQ
if (Power > 1.0) // w rozrządczym nie (jest błąd w FIZ!)
UpdatePantVolume(dt); // Ra 2014-07: obsługa zbiornika rozrządu oraz pantografów
if (EngineType == WheelsDriven)
d = (double)CabNo * dL; // na chwile dla testu
else
d = dL;
auto const d { (
EngineType == WheelsDriven ?
dL * CabNo : // na chwile dla testu
dL ) };
DistCounter += fabs(dL) / 1000.0;
dL = 0;
@@ -1553,6 +1534,7 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
if ((BrakeSlippingTimer > 0.8) && (ASBType != 128)) // ASBSpeed=0.8
Hamulec->ASB(0);
BrakeSlippingTimer += dt;
return d;
};
@@ -4621,7 +4603,7 @@ double TMoverParameters::TractionForce(double dt)
case 45:
{
if( ( ScndCtrlPos < ScndCtrlPosNo )
&& ( MainCtrlPos >= 10 ) ) {
&& ( MainCtrlPos >= 11 ) ) {
if( Im < MPTRelay[ ScndCtrlPos ].Iup ) {
++ScndCtrlPos;
@@ -4633,7 +4615,7 @@ double TMoverParameters::TractionForce(double dt)
}
}
// malenie
if( ( ScndCtrlPos > 0 ) && ( MainCtrlPos < 10 ) ) {
if( ( ScndCtrlPos > 0 ) && ( MainCtrlPos < 11 ) ) {
if( ScndCtrlPos == 1 ) {
if( Im > MPTRelay[ ScndCtrlPos - 1 ].Idown ) {
@@ -4647,11 +4629,11 @@ double TMoverParameters::TractionForce(double dt)
}
}
// 3rd level drops with master controller at position lower than 10...
if( MainCtrlPos < 10 ) {
if( MainCtrlPos < 11 ) {
ScndCtrlPos = std::min( 2, ScndCtrlPos );
}
// ...and below position 7 field shunt drops altogether
if( MainCtrlPos < 7 ) {
if( MainCtrlPos < 8 ) {
ScndCtrlPos = 0;
}
/*
@@ -4666,7 +4648,7 @@ double TMoverParameters::TractionForce(double dt)
case 46:
{
// wzrastanie
if( ( MainCtrlPos >= 10 )
if( ( MainCtrlPos >= 12 )
&& ( ScndCtrlPos < ScndCtrlPosNo ) ) {
if( ( ScndCtrlPos ) % 2 == 0 ) {
if( ( MPTRelay[ ScndCtrlPos ].Iup > Im ) ) {
@@ -4681,24 +4663,27 @@ double TMoverParameters::TractionForce(double dt)
}
}
// malenie
if( ( MainCtrlPos < 10 )
if( ( MainCtrlPos < 12 )
&& ( ScndCtrlPos > 0 ) ) {
if( ( ScndCtrlPos ) % 2 == 0 ) {
if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) {
--ScndCtrlPos;
if( Vel < 50.0 ) {
// above 50 km/h already active shunt field can be maintained until lower controller setting
if( ( ScndCtrlPos ) % 2 == 0 ) {
if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) {
--ScndCtrlPos;
}
}
}
else {
if( ( MPTRelay[ ScndCtrlPos + 1 ].Idown < Im )
&& ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) {
--ScndCtrlPos;
else {
if( ( MPTRelay[ ScndCtrlPos + 1 ].Idown < Im )
&& ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) {
--ScndCtrlPos;
}
}
}
}
if( MainCtrlPos < 10 ) {
if( MainCtrlPos < 11 ) {
ScndCtrlPos = std::min( 2, ScndCtrlPos );
}
if( MainCtrlPos < 7 ) {
if( MainCtrlPos < 8 ) {
ScndCtrlPos = 0;
}
break;

View File

@@ -3213,8 +3213,8 @@ void TTrain::UpdateMechPosition(double dt)
shake += 1.25 * MechSpring.ComputateForces(
vector3(
-mvControlled->AccN * dt * 5.0, // highlight side sway
mvControlled->AccV * dt,
-mvControlled->AccS * dt * 1.25 ), // accent acceleration/deceleration
-mvControlled->AccVert * dt,
-mvControlled->AccSVBased * dt * 1.25 ), // accent acceleration/deceleration
pMechShake );
if( Random( iVel ) > 25.0 ) {

View File

@@ -112,7 +112,7 @@ WyslijNamiary(TDynamicObject const *Vehicle)
r.fPar[7] = 0; // prędkość ruchu Z
r.fPar[8] = Vehicle->MoverParameters->AccS; // przyspieszenie X
r.fPar[9] = Vehicle->MoverParameters->AccN; // przyspieszenie Y //na razie nie
r.fPar[10] = Vehicle->MoverParameters->AccV; // przyspieszenie Z
r.fPar[10] = Vehicle->MoverParameters->AccVert; // przyspieszenie Z
r.fPar[11] = Vehicle->MoverParameters->DistCounter; // przejechana odległość w km
r.fPar[12] = Vehicle->MoverParameters->PipePress; // ciśnienie w PG
r.fPar[13] = Vehicle->MoverParameters->ScndPipePress; // ciśnienie w PZ

View File

@@ -1,5 +1,5 @@
#pragma once
#define VERSION_MAJOR 18
#define VERSION_MINOR 113
#define VERSION_MINOR 114
#define VERSION_REVISION 0