]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.h
Additional changes including updates to JSBSim to try to get interface and
[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 float GetWingArea(void) { return WingArea; }
176   /// Gets the wing span
177   inline float GetWingSpan(void) { return WingSpan; }
178   /// Gets the average wing chord
179   inline float Getcbar(void) { return cbar; }
180   inline float GetWingIncidence(void) { return WingIncidence; }
181   inline float GetHTailArea(void) { return HTailArea; }
182   inline float GetHTailArm(void)  { return HTailArm; }
183   inline float GetVTailArea(void) { return VTailArea; }
184   inline float GetVTailArm(void)  { return VTailArm; }
185   inline float Getlbarh(void) { return lbarh; } // HTailArm / cbar
186   inline float Getlbarv(void) { return lbarv; } // VTailArm / cbar
187   inline float Getvbarh(void) { return vbarh; } // H. Tail Volume
188   inline float 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& GetXYZrp(void) { return vXYZrp; }
193   inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
194   inline float GetXYZrp(int idx) { return vXYZrp(idx); }
195   inline float GetXYZep(int idx) { return vXYZep(idx); }
196   inline float GetAlphaCLMax(void) { return alphaclmax; }
197   inline float GetAlphaCLMin(void) { return alphaclmin; }
198
199   inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
200   inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
201
202   /// Subsystem types for specifying which will be output in the FDM data logging
203   enum  SubSystems {
204     /** Subsystem: Simulation (= 1)          */ ssSimulation      = 1,
205     /** Subsystem: Aerosurfaces (= 2)        */ ssAerosurfaces    = 2,
206     /** Subsystem: Body rates (= 4)          */ ssRates           = 4,
207     /** Subsystem: Velocities (= 8)          */ ssVelocities      = 8,
208     /** Subsystem: Forces (= 16)             */ ssForces          = 16,
209     /** Subsystem: Moments (= 32)            */ ssMoments         = 32,
210     /** Subsystem: Atmosphere (= 64)         */ ssAtmosphere      = 64,
211     /** Subsystem: Mass Properties (= 128)   */ ssMassProps       = 128,
212     /** Subsystem: Coefficients (= 256)      */ ssCoefficients    = 256,
213     /** Subsystem: Position (= 512)          */ ssPosition        = 512,
214     /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
215     /** Subsystem: FCS (= 2048)              */ ssFCS             = 2048,
216     /** Subsystem: Propulsion (= 4096)       */ ssPropulsion      = 4096
217   } subsystems;
218
219 private:
220   FGColumnVector3 vMoments;
221   FGColumnVector3 vForces;
222   FGColumnVector3 vXYZrp;
223   FGColumnVector3 vXYZep;
224   FGColumnVector3 vEuler;
225   FGColumnVector3 vDXYZcg;
226   FGColumnVector3 vBodyAccel;
227   float WingArea, WingSpan, cbar, WingIncidence;
228   float HTailArea, VTailArea, HTailArm, VTailArm;
229   float lbarh,lbarv,vbarh,vbarv;
230   float alphaclmax,alphaclmin;
231   string CFGVersion;
232   string AircraftName;
233
234   void ReadMetrics(FGConfigFile*);
235   void ReadPropulsion(FGConfigFile*);
236   void ReadFlightControls(FGConfigFile*);
237   void ReadAerodynamics(FGConfigFile*);
238   void ReadUndercarriage(FGConfigFile*);
239   void ReadPrologue(FGConfigFile*);
240   void ReadOutput(FGConfigFile*);
241   void Debug(void);
242 };
243
244 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245 #endif
246