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