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