From 7313b8f1dfed534bc73a0072f8d1542c3e8c9c08 Mon Sep 17 00:00:00 2001 From: Durk Talsma Date: Sat, 24 Jul 2010 09:19:37 +0200 Subject: [PATCH] - Trying to improve waypoint following. --- src/AIModel/AIAircraft.cxx | 12 ++++++------ src/AIModel/AIFlightPlan.cxx | 9 +++++++-- src/ATC/trafficcontrol.cxx | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 3440290d1..92f458427 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -629,12 +629,12 @@ bool FGAIAircraft::leadPointReached(FGAIFlightPlan::waypoint* curr) { // << dist_to_go << ": Lead distance " // << lead_dist << " " << curr->name // << " Ground target speed " << groundTargetSpeed << endl; - if (trafficRef) { - if (trafficRef->getCallSign() == "Transavia7584") { - cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " " - << _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << curr->name << endl; - } - } + // if (trafficRef) { + // if (trafficRef->getCallSign() == "Transavia7584") { + // cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " " + // << _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << curr->name << endl; + // } + // } return dist_to_go < lead_dist; } diff --git a/src/AIModel/AIFlightPlan.cxx b/src/AIModel/AIFlightPlan.cxx index 1ad358e0e..d3b042bbe 100644 --- a/src/AIModel/AIFlightPlan.cxx +++ b/src/AIModel/AIFlightPlan.cxx @@ -405,7 +405,7 @@ void FGAIFlightPlan::setLeadDistance(double speed, double bearing, return; } if (speed < 25) { - turn_radius = ((360/30)*15) / (2*M_PI); + turn_radius = ((360/30)*fabs(speed)) / (2*M_PI); } else turn_radius = 0.1911 * speed * speed; // an estimate for 25 degrees bank @@ -419,10 +419,15 @@ void FGAIFlightPlan::setLeadDistance(double speed, double bearing, //lead_distance = turn_radius * sin(leadInAngle * SG_DEGREES_TO_RADIANS); lead_distance = turn_radius * tan((leadInAngle * SG_DEGREES_TO_RADIANS)/2); - if (lead_distance > (3*turn_radius)) { + if ((lead_distance > (3*turn_radius)) && (current->on_ground == false)) { // cerr << "Warning: Lead-in distance is large. Inbound = " << inbound // << ". Outbound = " << outbound << ". Lead in angle = " << leadInAngle << ". Turn radius = " << turn_radius << endl; lead_distance = 3 * turn_radius; + return; + } + if ((leadInAngle > 90) && (current->on_ground == true)) { + lead_distance = turn_radius * tan((90 * SG_DEGREES_TO_RADIANS)/2); + return; } } diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index ba00b6019..998f350a9 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -510,7 +510,7 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m double onBoardRadioFreq1 = fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz"); int onBoardRadioFreqI0 = (int) floor(onBoardRadioFreq0 * 100 + 0.5); int onBoardRadioFreqI1 = (int) floor(onBoardRadioFreq1 * 100 + 0.5); - //cerr << "Using " << onBoardRadioFreq0 << ", " << onBoardRadioFreq1 << " and " << stationFreq << endl; + cerr << "Using " << onBoardRadioFreq0 << ", " << onBoardRadioFreq1 << " and " << stationFreq << " for " << text << endl; // Display ATC message only when one of the radios is tuned // the relevant frequency.