]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.h
Oct 2, 2000 JSBSim sync.
[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 <map>
104 #  else
105 #    include <vector.h>
106 #    include <map.h>
107 #  endif
108 #else
109 #  include <vector>
110 #  include <map>
111 #endif
112
113 #include "FGModel.h"
114 #include "FGCoefficient.h"
115 #include "FGEngine.h"
116 #include "FGTank.h"
117 #include "FGLGear.h"
118 #include "FGConfigFile.h"
119 #include "FGMatrix.h"
120
121 /*******************************************************************************
122 DEFINITIONS
123 *******************************************************************************/
124
125 /*******************************************************************************
126 CLASS DECLARATION
127 *******************************************************************************/
128
129 class FGAircraft : public FGModel {
130   enum {eL=1, eM, eN};
131   enum {eX=1, eY, eZ};
132   enum {eP=1, eQ, eR};
133   enum {ePhi=1, eTht, ePsi};
134
135 public:
136   FGAircraft(FGFDMExec*);
137   ~FGAircraft(void);
138
139   bool Run(void);
140   bool LoadAircraft(string, string, string);
141   inline string GetAircraftName(void) { return AircraftName; }
142   inline void SetGearUp(bool tt) { GearUp = tt; }
143   inline bool GetGearUp(void) { return GearUp; }
144   inline int GetNumGearUnits(void) { return lGear.size(); }
145   inline FGLGear* GetGearUnit(int ii) { return lGear[ii]; }
146   inline float GetWingArea(void) { return WingArea; }
147   inline float GetWingSpan(void) { return WingSpan; }
148   inline float Getcbar(void) { return cbar; }
149   inline FGEngine* GetEngine(int tt) { return Engine[tt]; }
150   inline FGTank* GetTank(int tt) { return Tank[tt]; }
151   inline float GetWeight(void) { return Weight; }
152   inline float GetMass(void) { return Mass; }
153   inline FGColumnVector GetMoments(void) { return vMoments; }
154   inline FGColumnVector GetForces(void) { return vForces; }
155   inline FGColumnVector GetvFs(void) { return vFs; }
156   inline float GetIxx(void) { return Ixx; }
157   inline float GetIyy(void) { return Iyy; }
158   inline float GetIzz(void) { return Izz; }
159   inline float GetIxz(void) { return Ixz; }
160   inline unsigned int GetNumEngines(void) { return numEngines; }
161   inline FGColumnVector GetXYZcg(void) { return vXYZcg; }
162   inline FGColumnVector GetXYZrp(void) { return vXYZrp; }
163   inline FGColumnVector GetXYZep(void) { return vXYZep; }
164   inline float GetNlf(void) { return nlf; }
165   inline float GetAlphaCLMax(void) { return alphaclmax; }
166   inline float GetAlphaCLMin(void) { return alphaclmin; }
167
168   inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
169   inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
170
171   inline FGCoefficient* GetCoeff(int axis, int idx) { return Coeff[axis][idx]; }
172   string GetCoefficientStrings(void);
173   string GetCoefficientValues(void);
174   string GetGroundReactionStrings(void);
175   string GetGroundReactionValues(void);
176
177   enum { ssSimulation      = 1,
178          ssAerosurfaces    = 2,
179          ssRates           = 4,
180          ssVelocities      = 8,
181          ssForces          = 16,
182          ssMoments         = 32,
183          ssAtmosphere      = 64,
184          ssMassProps       = 128,
185          ssCoefficients    = 256,
186          ssPosition        = 512,
187          ssGroundReactions = 1024 } subsystems;
188
189 private:
190   void GetState(void);
191   void FMAero(void);
192   void FMGear(void);
193   void FMMass(void);
194   void FMProp(void);
195   void MassChange(void);
196   FGColumnVector vMoments;
197   FGColumnVector vForces;
198   FGColumnVector vFs;
199   FGColumnVector vXYZrp;
200   FGColumnVector vbaseXYZcg;
201   FGColumnVector vXYZcg;
202   FGColumnVector vXYZep;
203   FGColumnVector vEuler;
204   float baseIxx, baseIyy, baseIzz, baseIxz, EmptyMass, Mass;
205   float Ixx, Iyy, Izz, Ixz;
206   float alpha, beta;
207   float WingArea, WingSpan, cbar;
208   float Weight, EmptyWeight;
209   float nlf,alphaclmax,alphaclmin;
210   float dt;
211   string CFGVersion;
212   string AircraftName;
213
214   unsigned int numTanks;
215   unsigned int numEngines;
216   unsigned int numSelectedOxiTanks;
217   unsigned int numSelectedFuelTanks;
218   FGTank* Tank[MAX_TANKS];           // need to make a vector
219   FGEngine *Engine[MAX_ENGINES];     // need to make a vector
220
221   typedef map<string,int> AxisIndex;
222   AxisIndex AxisIdx;
223
224   typedef vector<FGCoefficient*> CoeffArray;
225   
226   CoeffArray* Coeff;
227
228   void DisplayCoeffFactors(vector <eParam> multipliers);
229
230   bool GearUp;
231
232   string Axis[6];
233   vector <FGLGear*> lGear;
234   string AircraftPath;
235   string EnginePath;
236   void ReadMetrics(FGConfigFile*);
237   void ReadPropulsion(FGConfigFile*);
238   void ReadFlightControls(FGConfigFile*);
239   void ReadAerodynamics(FGConfigFile*);
240   void ReadUndercarriage(FGConfigFile*);
241   void ReadPrologue(FGConfigFile*);
242   void ReadOutput(FGConfigFile*);
243 };
244
245 /******************************************************************************/
246 #endif