2004-05-15 09:07:55 +00:00
|
|
|
// FGAIFlightPlan - class for loading and storing AI flight plans
|
|
|
|
// Written by David Culp, started May 2004
|
|
|
|
// - davidculp2@comcast.net
|
|
|
|
//
|
|
|
|
// 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-07-27 14:42:15 +00:00
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2004-05-15 09:07:55 +00:00
|
|
|
|
|
|
|
#ifndef _FG_AIFLIGHTPLAN_HXX
|
|
|
|
#define _FG_AIFLIGHTPLAN_HXX
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2004-07-22 18:50:29 +00:00
|
|
|
|
2009-01-30 18:48:44 +00:00
|
|
|
|
2004-07-22 18:50:29 +00:00
|
|
|
#include <Airports/simple.hxx>
|
2006-07-27 14:42:15 +00:00
|
|
|
#include <Navaids/awynet.hxx>
|
2004-07-22 18:50:29 +00:00
|
|
|
|
2004-09-07 09:53:23 +00:00
|
|
|
#include "AIBase.hxx"
|
|
|
|
|
2009-01-30 18:48:44 +00:00
|
|
|
|
|
|
|
|
2008-07-27 16:25:13 +00:00
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
class FGTaxiRoute;
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
class FGRunway;
|
2009-01-30 18:48:44 +00:00
|
|
|
class FGAIAircraft;
|
2004-05-15 09:07:55 +00:00
|
|
|
|
|
|
|
class FGAIFlightPlan {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
string name;
|
|
|
|
double latitude;
|
|
|
|
double longitude;
|
|
|
|
double altitude;
|
|
|
|
double speed;
|
|
|
|
double crossat;
|
2004-05-18 09:09:08 +00:00
|
|
|
bool finished;
|
2004-05-15 09:07:55 +00:00
|
|
|
bool gear_down;
|
|
|
|
bool flaps_down;
|
2004-05-21 16:50:19 +00:00
|
|
|
bool on_ground;
|
2006-08-26 07:22:20 +00:00
|
|
|
int routeIndex; // For AI/ATC purposes;
|
2007-03-30 22:51:52 +00:00
|
|
|
double time_sec;
|
|
|
|
string time;
|
|
|
|
|
2004-05-15 09:07:55 +00:00
|
|
|
} waypoint;
|
2009-03-08 17:14:05 +00:00
|
|
|
FGAIFlightPlan();
|
2007-07-08 08:46:29 +00:00
|
|
|
FGAIFlightPlan(const string& filename);
|
2009-01-30 18:48:44 +00:00
|
|
|
FGAIFlightPlan(FGAIAircraft *,
|
|
|
|
const std::string& p,
|
2004-07-22 18:50:29 +00:00
|
|
|
double course,
|
2004-11-29 09:41:43 +00:00
|
|
|
time_t start,
|
2004-07-22 18:50:29 +00:00
|
|
|
FGAirport *dep,
|
2005-02-10 09:01:51 +00:00
|
|
|
FGAirport *arr,
|
|
|
|
bool firstLeg,
|
|
|
|
double radius,
|
2006-02-11 13:16:56 +00:00
|
|
|
double alt,
|
|
|
|
double lat,
|
|
|
|
double lon,
|
|
|
|
double speed,
|
2005-10-25 13:49:55 +00:00
|
|
|
const string& fltType,
|
|
|
|
const string& acType,
|
|
|
|
const string& airline);
|
2004-05-15 09:07:55 +00:00
|
|
|
~FGAIFlightPlan();
|
|
|
|
|
2005-10-26 09:03:49 +00:00
|
|
|
waypoint* const getPreviousWaypoint( void ) const;
|
|
|
|
waypoint* const getCurrentWaypoint( void ) const;
|
|
|
|
waypoint* const getNextWaypoint( void ) const;
|
2005-02-10 09:01:51 +00:00
|
|
|
void IncrementWaypoint( bool erase );
|
2009-08-25 09:54:49 +00:00
|
|
|
void DecrementWaypoint( bool erase );
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2005-10-26 09:03:49 +00:00
|
|
|
double getDistanceToGo(double lat, double lon, waypoint* wp) const;
|
|
|
|
int getLeg () const { return leg;};
|
2004-05-15 09:07:55 +00:00
|
|
|
void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
|
|
|
|
void setLeadDistance(double distance_ft);
|
|
|
|
double getLeadDistance( void ) const {return lead_distance;}
|
2005-10-26 09:03:49 +00:00
|
|
|
double getBearing(waypoint* previous, waypoint* next) const;
|
|
|
|
double getBearing(double lat, double lon, waypoint* next) const;
|
2007-07-08 08:46:29 +00:00
|
|
|
time_t getStartTime() const { return start_time; }
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2009-01-30 18:48:44 +00:00
|
|
|
void create(FGAIAircraft *, FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
|
2005-10-25 13:49:55 +00:00
|
|
|
bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
|
2004-07-22 18:50:29 +00:00
|
|
|
|
2007-07-08 08:46:29 +00:00
|
|
|
void setLeg(int val) { leg = val;}
|
|
|
|
void setTime(time_t st) { start_time = st; }
|
|
|
|
int getGate() const { return gateId; }
|
|
|
|
double getLeadInAngle() const { return leadInAngle; }
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
const string& getRunway() const;
|
|
|
|
|
2007-07-08 08:46:29 +00:00
|
|
|
void setRepeat(bool r) { repeat = r; }
|
|
|
|
bool getRepeat(void) const { return repeat; }
|
2005-06-04 09:38:52 +00:00
|
|
|
void restart(void);
|
2007-07-08 08:46:29 +00:00
|
|
|
int getNrOfWayPoints() { return waypoints.size(); }
|
2006-08-26 07:22:20 +00:00
|
|
|
int getRouteIndex(int i); // returns the AI related index of this current routes.
|
2007-07-08 08:46:29 +00:00
|
|
|
FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
|
2006-08-26 07:22:20 +00:00
|
|
|
void deleteTaxiRoute();
|
2007-07-08 08:46:29 +00:00
|
|
|
string getRunway() { return activeRunway; }
|
|
|
|
bool isActive(time_t time) {return time >= this->getStartTime();}
|
2005-06-04 09:38:52 +00:00
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
void setRunway(string rwy) { activeRunway = rwy; };
|
|
|
|
string getRunwayClassFromTrafficType(string fltType);
|
|
|
|
|
2009-03-08 17:14:05 +00:00
|
|
|
void addWaypoint(waypoint* wpt) { waypoints.push_back(wpt); };
|
|
|
|
|
|
|
|
void setName(string n) { name = n; };
|
|
|
|
string getName() { return name; };
|
|
|
|
|
|
|
|
void setSID(FGAIFlightPlan* fp) { sid = fp;};
|
|
|
|
FGAIFlightPlan* getSID() { return sid; };
|
|
|
|
|
2004-05-15 09:07:55 +00:00
|
|
|
private:
|
James Turner:
Convert FGRunway to be heap-based, and inherit FGPositioned. This is a large, ugly change, since FGRunway was essentially a plain struct, with no accessors or abstraction. This change adds various helpers and accessors to FGRunway, but doesn't change many places to use them - that will be a follow up series of patches. It's still a large patch, but outside of FGAirport and FGRunway, mostly mechanical search-and-replace.
An interesting part of this change is that reciprocal runways now exist as independent objects, rather than being created on the fly by the search methods. This simplifies some pieces of code that search for and iterate runways. For users who only want one 'end' of a runway, the new 'isReciprocal' predicate allows them to ignore the 'other' end. Current the only user of this is the 'ground-radar' ATC feature. If we had data on which runways are truly 'single-ended', it would now be trivial to use this in the airport loader to *not* create the reciprocal.
2008-09-11 08:38:09 +00:00
|
|
|
FGRunway* rwy;
|
2009-03-08 17:14:05 +00:00
|
|
|
FGAIFlightPlan *sid;
|
2005-06-04 09:38:52 +00:00
|
|
|
typedef vector <waypoint*> wpt_vector_type;
|
2005-10-26 09:03:49 +00:00
|
|
|
typedef wpt_vector_type::const_iterator wpt_vector_iterator;
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2005-06-04 09:38:52 +00:00
|
|
|
wpt_vector_type waypoints;
|
|
|
|
wpt_vector_iterator wpt_iterator;
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2005-06-04 09:38:52 +00:00
|
|
|
bool repeat;
|
|
|
|
double distance_to_go;
|
|
|
|
double lead_distance;
|
2005-02-10 09:01:51 +00:00
|
|
|
double leadInAngle;
|
2007-07-08 08:46:29 +00:00
|
|
|
time_t start_time;
|
2005-02-10 09:01:51 +00:00
|
|
|
int leg;
|
- 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
|
|
|
int gateId, lastNodeVisited;
|
2005-10-18 18:44:37 +00:00
|
|
|
string activeRunway;
|
2006-07-29 18:17:19 +00:00
|
|
|
FGAirRoute airRoute;
|
|
|
|
FGTaxiRoute *taxiRoute;
|
2009-03-08 17:14:05 +00:00
|
|
|
string name;
|
2006-07-27 14:42:15 +00:00
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
void createPushBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const string&, const string&, const string&);
|
|
|
|
void createPushBackFallBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const string&, const string&, const string&);
|
2009-01-30 18:48:44 +00:00
|
|
|
void createTakeOff(FGAIAircraft *, bool, FGAirport *, double, const string&);
|
2009-02-15 15:29:56 +00:00
|
|
|
void createClimb(FGAIAircraft *, bool, FGAirport *, double, double, const string&);
|
|
|
|
void createCruise(FGAIAircraft *, bool, FGAirport*, FGAirport*, double, double, double, double, const string&);
|
|
|
|
void createDecent(FGAIAircraft *, FGAirport *, const string&);
|
|
|
|
void createLanding(FGAIAircraft *, FGAirport *);
|
|
|
|
void createParking(FGAIAircraft *, FGAirport *, double radius);
|
2005-02-10 09:01:51 +00:00
|
|
|
void deleteWaypoints();
|
|
|
|
void resetWaypoints();
|
2006-07-27 14:42:15 +00:00
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
void createLandingTaxi(FGAIAircraft *, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
|
|
|
|
void createDefaultLandingTaxi(FGAIAircraft *, FGAirport* aAirport);
|
|
|
|
void createDefaultTakeoffTaxi(FGAIAircraft *, FGAirport* aAirport, FGRunway* aRunway);
|
|
|
|
void createTakeoffTaxi(FGAIAircraft *, bool firstFlight, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
|
2008-12-30 07:41:15 +00:00
|
|
|
|
2009-02-15 15:29:56 +00:00
|
|
|
waypoint* createOnGround(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
|
|
|
|
waypoint* createInAir(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
|
|
|
|
waypoint* cloneWithPos(FGAIAircraft *, waypoint* aWpt, const std::string& aName, const SGGeod& aPos);
|
2009-03-08 17:14:05 +00:00
|
|
|
waypoint* clone(waypoint* aWpt);
|
2008-12-30 07:41:15 +00:00
|
|
|
|
2007-06-28 18:30:35 +00:00
|
|
|
|
2006-07-27 14:42:15 +00:00
|
|
|
//void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
|
|
|
|
void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
|
2009-03-08 17:14:05 +00:00
|
|
|
public:
|
|
|
|
wpt_vector_iterator getFirstWayPoint() { return waypoints.begin(); };
|
|
|
|
wpt_vector_iterator getLastWayPoint() { return waypoints.end(); };
|
2009-03-01 09:58:12 +00:00
|
|
|
|
2004-05-15 09:07:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _FG_AIFLIGHTPLAN_HXX
|