]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.h
Oct. 10, 2000 sync with JSBSim master repository.
[flightgear.git] / src / FDM / JSBSim / FGAircraft.h
1 /*******************************************************************************
2  
3  Header:       FGAircraft.h
4  Author:       Jon S. Berndt
5  Date started: 12/12/98
6  
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8  
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13  
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18  
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22  
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25  
26 HISTORY
27 --------------------------------------------------------------------------------
28 12/12/98   JSB   Created
29  
30 ********************************************************************************
31 SENTRY
32 *******************************************************************************/
33
34 #ifndef FGAIRCRAFT_H
35 #define FGAIRCRAFT_H
36
37 /*******************************************************************************
38 COMMENTS, REFERENCES,  and NOTES
39 *******************************************************************************/
40 /*
41 The aerodynamic coefficients used in this model typically are:
42  
43 Longitudinal
44   CL0 - Reference lift at zero alpha
45   CD0 - Reference drag at zero alpha
46   CDM - Drag due to Mach
47   CLa - Lift curve slope (w.r.t. alpha)
48   CDa - Drag curve slope (w.r.t. alpha)
49   CLq - Lift due to pitch rate
50   CLM - Lift due to Mach
51   CLadt - Lift due to alpha rate
52  
53   Cmadt - Pitching Moment due to alpha rate
54   Cm0 - Reference Pitching moment at zero alpha
55   Cma - Pitching moment slope (w.r.t. alpha)
56   Cmq - Pitch damping (pitch moment due to pitch rate)
57   CmM - Pitch Moment due to Mach
58  
59 Lateral
60   Cyb - Side force due to sideslip
61   Cyr - Side force due to yaw rate
62  
63   Clb - Dihedral effect (roll moment due to sideslip)
64   Clp - Roll damping (roll moment due to roll rate)
65   Clr - Roll moment due to yaw rate
66   Cnb - Weathercocking stability (yaw moment due to sideslip)
67   Cnp - Rudder adverse yaw (yaw moment due to roll rate)
68   Cnr - Yaw damping (yaw moment due to yaw rate)
69  
70 Control
71   CLDe - Lift due to elevator
72   CDDe - Drag due to elevator
73   CyDr - Side force due to rudder
74   CyDa - Side force due to aileron
75  
76   CmDe - Pitch moment due to elevator
77   ClDa - Roll moment due to aileron
78   ClDr - Roll moment due to rudder
79   CnDr - Yaw moment due to rudder
80   CnDa - Yaw moment due to aileron
81  
82 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
83          Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
84          School, January 1994
85 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
86          JSC 12960, July 1977
87 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
88          NASA-Ames", NASA CR-2497, January 1975
89 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
90          Wiley & Sons, 1979 ISBN 0-471-03032-5
91 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
92          1982 ISBN 0-471-08936-2
93 */
94
95 /*******************************************************************************
96 INCLUDES
97 *******************************************************************************/
98
99 #ifdef FGFS
100 #  include <simgear/compiler.h>
101 #  ifdef FG_HAVE_STD_INCLUDES
102 #    include <vector>
103 #    include <iterator>
104 #    include <map>
105 #  else
106 #    include <vector.h>
107 #    include <iterator.h>
108 #    include <map.h>
109 #  endif
110 #else
111 #  include <vector>
112 #  include <iterator>
113 #  include <map>
114 #endif
115
116 #include "FGModel.h"
117 #include "FGCoefficient.h"
118 #include "FGEngine.h"
119 #include "FGTank.h"
120 #include "FGLGear.h"
121 #include "FGConfigFile.h"
122 #include "FGMatrix.h"
123
124 /*******************************************************************************
125 DEFINITIONS
126 *******************************************************************************/
127
128 /** Encapsulates an Aircraft and its systems.
129     Owns all the parts (other classes) which make
130     up this aircraft. This includes the Engines, Tanks, Propellers, Nozzles,
131     aerodynamic and mass properties, landing gear, etc.
132     @author Jon S. Berndt
133     @version $Id$
134   */
135
136 /*******************************************************************************
137 CLASS DECLARATION
138 *******************************************************************************/
139
140 class FGAircraft : public FGModel {
141   enum {eL=1, eM, eN};
142   enum {eX=1, eY, eZ};
143   enum {eP=1, eQ, eR};
144   enum {ePhi=1, eTht, ePsi};
145
146 public:
147   /** Constructor
148       @param Executive a pointer to the parent executive object
149     */
150   FGAircraft(FGFDMExec *Executive);
151   /// Destructor
152   ~FGAircraft(void);
153
154   /** Runs the model; called by the Executive
155       @see JSBSim.cpp documentation
156       @return bool returns false if no error
157     */
158   bool Run(void);
159   /** Loads the aircraft.
160       The executive calls this method to load the aircraft into JSBSim.
161       @param apath path to the aircraft files (e.g. "aircraft/X15/")
162       @param epath path to engine files (e.g. "engine/")
163       @param acname name of aircraft (e.g. "X15")
164       @return true if succesful
165     */
166   bool LoadAircraft(string apath, string epath, string acname);
167   inline string GetAircraftName(void) { return AircraftName; }
168   inline void SetGearUp(bool tt) { GearUp = tt; }
169   inline bool GetGearUp(void) { return GearUp; }
170   inline int GetNumGearUnits(void) { return lGear.size(); }
171   inline FGLGear* GetGearUnit(int ii) { return &(lGear[ii]); }
172   inline float GetWingArea(void) { return WingArea; }
173   inline float GetWingSpan(void) { return WingSpan; }
174   inline float Getcbar(void) { return cbar; }
175   inline FGEngine* GetEngine(int tt) { return Engine[tt]; }
176   inline FGTank* GetTank(int tt) { return Tank[tt]; }
177   inline float GetWeight(void) { return Weight; }
178   inline float GetMass(void) { return Mass; }
179   inline FGColumnVector GetMoments(void) { return vMoments; }
180   inline FGColumnVector GetForces(void) { return vForces; }
181   inline FGColumnVector GetvFs(void) { return vFs; }
182   inline float GetIxx(void) { return Ixx; }
183   inline float GetIyy(void) { return Iyy; }
184   inline float GetIzz(void) { return Izz; }
185   inline float GetIxz(void) { return Ixz; }
186   inline unsigned int GetNumEngines(void) { return numEngines; }
187   inline FGColumnVector GetXYZcg(void) { return vXYZcg; }
188   inline FGColumnVector GetXYZrp(void) { return vXYZrp; }
189   inline FGColumnVector GetXYZep(void) { return vXYZep; }
190   inline float GetNlf(void) { return nlf; }
191   inline float GetAlphaCLMax(void) { return alphaclmax; }
192   inline float GetAlphaCLMin(void) { return alphaclmin; }
193
194   inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
195   inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
196
197   inline FGCoefficient* GetCoeff(int axis, int idx) { return Coeff[axis][idx]; }
198   string GetCoefficientStrings(void);
199   string GetCoefficientValues(void);
200   string GetGroundReactionStrings(void);
201   string GetGroundReactionValues(void);
202
203   enum { ssSimulation      = 1,
204          ssAerosurfaces    = 2,
205          ssRates           = 4,
206          ssVelocities      = 8,
207          ssForces          = 16,
208          ssMoments         = 32,
209          ssAtmosphere      = 64,
210          ssMassProps       = 128,
211          ssCoefficients    = 256,
212          ssPosition        = 512,
213          ssGroundReactions = 1024 } subsystems;
214
215 private:
216   void GetState(void);
217   void FMAero(void);
218   void FMGear(void);
219   void FMMass(void);
220   void FMProp(void);
221   void MassChange(void);
222   FGColumnVector vMoments;
223   FGColumnVector vForces;
224   FGColumnVector vFs;
225   FGColumnVector vXYZrp;
226   FGColumnVector vbaseXYZcg;
227   FGColumnVector vXYZcg;
228   FGColumnVector vXYZep;
229   FGColumnVector vEuler;
230   float baseIxx, baseIyy, baseIzz, baseIxz, EmptyMass, Mass;
231   float Ixx, Iyy, Izz, Ixz;
232   float alpha, beta;
233   float WingArea, WingSpan, cbar;
234   float Weight, EmptyWeight;
235   float nlf,alphaclmax,alphaclmin;
236   float dt;
237   string CFGVersion;
238   string AircraftName;
239
240   unsigned int numTanks;
241   unsigned int numEngines;
242   unsigned int numSelectedOxiTanks;
243   unsigned int numSelectedFuelTanks;
244   FGTank* Tank[MAX_TANKS];           // need to make a vector
245   FGEngine *Engine[MAX_ENGINES];     // need to make a vector
246
247   typedef map<string,int> AxisIndex;
248   AxisIndex AxisIdx;
249
250   typedef vector<FGCoefficient*> CoeffArray;
251   
252   CoeffArray* Coeff;
253
254   void DisplayCoeffFactors(vector <eParam> multipliers);
255
256   bool GearUp;
257
258   string Axis[6];
259   vector <FGLGear> lGear;
260
261   string AircraftPath;
262   string EnginePath;
263   void ReadMetrics(FGConfigFile*);
264   void ReadPropulsion(FGConfigFile*);
265   void ReadFlightControls(FGConfigFile*);
266   void ReadAerodynamics(FGConfigFile*);
267   void ReadUndercarriage(FGConfigFile*);
268   void ReadPrologue(FGConfigFile*);
269   void ReadOutput(FGConfigFile*);
270 };
271
272 /******************************************************************************/
273 #endif