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