]> git.mxchange.org Git - flightgear.git/commitdiff
Fixing an age old bug. AIAircraft arriving on an airport never received a proper...
authorDurk Talsma <durktals@gmail.com>
Sat, 12 Nov 2011 17:40:23 +0000 (18:40 +0100)
committerDurk Talsma <durktals@gmail.com>
Sat, 12 Nov 2011 17:40:23 +0000 (18:40 +0100)
src/AIModel/AIAircraft.cxx
src/AIModel/AIFlightPlanCreate.cxx
src/AIModel/AIFlightPlanCreatePushBack.cxx
src/Airports/dynamics.cxx

index 2722886c6053750a54e5007a6c3e4dc440582cb2..69c519f63d9824231fd4d33998b48bec2a980467 100644 (file)
@@ -820,10 +820,10 @@ bool FGAIAircraft::leadPointReached(FGAIWaypoint* curr) {
        } 
     if (trafficRef) {
          //cerr << "Tracking callsign : \"" << fgGetString("/ai/track-callsign") << "\"" << endl;
-/*         if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
-              cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " " 
-                   << _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->name << " " << vs << " " << tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << endl; 
-         }*/
+         //if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
+              //cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " " 
+              //     << _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->getName() << " " << vs << " " << //tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << endl; 
+         //}
      }
     if ((dist_to_go < lead_dist) ||
         ((dist_to_go > prev_dist_to_go) && (bearing > (minBearing * 1.1))) ) {
@@ -1275,9 +1275,9 @@ void FGAIAircraft::updateActualState() {
     updatePosition();
 
     if (onGround())
-        speed = _performance->actualSpeed(this, groundTargetSpeed, dt);
+        speed = _performance->actualSpeed(this, groundTargetSpeed, dt, holdPos);
     else
-        speed = _performance->actualSpeed(this, (tgt_speed *speedFraction), dt);
+        speed = _performance->actualSpeed(this, (tgt_speed *speedFraction), dt, false);
     //assertSpeed(speed);
     updateHeading();
     roll = _performance->actualBankAngle(this, tgt_roll, dt);
index d50ff58dad68b5b2d3d48968613530291497e80e..8375c854e7340b8bd1bdc25b22670042133de6c9 100644 (file)
@@ -357,7 +357,7 @@ void FGAIFlightPlan::createDefaultLandingTaxi(FGAIAircraft * ac,
     double heading, lat, lon;
     aAirport->getDynamics()->getParking(gateId, &lat, &lon, &heading);
     wpt =
-        createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), airportElev,
+        createOnGround(ac, "ENDtaxi", SGGeod::fromDeg(lon, lat), airportElev,
                        ac->getPerformance()->vTaxi());
     pushBackWaypoint(wpt);
 }
@@ -1039,7 +1039,7 @@ bool FGAIFlightPlan::createParking(FGAIAircraft * ac, FGAirport * apt,
     pushBackWaypoint(wpt);
 
     wpt =
-        createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), aptElev,
+        createOnGround(ac, "END-Parking", SGGeod::fromDeg(lon, lat), aptElev,
                        vTaxiReduced);
     pushBackWaypoint(wpt);
     return true;
index c1da283adc4330a8e7b03847996dc8839e6a6c91..d5c79356ee1728892d007a5401ecc8319ed3cc48 100644 (file)
 
 // TODO: Use James Turner's createOnGround functions.
 bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
-                                   bool firstFlight, FGAirport *dep, 
-                                   double latitude,
-                                   double longitude,
-                                   double radius,
-                                   const string& fltType,
-                                   const string& aircraftType,
-                                   const string& airline)
+                                    bool firstFlight, FGAirport *dep,
+                                    double latitude,
+                                    double longitude,
+                                    double radius,
+                                    const string& fltType,
+                                    const string& aircraftType,
+                                    const string& airline)
 {
     double lat, lon, heading;
     double vTaxi = ac->getPerformance()->vTaxi();
@@ -56,185 +56,185 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
     activeRunway.clear();
 
     if (!(dep->getDynamics()->getGroundNetwork()->exists())) {
-       //cerr << "Push Back fallback" << endl;
-       createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
-                             radius, fltType, aircraftType, airline);
+        //cerr << "Push Back fallback" << endl;
+        createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
+                               radius, fltType, aircraftType, airline);
     } else {
-       if (firstFlight) {
-           
-           if (!(dep->getDynamics()->getAvailableParking(&lat, &lon, 
-                                                         &heading, &gateId, 
-                                                         radius, fltType, 
-                                                         aircraftType, airline))) {
-                   SG_LOG(SG_INPUT, SG_WARN, "Warning: Could not find parking for a " << 
-                                             aircraftType <<
-                                             " of flight type " << fltType << 
-                                             " of airline     " << airline <<
-                                             " at airport     " << dep->getId());
-                   return false;
-                   char buffer[10];
-                   snprintf (buffer, 10, "%d", gateId);
-                   SGGeod coord = coord.fromDeg(lon, lat);
-                   //FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
-                   FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
-                 wpt->setRouteIndex(-1);
-                 pushBackWaypoint(wpt);
-           }
-         //cerr << "Success : GateId = " << gateId << endl;
-         SG_LOG(SG_INPUT, SG_WARN, "Warning: Succesfully found a parking for a " << 
-                                             aircraftType <<
-                                             " of flight type " << fltType << 
-                                             " of airline     " << airline <<
-                                             " at airport     " << dep->getId());
-       } else {
-           //cerr << "Push Back follow-up Flight" << endl;
-           dep->getDynamics()->getParking(gateId, &lat, &lon, &heading);
-       }
-       if (gateId < 0) {
-           createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
-                                   radius, fltType, aircraftType, airline);
-           return true;
-
-       }
-       //cerr << "getting parking " << gateId;
-       //cerr << " for a " << 
-       //                                      aircraftType <<
-       //                                      " of flight type " << fltType << 
-       //                                      " of airline     " << airline <<
-       //                                      " at airport     " << dep->getId() << endl;
-       FGParking *parking = dep->getDynamics()->getParking(gateId);
-       int pushBackNode = parking->getPushBackPoint();
-
-
-       pushBackRoute = parking->getPushBackRoute();
-       if ((pushBackNode > 0) && (pushBackRoute == 0)) {  // Load the already established route for this gate
-           int node, rte;
-           FGTaxiRoute route;
-           //cerr << "Creating push-back for " << gateId << " (" << parking->getName() << ") using push-back point " << pushBackNode << endl;
-           route = dep->getDynamics()->getGroundNetwork()->findShortestRoute(gateId, pushBackNode, false);
-           parking->setPushBackRoute(new FGTaxiRoute(route));
-           
-
-           pushBackRoute = parking->getPushBackRoute();
-           int size = pushBackRoute->size();
-           if (size < 2) {
-               SG_LOG(SG_GENERAL, SG_WARN, "Push back route from gate " << gateId << " has only " << size << " nodes.");
-               SG_LOG(SG_GENERAL, SG_WARN, "Using  " << pushBackNode);
-           }
-           pushBackRoute->first();
-           while(pushBackRoute->next(&node, &rte))
-             {
-               //FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findSegment(node)->getEnd();
-               char buffer[10];
-               snprintf (buffer, 10, "%d", node);
-               FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
-               //ids.pop_back();  
-               //wpt = new waypoint;
-               SGGeod coord = coord.fromDeg(tn->getLongitude(), tn->getLatitude());
-               FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
-
-               wpt->setRouteIndex(rte);
-               pushBackWaypoint(wpt);
-             }
-             // some special considerations for the last point:
-             waypoints.back()->setName(string("PushBackPoint"));
-             waypoints.back()->setSpeed(vTaxi);
-             ac->setTaxiClearanceRequest(true);
-       } else {  // In case of a push forward departure...
-         ac->setTaxiClearanceRequest(false);
-         double lat2 = 0.0, lon2 = 0.0, az2 = 0.0;
-
-         //cerr << "Creating final push forward point for gate " << gateId << endl;
-         FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(gateId);
-         FGTaxiSegmentVectorIterator ts = tn->getBeginRoute();
-         FGTaxiSegmentVectorIterator te = tn->getEndRoute();
-         // if the starting node equals the ending node, then there aren't any routes for this parking.
-          // in cases like these we should flag the gate as being inoperative and return false
-         if (ts == te) {
-             SG_LOG(SG_GENERAL, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
-              parking->setAvailable(false);
-              return false;
-         }
-         tn = (*ts)->getEnd();
-         lastNodeVisited = tn->getIndex();
-         if (tn == NULL) {
-             SG_LOG(SG_GENERAL, SG_ALERT, "No valid taxinode found");
-             exit(1);
-         }
-         double distance = (*ts)->getLength();
-         //cerr << "Length of push forward route = " << distance << " and heading is " << heading << endl;
-         lat2 =  tn->getLatitude();
-         lon2 =  tn->getLongitude();
-
-         for (int i = 1; i < 10; i++) {
-               geo_direct_wgs_84 ( 0, lat, lon, heading, 
-                                 ((i / 10.0) * distance), &lat2, &lon2, &az2 );
-               char buffer[16];
-               snprintf(buffer, 16, "pushback-%02d", i);
-               SGGeod coord = coord.fromDeg(lon2, lat2);
-               //cerr << i << endl;
-               FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiReduced);
-
-               wpt->setRouteIndex((*ts)->getIndex());
-               pushBackWaypoint(wpt); 
-         }
-         // cerr << "Done " << endl;
-         waypoints.back()->setName(string("PushBackPoint"));
-         // cerr << "Done assinging new name" << endl;
-       }
+        if (firstFlight) {
+
+            if (!(dep->getDynamics()->getAvailableParking(&lat, &lon,
+                    &heading, &gateId,
+                    radius, fltType,
+                    aircraftType, airline))) {
+                SG_LOG(SG_INPUT, SG_WARN, "Warning: Could not find parking for a " <<
+                       aircraftType <<
+                       " of flight type " << fltType <<
+                       " of airline     " << airline <<
+                       " at airport     " << dep->getId());
+                return false;
+                char buffer[10];
+                snprintf (buffer, 10, "%d", gateId);
+                SGGeod coord = coord.fromDeg(lon, lat);
+                //FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
+                FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
+                wpt->setRouteIndex(-1);
+                pushBackWaypoint(wpt);
+            }
+            //cerr << "Success : GateId = " << gateId << endl;
+            SG_LOG(SG_INPUT, SG_WARN, "Warning: Succesfully found a parking for a " <<
+                   aircraftType <<
+                   " of flight type " << fltType <<
+                   " of airline     " << airline <<
+                   " at airport     " << dep->getId());
+        } else {
+            //cerr << "Push Back follow-up Flight" << endl;
+            dep->getDynamics()->getParking(gateId, &lat, &lon, &heading);
+        }
+        if (gateId < 0) {
+            createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
+                                   radius, fltType, aircraftType, airline);
+            return true;
+
+        }
+        //cerr << "getting parking " << gateId;
+        //cerr << " for a " <<
+        //                                      aircraftType <<
+        //                                      " of flight type " << fltType <<
+        //                                      " of airline     " << airline <<
+        //                                      " at airport     " << dep->getId() << endl;
+        FGParking *parking = dep->getDynamics()->getParking(gateId);
+        int pushBackNode = parking->getPushBackPoint();
+
+
+        pushBackRoute = parking->getPushBackRoute();
+        if ((pushBackNode > 0) && (pushBackRoute == 0)) {  // Load the already established route for this gate
+            int node, rte;
+            FGTaxiRoute route;
+            //cerr << "Creating push-back for " << gateId << " (" << parking->getName() << ") using push-back point " << pushBackNode << endl;
+            route = dep->getDynamics()->getGroundNetwork()->findShortestRoute(gateId, pushBackNode, false);
+            parking->setPushBackRoute(new FGTaxiRoute(route));
+
+
+            pushBackRoute = parking->getPushBackRoute();
+            int size = pushBackRoute->size();
+            if (size < 2) {
+                SG_LOG(SG_GENERAL, SG_WARN, "Push back route from gate " << gateId << " has only " << size << " nodes.");
+                SG_LOG(SG_GENERAL, SG_WARN, "Using  " << pushBackNode);
+            }
+            pushBackRoute->first();
+            while (pushBackRoute->next(&node, &rte))
+            {
+                //FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findSegment(node)->getEnd();
+                char buffer[10];
+                snprintf (buffer, 10, "%d", node);
+                FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
+                //ids.pop_back();
+                //wpt = new waypoint;
+                SGGeod coord = coord.fromDeg(tn->getLongitude(), tn->getLatitude());
+                FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
+
+                wpt->setRouteIndex(rte);
+                pushBackWaypoint(wpt);
+            }
+            // some special considerations for the last point:
+            waypoints.back()->setName(string("PushBackPoint"));
+            waypoints.back()->setSpeed(vTaxi);
+            ac->setTaxiClearanceRequest(true);
+        } else {  // In case of a push forward departure...
+            ac->setTaxiClearanceRequest(false);
+            double lat2 = 0.0, lon2 = 0.0, az2 = 0.0;
+
+            //cerr << "Creating final push forward point for gate " << gateId << endl;
+            FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(gateId);
+            FGTaxiSegmentVectorIterator ts = tn->getBeginRoute();
+            FGTaxiSegmentVectorIterator te = tn->getEndRoute();
+            // if the starting node equals the ending node, then there aren't any routes for this parking.
+            // in cases like these we should flag the gate as being inoperative and return false
+            if (ts == te) {
+                SG_LOG(SG_GENERAL, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
+                parking->setAvailable(false);
+                return false;
+            }
+            tn = (*ts)->getEnd();
+            lastNodeVisited = tn->getIndex();
+            if (tn == NULL) {
+                SG_LOG(SG_GENERAL, SG_ALERT, "No valid taxinode found");
+                exit(1);
+            }
+            double distance = (*ts)->getLength();
+            //cerr << "Length of push forward route = " << distance << " and heading is " << heading << endl;
+            lat2 =  tn->getLatitude();
+            lon2 =  tn->getLongitude();
+
+            for (int i = 1; i < 10; i++) {
+                geo_direct_wgs_84 ( 0, lat, lon, heading,
+                                    ((i / 10.0) * distance), &lat2, &lon2, &az2 );
+                char buffer[16];
+                snprintf(buffer, 16, "pushback-%02d", i);
+                SGGeod coord = coord.fromDeg(lon2, lat2);
+                //cerr << i << endl;
+                FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiReduced);
+
+                wpt->setRouteIndex((*ts)->getIndex());
+                pushBackWaypoint(wpt);
+            }
+            // cerr << "Done " << endl;
+            waypoints.back()->setName(string("PushBackPoint"));
+            // cerr << "Done assinging new name" << endl;
+        }
     }
     return true;
 }
 /*******************************************************************
 * createPushBackFallBack
-* This is the backup function for airports that don't have a 
-* network yet. 
+* This is the backup function for airports that don't have a
+* network yet.
 ******************************************************************/
-void FGAIFlightPlan::createPushBackFallBack(FGAIAircraft *ac, bool firstFlight, FGAirport *dep, 
-                                   double latitude,
-                                   double longitude,
-                                   double radius,
-                                   const string& fltType,
-                                   const string& aircraftType,
-                                   const string& airline)
+void FGAIFlightPlan::createPushBackFallBack(FGAIAircraft *ac, bool firstFlight, FGAirport *dep,
+        double latitude,
+        double longitude,
+        double radius,
+        const string& fltType,
+        const string& aircraftType,
+        const string& airline)
 {
-  double heading;
-  double lat;
-  double lon;
-  double lat2 = 0.0;
-  double lon2 = 0.0;
-  double az2 = 0.0;
+    double heading;
+    double lat;
+    double lon;
+    double lat2 = 0.0;
+    double lon2 = 0.0;
+    double az2 = 0.0;
 
-  double vTaxi = ac->getPerformance()->vTaxi();
-  double vTaxiBackward = vTaxi * (-2.0/3.0);
-  double vTaxiReduced  = vTaxi * (2.0/3.0);
+    double vTaxi = ac->getPerformance()->vTaxi();
+    double vTaxiBackward = vTaxi * (-2.0/3.0);
+    double vTaxiReduced  = vTaxi * (2.0/3.0);
 
 
 
-  dep->getDynamics()->getParking(-1, &lat, &lon, &heading);
+    dep->getDynamics()->getParking(-1, &lat, &lon, &heading);
 
-  heading += 180.0;
-  if (heading > 360)
-       heading -= 360;
+    heading += 180.0;
+    if (heading > 360)
+        heading -= 360;
 
-  SGGeod coord = coord.fromDeg(lon, lat);
-  FGAIWaypoint *wpt = createOnGround(ac, string("park"), coord, dep->getElevation(), vTaxiBackward);
+    SGGeod coord = coord.fromDeg(lon, lat);
+    FGAIWaypoint *wpt = createOnGround(ac, string("park"), coord, dep->getElevation(), vTaxiBackward);
 
-  pushBackWaypoint(wpt); 
+    pushBackWaypoint(wpt);
 
-  geo_direct_wgs_84 ( 0, lat, lon, heading, 
-                     10, 
-                     &lat2, &lon2, &az2 );
-  coord = coord.fromDeg(lon2, lat2); 
-  wpt = createOnGround(ac, string("park2"), coord, dep->getElevation(), vTaxiBackward);
+    geo_direct_wgs_84 ( 0, lat, lon, heading,
+                        10,
+                        &lat2, &lon2, &az2 );
+    coord = coord.fromDeg(lon2, lat2);
+    wpt = createOnGround(ac, string("park2"), coord, dep->getElevation(), vTaxiBackward);
 
-  pushBackWaypoint(wpt); 
+    pushBackWaypoint(wpt);
 
-  geo_direct_wgs_84 ( 0, lat, lon, heading, 
-                     2.2*radius,           
-                     &lat2, &lon2, &az2 );
-  coord = coord.fromDeg(lon2, lat2); 
-  wpt = createOnGround(ac, string("taxiStart"), coord, dep->getElevation(), vTaxiReduced);
-  pushBackWaypoint(wpt);
+    geo_direct_wgs_84 ( 0, lat, lon, heading,
+                        2.2*radius,
+                        &lat2, &lon2, &az2 );
+    coord = coord.fromDeg(lon2, lat2);
+    wpt = createOnGround(ac, string("taxiStart"), coord, dep->getElevation(), vTaxiReduced);
+    pushBackWaypoint(wpt);
 
 }
index 293d2ff6a5682756478a7d0f472af9db1de39fdb..5a077968d1cad8f7bbc1d9ff456fd7b6e108e452 100644 (file)
@@ -102,6 +102,7 @@ bool FGAirportDynamics::getAvailableParking(double *lat, double *lon,
         //cerr << "Could not find parking spot at " << _ap->getId() << endl;
         *lat = _ap->getLatitude();
         *lon = _ap->getLongitude();
+        * gateId = -1;
         *heading = 0;
         found = true;
     } else {