1
0
Fork 0

All start from parking position with no ground net

Fix for https://sourceforge.net/p/flightgear/codetickets/2125/

Previously, selecting a non-pushback parking position from the l
auncher that did not have a ground network resulted in the
aircraft being placed in the center of the airport.

This resolves the problem by creating a default segment simply
moving forward 2m.
This commit is contained in:
Stuart Buchanan 2019-05-04 17:43:33 +01:00
parent df352346ad
commit 1d1096d6f7

View file

@ -52,7 +52,7 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
double vTaxi = ac->getPerformance()->vTaxi();
double vTaxiBackward = vTaxi * (-2.0/3.0);
double vTaxiReduced = vTaxi * (2.0/3.0);
// Active runway can be conditionally set by ATC, so at the start of a new flight, this
// must be reset.
activeRunway.clear();
@ -63,7 +63,7 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
radius, fltType, aircraftType, airline);
return true;
}
// establish the parking position / gate if required
if (firstFlight) {
// if the airprot has no parking positions defined, don't log
@ -83,35 +83,35 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
return false;
}
}
if (!gate.isValid()) {
createPushBackFallBack(ac, firstFlight, dep,
radius, fltType, aircraftType, airline);
return true;
}
FGGroundNetwork* groundNet = dep->groundNetwork();
FGParking *parking = gate.parking();
if (parking && parking->getPushBackPoint() != nullptr) {
FGTaxiRoute route = groundNet->findShortestRoute(parking, parking->getPushBackPoint(), false);
int size = route.size();
if (size < 2) {
SG_LOG(SG_AI, SG_DEV_WARN, "Push back route from gate " << parking->ident() << " has only " << size << " nodes.");
SG_LOG(SG_AI, SG_DEV_WARN, "Using " << parking->getPushBackPoint());
}
route.first();
FGTaxiNodeRef node;
int rte;
while (route.next(node, &rte))
{
char buffer[10];
snprintf (buffer, 10, "%d", node->getIndex());
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), node->geod(), dep->getElevation(), vTaxiBackward);
/*
if (previous) {
FGTaxiSegment* segment = groundNet->findSegment(previous, node);
@ -121,8 +121,8 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
int x = (int) tn->guid();
wpt->setRouteIndex(x);
}*/
wpt->setRouteIndex(rte);
wpt->setRouteIndex(rte);
pushBackWaypoint(wpt);
//previous = node;
}
@ -134,34 +134,42 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
ac->setTaxiClearanceRequest(false);
double az2 = 0.0;
FGTaxiSegment* pushForwardSegment = dep->groundNetwork()->findSegment(parking, 0);
// there aren't any routes for this parking.
if (!pushForwardSegment) {
SG_LOG(SG_AI, SG_DEV_WARN, "Gate " << parking->ident() << "/" << parking->getName()
FGTaxiSegment* pushForwardSegment = dep->groundNetwork()->findSegment(parking, 0);
if (!pushForwardSegment) {
// there aren't any routes for this parking, so create a simple segment straight ahead for 2 meters based on the parking heading
SG_LOG(SG_AI, SG_DEV_WARN, "Gate " << parking->ident() << "/" << parking->getName()
<< " at " << dep->getId()
<< " doesn't seem to have routes associated with it.");
return false;
}
lastNodeVisited = pushForwardSegment->getEnd();
double distance = pushForwardSegment->getLength();
FGAIWaypoint *wpt = createOnGround(ac, string("park"), dep->geod(), dep->getElevation(), vTaxiReduced);
pushBackWaypoint(wpt);
double parkingHeading = parking->getHeading();
for (int i = 1; i < 10; i++) {
SGGeod pushForwardPt;
SGGeodesy::direct(parking->geod(), parkingHeading,
((i / 10.0) * distance), pushForwardPt, az2);
char buffer[16];
snprintf(buffer, 16, "pushback-%02d", i);
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), pushForwardPt, dep->getElevation(), vTaxiReduced);
SGGeod coord;
SGGeodesy::direct(dep->geod(), parking->getHeading(), 2.0, coord, az2);
wpt = createOnGround(ac, string("taxiStart"), coord, dep->getElevation(), vTaxiReduced);
pushBackWaypoint(wpt);
return true;
}
wpt->setRouteIndex(pushForwardSegment->getIndex());
pushBackWaypoint(wpt);
}
lastNodeVisited = pushForwardSegment->getEnd();
double distance = pushForwardSegment->getLength();
waypoints.back()->setName(string("PushBackPoint"));
// cerr << "Done assinging new name" << endl;
double parkingHeading = parking->getHeading();
for (int i = 1; i < 10; i++) {
SGGeod pushForwardPt;
SGGeodesy::direct(parking->geod(), parkingHeading,
((i / 10.0) * distance), pushForwardPt, az2);
char buffer[16];
snprintf(buffer, 16, "pushback-%02d", i);
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), pushForwardPt, dep->getElevation(), vTaxiReduced);
wpt->setRouteIndex(pushForwardSegment->getIndex());
pushBackWaypoint(wpt);
}
waypoints.back()->setName(string("PushBackPoint"));
// cerr << "Done assinging new name" << endl;
}
return true;
@ -193,7 +201,7 @@ void FGAIFlightPlan::createPushBackFallBack(FGAIAircraft *ac, bool firstFlight,
wpt = createOnGround(ac, string("park2"), coord, dep->getElevation(), vTaxiBackward);
pushBackWaypoint(wpt);
SGGeodesy::direct(dep->geod(), heading, 2.2 * radius, coord, az2);
wpt = createOnGround(ac, string("taxiStart"), coord, dep->getElevation(), vTaxiReduced);
pushBackWaypoint(wpt);