1 // FGAILocalTraffic - AIEntity derived class with enough logic to
2 // fly and interact with the traffic pattern.
4 // Written by David Luff, started March 2002.
6 // Copyright (C) 2002 David C. Luff - david.luff@nottingham.ac.uk
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 /*****************************************************************
24 * WARNING - Curt has some ideas about AI traffic so anything in here
25 * may get rewritten or scrapped. Contact Curt curt@flightgear.org
26 * before spending any time or effort on this code!!!
28 ******************************************************************/
30 #ifndef _FG_AILocalTraffic_HXX
31 #define _FG_AILocalTraffic_HXX
35 #include <simgear/math/point3d.hxx>
38 #include "AIPlane.hxx"
39 #include "ATCProjection.hxx"
41 typedef enum PatternLeg {
55 // perhaps we could use an FGRunway instead of this
56 typedef struct RunwayDetails {
57 Point3D threshold_pos;
58 Point3D end1ortho; // ortho projection end1 (the threshold ATM)
59 Point3D end2ortho; // ortho projection end2 (the take off end in the current hardwired scheme)
62 double hdg; // true runway heading
65 typedef struct StartofDescent {
71 class FGAILocalTraffic : public FGAIPlane {
81 // Run the internal calculations
82 void Update(double dt);
86 // Attempt to enter the traffic pattern in a reasonably intelligent manner
87 void EnterTrafficPattern(double dt);
90 FGATCAlignedProjection ortho; // Orthogonal mapping of the local area with the threshold at the origin
91 // and the runway aligned with the y axis.
93 // Airport/runway/pattern details
94 char* airport; // The ICAO code of the airport that we're operating around
95 FGTower* tower; // A pointer to the tower control.
97 double patternDirection; // 1 for right, -1 for left (This is double because we multiply/divide turn rates
98 // with it to get RH/LH turns - DON'T convert it to int under ANY circumstances!!
99 double glideAngle; // Assumed to be visual glidepath angle for FGAILocalTraffic - can be found at www.airnav.com
100 // Its conceivable that patternDirection and glidePath could be moved into the RunwayDetails structure.
102 // Performance characteristics of the plane in knots and ft/min - some of this might get moved out into FGAIPlane
104 double best_rate_of_climb_speed;
105 double best_rate_of_climb;
106 double nominal_climb_speed;
107 double nominal_climb_rate;
108 double nominal_circuit_speed;
109 double min_circuit_speed;
110 double max_circuit_speed;
111 double nominal_descent_rate;
112 double nominal_approach_speed;
113 double nominal_final_speed;
114 double stall_speed_landing_config;
116 // environment - some of this might get moved into FGAIPlane
117 double wind_from_hdg; // degrees
118 double wind_speed_knots; // knots
120 // Pattern details that (may) change
121 int numInPattern; // Number of planes in the pattern (this might get more complicated if high performance GA aircraft fly a higher pattern eventually)
122 int numAhead; // More importantly - how many of them are ahead of us?
123 double distToNext; // And even more importantly, how near are we getting to the one immediately ahead?
124 PatternLeg leg; // Out current position in the pattern
125 StartofDescent SoD; // Start of descent calculated wrt wind, pattern size & altitude, glideslope etc
127 void FlyTrafficPattern(double dt);
129 // TODO - need to add something to define what option we are flying - Touch and go / Stop and go / Landing properly / others?
131 void TransmitPatternPositionReport();
133 void CalculateStartofDescent();
136 #endif // _FG_AILocalTraffic_HXX