Make AIplanes respond to TCAS RAs.
This commit is contained in:
parent
27a0ff5442
commit
f6b9c5b908
2 changed files with 31 additions and 1 deletions
|
@ -332,6 +332,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) {
|
|||
use_perf_vs = false;
|
||||
tgt_vs = (curr->crossat - altitude_ft) / (fp->getDistanceToGo(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr)
|
||||
/ 6076.0 / speed*60.0);
|
||||
checkTcas();
|
||||
tgt_altitude_ft = curr->crossat;
|
||||
} else {
|
||||
use_perf_vs = true;
|
||||
|
@ -343,6 +344,32 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) {
|
|||
}
|
||||
}
|
||||
|
||||
void FGAIAircraft::checkTcas(void)
|
||||
{
|
||||
if (props->getIntValue("tcas/threat-level",0)==3)
|
||||
{
|
||||
int RASense = props->getIntValue("tcas/ra-sense",0);
|
||||
if ((RASense>0)&&(tgt_vs<4000))
|
||||
// upward RA: climb!
|
||||
tgt_vs = 4000;
|
||||
else
|
||||
if (RASense<0)
|
||||
{
|
||||
// downward RA: descend!
|
||||
if (altitude_ft < 1000)
|
||||
{
|
||||
// too low: level off
|
||||
if (tgt_vs>0)
|
||||
tgt_vs = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tgt_vs >- 4000)
|
||||
tgt_vs = -4000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FGAIAircraft::initializeFlightPlan() {
|
||||
}
|
||||
|
@ -603,6 +630,7 @@ void FGAIAircraft::handleFirstWaypoint() {
|
|||
tgt_vs = (curr->crossat - prev->altitude)
|
||||
/ (fp->getDistanceToGo(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr)
|
||||
/ 6076.0 / prev->speed*60.0);
|
||||
checkTcas();
|
||||
tgt_altitude_ft = curr->crossat;
|
||||
} else {
|
||||
use_perf_vs = true;
|
||||
|
@ -1025,6 +1053,7 @@ void FGAIAircraft::updateVerticalSpeedTarget() {
|
|||
}
|
||||
} //else
|
||||
// tgt_vs = 0.0;
|
||||
checkTcas();
|
||||
}
|
||||
|
||||
void FGAIAircraft::updatePitchAngleTarget() {
|
||||
|
@ -1183,4 +1212,4 @@ time_t FGAIAircraft::checkForArrivalTime(string wptName) {
|
|||
cerr << "Checking arrival time: ete " << ete << ". Time to go : " << secondsToGo << ". Track length = " << tracklength << endl;
|
||||
}
|
||||
return (ete - secondsToGo); // Positive when we're too slow...
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ public:
|
|||
inline double airspeed() const { return props->getFloatValue("velocities/airspeed-kt");};
|
||||
std::string atGate();
|
||||
|
||||
void checkTcas();
|
||||
|
||||
protected:
|
||||
void Run(double dt);
|
||||
|
|
Loading…
Add table
Reference in a new issue