]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.h
Latest JSBSim changes.
[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 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #  ifdef SG_HAVE_STD_INCLUDES
44 #    include <vector>
45 #    include <iterator>
46 #  else
47 #    include <vector.h>
48 #    include <iterator.h>
49 #  endif
50 #else
51 #  include <vector>
52 #  include <iterator>
53 #endif
54
55 #include "FGModel.h"
56 #include "FGPropulsion.h"
57 #include "FGConfigFile.h"
58 #include "FGMatrix33.h"
59 #include "FGColumnVector3.h"
60 #include "FGColumnVector4.h"
61 #include "FGLGear.h"
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 DEFINITIONS
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 #define ID_AIRCRAFT "$Id$"
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 FORWARD DECLARATIONS
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76
77 Longitudinal
78   CL0 - Reference lift at zero alpha
79   CD0 - Reference drag at zero alpha
80   CDM - Drag due to Mach
81   CLa - Lift curve slope (w.r.t. alpha)
82   CDa - Drag curve slope (w.r.t. alpha)
83   CLq - Lift due to pitch rate
84   CLM - Lift due to Mach
85   CLadt - Lift due to alpha rate
86  
87   Cmadt - Pitching Moment due to alpha rate
88   Cm0 - Reference Pitching moment at zero alpha
89   Cma - Pitching moment slope (w.r.t. alpha)
90   Cmq - Pitch damping (pitch moment due to pitch rate)
91   CmM - Pitch Moment due to Mach
92  
93 Lateral
94   Cyb - Side force due to sideslip
95   Cyr - Side force due to yaw rate
96  
97   Clb - Dihedral effect (roll moment due to sideslip)
98   Clp - Roll damping (roll moment due to roll rate)
99   Clr - Roll moment due to yaw rate
100   Cnb - Weathercocking stability (yaw moment due to sideslip)
101   Cnp - Rudder adverse yaw (yaw moment due to roll rate)
102   Cnr - Yaw damping (yaw moment due to yaw rate)
103  
104 Control
105   CLDe - Lift due to elevator
106   CDDe - Drag due to elevator
107   CyDr - Side force due to rudder
108   CyDa - Side force due to aileron
109  
110   CmDe - Pitch moment due to elevator
111   ClDa - Roll moment due to aileron
112   ClDr - Roll moment due to rudder
113   CnDr - Yaw moment due to rudder
114   CnDa - Yaw moment due to aileron
115
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 CLASS DOCUMENTATION
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
119
120 /** Encapsulates an Aircraft and its systems.
121     Owns all the parts (other classes) which make up this aircraft. This includes
122     the Engines, Tanks, Propellers, Nozzles, Aerodynamic and Mass properties,
123     landing gear, etc. These constituent parts may actually run as separate
124     JSBSim models themselves, but the responsibility for initializing them and
125     for retrieving their force and moment contributions falls to FGAircraft.<br>
126     When an aircraft model is loaded the config file is parsed and for each of the
127     sections of the config file (propulsion, flight control, etc.) the
128     corresponding "ReadXXX()" method is called. From within this method the 
129     "Load()" method of that system is called (e.g. LoadFCS).
130     @author Jon S. Berndt
131     @version $Id$
132     @see
133      <ol><li>Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
134            Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
135            School, January 1994</li>
136      <li>D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
137      JSC 12960, July 1977</li>
138      <li>Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
139      NASA-Ames", NASA CR-2497, January 1975</li>
140      <li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
141      Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
142      <li>Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
143      1982 ISBN 0-471-08936-2</li></ol>
144 */
145
146 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147 CLASS DECLARATION
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
149
150 class FGAircraft : public FGModel {
151 public:
152   /** Constructor
153       @param Executive a pointer to the parent executive object */
154   FGAircraft(FGFDMExec *Executive);
155   
156   /// Destructor
157   ~FGAircraft();
158
159   /** Runs the Aircraft model; called by the Executive
160       @see JSBSim.cpp documentation
161       @return false if no error */
162   bool Run(void);
163   
164   /** Loads the aircraft.
165       The executive calls this method to load the aircraft into JSBSim.
166       @param AC_cfg a pointer to the config file instance
167       @return true if successful */
168   bool Load(FGConfigFile* AC_cfg);
169   
170   /** Gets the aircraft name
171       @return the name of the aircraft as a string type */
172   inline string GetAircraftName(void) { return AircraftName; }
173   
174   /// Gets the wing area
175   inline double GetWingArea(void) { return WingArea; }
176   /// Gets the wing span
177   inline double GetWingSpan(void) { return WingSpan; }
178   /// Gets the average wing chord
179   inline double Getcbar(void) { return cbar; }
180   inline double GetWingIncidence(void) { return WingIncidence; }
181   inline double GetHTailArea(void) { return HTailArea; }
182   inline double GetHTailArm(void)  { return HTailArm; }
183   inline double GetVTailArea(void) { return VTailArea; }
184   inline double GetVTailArm(void)  { return VTailArm; }
185   inline double Getlbarh(void) { return lbarh; } // HTailArm / cbar
186   inline double Getlbarv(void) { return lbarv; } // VTailArm / cbar
187   inline double Getvbarh(void) { return vbarh; } // H. Tail Volume
188   inline double Getvbarv(void) { return vbarv; } // V. Tail Volume
189   inline FGColumnVector3& GetMoments(void) { return vMoments; }
190   inline FGColumnVector3& GetForces(void) { return vForces; }
191   inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
192   inline FGColumnVector3& GetNcg   (void)    { return vNcg; }
193   inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
194   inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
195   inline double GetXYZrp(int idx) { return vXYZrp(idx); }
196   inline double GetXYZep(int idx) { return vXYZep(idx); }
197   inline double GetAlphaCLMax(void) { return alphaclmax; }
198   inline double GetAlphaCLMin(void) { return alphaclmin; }
199
200   inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
201   inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
202   
203   inline double GetStallWarn(void) { return impending_stall; }
204   
205   float GetNlf(void);
206   
207   inline FGColumnVector3& GetNwcg(void) { return vNwcg; }
208
209 private:
210   FGColumnVector3 vMoments;
211   FGColumnVector3 vForces;
212   FGColumnVector3 vXYZrp;
213   FGColumnVector3 vXYZep;
214   FGColumnVector3 vEuler;
215   FGColumnVector3 vDXYZcg;
216   FGColumnVector3 vBodyAccel;
217   FGColumnVector3 vNcg;
218   FGColumnVector3 vNwcg;
219
220   double WingArea, WingSpan, cbar, WingIncidence;
221   double HTailArea, VTailArea, HTailArm, VTailArm;
222   double lbarh,lbarv,vbarh,vbarv;
223   double alphaclmax,alphaclmin;
224   double impending_stall;
225   string CFGVersion;
226   string AircraftName;
227
228   bool ReadMetrics(FGConfigFile*);
229   bool ReadPropulsion(FGConfigFile*);
230   bool ReadFlightControls(FGConfigFile*);
231   bool ReadAerodynamics(FGConfigFile*);
232   bool ReadUndercarriage(FGConfigFile*);
233   bool ReadPrologue(FGConfigFile*);
234   bool ReadOutput(FGConfigFile*);
235   void Debug(int from);
236 };
237
238 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 #endif
240