]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGExternalReactions.h
Update to the latest version of JSBSim which supports Lighter Than Air craft
[flightgear.git] / src / FDM / JSBSim / models / FGExternalReactions.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGExternalReactions.h
4  Author:       David P. Culp
5  Date started: 17/11/06
6
7  ------------- Copyright (C) 2006  David P. Culp (davidculp2@comcast.net) -------------
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 17/11/06   DPC   Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGEXTERNALREACTIONS_H
35 #define FGEXTERNALREACTIONS_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #endif
44
45 #include "FGModel.h"
46 #include "FGExternalForce.h"
47 #include <input_output/FGXMLElement.h>
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 DEFINITIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 #define ID_EXTERNALREACTIONS "$Id$"
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 FORWARD DECLARATIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 namespace JSBSim {
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 CLASS DOCUMENTATION
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 /** Manages the external and/or arbitrary forces.
66     The external reactions capability in JSBSim really should be named
67     "arbitrary forces", because this feature can be used to model a wide
68     variety of forces that act on a vehicle. Some examples include: parachutes,
69     catapult, arresting hook, and tow line.
70     
71     This class acts similarly to the other "manager classes" (FGPropulsion, 
72     FGFCS, FGGroundReactions, FGAerodynamics) because it manages collections
73     of constituent forces. The individual forces are implemented with the
74     FGExternalForce class.
75     
76     The format of the <em>optional</em> external reactions section in the config
77     file is as follows:
78     
79     @code
80 <external_reactions>
81
82   <!-- Interface properties, a.k.a. property declarations -->
83   <property> ... </property>
84     
85   <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
86     ...
87   </force>
88
89   <!-- Additional force definitions may follow -->
90   <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
91     ...
92   </force>
93
94 </external_reactions>
95     @endcode
96
97     See the FGExternalForce class for more information on the format of the
98     force specification itself.
99     
100     When force elements are encountered in the configuration file, a new instance
101     of the FGExternalForce class is created and a pointer to the class is pushed
102     onto the Forces vector.
103     
104     This class is one of a few of the manager classes that allows properties
105     to be "declared". In code, these are represented by the
106     <em>interface_properties</em> vector. Properties that have not yet been
107     created in an already parsed section of the configuration file and that are
108     used in the definition of an external force should be declared in the
109     external_reactions section because they will not be created automatically,
110     and so would cause an error, since the property cannot be found to exist.
111         
112     See the FGExternalForce documentation for details on how forces are
113     actually calculated.
114   */
115
116 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 CLASS DECLARATION
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
119
120 class FGExternalReactions : public FGModel
121 {
122 public:
123   /** Constructor.
124       @param fdmex pointer to the main executive class.
125   */
126   FGExternalReactions(FGFDMExec* fdmex);
127   
128   /** Destructor.
129       Within the destructor the Forces and interface_properties vectors are
130       cleared out and the items pointed to are deleted.
131   */
132   ~FGExternalReactions(void);
133
134   bool InitModel(void);
135
136   /** Sum all the constituent forces for this cycle.
137       @return true always.
138   */
139   bool Run(void);
140   
141   /** Loads the external forces from the XML configuration file.
142       If the external_reactions section is encountered in the vehicle configuration
143       file, this Load() method is called. All external forces will be parsed, and 
144       a FGExternalForce object will be instantiated for each force definition.
145       @param el a pointer to the XML element holding the external reactions definition.
146   */
147   bool Load(Element* el);
148
149   /** Retrieves the total forces defined in the external reactions.
150       @return the total force in pounds.
151   */
152   FGColumnVector3 GetForces(void) {return vTotalForces;}
153
154   /** Retrieves the total moment resulting from the forces defined in the external reactions.
155       @return the total moment in foot-pounds.
156   */
157   FGColumnVector3 GetMoments(void) {return vTotalMoments;}
158
159 private:
160
161   vector <FGExternalForce*> Forces;
162   unsigned int numForces;
163   FGColumnVector3 vTotalForces;
164   FGColumnVector3 vTotalMoments;
165   vector <double*> interface_properties;
166
167   bool NoneDefined;
168
169   void Debug(int from);
170 };
171 }
172 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 #endif
174