2005-02-10 09:01:51 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* AIFlightPlanCreate.cxx
|
|
|
|
* Written by Durk Talsma, started May, 2004.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-02-10 09:01:51 +00:00
|
|
|
*
|
|
|
|
**************************************************************************/
|
2008-12-27 16:09:01 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-02-18 10:16:30 +00:00
|
|
|
#include "AIFlightPlan.hxx"
|
2005-02-10 09:01:51 +00:00
|
|
|
#include <simgear/math/sg_geodesy.hxx>
|
2009-03-01 09:58:12 +00:00
|
|
|
#include <simgear/props/props.hxx>
|
|
|
|
#include <simgear/props/props_io.hxx>
|
|
|
|
|
2005-02-10 09:01:51 +00:00
|
|
|
#include <Airports/runways.hxx>
|
2008-08-14 18:13:39 +00:00
|
|
|
#include <Airports/dynamics.hxx>
|
2009-01-31 08:20:47 +00:00
|
|
|
#include "AIAircraft.hxx"
|
|
|
|
#include "performancedata.hxx"
|
2005-02-10 09:01:51 +00:00
|
|
|
|
|
|
|
#include <Environment/environment_mgr.hxx>
|
|
|
|
#include <Environment/environment.hxx>
|
|
|
|
|
|
|
|
|
|
|
|
/* FGAIFlightPlan::create()
|
|
|
|
* dynamically create a flight plan for AI traffic, based on data provided by the
|
|
|
|
* Traffic Manager, when reading a filed flightplan failes. (DT, 2004/07/10)
|
|
|
|
*
|
2006-03-19 07:41:48 +00:00
|
|
|
* This is the top-level function, and the only one that is publicly available.
|
2005-02-10 09:01:51 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// Check lat/lon values during initialization;
|
2009-01-30 18:48:44 +00:00
|
|
|
void FGAIFlightPlan::create(FGAIAircraft *ac, FGAirport *dep, FGAirport *arr, int legNr,
|
2006-03-19 07:41:48 +00:00
|
|
|
double alt, double speed, double latitude,
|
|
|
|
double longitude, bool firstFlight,double radius,
|
|
|
|
const string& fltType, const string& aircraftType,
|
|
|
|
const string& airline)
|
2005-02-10 09:01:51 +00:00
|
|
|
{
|
|
|
|
int currWpt = wpt_iterator - waypoints.begin();
|
|
|
|
switch(legNr)
|
|
|
|
{
|
2006-08-26 07:22:20 +00:00
|
|
|
case 1:
|
2009-02-15 15:29:56 +00:00
|
|
|
createPushBack(ac, firstFlight,dep, latitude, longitude,
|
2006-03-19 07:41:48 +00:00
|
|
|
radius, fltType, aircraftType, airline);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2009-02-15 15:29:56 +00:00
|
|
|
createTakeoffTaxi(ac, firstFlight, dep, radius, fltType, aircraftType, airline);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2009-01-30 18:48:44 +00:00
|
|
|
createTakeOff(ac, firstFlight, dep, speed, fltType);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2009-02-15 15:29:56 +00:00
|
|
|
createClimb(ac, firstFlight, dep, speed, alt, fltType);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2009-02-15 15:29:56 +00:00
|
|
|
createCruise(ac, firstFlight, dep,arr, latitude, longitude, speed, alt, fltType);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2009-02-15 15:29:56 +00:00
|
|
|
createDecent(ac, arr, fltType);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2009-02-15 15:29:56 +00:00
|
|
|
createLanding(ac, arr);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
|
|
|
case 8:
|
2009-02-15 15:29:56 +00:00
|
|
|
createLandingTaxi(ac, arr, radius, fltType, aircraftType, airline);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
2006-03-19 07:41:48 +00:00
|
|
|
case 9:
|
2009-02-15 15:29:56 +00:00
|
|
|
createParking(ac, arr, radius);
|
2005-02-10 09:01:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//exit(1);
|
2006-03-19 07:41:48 +00:00
|
|
|
SG_LOG(SG_INPUT, SG_ALERT, "AIFlightPlan::create() attempting to create unknown leg"
|
|
|
|
" this is probably an internal program error");
|
2005-02-10 09:01:51 +00:00
|
|
|
}
|
|
|
|
wpt_iterator = waypoints.begin()+currWpt;
|
|
|
|
leg++;
|
|
|
|
}
|
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
FGAIFlightPlan::waypoint*
|
2009-02-15 15:29:56 +00:00
|
|
|
FGAIFlightPlan::createOnGround(FGAIAircraft *ac, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed)
|
2008-12-30 07:41:15 +00:00
|
|
|
{
|
|
|
|
waypoint* wpt = new waypoint;
|
|
|
|
wpt->name = aName;
|
|
|
|
wpt->longitude = aPos.getLongitudeDeg();
|
|
|
|
wpt->latitude = aPos.getLatitudeDeg();
|
|
|
|
wpt->altitude = aElev;
|
|
|
|
wpt->speed = aSpeed;
|
|
|
|
wpt->crossat = -10000;
|
|
|
|
wpt->gear_down = true;
|
|
|
|
wpt->flaps_down= true;
|
|
|
|
wpt->finished = false;
|
|
|
|
wpt->on_ground = true;
|
|
|
|
wpt->routeIndex= 0;
|
|
|
|
return wpt;
|
|
|
|
}
|
2006-08-26 07:22:20 +00:00
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
FGAIFlightPlan::waypoint*
|
2009-02-15 15:29:56 +00:00
|
|
|
FGAIFlightPlan::createInAir(FGAIAircraft *ac, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed)
|
2008-12-30 07:41:15 +00:00
|
|
|
{
|
|
|
|
waypoint* wpt = new waypoint;
|
|
|
|
wpt->name = aName;
|
|
|
|
wpt->longitude = aPos.getLongitudeDeg();
|
|
|
|
wpt->latitude = aPos.getLatitudeDeg();
|
|
|
|
wpt->altitude = aElev;
|
|
|
|
wpt->speed = aSpeed;
|
|
|
|
wpt->crossat = -10000;
|
|
|
|
wpt->gear_down = false;
|
|
|
|
wpt->flaps_down= false;
|
|
|
|
wpt->finished = false;
|
|
|
|
wpt->on_ground = false;
|
|
|
|
wpt->routeIndex= 0;
|
|
|
|
return wpt;
|
|
|
|
}
|
- Ground network XML parsing code reads the new attributes "holdPointType"
and "isOnRunway".
- Added initial support for AI controlled pushback operations, making use of the
current editing capabilities of TaxiDraw CVS / New_GUI_CODE. The current
implementation is slightly more computationally intensive than strictly
required, due to the currently inability of taxidraw to link one specific
pushBack point to to a particular startup location. FlightGear now determines
this dynamically, and once we have that functionality in TaxiDraw, the
initialization part of createPushBack() can be further simplified.
- Smoother transition from pushback to taxi. No more skipping of waypoints, and
aircraft wait for two minutes at pushback point.
- The classes FGTaxiNode, FGTaxiSegment, and FGParking, now have copy
constructors, and assignment operators.
- Removed declaration of undefined constructor FGTaxiNode(double, double, int)
- Array boundry checks and cleanup.
- Modified Dijkstra path search algoritm to solve partial problems. Currently
limited to include pushback points and routes only, but can probably be
extended to a more general approach.
- Added initial support for giving certain routes in the network a penalty, in
order to discourage the use of certain routes over others.
2007-08-08 06:09:58 +00:00
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
FGAIFlightPlan::waypoint*
|
2009-02-15 15:29:56 +00:00
|
|
|
FGAIFlightPlan::cloneWithPos(FGAIAircraft *ac, waypoint* aWpt, const std::string& aName, const SGGeod& aPos)
|
2008-12-30 07:41:15 +00:00
|
|
|
{
|
|
|
|
waypoint* wpt = new waypoint;
|
|
|
|
wpt->name = aName;
|
|
|
|
wpt->longitude = aPos.getLongitudeDeg();
|
|
|
|
wpt->latitude = aPos.getLatitudeDeg();
|
|
|
|
|
|
|
|
wpt->altitude = aWpt->altitude;
|
|
|
|
wpt->speed = aWpt->speed;
|
|
|
|
wpt->crossat = aWpt->crossat;
|
|
|
|
wpt->gear_down = aWpt->gear_down;
|
|
|
|
wpt->flaps_down= aWpt->flaps_down;
|
|
|
|
wpt->finished = aWpt->finished;
|
|
|
|
wpt->on_ground = aWpt->on_ground;
|
|
|
|
wpt->routeIndex = 0;
|
|
|
|
|
|
|
|
return wpt;
|
|
|
|
}
|
- Ground network XML parsing code reads the new attributes "holdPointType"
and "isOnRunway".
- Added initial support for AI controlled pushback operations, making use of the
current editing capabilities of TaxiDraw CVS / New_GUI_CODE. The current
implementation is slightly more computationally intensive than strictly
required, due to the currently inability of taxidraw to link one specific
pushBack point to to a particular startup location. FlightGear now determines
this dynamically, and once we have that functionality in TaxiDraw, the
initialization part of createPushBack() can be further simplified.
- Smoother transition from pushback to taxi. No more skipping of waypoints, and
aircraft wait for two minutes at pushback point.
- The classes FGTaxiNode, FGTaxiSegment, and FGParking, now have copy
constructors, and assignment operators.
- Removed declaration of undefined constructor FGTaxiNode(double, double, int)
- Array boundry checks and cleanup.
- Modified Dijkstra path search algoritm to solve partial problems. Currently
limited to include pushback points and routes only, but can probably be
extended to a more general approach.
- Added initial support for giving certain routes in the network a penalty, in
order to discourage the use of certain routes over others.
2007-08-08 06:09:58 +00:00
|
|
|
|
2009-03-08 17:14:05 +00:00
|
|
|
FGAIFlightPlan::waypoint*
|
|
|
|
FGAIFlightPlan::clone(waypoint* aWpt)
|
|
|
|
{
|
|
|
|
waypoint* wpt = new waypoint;
|
|
|
|
wpt->name = aWpt->name;
|
|
|
|
wpt->longitude = aWpt->longitude;
|
|
|
|
wpt->latitude = aWpt->latitude;
|
|
|
|
|
|
|
|
wpt->altitude = aWpt->altitude;
|
|
|
|
wpt->speed = aWpt->speed;
|
|
|
|
wpt->crossat = aWpt->crossat;
|
|
|
|
wpt->gear_down = aWpt->gear_down;
|
|
|
|
wpt->flaps_down= aWpt->flaps_down;
|
|
|
|
wpt->finished = aWpt->finished;
|
|
|
|
wpt->on_ground = aWpt->on_ground;
|
|
|
|
wpt->routeIndex = 0;
|
|
|
|
|
|
|
|
return wpt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
void FGAIFlightPlan::createDefaultTakeoffTaxi(FGAIAircraft *ac, FGAirport* aAirport, FGRunway* aRunway)
|
2008-12-30 07:41:15 +00:00
|
|
|
{
|
|
|
|
SGGeod runwayTakeoff = aRunway->pointOnCenterline(5.0);
|
|
|
|
double airportElev = aAirport->getElevation();
|
|
|
|
|
|
|
|
waypoint* wpt;
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "Airport Center", aAirport->geod(), airportElev, ac->getPerformance()->vTaxi());
|
2008-12-30 07:41:15 +00:00
|
|
|
waypoints.push_back(wpt);
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "Runway Takeoff", runwayTakeoff, airportElev, ac->getPerformance()->vTaxi());
|
2008-12-30 07:41:15 +00:00
|
|
|
waypoints.push_back(wpt);
|
|
|
|
}
|
- Ground network XML parsing code reads the new attributes "holdPointType"
and "isOnRunway".
- Added initial support for AI controlled pushback operations, making use of the
current editing capabilities of TaxiDraw CVS / New_GUI_CODE. The current
implementation is slightly more computationally intensive than strictly
required, due to the currently inability of taxidraw to link one specific
pushBack point to to a particular startup location. FlightGear now determines
this dynamically, and once we have that functionality in TaxiDraw, the
initialization part of createPushBack() can be further simplified.
- Smoother transition from pushback to taxi. No more skipping of waypoints, and
aircraft wait for two minutes at pushback point.
- The classes FGTaxiNode, FGTaxiSegment, and FGParking, now have copy
constructors, and assignment operators.
- Removed declaration of undefined constructor FGTaxiNode(double, double, int)
- Array boundry checks and cleanup.
- Modified Dijkstra path search algoritm to solve partial problems. Currently
limited to include pushback points and routes only, but can probably be
extended to a more general approach.
- Added initial support for giving certain routes in the network a penalty, in
order to discourage the use of certain routes over others.
2007-08-08 06:09:58 +00:00
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
void FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft *ac, bool firstFlight,
|
2008-12-30 07:41:15 +00:00
|
|
|
FGAirport *apt,
|
2006-03-19 07:41:48 +00:00
|
|
|
double radius, const string& fltType,
|
|
|
|
const string& acType, const string& airline)
|
2005-02-10 09:01:51 +00:00
|
|
|
{
|
2008-12-30 07:41:15 +00:00
|
|
|
double heading, lat, lon;
|
|
|
|
|
|
|
|
// If this function is called during initialization,
|
|
|
|
// make sure we obtain a valid gate ID first
|
|
|
|
// and place the model at the location of the gate.
|
|
|
|
if (firstFlight) {
|
|
|
|
if (!(apt->getDynamics()->getAvailableParking(&lat, &lon,
|
|
|
|
&heading, &gateId,
|
|
|
|
radius, fltType,
|
|
|
|
acType, airline)))
|
2005-02-10 09:01:51 +00:00
|
|
|
{
|
2008-12-30 07:41:15 +00:00
|
|
|
SG_LOG(SG_INPUT, SG_WARN, "Could not find parking for a " <<
|
|
|
|
acType <<
|
|
|
|
" of flight type " << fltType <<
|
|
|
|
" of airline " << airline <<
|
|
|
|
" at airport " << apt->getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string rwyClass = getRunwayClassFromTrafficType(fltType);
|
2009-02-15 15:29:56 +00:00
|
|
|
|
|
|
|
// 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();
|
|
|
|
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, depHeading);
|
|
|
|
}
|
2008-12-30 07:41:15 +00:00
|
|
|
rwy = apt->getRunwayByIdent(activeRunway);
|
|
|
|
SGGeod runwayTakeoff = rwy->pointOnCenterline(5.0);
|
- Ground network XML parsing code reads the new attributes "holdPointType"
and "isOnRunway".
- Added initial support for AI controlled pushback operations, making use of the
current editing capabilities of TaxiDraw CVS / New_GUI_CODE. The current
implementation is slightly more computationally intensive than strictly
required, due to the currently inability of taxidraw to link one specific
pushBack point to to a particular startup location. FlightGear now determines
this dynamically, and once we have that functionality in TaxiDraw, the
initialization part of createPushBack() can be further simplified.
- Smoother transition from pushback to taxi. No more skipping of waypoints, and
aircraft wait for two minutes at pushback point.
- The classes FGTaxiNode, FGTaxiSegment, and FGParking, now have copy
constructors, and assignment operators.
- Removed declaration of undefined constructor FGTaxiNode(double, double, int)
- Array boundry checks and cleanup.
- Modified Dijkstra path search algoritm to solve partial problems. Currently
limited to include pushback points and routes only, but can probably be
extended to a more general approach.
- Added initial support for giving certain routes in the network a penalty, in
order to discourage the use of certain routes over others.
2007-08-08 06:09:58 +00:00
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
FGGroundNetwork* gn = apt->getDynamics()->getGroundNetwork();
|
|
|
|
if (!gn->exists()) {
|
2009-02-15 15:29:56 +00:00
|
|
|
createDefaultTakeoffTaxi(ac, apt, rwy);
|
2008-12-30 07:41:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
intVec ids;
|
|
|
|
int runwayId = gn->findNearestNode(runwayTakeoff);
|
|
|
|
|
|
|
|
// A negative gateId indicates an overflow parking, use a
|
|
|
|
// fallback mechanism for this.
|
|
|
|
// Starting from gate 0 in this case is a bit of a hack
|
|
|
|
// which requires a more proper solution later on.
|
|
|
|
delete taxiRoute;
|
|
|
|
taxiRoute = new FGTaxiRoute;
|
|
|
|
|
|
|
|
// Determine which node to start from.
|
|
|
|
int node = 0;
|
|
|
|
// Find out which node to start from
|
|
|
|
FGParking *park = apt->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 = lastNodeVisited;
|
|
|
|
}
|
|
|
|
}
|
- Ground network XML parsing code reads the new attributes "holdPointType"
and "isOnRunway".
- Added initial support for AI controlled pushback operations, making use of the
current editing capabilities of TaxiDraw CVS / New_GUI_CODE. The current
implementation is slightly more computationally intensive than strictly
required, due to the currently inability of taxidraw to link one specific
pushBack point to to a particular startup location. FlightGear now determines
this dynamically, and once we have that functionality in TaxiDraw, the
initialization part of createPushBack() can be further simplified.
- Smoother transition from pushback to taxi. No more skipping of waypoints, and
aircraft wait for two minutes at pushback point.
- The classes FGTaxiNode, FGTaxiSegment, and FGParking, now have copy
constructors, and assignment operators.
- Removed declaration of undefined constructor FGTaxiNode(double, double, int)
- Array boundry checks and cleanup.
- Modified Dijkstra path search algoritm to solve partial problems. Currently
limited to include pushback points and routes only, but can probably be
extended to a more general approach.
- Added initial support for giving certain routes in the network a penalty, in
order to discourage the use of certain routes over others.
2007-08-08 06:09:58 +00:00
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
*taxiRoute = gn->findShortestRoute(node, runwayId);
|
|
|
|
intVecIterator i;
|
2006-03-19 07:41:48 +00:00
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
if (taxiRoute->empty()) {
|
2009-02-15 15:29:56 +00:00
|
|
|
createDefaultTakeoffTaxi(ac, apt, rwy);
|
2008-12-30 07:41:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
taxiRoute->first();
|
|
|
|
//bool isPushBackPoint = false;
|
|
|
|
if (firstFlight) {
|
|
|
|
// If this is called during initialization, randomly
|
|
|
|
// skip a number of waypoints to get a more realistic
|
|
|
|
// taxi situation.
|
|
|
|
int nrWaypointsToSkip = rand() % taxiRoute->size();
|
|
|
|
// but make sure we always keep two active waypoints
|
|
|
|
// to prevent a segmentation fault
|
|
|
|
for (int i = 0; i < nrWaypointsToSkip-2; i++) {
|
|
|
|
taxiRoute->next(&node);
|
2005-02-10 09:01:51 +00:00
|
|
|
}
|
2008-12-30 07:41:15 +00:00
|
|
|
apt->getDynamics()->releaseParking(gateId);
|
|
|
|
} else {
|
|
|
|
if (taxiRoute->size() > 1) {
|
|
|
|
taxiRoute->next(&node); // 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
|
|
|
|
int route;
|
|
|
|
while(taxiRoute->next(&node, &route)) {
|
2006-08-26 07:22:20 +00:00
|
|
|
char buffer[10];
|
|
|
|
snprintf (buffer, 10, "%d", node);
|
2005-12-29 13:58:21 +00:00
|
|
|
FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
|
2009-05-05 10:36:38 +00:00
|
|
|
waypoint* wpt = createOnGround(ac, buffer, tn->geod(), apt->getElevation(), ac->getPerformance()->vTaxi());
|
2008-12-30 07:41:15 +00:00
|
|
|
wpt->routeIndex = route;
|
2005-10-18 18:44:37 +00:00
|
|
|
waypoints.push_back(wpt);
|
2008-12-30 07:41:15 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-19 07:41:48 +00:00
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
void FGAIFlightPlan::createDefaultLandingTaxi(FGAIAircraft *ac, FGAirport* aAirport)
|
2008-12-30 07:41:15 +00:00
|
|
|
{
|
|
|
|
SGGeod lastWptPos =
|
|
|
|
SGGeod::fromDeg(waypoints.back()->longitude, waypoints.back()->latitude);
|
|
|
|
double airportElev = aAirport->getElevation();
|
|
|
|
|
|
|
|
waypoint* wpt;
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "Runway Exit", lastWptPos, airportElev, ac->getPerformance()->vTaxi());
|
2008-12-30 07:41:15 +00:00
|
|
|
waypoints.push_back(wpt);
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "Airport Center", aAirport->geod(), airportElev, ac->getPerformance()->vTaxi());
|
2008-12-30 07:41:15 +00:00
|
|
|
waypoints.push_back(wpt);
|
|
|
|
|
|
|
|
double heading, lat, lon;
|
|
|
|
aAirport->getDynamics()->getParking(gateId, &lat, &lon, &heading);
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), airportElev, ac->getPerformance()->vTaxi());
|
2008-12-30 07:41:15 +00:00
|
|
|
waypoints.push_back(wpt);
|
|
|
|
}
|
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
void FGAIFlightPlan::createLandingTaxi(FGAIAircraft *ac, FGAirport *apt,
|
2008-12-30 07:41:15 +00:00
|
|
|
double radius, const string& fltType,
|
|
|
|
const string& acType, const string& airline)
|
|
|
|
{
|
|
|
|
double heading, lat, lon;
|
|
|
|
apt->getDynamics()->getAvailableParking(&lat, &lon, &heading,
|
|
|
|
&gateId, radius, fltType, acType, airline);
|
|
|
|
|
|
|
|
SGGeod lastWptPos =
|
|
|
|
SGGeod::fromDeg(waypoints.back()->longitude, waypoints.back()->latitude);
|
|
|
|
FGGroundNetwork* gn = apt->getDynamics()->getGroundNetwork();
|
|
|
|
|
|
|
|
// Find a route from runway end to parking/gate.
|
|
|
|
if (!gn->exists()) {
|
2009-02-15 15:29:56 +00:00
|
|
|
createDefaultLandingTaxi(ac, apt);
|
2008-12-30 07:41:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
intVec ids;
|
|
|
|
int runwayId = gn->findNearestNode(lastWptPos);
|
|
|
|
// A negative gateId indicates an overflow parking, use a
|
|
|
|
// fallback mechanism for this.
|
|
|
|
// Starting from gate 0 is a bit of a hack...
|
|
|
|
//FGTaxiRoute route;
|
|
|
|
delete taxiRoute;
|
|
|
|
taxiRoute = new FGTaxiRoute;
|
|
|
|
if (gateId >= 0)
|
|
|
|
*taxiRoute = gn->findShortestRoute(runwayId, gateId);
|
|
|
|
else
|
|
|
|
*taxiRoute = gn->findShortestRoute(runwayId, 0);
|
|
|
|
intVecIterator i;
|
|
|
|
|
|
|
|
if (taxiRoute->empty()) {
|
2009-02-15 15:29:56 +00:00
|
|
|
createDefaultLandingTaxi(ac, apt);
|
2008-12-30 07:41:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int node;
|
|
|
|
taxiRoute->first();
|
|
|
|
int size = taxiRoute->size();
|
|
|
|
// Omit the last two waypoints, as
|
|
|
|
// those are created by createParking()
|
|
|
|
int route;
|
|
|
|
for (int i = 0; i < size-2; i++) {
|
|
|
|
taxiRoute->next(&node, &route);
|
|
|
|
char buffer[10];
|
|
|
|
snprintf (buffer, 10, "%d", node);
|
|
|
|
FGTaxiNode *tn = gn->findNode(node);
|
2009-05-05 10:36:38 +00:00
|
|
|
waypoint* wpt = createOnGround(ac, buffer, tn->geod(), apt->getElevation(), ac->getPerformance()->vTaxi());
|
2008-12-30 07:41:15 +00:00
|
|
|
wpt->routeIndex = route;
|
|
|
|
waypoints.push_back(wpt);
|
|
|
|
}
|
2005-02-10 09:01:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* CreateTakeOff
|
|
|
|
* initialize the Aircraft at the parking location
|
|
|
|
******************************************************************/
|
2009-01-30 18:48:44 +00:00
|
|
|
void FGAIFlightPlan::createTakeOff(FGAIAircraft *ac, bool firstFlight, FGAirport *apt, double speed, const string &fltType)
|
2005-02-10 09:01:51 +00:00
|
|
|
{
|
2009-05-05 10:36:38 +00:00
|
|
|
double accel = ac->getPerformance()->acceleration();
|
|
|
|
double vTaxi = ac->getPerformance()->vTaxi();
|
|
|
|
double vRotate = ac->getPerformance()->vRotate();
|
|
|
|
double vTakeoff = ac->getPerformance()->vTakeoff();
|
|
|
|
double vClimb = ac->getPerformance()->vClimb();
|
2009-01-30 18:48:44 +00:00
|
|
|
// Acceleration = dV / dT
|
|
|
|
// Acceleration X dT = dV
|
|
|
|
// dT = dT / Acceleration
|
|
|
|
//d = (Vf^2 - Vo^2) / (2*a)
|
2009-05-05 10:36:38 +00:00
|
|
|
double accelTime = (vRotate - vTaxi) / accel;
|
2009-01-30 21:15:48 +00:00
|
|
|
//cerr << "Using " << accelTime << " as total acceleration time" << endl;
|
2009-05-05 10:36:38 +00:00
|
|
|
double accelDistance = (vRotate*vRotate - vTaxi*vTaxi) / (2*accel);
|
2009-01-30 21:15:48 +00:00
|
|
|
//cerr << "Using " << accelDistance << " " << accel << " " << vRotate << endl;
|
2009-01-30 18:48:44 +00:00
|
|
|
waypoint *wpt;
|
|
|
|
// Get the current active runway, based on code from David Luff
|
|
|
|
// This should actually be unified and extended to include
|
|
|
|
// Preferential runway use schema's
|
|
|
|
// NOTE: DT (2009-01-18: IIRC, this is currently already the case,
|
|
|
|
// because the getActive runway function takes care of that.
|
|
|
|
if (firstFlight)
|
|
|
|
{
|
|
|
|
string rwyClass = getRunwayClassFromTrafficType(fltType);
|
2009-02-15 15:29:56 +00:00
|
|
|
double heading = ac->getTrafficRef()->getCourse();
|
|
|
|
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, heading);
|
2009-01-30 18:48:44 +00:00
|
|
|
rwy = apt->getRunwayByIdent(activeRunway);
|
|
|
|
}
|
|
|
|
|
|
|
|
double airportElev = apt->getElevation();
|
|
|
|
// Acceleration point, 105 meters into the runway,
|
|
|
|
SGGeod accelPoint = rwy->pointOnCenterline(105.0);
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "accel", accelPoint, airportElev, vClimb);
|
|
|
|
waypoints.push_back(wpt);
|
|
|
|
|
2009-01-30 18:48:44 +00:00
|
|
|
//Start Climbing to 3000 ft. Let's do this
|
|
|
|
// at the center of the runway for now:
|
|
|
|
SGGeod rotate = rwy->pointOnCenterline(105.0+accelDistance);
|
2009-02-15 15:29:56 +00:00
|
|
|
wpt = cloneWithPos(ac, wpt, "SOC", rotate);
|
2009-01-30 18:48:44 +00:00
|
|
|
wpt->altitude = airportElev+1000;
|
|
|
|
wpt->on_ground = false;
|
|
|
|
waypoints.push_back(wpt);
|
2006-10-06 17:36:31 +00:00
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
wpt = cloneWithPos(ac, wpt, "3000 ft", rwy->end());
|
2009-01-30 18:48:44 +00:00
|
|
|
wpt->altitude = airportElev+3000;
|
|
|
|
waypoints.push_back(wpt);
|
2006-10-06 17:36:31 +00:00
|
|
|
|
2009-01-30 18:48:44 +00:00
|
|
|
// Finally, add two more waypoints, so that aircraft will remain under
|
|
|
|
// Tower control until they have reached the 3000 ft climb point
|
|
|
|
SGGeod pt = rwy->pointOnCenterline(5000 + rwy->lengthM() * 0.5);
|
2009-02-15 15:29:56 +00:00
|
|
|
wpt = cloneWithPos(ac, wpt, "5000 ft", pt);
|
2009-01-30 18:48:44 +00:00
|
|
|
wpt->altitude = airportElev+5000;
|
|
|
|
waypoints.push_back(wpt);
|
2005-02-10 09:01:51 +00:00
|
|
|
}
|
2008-12-30 07:41:15 +00:00
|
|
|
|
2005-02-10 09:01:51 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* CreateClimb
|
|
|
|
* initialize the Aircraft at the parking location
|
|
|
|
******************************************************************/
|
2009-02-15 15:29:56 +00:00
|
|
|
void FGAIFlightPlan::createClimb(FGAIAircraft *ac, bool firstFlight, FGAirport *apt, double speed, double alt, const string &fltType)
|
2005-02-10 09:01:51 +00:00
|
|
|
{
|
|
|
|
waypoint *wpt;
|
2009-03-01 09:58:12 +00:00
|
|
|
bool planLoaded = false;
|
|
|
|
string fPLName;
|
2009-05-05 10:36:38 +00:00
|
|
|
double vClimb = ac->getPerformance()->vClimb();
|
2005-02-10 09:01:51 +00:00
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
if (firstFlight) {
|
|
|
|
string rwyClass = getRunwayClassFromTrafficType(fltType);
|
2009-02-15 15:29:56 +00:00
|
|
|
double heading = ac->getTrafficRef()->getCourse();
|
|
|
|
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, heading);
|
2008-12-30 07:41:15 +00:00
|
|
|
rwy = apt->getRunwayByIdent(activeRunway);
|
|
|
|
}
|
2009-03-08 17:14:05 +00:00
|
|
|
if (sid) {
|
|
|
|
for (wpt_vector_iterator i = sid->getFirstWayPoint();
|
|
|
|
i != sid->getLastWayPoint();
|
|
|
|
i++) {
|
|
|
|
waypoints.push_back(clone(*(i)));
|
|
|
|
//cerr << " Cloning waypoint " << endl;
|
|
|
|
}
|
|
|
|
} else {
|
2009-03-01 09:58:12 +00:00
|
|
|
SGGeod climb1 = rwy->pointOnCenterline(10*SG_NM_TO_METER);
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createInAir(ac, "10000ft climb", climb1, vClimb, 10000);
|
2009-03-01 09:58:12 +00:00
|
|
|
wpt->gear_down = true;
|
|
|
|
wpt->flaps_down= true;
|
|
|
|
waypoints.push_back(wpt);
|
|
|
|
|
|
|
|
SGGeod climb2 = rwy->pointOnCenterline(20*SG_NM_TO_METER);
|
|
|
|
wpt = cloneWithPos(ac, wpt, "18000ft climb", climb2);
|
|
|
|
wpt->altitude = 18000;
|
|
|
|
waypoints.push_back(wpt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-10 09:01:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* CreateDecent
|
|
|
|
* initialize the Aircraft at the parking location
|
|
|
|
******************************************************************/
|
2009-02-15 15:29:56 +00:00
|
|
|
void FGAIFlightPlan::createDecent(FGAIAircraft *ac, FGAirport *apt, const string &fltType)
|
2005-02-10 09:01:51 +00:00
|
|
|
{
|
|
|
|
// Ten thousand ft. Slowing down to 240 kts
|
|
|
|
waypoint *wpt;
|
2009-05-05 10:36:38 +00:00
|
|
|
double vDecent = ac->getPerformance()->vDescent();
|
|
|
|
double vApproach = ac->getPerformance()->vApproach();
|
2005-02-10 09:01:51 +00:00
|
|
|
|
|
|
|
//Beginning of Decent
|
2005-10-18 18:44:37 +00:00
|
|
|
//string name;
|
|
|
|
// allow "mil" and "gen" as well
|
2007-06-28 18:30:35 +00:00
|
|
|
string rwyClass = getRunwayClassFromTrafficType(fltType);
|
2009-02-15 15:29:56 +00:00
|
|
|
double heading = ac->getTrafficRef()->getCourse();
|
|
|
|
apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, heading);
|
2008-08-14 18:13:39 +00:00
|
|
|
rwy = apt->getRunwayByIdent(activeRunway);
|
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
SGGeod descent1 = rwy->pointOnCenterline(-100000); // 100km out
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createInAir(ac, "Dec 10000ft", descent1, apt->getElevation(), vDecent);
|
2005-02-10 09:01:51 +00:00
|
|
|
wpt->crossat = 10000;
|
|
|
|
waypoints.push_back(wpt);
|
2006-03-19 07:41:48 +00:00
|
|
|
|
2005-02-10 09:01:51 +00:00
|
|
|
// Three thousand ft. Slowing down to 160 kts
|
2008-12-30 07:41:15 +00:00
|
|
|
SGGeod descent2 = rwy->pointOnCenterline(-8*SG_NM_TO_METER); // 8nm out
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createInAir(ac, "DEC 3000ft", descent2, apt->getElevation(), vApproach);
|
2005-02-10 09:01:51 +00:00
|
|
|
wpt->crossat = 3000;
|
|
|
|
wpt->gear_down = true;
|
|
|
|
wpt->flaps_down= true;
|
|
|
|
waypoints.push_back(wpt);
|
|
|
|
}
|
|
|
|
/*******************************************************************
|
|
|
|
* CreateLanding
|
|
|
|
* initialize the Aircraft at the parking location
|
|
|
|
******************************************************************/
|
2009-02-15 15:29:56 +00:00
|
|
|
void FGAIFlightPlan::createLanding(FGAIAircraft *ac, FGAirport *apt)
|
2005-02-10 09:01:51 +00:00
|
|
|
{
|
2009-05-05 10:36:38 +00:00
|
|
|
double vTouchdown = ac->getPerformance()->vTouchdown();
|
|
|
|
double vTaxi = ac->getPerformance()->vTaxi();
|
|
|
|
|
2005-02-10 09:01:51 +00:00
|
|
|
waypoint *wpt;
|
2008-12-30 07:41:15 +00:00
|
|
|
double aptElev = apt->getElevation();
|
2005-02-10 09:01:51 +00:00
|
|
|
//Runway Threshold
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "Threshold", rwy->threshold(), aptElev, vTouchdown);
|
2008-12-30 07:41:15 +00:00
|
|
|
wpt->crossat = apt->getElevation();
|
2005-02-10 09:01:51 +00:00
|
|
|
waypoints.push_back(wpt);
|
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
// Roll-out
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "Center", rwy->geod(), aptElev, vTaxi*2);
|
2005-02-10 09:01:51 +00:00
|
|
|
waypoints.push_back(wpt);
|
|
|
|
|
2008-12-30 07:41:15 +00:00
|
|
|
SGGeod rollOut = rwy->pointOnCenterline(rwy->lengthM() * 0.9);
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "Roll Out", rollOut, aptElev, vTaxi);
|
2005-02-10 09:01:51 +00:00
|
|
|
wpt->crossat = apt->getElevation();
|
|
|
|
waypoints.push_back(wpt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* CreateParking
|
|
|
|
* initialize the Aircraft at the parking location
|
|
|
|
******************************************************************/
|
2009-02-15 15:29:56 +00:00
|
|
|
void FGAIFlightPlan::createParking(FGAIAircraft *ac, FGAirport *apt, double radius)
|
2005-02-10 09:01:51 +00:00
|
|
|
{
|
|
|
|
waypoint* wpt;
|
2008-12-30 07:41:15 +00:00
|
|
|
double aptElev = apt->getElevation();
|
2006-03-19 07:41:48 +00:00
|
|
|
double lat, lat2;
|
|
|
|
double lon, lon2;
|
|
|
|
double az2;
|
2005-02-10 09:01:51 +00:00
|
|
|
double heading;
|
2009-05-05 10:36:38 +00:00
|
|
|
|
|
|
|
double vTaxi = ac->getPerformance()->vTaxi();
|
|
|
|
double vTaxiReduced = vTaxi * (2.0/3.0);
|
2005-12-29 13:58:21 +00:00
|
|
|
apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
|
2005-02-10 09:01:51 +00:00
|
|
|
heading += 180.0;
|
|
|
|
if (heading > 360)
|
|
|
|
heading -= 360;
|
2006-03-19 07:41:48 +00:00
|
|
|
geo_direct_wgs_84 ( 0, lat, lon, heading,
|
|
|
|
2.2*radius,
|
|
|
|
&lat2, &lon2, &az2 );
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "taxiStart", SGGeod::fromDeg(lon2, lat2), aptElev, vTaxiReduced);
|
2008-12-30 07:41:15 +00:00
|
|
|
waypoints.push_back(wpt);
|
|
|
|
|
2006-03-19 07:41:48 +00:00
|
|
|
geo_direct_wgs_84 ( 0, lat, lon, heading,
|
|
|
|
0.1 *radius,
|
|
|
|
&lat2, &lon2, &az2 );
|
2008-12-30 07:41:15 +00:00
|
|
|
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "taxiStart2", SGGeod::fromDeg(lon2, lat2), aptElev, vTaxiReduced);
|
2006-03-19 07:41:48 +00:00
|
|
|
waypoints.push_back(wpt);
|
2005-02-10 09:01:51 +00:00
|
|
|
|
2009-05-05 10:36:38 +00:00
|
|
|
wpt = createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), aptElev, vTaxiReduced);
|
2005-02-10 09:01:51 +00:00
|
|
|
waypoints.push_back(wpt);
|
|
|
|
}
|
2007-06-28 18:30:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param fltType a string describing the type of
|
|
|
|
* traffic, normally used for gate assignments
|
|
|
|
* @return a converted string that gives the runway
|
|
|
|
* preference schedule to be used at aircraft having
|
|
|
|
* a preferential runway schedule implemented (i.e.
|
|
|
|
* having a rwyprefs.xml file
|
|
|
|
*
|
|
|
|
* Currently valid traffic types for gate assignment:
|
|
|
|
* - gate (commercial gate)
|
|
|
|
* - cargo (commercial gargo),
|
|
|
|
* - ga (general aviation) ,
|
|
|
|
* - ul (ultralight),
|
|
|
|
* - mil-fighter (military - fighter),
|
|
|
|
* - mil-transport (military - transport)
|
|
|
|
*
|
|
|
|
* Valid runway classes:
|
|
|
|
* - com (commercial traffic: jetliners, passenger and cargo)
|
|
|
|
* - gen (general aviation)
|
|
|
|
* - ul (ultralight: I can imagine that these may share a runway with ga on some airports)
|
|
|
|
* - mil (all military traffic)
|
|
|
|
*/
|
|
|
|
string FGAIFlightPlan::getRunwayClassFromTrafficType(string fltType)
|
|
|
|
{
|
|
|
|
if ((fltType == "gate") || (fltType == "cargo")) {
|
|
|
|
return string("com");
|
|
|
|
}
|
|
|
|
if (fltType == "ga") {
|
|
|
|
return string ("gen");
|
|
|
|
}
|
|
|
|
if (fltType == "ul") {
|
|
|
|
return string("ul");
|
|
|
|
}
|
|
|
|
if ((fltType == "mil-fighter") || (fltType == "mil-transport")) {
|
|
|
|
return string("mil");
|
|
|
|
}
|
- Ground network XML parsing code reads the new attributes "holdPointType"
and "isOnRunway".
- Added initial support for AI controlled pushback operations, making use of the
current editing capabilities of TaxiDraw CVS / New_GUI_CODE. The current
implementation is slightly more computationally intensive than strictly
required, due to the currently inability of taxidraw to link one specific
pushBack point to to a particular startup location. FlightGear now determines
this dynamically, and once we have that functionality in TaxiDraw, the
initialization part of createPushBack() can be further simplified.
- Smoother transition from pushback to taxi. No more skipping of waypoints, and
aircraft wait for two minutes at pushback point.
- The classes FGTaxiNode, FGTaxiSegment, and FGParking, now have copy
constructors, and assignment operators.
- Removed declaration of undefined constructor FGTaxiNode(double, double, int)
- Array boundry checks and cleanup.
- Modified Dijkstra path search algoritm to solve partial problems. Currently
limited to include pushback points and routes only, but can probably be
extended to a more general approach.
- Added initial support for giving certain routes in the network a penalty, in
order to discourage the use of certain routes over others.
2007-08-08 06:09:58 +00:00
|
|
|
return string("com");
|
2007-06-28 18:30:35 +00:00
|
|
|
}
|