mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 20:59:19 +02:00
AI cruise control fix, minor refactoring
This commit is contained in:
47
Driver.cpp
47
Driver.cpp
@@ -2906,15 +2906,12 @@ bool TController::IncSpeed()
|
|||||||
if (Ready || (iDrivigFlags & movePress) || (mvOccupied->ShuntMode)) //{(BrakePress<=0.01*MaxBrakePress)}
|
if (Ready || (iDrivigFlags & movePress) || (mvOccupied->ShuntMode)) //{(BrakePress<=0.01*MaxBrakePress)}
|
||||||
{
|
{
|
||||||
OK = mvControlling->IncMainCtrl(std::max(1,mvOccupied->MainCtrlPosNo/10));
|
OK = mvControlling->IncMainCtrl(std::max(1,mvOccupied->MainCtrlPosNo/10));
|
||||||
//tutaj jeszcze powinien być tempomat
|
// cruise control
|
||||||
|
auto const SpeedCntrlVel { (
|
||||||
double SpeedCntrlVel = VelDesired;
|
( ActualProximityDist > std::max( 50.0, fMaxProximityDist ) ) ?
|
||||||
if (fProximityDist < 50)
|
VelDesired :
|
||||||
{
|
min_speed( VelDesired, VelNext ) ) };
|
||||||
SpeedCntrlVel = std::min(SpeedCntrlVel, VelNext);
|
|
||||||
}
|
|
||||||
SpeedCntrl(SpeedCntrlVel);
|
SpeedCntrl(SpeedCntrlVel);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TEngineType::WheelsDriven:
|
case TEngineType::WheelsDriven:
|
||||||
@@ -3081,20 +3078,15 @@ void TController::SpeedSet()
|
|||||||
else if (Ready || (iDrivigFlags & movePress)) // o ile może jechać
|
else if (Ready || (iDrivigFlags & movePress)) // o ile może jechać
|
||||||
if (fAccGravity < -0.10) // i jedzie pod górę większą niż 10 promil
|
if (fAccGravity < -0.10) // i jedzie pod górę większą niż 10 promil
|
||||||
{ // procedura wjeżdżania na ekstremalne wzniesienia
|
{ // procedura wjeżdżania na ekstremalne wzniesienia
|
||||||
if (fabs(mvControlling->Im) >
|
if (fabs(mvControlling->Im) > 0.85 * mvControlling->Imax) // a prąd jest większy niż 85% nadmiarowego
|
||||||
0.85 * mvControlling->Imax) // a prąd jest większy niż 85% nadmiarowego
|
if (mvControlling->Imax * mvControlling->Voltage / (fMass * fAccGravity) < -2.8) // a na niskim się za szybko nie pojedzie
|
||||||
// if (mvControlling->Imin*mvControlling->Voltage/(fMass*fAccGravity)<-2.8) //a
|
|
||||||
// na niskim się za szybko nie pojedzie
|
|
||||||
if (mvControlling->Imax * mvControlling->Voltage / (fMass * fAccGravity) <
|
|
||||||
-2.8) // a na niskim się za szybko nie pojedzie
|
|
||||||
{ // włączenie wysokiego rozruchu;
|
{ // włączenie wysokiego rozruchu;
|
||||||
// (I*U)[A*V=W=kg*m*m/sss]/(m[kg]*a[m/ss])=v[m/s]; 2.8m/ss=10km/h
|
// (I*U)[A*V=W=kg*m*m/sss]/(m[kg]*a[m/ss])=v[m/s]; 2.8m/ss=10km/h
|
||||||
if (mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1)
|
if (mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1)
|
||||||
{ // jeśli jedzie na równoległym, to zbijamy do szeregowego, aby włączyć
|
{ // jeśli jedzie na równoległym, to zbijamy do szeregowego, aby włączyć
|
||||||
// wysoki rozruch
|
// wysoki rozruch
|
||||||
if (mvControlling->ScndCtrlPos > 0) // jeżeli jest bocznik
|
if (mvControlling->ScndCtrlPos > 0) // jeżeli jest bocznik
|
||||||
mvControlling->DecScndCtrl(
|
mvControlling->DecScndCtrl(2); // wyłączyć bocznik, bo może blokować skręcenie NJ
|
||||||
2); // wyłączyć bocznik, bo może blokować skręcenie NJ
|
|
||||||
do // skręcanie do bezoporowej na szeregowym
|
do // skręcanie do bezoporowej na szeregowym
|
||||||
mvControlling->DecMainCtrl(1); // kręcimy nastawnik jazdy o 1 wstecz
|
mvControlling->DecMainCtrl(1); // kręcimy nastawnik jazdy o 1 wstecz
|
||||||
while (mvControlling->MainCtrlPos ?
|
while (mvControlling->MainCtrlPos ?
|
||||||
@@ -3102,8 +3094,7 @@ void TController::SpeedSet()
|
|||||||
false); // oporowa zapętla
|
false); // oporowa zapętla
|
||||||
}
|
}
|
||||||
if (mvControlling->Imax < mvControlling->ImaxHi) // jeśli da się na wysokim
|
if (mvControlling->Imax < mvControlling->ImaxHi) // jeśli da się na wysokim
|
||||||
mvControlling->CurrentSwitch(
|
mvControlling->CurrentSwitch(true); // rozruch wysoki (za to może się ślizgać)
|
||||||
true); // rozruch wysoki (za to może się ślizgać)
|
|
||||||
if (ReactionTime > 0.1)
|
if (ReactionTime > 0.1)
|
||||||
ReactionTime = 0.1; // orientuj się szybciej
|
ReactionTime = 0.1; // orientuj się szybciej
|
||||||
} // if (Im>Imin)
|
} // if (Im>Imin)
|
||||||
@@ -3132,23 +3123,12 @@ void TController::SpeedSet()
|
|||||||
if (mvOccupied->Vel >= 30.0) // jak się rozpędził
|
if (mvOccupied->Vel >= 30.0) // jak się rozpędził
|
||||||
if (fAccGravity > -0.02) // a i pochylenie mnijsze niż 2‰
|
if (fAccGravity > -0.02) // a i pochylenie mnijsze niż 2‰
|
||||||
mvControlling->CurrentSwitch(false); // rozruch wysoki wyłącz
|
mvControlling->CurrentSwitch(false); // rozruch wysoki wyłącz
|
||||||
// dokręcanie do bezoporowej, bo IncSpeed() może nie być wywoływane
|
|
||||||
// if (mvOccupied->Vel<VelDesired)
|
|
||||||
// if (AccDesired>-0.1) //nie ma hamować
|
|
||||||
// if (Controlling->RList[MainCtrlPos].R>0.0)
|
|
||||||
// if (Im<1.3*Imin) //lekkie przekroczenie miimalnego prądu jest dopuszczalne
|
|
||||||
// IncMainCtrl(1); //zwieksz nastawnik skoro możesz - tak aby się ustawic na
|
|
||||||
// bezoporowej
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TEngineType::Dumb:
|
case TEngineType::Dumb:
|
||||||
case TEngineType::DieselElectric:
|
case TEngineType::DieselElectric:
|
||||||
case TEngineType::ElectricInductionMotor:
|
case TEngineType::ElectricInductionMotor:
|
||||||
break;
|
break;
|
||||||
// WheelsDriven :
|
|
||||||
// begin
|
|
||||||
// OK:=False;
|
|
||||||
// end;
|
|
||||||
case TEngineType::DieselEngine:
|
case TEngineType::DieselEngine:
|
||||||
// Ra 2014-06: "automatyczna" skrzynia biegów...
|
// Ra 2014-06: "automatyczna" skrzynia biegów...
|
||||||
if (!mvControlling->MotorParam[mvControlling->ScndCtrlPos].AutoSwitch) // gdy biegi ręczne
|
if (!mvControlling->MotorParam[mvControlling->ScndCtrlPos].AutoSwitch) // gdy biegi ręczne
|
||||||
@@ -4901,13 +4881,10 @@ TController::UpdateSituation(double dt) {
|
|||||||
#endif
|
#endif
|
||||||
// ustalanie zadanego przyspieszenia
|
// ustalanie zadanego przyspieszenia
|
||||||
//(ActualProximityDist) - odległość do miejsca zmniejszenia prędkości
|
//(ActualProximityDist) - odległość do miejsca zmniejszenia prędkości
|
||||||
//(AccPreferred) - wynika z psychyki oraz uwzglęnia już ewentualne zderzenie z
|
//(AccPreferred) - wynika z psychyki oraz uwzglęnia już ewentualne zderzenie z pojazdem z przodu, ujemne gdy należy hamować
|
||||||
// pojazdem z przodu, ujemne gdy należy hamować
|
|
||||||
//(AccDesired) - uwzględnia sygnały na drodze ruchu, ujemne gdy należy hamować
|
//(AccDesired) - uwzględnia sygnały na drodze ruchu, ujemne gdy należy hamować
|
||||||
//(fAccGravity) - chwilowe przspieszenie grawitacyjne, ujemne działa przeciwnie do
|
//(fAccGravity) - chwilowe przspieszenie grawitacyjne, ujemne działa przeciwnie do zadanego kierunku jazdy
|
||||||
// zadanego kierunku jazdy
|
//(AbsAccS) - chwilowe przyspieszenie pojazu (uwzględnia grawitację), ujemne działa przeciwnie do zadanego kierunku jazdy
|
||||||
//(AbsAccS) - chwilowe przyspieszenie pojazu (uwzględnia grawitację), ujemne działa
|
|
||||||
// przeciwnie do zadanego kierunku jazdy
|
|
||||||
//(AccDesired) porównujemy z (fAccGravity) albo (AbsAccS)
|
//(AccDesired) porównujemy z (fAccGravity) albo (AbsAccS)
|
||||||
if( ( VelNext >= 0.0 )
|
if( ( VelNext >= 0.0 )
|
||||||
&& ( ActualProximityDist <= routescanrange )
|
&& ( ActualProximityDist <= routescanrange )
|
||||||
|
|||||||
1
Driver.h
1
Driver.h
@@ -265,7 +265,6 @@ private:
|
|||||||
double VelNext = 120.0; // prędkość, jaka ma być po przejechaniu długości ProximityDist
|
double VelNext = 120.0; // prędkość, jaka ma być po przejechaniu długości ProximityDist
|
||||||
double VelRestricted = -1.0; // speed of travel after passing a permissive signal at stop
|
double VelRestricted = -1.0; // speed of travel after passing a permissive signal at stop
|
||||||
private:
|
private:
|
||||||
double fProximityDist = 0.0; // odleglosc podawana w SetProximityVelocity(); >0:przeliczać do punktu, <0:podana wartość
|
|
||||||
double FirstSemaphorDist = 10000.0; // odległość do pierwszego znalezionego semafora
|
double FirstSemaphorDist = 10000.0; // odległość do pierwszego znalezionego semafora
|
||||||
public:
|
public:
|
||||||
double ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia
|
double ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia
|
||||||
|
|||||||
@@ -5398,8 +5398,6 @@ bool TMoverParameters::AutoRelaySwitch(bool State)
|
|||||||
bool TMoverParameters::AutoRelayCheck(void)
|
bool TMoverParameters::AutoRelayCheck(void)
|
||||||
{
|
{
|
||||||
bool OK = false; // b:int;
|
bool OK = false; // b:int;
|
||||||
bool ARFASI = false;
|
|
||||||
bool ARFASI2 = false; // sprawdzenie wszystkich warunkow (AutoRelayFlag, AutoSwitch, Im<Imin)
|
|
||||||
bool ARC = false;
|
bool ARC = false;
|
||||||
|
|
||||||
// Ra 2014-06: dla SN61 nie działa prawidłowo
|
// Ra 2014-06: dla SN61 nie działa prawidłowo
|
||||||
@@ -5421,11 +5419,14 @@ bool TMoverParameters::AutoRelayCheck(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ARFASI2 = (!AutoRelayFlag) || ((MotorParam[ScndCtrlActualPos].AutoSwitch) &&
|
// sprawdzenie wszystkich warunkow (AutoRelayFlag, AutoSwitch, Im<Imin)
|
||||||
(abs(Im) < Imin)); // wszystkie warunki w jednym
|
auto const ARFASI2 { (
|
||||||
ARFASI = (!AutoRelayFlag) || ((RList[MainCtrlActualPos].AutoSwitch) && (abs(Im) < Imin)) ||
|
( !AutoRelayFlag )
|
||||||
((!RList[MainCtrlActualPos].AutoSwitch) &&
|
|| ( ( MotorParam[ ScndCtrlActualPos ].AutoSwitch ) && ( abs( Im ) < Imin ) ) ) };
|
||||||
(RList[MainCtrlActualPos].Relay < MainCtrlPos)); // wszystkie warunki w jednym
|
auto const ARFASI { (
|
||||||
|
( !AutoRelayFlag )
|
||||||
|
|| ( ( RList[ MainCtrlActualPos ].AutoSwitch ) && ( abs( Im ) < Imin ) )
|
||||||
|
|| ( ( !RList[ MainCtrlActualPos ].AutoSwitch ) && ( RList[ MainCtrlActualPos ].Relay < MainCtrlPos ) ) ) };
|
||||||
// brak PSR na tej pozycji działa PSR i prąd poniżej progu
|
// brak PSR na tej pozycji działa PSR i prąd poniżej progu
|
||||||
// na tej pozycji nie działa PSR i pozycja walu ponizej
|
// na tej pozycji nie działa PSR i pozycja walu ponizej
|
||||||
// chodzi w tym wszystkim o to, żeby można było zatrzymać rozruch na
|
// chodzi w tym wszystkim o to, żeby można było zatrzymać rozruch na
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ cParser::cParser( std::string const &Stream, buffertype const Type, std::string
|
|||||||
if( ( Stream.size() >= 4 )
|
if( ( Stream.size() >= 4 )
|
||||||
&& ( ToLower( Stream.substr( Stream.size() - 4 ) ) == ".inc" ) ) {
|
&& ( ToLower( Stream.substr( Stream.size() - 4 ) ) == ".inc" ) ) {
|
||||||
mIncFile = true;
|
mIncFile = true;
|
||||||
scene::Groups.begin();
|
scene::Groups.create();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ cParser::~cParser() {
|
|||||||
|
|
||||||
if( true == mIncFile ) {
|
if( true == mIncFile ) {
|
||||||
// wrap up the node group holding content of processed file
|
// wrap up the node group holding content of processed file
|
||||||
scene::Groups.end();
|
scene::Groups.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ node_groups Groups;
|
|||||||
|
|
||||||
// requests creation of a new node group. returns: handle to the group
|
// requests creation of a new node group. returns: handle to the group
|
||||||
scene::group_handle
|
scene::group_handle
|
||||||
node_groups::begin() {
|
node_groups::create() {
|
||||||
|
|
||||||
m_activegroup.push( create_handle() );
|
m_activegroup.push( create_handle() );
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ node_groups::begin() {
|
|||||||
|
|
||||||
// indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty
|
// indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty
|
||||||
scene::group_handle
|
scene::group_handle
|
||||||
node_groups::end() {
|
node_groups::close() {
|
||||||
|
|
||||||
if( false == m_activegroup.empty() ) {
|
if( false == m_activegroup.empty() ) {
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ node_groups::handle() const {
|
|||||||
|
|
||||||
// places provided node in specified group
|
// places provided node in specified group
|
||||||
void
|
void
|
||||||
node_groups::register_node( scene::basic_node *Node, scene::group_handle const Group ) {
|
node_groups::insert( scene::group_handle const Group, scene::basic_node *Node ) {
|
||||||
|
|
||||||
// TBD, TODO: automatically unregister the node from its current group?
|
// TBD, TODO: automatically unregister the node from its current group?
|
||||||
Node->group( Group );
|
Node->group( Group );
|
||||||
|
|||||||
@@ -27,16 +27,16 @@ public:
|
|||||||
// methods
|
// methods
|
||||||
// requests creation of a new node group. returns: handle to the group
|
// requests creation of a new node group. returns: handle to the group
|
||||||
group_handle
|
group_handle
|
||||||
begin();
|
create();
|
||||||
// indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty
|
// indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty
|
||||||
group_handle
|
group_handle
|
||||||
end();
|
close();
|
||||||
// returns current active group, or null_handle if group stack is empty
|
// returns current active group, or null_handle if group stack is empty
|
||||||
group_handle
|
group_handle
|
||||||
handle() const;
|
handle() const;
|
||||||
// places provided node in specified group
|
// places provided node in specified group
|
||||||
void
|
void
|
||||||
register_node( scene::basic_node *Node, scene::group_handle const Group );
|
insert( scene::group_handle const Group, scene::basic_node *Node );
|
||||||
std::pair<node_sequence::iterator, node_sequence::iterator>
|
std::pair<node_sequence::iterator, node_sequence::iterator>
|
||||||
group( scene::group_handle const Group ) {
|
group( scene::group_handle const Group ) {
|
||||||
auto &group { m_groupmap[ Group ] };
|
auto &group { m_groupmap[ Group ] };
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
|||||||
delete pathnode;
|
delete pathnode;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
scene::Groups.register_node( path, scene::Groups.handle() );
|
scene::Groups.insert( scene::Groups.handle(), path );
|
||||||
simulation::Region->insert_and_register( path );
|
simulation::Region->insert_and_register( path );
|
||||||
}
|
}
|
||||||
else if( nodedata.type == "traction" ) {
|
else if( nodedata.type == "traction" ) {
|
||||||
@@ -317,7 +317,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
|||||||
if( false == simulation::Traction.insert( traction ) ) {
|
if( false == simulation::Traction.insert( traction ) ) {
|
||||||
ErrorLog( "Bad scenario: traction piece with duplicate name \"" + traction->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
|
ErrorLog( "Bad scenario: traction piece with duplicate name \"" + traction->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
|
||||||
}
|
}
|
||||||
scene::Groups.register_node( traction, scene::Groups.handle() );
|
scene::Groups.insert( scene::Groups.handle(), traction );
|
||||||
simulation::Region->insert_and_register( traction );
|
simulation::Region->insert_and_register( traction );
|
||||||
}
|
}
|
||||||
else if( nodedata.type == "tractionpowersource" ) {
|
else if( nodedata.type == "tractionpowersource" ) {
|
||||||
@@ -378,7 +378,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
|||||||
if( false == simulation::Instances.insert( instance ) ) {
|
if( false == simulation::Instances.insert( instance ) ) {
|
||||||
ErrorLog( "Bad scenario: 3d model instance with duplicate name \"" + instance->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
|
ErrorLog( "Bad scenario: 3d model instance with duplicate name \"" + instance->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
|
||||||
}
|
}
|
||||||
scene::Groups.register_node( instance, scene::Groups.handle() );
|
scene::Groups.insert( scene::Groups.handle(), instance );
|
||||||
simulation::Region->insert( instance );
|
simulation::Region->insert( instance );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,7 +421,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
|||||||
if( false == simulation::Memory.insert( memorycell ) ) {
|
if( false == simulation::Memory.insert( memorycell ) ) {
|
||||||
ErrorLog( "Bad scenario: memory memorycell with duplicate name \"" + memorycell->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
|
ErrorLog( "Bad scenario: memory memorycell with duplicate name \"" + memorycell->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
|
||||||
}
|
}
|
||||||
scene::Groups.register_node( memorycell, scene::Groups.handle() );
|
scene::Groups.insert( scene::Groups.handle(), memorycell );
|
||||||
simulation::Region->insert( memorycell );
|
simulation::Region->insert( memorycell );
|
||||||
}
|
}
|
||||||
else if( nodedata.type == "eventlauncher" ) {
|
else if( nodedata.type == "eventlauncher" ) {
|
||||||
@@ -436,7 +436,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
|||||||
simulation::Events.queue( eventlauncher );
|
simulation::Events.queue( eventlauncher );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scene::Groups.register_node( eventlauncher, scene::Groups.handle() );
|
scene::Groups.insert( scene::Groups.handle(), eventlauncher );
|
||||||
simulation::Region->insert( eventlauncher );
|
simulation::Region->insert( eventlauncher );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user