]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAircraft.h
Merge branch 'topic/tape' into next
[flightgear.git] / src / FDM / JSBSim / models / 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 Lesser 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 Lesser General Public License for more
17  details.
18
19  You should have received a copy of the GNU Lesser 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 Lesser 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 #include <vector>
42
43 #include "FGModel.h"
44 #include <input_output/FGXMLElement.h>
45 #include <math/FGColumnVector3.h>
46
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 DEFINITIONS
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50
51 #define ID_AIRCRAFT "$Id$"
52
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 FORWARD DECLARATIONS
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
57 namespace JSBSim {
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 CLASS DOCUMENTATION
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 /** Encapsulates an Aircraft and its systems.
64 <p> Owns all the parts (other classes) which make up this aircraft. This includes
65     the Engines, Tanks, Propellers, Nozzles, Aerodynamic and Mass properties,
66     landing gear, etc. These constituent parts may actually run as separate
67     JSBSim models themselves, but the responsibility for initializing them and
68     for retrieving their force and moment contributions falls to FGAircraft.
69 <p> The \<metrics> section of the aircraft configuration file is read here, and
70     the metrical information is held by this class.
71 <h3>Configuration File Format for \<metrics> Section:</h3>
72 @code
73     <metrics>
74         <wingarea unit="{FT2 | M2}"> {number} </wingarea>
75         <wingspan unit="{FT | M}"> {number} </wingspan>
76         <chord unit="{FT | M}"> {number} </chord>
77         <htailarea unit="{FT2 | M2}"> {number} </htailarea>
78         <htailarm unit="{FT | M}"> {number} </htailarm>
79         <vtailarea unit="{FT2 | M}"> {number} </vtailarea>
80         <vtailarm unit="{FT | M}"> {number} </vtailarm>
81         <wing_incidence unit="{RAD | DEG}"> {number} </wing_incidence>
82         <location name="{AERORP | EYEPOINT | VRP}" unit="{IN | M}">
83             <x> {number} </x>
84             <y> {number} </y>
85             <z> {number} </z>
86         </location>
87         {other location blocks}
88     </metrics>
89 @endcode
90
91     @author Jon S. Berndt
92     @version $Id$
93     @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
94            Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
95            School, January 1994
96     @see D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
97      JSC 12960, July 1977
98     @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
99      NASA-Ames", NASA CR-2497, January 1975
100     @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
101      Wiley & Sons, 1979 ISBN 0-471-03032-5
102     @see Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
103      1982 ISBN 0-471-08936-2
104 */
105
106 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 CLASS DECLARATION
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
109
110 class FGAircraft : public FGModel {
111 public:
112   /** Constructor
113       @param Executive a pointer to the parent executive object */
114   FGAircraft(FGFDMExec *Executive);
115
116   /// Destructor
117   ~FGAircraft();
118
119   /** Runs the Aircraft model; called by the Executive
120       @see JSBSim.cpp documentation
121       @return false if no error */
122   bool Run(void);
123
124   bool InitModel(void);
125
126   /** Loads the aircraft.
127       The executive calls this method to load the aircraft into JSBSim.
128       @param el a pointer to the element tree
129       @return true if successful */
130   bool Load(Element* el);
131
132   /** Gets the aircraft name
133       @return the name of the aircraft as a string type */
134   inline string GetAircraftName(void) { return AircraftName; }
135
136   /// Gets the wing area
137   double GetWingArea(void) const { return WingArea; }
138   /// Gets the wing span
139   double GetWingSpan(void) const { return WingSpan; }
140   /// Gets the average wing chord
141   double Getcbar(void) const { return cbar; }
142   inline double GetWingIncidence(void) const { return WingIncidence; }
143   inline double GetWingIncidenceDeg(void) const { return WingIncidence*radtodeg; }
144   inline double GetHTailArea(void) const { return HTailArea; }
145   inline double GetHTailArm(void)  const { return HTailArm; }
146   inline double GetVTailArea(void) const { return VTailArea; }
147   inline double GetVTailArm(void)  const { return VTailArm; }
148   inline double Getlbarh(void) const { return lbarh; } // HTailArm / cbar
149   inline double Getlbarv(void) const { return lbarv; } // VTailArm / cbar
150   inline double Getvbarh(void) const { return vbarh; } // H. Tail Volume
151   inline double Getvbarv(void) const { return vbarv; } // V. Tail Volume
152   inline FGColumnVector3& GetMoments(void) { return vMoments; }
153   inline double GetMoments(int idx) const { return vMoments(idx); }
154   inline FGColumnVector3& GetForces(void) { return vForces; }
155   inline double GetForces(int idx) const { return vForces(idx); }
156   inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
157   inline double GetBodyAccel(int idx) { return vBodyAccel(idx); }
158   inline FGColumnVector3& GetNcg   (void)  { return vNcg; }
159   inline double GetNcg(int idx)  { return vNcg(idx); }
160   inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
161   inline FGColumnVector3& GetXYZvrp(void) { return vXYZvrp; }
162   inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
163   inline double GetXYZrp(int idx) const { return vXYZrp(idx); }
164   inline double GetXYZvrp(int idx) const { return vXYZvrp(idx); }
165   inline double GetXYZep(int idx) const { return vXYZep(idx); }
166   inline void SetAircraftName(string name) {AircraftName = name;}
167   inline void SetHoldDown(int hd) {HoldDown = hd;}
168   inline int GetHoldDown(void) const {return HoldDown;}
169
170   void SetXYZrp(int idx, double value) {vXYZrp(idx) = value;}
171
172   void SetWingArea(double S) {WingArea = S;}
173
174   double GetNlf(void) const;
175
176   inline FGColumnVector3& GetNwcg(void) { return vNwcg; }
177
178   void bind(void);
179   void unbind(void);
180
181 private:
182   FGColumnVector3 vMoments;
183   FGColumnVector3 vForces;
184   FGColumnVector3 vXYZrp;
185   FGColumnVector3 vXYZvrp;
186   FGColumnVector3 vXYZep;
187   FGColumnVector3 vDXYZcg;
188   FGColumnVector3 vBodyAccel;
189   FGColumnVector3 vNcg;
190   FGColumnVector3 vNwcg;
191
192   double WingArea, WingSpan, cbar, WingIncidence;
193   double HTailArea, VTailArea, HTailArm, VTailArm;
194   double lbarh,lbarv,vbarh,vbarv;
195   int HoldDown;
196   string AircraftName;
197
198   void Debug(int from);
199 };
200
201 } // namespace JSBSim
202 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 #endif
204