#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
+#include <Airports/simple.hxx>
#include <Airports/runways.hxx>
#include <Airports/dynamics.hxx>
#include "AIAircraft.hxx"
// Check lat/lon values during initialization;
-void FGAIFlightPlan::create(FGAIAircraft * ac, FGAirport * dep,
+bool FGAIFlightPlan::create(FGAIAircraft * ac, FGAirport * dep,
FGAirport * arr, int legNr, double alt,
double speed, double latitude,
double longitude, bool firstFlight,
const string & aircraftType,
const string & airline, double distance)
{
+ bool retVal = true;
int currWpt = wpt_iterator - waypoints.begin();
switch (legNr) {
case 1:
- createPushBack(ac, firstFlight, dep, latitude, longitude,
- radius, fltType, aircraftType, airline);
+ retVal = createPushBack(ac, firstFlight, dep, latitude, longitude,
+ radius, fltType, aircraftType, airline);
break;
case 2:
- createTakeoffTaxi(ac, firstFlight, dep, radius, fltType,
+ retVal = createTakeoffTaxi(ac, firstFlight, dep, radius, fltType,
aircraftType, airline);
break;
case 3:
- createTakeOff(ac, firstFlight, dep, speed, fltType);
+ retVal = createTakeOff(ac, firstFlight, dep, speed, fltType);
break;
case 4:
- createClimb(ac, firstFlight, dep, speed, alt, fltType);
+ retVal = createClimb(ac, firstFlight, dep, speed, alt, fltType);
break;
case 5:
- createCruise(ac, firstFlight, dep, arr, latitude, longitude, speed,
+ retVal = createCruise(ac, firstFlight, dep, arr, latitude, longitude, speed,
alt, fltType);
break;
case 6:
- createDescent(ac, arr, latitude, longitude, speed, alt, fltType,
+ retVal = createDescent(ac, arr, latitude, longitude, speed, alt, fltType,
distance);
break;
case 7:
- createLanding(ac, arr, fltType);
+ retVal = createLanding(ac, arr, fltType);
break;
case 8:
- createLandingTaxi(ac, arr, radius, fltType, aircraftType, airline);
+ retVal = createLandingTaxi(ac, arr, radius, fltType, aircraftType, airline);
break;
case 9:
- createParking(ac, arr, radius);
+ retVal = createParking(ac, arr, radius);
break;
default:
//exit(1);
}
wpt_iterator = waypoints.begin() + currWpt;
leg++;
+ return retVal;
}
FGAIFlightPlan::waypoint *
waypoints.push_back(wpt);
}
-void FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
+bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
FGAirport * apt,
double radius,
const string & fltType,
FGGroundNetwork *gn = apt->getDynamics()->getGroundNetwork();
if (!gn->exists()) {
createDefaultTakeoffTaxi(ac, apt, rwy);
- return;
+ return true;
}
intVec ids;
if (taxiRoute->empty()) {
createDefaultTakeoffTaxi(ac, apt, rwy);
- return;
+ return true;
}
taxiRoute->first();
wpt->routeIndex = route;
waypoints.push_back(wpt);
}
+ return true;
}
void FGAIFlightPlan::createDefaultLandingTaxi(FGAIAircraft * ac,
waypoints.push_back(wpt);
}
-void FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, FGAirport * apt,
+bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, FGAirport * apt,
double radius,
const string & fltType,
const string & acType,
// Find a route from runway end to parking/gate.
if (!gn->exists()) {
createDefaultLandingTaxi(ac, apt);
- return;
+ return true;
}
intVec ids;
if (taxiRoute->empty()) {
createDefaultLandingTaxi(ac, apt);
- return;
+ return true;
}
int node;
wpt->routeIndex = route;
waypoints.push_back(wpt);
}
+ return true;
}
/*******************************************************************
* more likely however.
*
******************************************************************/
-void FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, bool firstFlight,
+bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, bool firstFlight,
FGAirport * apt, double speed,
const string & fltType)
{
double vTaxi = ac->getPerformance()->vTaxi();
double vRotate = ac->getPerformance()->vRotate();
double vTakeoff = ac->getPerformance()->vTakeoff();
- double vClimb = ac->getPerformance()->vClimb();
+ //double vClimb = ac->getPerformance()->vClimb();
double accelMetric = (accel * SG_NM_TO_METER) / 3600;
double vTaxiMetric = (vTaxi * SG_NM_TO_METER) / 3600;
double vRotateMetric = (vRotate * SG_NM_TO_METER) / 3600;
double vTakeoffMetric = (vTakeoff * SG_NM_TO_METER) / 3600;
- double vClimbMetric = (vClimb * SG_NM_TO_METER) / 3600;
+ //double vClimbMetric = (vClimb * SG_NM_TO_METER) / 3600;
// Acceleration = dV / dT
// Acceleration X dT = dV
// dT = dT / Acceleration
wpt = cloneWithPos(ac, wpt, "5000 ft", pt);
wpt->altitude = airportElev + 5000;
waypoints.push_back(wpt);
+ return true;
}
/*******************************************************************
* CreateClimb
* initialize the Aircraft at the parking location
******************************************************************/
-void FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight,
+bool FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight,
FGAirport * apt, double speed, double alt,
const string & fltType)
{
wpt->altitude = 18000;
waypoints.push_back(wpt);
}
+ return true;
}
* Generate a flight path from the last waypoint of the cruise to
* the permission to land point
******************************************************************/
-void FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
+bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
double latitude, double longitude,
double speed, double alt,
const string & fltType,
// Create a slow descent path that ends 250 lateral to the runway.
double initialTurnRadius = getTurnRadius(vDescent, true);
- double finalTurnRadius = getTurnRadius(vApproach, true);
+ //double finalTurnRadius = getTurnRadius(vApproach, true);
// get length of the downwind leg for the intended runway
double distanceOut = apt->getDynamics()->getApproachController()->getRunway(rwy->name())->getApproachDistance(); //12 * SG_NM_TO_METER;
if (reposition) {
double tempDistance;
- double minDistance = HUGE_VAL;
+ //double minDistance = HUGE_VAL;
string wptName;
tempDistance = SGGeodesy::distanceM(current, initialTarget);
time_t eta =
//cerr << "Repositioning to waypoint " << (*waypoints.begin())->name << endl;
ac->resetPositionFromFlightPlan();
}
-
-
+ return true;
}
/*******************************************************************
hardcoded at 5000 meters from the threshold) to the threshold, at
a standard glide slope angle of 3 degrees.
******************************************************************/
-void FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
+bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
const string & fltType)
{
double vTouchdown = ac->getPerformance()->vTouchdown();
- double vTaxi = ac->getPerformance()->vTaxi();
+ //double vTaxi = ac->getPerformance()->vTaxi();
//string rwyClass = getRunwayClassFromTrafficType(fltType);
//double heading = ac->getTrafficRef()->getCourse();
wpt->crossat = apt->getElevation();
waypoints.push_back(wpt);
*/
+ return true;
}
/*******************************************************************
* CreateParking
* initialize the Aircraft at the parking location
******************************************************************/
-void FGAIFlightPlan::createParking(FGAIAircraft * ac, FGAirport * apt,
+bool FGAIFlightPlan::createParking(FGAIAircraft * ac, FGAirport * apt,
double radius)
{
waypoint *wpt;
createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), aptElev,
vTaxiReduced);
waypoints.push_back(wpt);
+ return true;
}
/**