Simple FlightPlan generation and execution for the user aircraft: This will allow ATC guided taxiing to the runway.
This commit is contained in:
parent
81c0e0b3df
commit
6ee1d7411b
7 changed files with 104 additions and 19 deletions
|
@ -997,8 +997,8 @@ void FGAIAircraft::updateHeading() {
|
|||
}
|
||||
}
|
||||
if (trafficRef)
|
||||
cerr << trafficRef->getCallSign() << " Heading "
|
||||
<< hdg << ". Target " << tgt_heading << ". Diff " << fabs(sum - tgt_heading) << ". Speed " << speed << "Heading change rate : " << headingChangeRate << " bacnk sence " << bank_sense << endl;
|
||||
//cerr << trafficRef->getCallSign() << " Heading "
|
||||
// << hdg << ". Target " << tgt_heading << ". Diff " << fabs(sum - tgt_heading) << ". Speed " << speed << "Heading change rate : " << headingChangeRate << " bacnk sence " << bank_sense << endl;
|
||||
hdg += headingChangeRate * dt * sqrt(fabs(speed) / 15);
|
||||
headingError = headingDiff;
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// FGAIAircraft - AIBase derived class creates an AI aircraft
|
||||
//
|
||||
// Written by David Culp, started October 2003.
|
||||
|
@ -97,6 +96,8 @@ public:
|
|||
std::string atGate();
|
||||
|
||||
void checkTcas();
|
||||
|
||||
FGATCController * getATCController() { return controller; };
|
||||
|
||||
protected:
|
||||
void Run(double dt);
|
||||
|
|
|
@ -165,7 +165,66 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
|
|||
// cerr << "Waypoint Name: " << (*i)->name << endl;
|
||||
//}
|
||||
} else {
|
||||
/*
|
||||
string rwyClass = getRunwayClassFromTrafficType(fltType);
|
||||
|
||||
// Only set this if it hasn't been set by ATC already.
|
||||
if (activeRunway.empty()) {
|
||||
//cerr << "Getting runway for " << ac->getTrafficRef()->getCallSign() << " at " << apt->getId() << endl;
|
||||
double depHeading = ac->getTrafficRef()->getCourse();
|
||||
dep->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
|
||||
depHeading);
|
||||
}
|
||||
rwy = dep->getRunwayByIdent(activeRunway);
|
||||
SGGeod runwayTakeoff = rwy->pointOnCenterline(5.0);
|
||||
|
||||
FGGroundNetwork *gn = dep->getDynamics()->getGroundNetwork();
|
||||
if (!gn->exists()) {
|
||||
createDefaultTakeoffTaxi(ac, dep, rwy);
|
||||
return true;
|
||||
}
|
||||
int runwayId = gn->findNearestNode(runwayTakeoff);
|
||||
int node = 0;
|
||||
// Find out which node to start from
|
||||
FGParking *park = dep->getDynamics()->getParking(gateId);
|
||||
if (park) {
|
||||
node = park->getPushBackPoint();
|
||||
}
|
||||
|
||||
if (node == -1) {
|
||||
node = gateId;
|
||||
}
|
||||
// HAndle case where parking doens't have a node
|
||||
if ((node == 0) && park) {
|
||||
if (firstFlight) {
|
||||
node = gateId;
|
||||
} else {
|
||||
node = gateId;
|
||||
}
|
||||
}
|
||||
//delete taxiRoute;
|
||||
//taxiRoute = new FGTaxiRoute;
|
||||
FGTaxiRoute tr = gn->findShortestRoute(node, runwayId);
|
||||
int route;
|
||||
FGTaxiNode *tn;
|
||||
waypoint *wpt;
|
||||
int nr = 0;
|
||||
cerr << "Creating taxiroute from gate: " << gateId << " at " << dep->getId() << endl;
|
||||
while (tr.next(&node, &route) && (nr++ < 3)) {
|
||||
char buffer[10];
|
||||
snprintf(buffer, 10, "%d", node);
|
||||
tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
|
||||
wpt = createOnGround(ac, buffer, tn->getGeod(), dep->getElevation(),
|
||||
vTaxiReduced);
|
||||
wpt->routeIndex = route;
|
||||
waypoints.push_back(wpt);
|
||||
}
|
||||
wpt->name = "PushBackPoint";
|
||||
lastNodeVisited = tn->getIndex();
|
||||
//FGTaxiNode *firstNode = findNode(gateId);
|
||||
//FGTaxiNode *lastNode = findNode(runwayId);
|
||||
//cerr << "Creating direct forward departure route fragment" << endl;
|
||||
*/
|
||||
double lat2 = 0.0, lon2 = 0.0, az2 = 0.0;
|
||||
waypoint *wpt;
|
||||
geo_direct_wgs_84 ( 0, lat, lon, heading,
|
||||
|
@ -227,8 +286,6 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
|
|||
wpt->on_ground = true;
|
||||
wpt->routeIndex = (*ts)->getIndex();
|
||||
waypoints.push_back(wpt);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -170,13 +170,40 @@ void FGATCManager::addController(FGATCController *controller) {
|
|||
|
||||
void FGATCManager::update ( double time ) {
|
||||
//cerr << "ATC update code is running at time: " << time << endl;
|
||||
// Test code: let my virtual co-pilot handle ATC:
|
||||
|
||||
|
||||
|
||||
FGAIFlightPlan *fp = ai_ac.GetFlightPlan();
|
||||
|
||||
/* test code : find out how the routing develops */
|
||||
int size = fp->getNrOfWayPoints();
|
||||
//cerr << "Setting pos" << pos << " ";
|
||||
cerr << "setting intentions " ;
|
||||
for (int i = 0; i < size; i++) {
|
||||
int val = fp->getRouteIndex(i);
|
||||
cerr << val << " ";
|
||||
//if ((val) && (val != pos)) {
|
||||
//intentions.push_back(val);
|
||||
//cerr << "[done ] " << endl;
|
||||
//}
|
||||
}
|
||||
cerr << "[done ] " << endl;
|
||||
double longitude = fgGetDouble("/position/longitude-deg");
|
||||
double latitude = fgGetDouble("/position/latitude-deg");
|
||||
double heading = fgGetDouble("/orientation/heading-deg");
|
||||
double speed = fgGetDouble("/velocities/groundspeed-kt");
|
||||
double altitude = fgGetDouble("/position/altitude-ft");
|
||||
ai_ac.setLatitude(latitude);
|
||||
ai_ac.setLongitude(longitude);
|
||||
ai_ac.setAltitude(altitude);
|
||||
ai_ac.setHeading(heading);
|
||||
ai_ac.setSpeed(speed);
|
||||
ai_ac.update(time);
|
||||
controller = ai_ac.getATCController();
|
||||
currentATCDialog->update(time);
|
||||
if (controller) {
|
||||
double longitude = fgGetDouble("/position/longitude-deg");
|
||||
double latitude = fgGetDouble("/position/latitude-deg");
|
||||
double heading = fgGetDouble("/orientation/heading-deg");
|
||||
double speed = fgGetDouble("/velocities/groundspeed-kt");
|
||||
double altitude = fgGetDouble("/position/altitude-ft");
|
||||
|
||||
|
||||
//cerr << "Running FGATCManager::update()" << endl;
|
||||
controller->updateAircraftInformation(ai_ac.getID(),
|
||||
|
@ -188,13 +215,9 @@ void FGATCManager::update ( double time ) {
|
|||
//string airport = fgGetString("/sim/presets/airport-id");
|
||||
//FGAirport *apt = FGAirport::findByIdent(airport);
|
||||
// AT this stage we should update the flightplan, so that waypoint incrementing is conducted as well as leg loading.
|
||||
ai_ac.setLatitude(latitude);
|
||||
ai_ac.setLongitude(longitude);
|
||||
ai_ac.setAltitude(altitude);
|
||||
ai_ac.setHeading(heading);
|
||||
ai_ac.setSpeed(speed);
|
||||
ai_ac.update(time);
|
||||
controller->render();
|
||||
|
||||
controller->render();
|
||||
|
||||
//cerr << "Adding groundnetWork to the scenegraph::update" << endl;
|
||||
}
|
||||
//globals->get_scenery()->get_scene_graph()->addChild(node);
|
||||
|
|
|
@ -1033,6 +1033,7 @@ void FGStartupController::signOff(int id)
|
|||
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||
"AI error: Aircraft without traffic record is signing off from tower");
|
||||
} else {
|
||||
cerr << i->getAircraft()->getCallSign() << " signing off from startupcontroller" << endl;
|
||||
i = activeTraffic.erase(i);
|
||||
}
|
||||
}
|
||||
|
@ -1182,6 +1183,7 @@ void FGStartupController::render()
|
|||
for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
|
||||
// Handle start point
|
||||
int pos = i->getCurrentPosition();
|
||||
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "pos = " << pos << endl;
|
||||
if (pos > 0) {
|
||||
FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(pos);
|
||||
SGGeod start(SGGeod::fromDeg((i->getLongitude()), (i->getLatitude())));
|
||||
|
@ -1232,6 +1234,7 @@ void FGStartupController::render()
|
|||
osg::Matrix obj_pos;
|
||||
int k = (*j);
|
||||
if (k > 0) {
|
||||
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "intention = " << k << endl;
|
||||
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
||||
obj_trans->setDataVariance(osg::Object::STATIC);
|
||||
FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(k);
|
||||
|
@ -1261,7 +1264,7 @@ void FGStartupController::render()
|
|||
cerr << "BIG FAT WARNING: k is here : " << pos << endl;
|
||||
}
|
||||
}
|
||||
dx += 0.1;
|
||||
//dx += 0.1;
|
||||
}
|
||||
globals->get_scenery()->get_scene_graph()->addChild(group);
|
||||
}
|
||||
|
|
|
@ -1202,7 +1202,7 @@ void FGGroundNetwork::render()
|
|||
group->addChild( obj_trans );
|
||||
}
|
||||
}
|
||||
dx += 0.1;
|
||||
//dx += 0.1;
|
||||
}
|
||||
globals->get_scenery()->get_scene_graph()->addChild(group);
|
||||
}
|
|
@ -181,6 +181,7 @@ public:
|
|||
routes = rts;
|
||||
distance = dist;
|
||||
currNode = nodes.begin();
|
||||
currRoute = routes.begin();
|
||||
// depth = dpth;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue