}
}
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 {
-
// FGAIAircraft - AIBase derived class creates an AI aircraft
//
// Written by David Culp, started October 2003.
std::string atGate();
void checkTcas();
+
+ FGATCController * getATCController() { return controller; };
protected:
void Run(double dt);
// 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,
wpt->on_ground = true;
wpt->routeIndex = (*ts)->getIndex();
waypoints.push_back(wpt);
-
-
}
}
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(),
//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);
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);
}
}
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())));
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);
cerr << "BIG FAT WARNING: k is here : " << pos << endl;
}
}
- dx += 0.1;
+ //dx += 0.1;
}
globals->get_scenery()->get_scene_graph()->addChild(group);
}
group->addChild( obj_trans );
}
}
- dx += 0.1;
+ //dx += 0.1;
}
globals->get_scenery()->get_scene_graph()->addChild(group);
}
\ No newline at end of file
routes = rts;
distance = dist;
currNode = nodes.begin();
+ currRoute = routes.begin();
// depth = dpth;
};