Reinstate the backbone of the "I" part of the Interactive traffic system.
This commit is contained in:
parent
dbde1f2232
commit
8e2d0d2a76
4 changed files with 54 additions and 24 deletions
|
@ -211,7 +211,7 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
|
||||||
const string & acType,
|
const string & acType,
|
||||||
const string & airline)
|
const string & airline)
|
||||||
{
|
{
|
||||||
|
int route;
|
||||||
// If this function is called during initialization,
|
// If this function is called during initialization,
|
||||||
// make sure we obtain a valid gate ID first
|
// make sure we obtain a valid gate ID first
|
||||||
// and place the model at the location of the gate.
|
// and place the model at the location of the gate.
|
||||||
|
@ -298,24 +298,24 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
|
||||||
// but make sure we always keep two active waypoints
|
// but make sure we always keep two active waypoints
|
||||||
// to prevent a segmentation fault
|
// to prevent a segmentation fault
|
||||||
for (int i = 0; i < nrWaypointsToSkip - 3; i++) {
|
for (int i = 0; i < nrWaypointsToSkip - 3; i++) {
|
||||||
taxiRoute.next(&node);
|
taxiRoute.next(&node, &route);
|
||||||
}
|
}
|
||||||
|
|
||||||
gate.release(); // free up our gate as required
|
gate.release(); // free up our gate as required
|
||||||
} else {
|
} else {
|
||||||
if (taxiRoute.size() > 1) {
|
if (taxiRoute.size() > 1) {
|
||||||
taxiRoute.next(&node); // chop off the first waypoint, because that is already the last of the pushback route
|
taxiRoute.next(&node, &route); // chop off the first waypoint, because that is already the last of the pushback route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// push each node on the taxi route as a waypoint
|
// push each node on the taxi route as a waypoint
|
||||||
// int route;
|
|
||||||
//cerr << "Building taxi route" << endl;
|
//cerr << "Building taxi route" << endl;
|
||||||
|
|
||||||
// Note that the line wpt->setRouteIndex was commented out by revision [afcdbd] 2012-01-01,
|
// Note that the line wpt->setRouteIndex was commented out by revision [afcdbd] 2012-01-01,
|
||||||
// which breaks the rendering functions.
|
// which breaks the rendering functions.
|
||||||
// These can probably be generated on the fly however.
|
// These can probably be generated on the fly however.
|
||||||
while (taxiRoute.next(&node)) {
|
while (taxiRoute.next(&node, &route)) {
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
snprintf(buffer, 10, "%lld", (long long int) node);
|
snprintf(buffer, 10, "%lld", (long long int) node);
|
||||||
FGTaxiNode *tn =
|
FGTaxiNode *tn =
|
||||||
|
@ -323,8 +323,7 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
|
||||||
FGAIWaypoint *wpt =
|
FGAIWaypoint *wpt =
|
||||||
createOnGround(ac, buffer, tn->geod(), apt->getElevation(),
|
createOnGround(ac, buffer, tn->geod(), apt->getElevation(),
|
||||||
ac->getPerformance()->vTaxi());
|
ac->getPerformance()->vTaxi());
|
||||||
// TODO: find an alternative way to pass route information to the waypoint.
|
wpt->setRouteIndex(route);
|
||||||
//wpt->setRouteIndex(route);
|
|
||||||
//cerr << "Nodes left " << taxiRoute->nodesLeft() << " ";
|
//cerr << "Nodes left " << taxiRoute->nodesLeft() << " ";
|
||||||
if (taxiRoute.nodesLeft() == 1) {
|
if (taxiRoute.nodesLeft() == 1) {
|
||||||
// Note that we actually have hold points in the ground network, but this is just an initial test.
|
// Note that we actually have hold points in the ground network, but this is just an initial test.
|
||||||
|
@ -376,6 +375,7 @@ bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, FGAirport * apt,
|
||||||
const string & acType,
|
const string & acType,
|
||||||
const string & airline)
|
const string & airline)
|
||||||
{
|
{
|
||||||
|
int route;
|
||||||
gate = apt->getDynamics()->getAvailableParking(radius, fltType,
|
gate = apt->getDynamics()->getAvailableParking(radius, fltType,
|
||||||
acType, airline);
|
acType, airline);
|
||||||
|
|
||||||
|
@ -414,15 +414,15 @@ bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, FGAirport * apt,
|
||||||
// those are created by createParking()
|
// those are created by createParking()
|
||||||
// int route;
|
// int route;
|
||||||
for (int i = 0; i < size - 2; i++) {
|
for (int i = 0; i < size - 2; i++) {
|
||||||
taxiRoute.next(&node);
|
taxiRoute.next(&node, &route);
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
snprintf(buffer, 10, "%lld", (long long int) node);
|
snprintf(buffer, 10, "%lld", (long long int) node);
|
||||||
FGTaxiNode *tn = gn->findNode(node);
|
FGTaxiNode *tn = gn->findNode(node);
|
||||||
FGAIWaypoint *wpt =
|
FGAIWaypoint *wpt =
|
||||||
createOnGround(ac, buffer, tn->geod(), apt->getElevation(),
|
createOnGround(ac, buffer, tn->geod(), apt->getElevation(),
|
||||||
ac->getPerformance()->vTaxi());
|
ac->getPerformance()->vTaxi());
|
||||||
//TODO: find an alternative way to pass route information to the waypoint.
|
|
||||||
//wpt->setRouteIndex(route);
|
wpt->setRouteIndex(route);
|
||||||
pushBackWaypoint(wpt);
|
pushBackWaypoint(wpt);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -51,6 +51,7 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
|
||||||
double vTaxi = ac->getPerformance()->vTaxi();
|
double vTaxi = ac->getPerformance()->vTaxi();
|
||||||
double vTaxiBackward = vTaxi * (-2.0/3.0);
|
double vTaxiBackward = vTaxi * (-2.0/3.0);
|
||||||
double vTaxiReduced = 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
|
// Active runway can be conditionally set by ATC, so at the start of a new flight, this
|
||||||
// must be reset.
|
// must be reset.
|
||||||
activeRunway.clear();
|
activeRunway.clear();
|
||||||
|
@ -95,15 +96,17 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
|
||||||
}
|
}
|
||||||
|
|
||||||
route.first();
|
route.first();
|
||||||
PositionedID node, previous= 0;
|
PositionedID node;
|
||||||
|
int rte;
|
||||||
|
|
||||||
while (route.next(&node))
|
while (route.next(&node, &rte))
|
||||||
{
|
{
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
snprintf (buffer, 10, "%lld", (long long int) node);
|
snprintf (buffer, 10, "%lld", (long long int) node);
|
||||||
FGTaxiNode *tn = groundNet->findNode(node);
|
FGTaxiNode *tn = groundNet->findNode(node);
|
||||||
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), tn->geod(), dep->getElevation(), vTaxiBackward);
|
FGAIWaypoint *wpt = createOnGround(ac, string(buffer), tn->geod(), dep->getElevation(), vTaxiBackward);
|
||||||
|
|
||||||
|
/*
|
||||||
if (previous) {
|
if (previous) {
|
||||||
FGTaxiSegment* segment = groundNet->findSegment(previous, node);
|
FGTaxiSegment* segment = groundNet->findSegment(previous, node);
|
||||||
wpt->setRouteIndex(segment->getIndex());
|
wpt->setRouteIndex(segment->getIndex());
|
||||||
|
@ -111,10 +114,11 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
|
||||||
// not on the route yet, make up a unique segment ID
|
// not on the route yet, make up a unique segment ID
|
||||||
int x = (int) tn->guid();
|
int x = (int) tn->guid();
|
||||||
wpt->setRouteIndex(x);
|
wpt->setRouteIndex(x);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
wpt->setRouteIndex(rte);
|
||||||
pushBackWaypoint(wpt);
|
pushBackWaypoint(wpt);
|
||||||
previous = node;
|
//previous = node;
|
||||||
}
|
}
|
||||||
// some special considerations for the last point:
|
// some special considerations for the last point:
|
||||||
waypoints.back()->setName(string("PushBackPoint"));
|
waypoints.back()->setName(string("PushBackPoint"));
|
||||||
|
|
|
@ -145,13 +145,22 @@ void FGTaxiSegment::unblock(time_t now)
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* FGTaxiRoute
|
* FGTaxiRoute
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
bool FGTaxiRoute::next(PositionedID *nde)
|
bool FGTaxiRoute::next(PositionedID *nde, int *rte)
|
||||||
{
|
{
|
||||||
|
if (nodes.size() != (routes.size()) + 1) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "ALERT: Misconfigured TaxiRoute : " << nodes.size() << " " << routes.size());
|
||||||
|
throw sg_range_exception("Misconfigured taxi route");
|
||||||
|
}
|
||||||
if (currNode == nodes.end())
|
if (currNode == nodes.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*nde = *(currNode);
|
*nde = *(currNode);
|
||||||
|
if (currNode != nodes.begin()) {
|
||||||
|
*rte = *(currRoute);
|
||||||
|
currRoute++;
|
||||||
|
} else {
|
||||||
|
// Handle special case for the first node.
|
||||||
|
*rte = -1 * *(currRoute);
|
||||||
|
}
|
||||||
currNode++;
|
currNode++;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -255,7 +264,7 @@ void FGGroundNetwork::init(FGAirport* pr)
|
||||||
segment->setIndex(index++);
|
segment->setIndex(index++);
|
||||||
|
|
||||||
if (segment->oppositeDirection) {
|
if (segment->oppositeDirection) {
|
||||||
continue; // already establish
|
continue; // already established
|
||||||
}
|
}
|
||||||
|
|
||||||
FGTaxiSegment* opp = findSegment(segment->endNode, segment->startNode);
|
FGTaxiSegment* opp = findSegment(segment->endNode, segment->startNode);
|
||||||
|
@ -469,14 +478,21 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(PositionedID start, PositionedID
|
||||||
|
|
||||||
// assemble route from backtrace information
|
// assemble route from backtrace information
|
||||||
PositionedIDVec nodes;
|
PositionedIDVec nodes;
|
||||||
|
intVec routes;
|
||||||
FGTaxiNode *bt = lastNode;
|
FGTaxiNode *bt = lastNode;
|
||||||
|
|
||||||
while (searchData[bt].previousNode != 0) {
|
while (searchData[bt].previousNode != 0) {
|
||||||
nodes.push_back(bt->guid());
|
nodes.push_back(bt->guid());
|
||||||
|
FGTaxiSegment *segment = findSegment(searchData[bt].previousNode->guid(), bt->guid());
|
||||||
|
int idx = segment->getIndex();
|
||||||
|
routes.push_back(idx);
|
||||||
bt = searchData[bt].previousNode;
|
bt = searchData[bt].previousNode;
|
||||||
|
|
||||||
}
|
}
|
||||||
nodes.push_back(start);
|
nodes.push_back(start);
|
||||||
reverse(nodes.begin(), nodes.end());
|
reverse(nodes.begin(), nodes.end());
|
||||||
return FGTaxiRoute(nodes, searchData[lastNode].score, 0);
|
reverse(routes.begin(), routes.end());
|
||||||
|
return FGTaxiRoute(nodes, routes, searchData[lastNode].score, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ATC Related Functions */
|
/* ATC Related Functions */
|
||||||
|
|
|
@ -108,32 +108,41 @@ class FGTaxiRoute
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
PositionedIDVec nodes;
|
PositionedIDVec nodes;
|
||||||
|
intVec routes;
|
||||||
double distance;
|
double distance;
|
||||||
PositionedIDVec::iterator currNode;
|
PositionedIDVec::iterator currNode;
|
||||||
|
intVec::iterator currRoute;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGTaxiRoute() {
|
FGTaxiRoute() {
|
||||||
distance = 0;
|
distance = 0;
|
||||||
currNode = nodes.begin();
|
currNode = nodes.begin();
|
||||||
|
currRoute = routes.begin();
|
||||||
};
|
};
|
||||||
|
|
||||||
FGTaxiRoute(const PositionedIDVec& nds, double dist, int dpth) {
|
FGTaxiRoute(const PositionedIDVec& nds, intVec rts, double dist, int dpth) {
|
||||||
nodes = nds;
|
nodes = nds;
|
||||||
|
routes = rts;
|
||||||
distance = dist;
|
distance = dist;
|
||||||
currNode = nodes.begin();
|
currNode = nodes.begin();
|
||||||
|
currRoute = routes.begin();
|
||||||
};
|
};
|
||||||
|
|
||||||
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
|
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
|
||||||
nodes = other.nodes;
|
nodes = other.nodes;
|
||||||
|
routes = other.routes;
|
||||||
distance = other.distance;
|
distance = other.distance;
|
||||||
currNode = nodes.begin();
|
currNode = nodes.begin();
|
||||||
|
currRoute = routes.begin();
|
||||||
return *this;
|
return *this;
|
||||||
};
|
};
|
||||||
|
|
||||||
FGTaxiRoute(const FGTaxiRoute& copy) :
|
FGTaxiRoute(const FGTaxiRoute& copy) :
|
||||||
nodes(copy.nodes),
|
nodes(copy.nodes),
|
||||||
|
routes(copy.routes),
|
||||||
distance(copy.distance),
|
distance(copy.distance),
|
||||||
currNode(nodes.begin())
|
currNode(nodes.begin()),
|
||||||
|
currRoute(routes.begin())
|
||||||
{};
|
{};
|
||||||
|
|
||||||
bool operator< (const FGTaxiRoute &other) const {
|
bool operator< (const FGTaxiRoute &other) const {
|
||||||
|
@ -142,10 +151,11 @@ public:
|
||||||
bool empty () {
|
bool empty () {
|
||||||
return nodes.empty();
|
return nodes.empty();
|
||||||
};
|
};
|
||||||
bool next(PositionedID *nde);
|
bool next(PositionedID *nde, int *rte);
|
||||||
|
|
||||||
void first() {
|
void first() {
|
||||||
currNode = nodes.begin();
|
currNode = nodes.begin();
|
||||||
|
currRoute = routes.begin();
|
||||||
};
|
};
|
||||||
int size() {
|
int size() {
|
||||||
return nodes.size();
|
return nodes.size();
|
||||||
|
|
Loading…
Add table
Reference in a new issue