1
0
Fork 0

Changes to the AIModel code, to prepare for the new traffic manager code:

- Leg loading can fail when no additional flights are available
- Better support for waypoint interception during pushback (speed ~ 0)
This commit is contained in:
durk 2008-11-16 13:41:24 +00:00
parent 845196800b
commit 931c661b40
6 changed files with 36 additions and 8 deletions

View file

@ -268,7 +268,10 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) {
//TODO let the fp handle this (loading of next leg)
fp->IncrementWaypoint((bool) trafficRef);
if (!(fp->getNextWaypoint()) && trafficRef)
loadNextLeg();
if (!loadNextLeg()) {
setDie(true);
return;
}
prev = fp->getPreviousWaypoint();
curr = fp->getCurrentWaypoint();
@ -323,11 +326,13 @@ bool FGAIAircraft::_getGearDown() const {
}
void FGAIAircraft::loadNextLeg() {
bool FGAIAircraft::loadNextLeg() {
int leg;
if ((leg = fp->getLeg()) == 10) {
trafficRef->next();
if (!trafficRef->next()) {
return false;
}
setCallSign(trafficRef->getCallSign());
//props->setStringValue("callsign", callsign.c_str());
leg = 1;
@ -354,7 +359,9 @@ void FGAIAircraft::loadNextLeg() {
trafficRef->getFlightType(),
acType,
company);
//cerr << "created leg " << leg << " for " << trafficRef->getCallSign() << endl;
}
return true;
}
@ -535,7 +542,10 @@ void FGAIAircraft::handleFirstWaypoint() {
//TODO fp should handle this
fp->IncrementWaypoint(eraseWaypoints);
if (!(fp->getNextWaypoint()) && trafficRef)
loadNextLeg();
if (!loadNextLeg()) {
setDie(true);
return;
}
prev = fp->getPreviousWaypoint(); //first waypoint
curr = fp->getCurrentWaypoint(); //second waypoint
@ -616,7 +626,11 @@ bool FGAIAircraft::leadPointReached(FGAIFlightPlan::waypoint* curr) {
//prev_dist_to_go = dist_to_go;
//if (dist_to_go < lead_dist)
// cerr << trafficRef->getCallSign() << " Distance : " << dist_to_go << ": Lead distance " << lead_dist << " " << curr->name << endl;
// cerr << trafficRef->getCallSign() << " Distance : "
// << dist_to_go << ": Lead distance "
// << lead_dist << " " << curr->name
// << " Ground target speed " << groundTargetSpeed << endl;
return dist_to_go < lead_dist;
}
@ -631,7 +645,7 @@ bool FGAIAircraft::aiTrafficVisible() {
user.CourseAndDistance(current, &course, &distance);
return ((distance * SG_METER_TO_NM) <= TRAFFICTOAIDIST);
return ((distance * SG_METER_TO_NM) <= TRAFFICTOAIDISTTODIE);
}
@ -654,6 +668,7 @@ bool FGAIAircraft::handleAirportEndPoints(FGAIFlightPlan::waypoint* prev, time_t
// This waypoint marks the fact that the aircraft has passed the initial taxi
// departure waypoint, so it can release the parking.
//cerr << trafficRef->getCallSign() << " has passed waypoint " << prev->name << " at speed " << speed << endl;
if (prev->name == "PushBackPoint") {
dep->getDynamics()->releaseParking(fp->getGate());
time_t holdUntil = now + 120;

View file

@ -64,7 +64,7 @@ public:
void getGroundElev(double dt); //TODO these 3 really need to be public?
void doGroundAltitude();
void loadNextLeg ();
bool loadNextLeg ();
void setAcType(const string& ac) { acType = ac; };
void setCompany(const string& comp) { company = comp;};

View file

@ -381,6 +381,10 @@ void FGAIFlightPlan::setLeadDistance(double speed, double bearing,
// At a turn rate of 30 degrees per second, it takes 12 seconds to do a full 360 degree turn
// So, to get an estimate of the turn radius, calculate the cicumference of the circle
// we travel on. Get the turn radius by dividing by PI (*2).
if (speed < 0.5) {
lead_distance = 0.5;
return;
}
if (speed < 25) {
turn_radius = ((360/30)*15) / (2*M_PI);
} else

View file

@ -577,7 +577,7 @@ void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double spee
wpt->latitude = lat2;
wpt->longitude = lon2;
wpt->altitude = apt->getElevation()+5000;
wpt->speed = speed;
wpt->speed = speed;
wpt->crossat = -10000;
wpt->gear_down = true;
wpt->flaps_down= true;
@ -585,6 +585,11 @@ void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double spee
wpt->on_ground = false;
wpt->routeIndex = 0;
waypoints.push_back(wpt);
//cerr << "Created takeoff plan : " << endl;
//for (wpt_vector_iterator i = waypoints.begin(); i != waypoints.end(); i++) {
// cerr << "Waypoint Name: " << (*i)->name << ". Speed = " << (*i)->speed << endl;
//}
// geo_direct_wgs_84 ( 0, rwy->latitude(), rwy->longitude(), heading,
// 100000,

View file

@ -141,6 +141,9 @@ void FGAIFlightPlan::createPushBack(bool firstFlight, FGAirport *dep,
// some special considerations for the last point:
wpt->name = string("PushBackPoint");
wpt->speed = 15;
//for (wpt_vector_iterator i = waypoints.begin(); i != waypoints.end(); i++) {
// cerr << "Waypoint Name: " << (*i)->name << endl;
//}
} else {
//cerr << "Creating direct forward departure route fragment" << endl;
double lat2, lon2, az2;

View file

@ -20,6 +20,7 @@
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/structure/exception.hxx>
#include <Main/globals.hxx>