1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Header: FGExternalReactions.h
7 ------------- Copyright (C) 2006 David P. Culp (davidculp2@comcast.net) -------------
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
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
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.
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.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34 #ifndef FGEXTERNALREACTIONS_H
35 #define FGEXTERNALREACTIONS_H
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 #include "FGExternalForce.h"
43 #include <input_output/FGXMLElement.h>
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 #define ID_EXTERNALREACTIONS "$Id$"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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.
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.
72 The format of the <em>optional</em> external reactions section in the config
78 <!-- Interface properties, a.k.a. property declarations -->
79 <property> ... </property>
81 <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
85 <!-- Additional force definitions may follow -->
86 <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
93 See the FGExternalForce class for more information on the format of the
94 force specification itself.
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.
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.
108 See the FGExternalForce documentation for details on how forces are
112 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
116 class FGExternalReactions : public FGModel
120 @param fdmex pointer to the main executive class.
122 FGExternalReactions(FGFDMExec* fdmex);
125 Within the destructor the Forces and interface_properties vectors are
126 cleared out and the items pointed to are deleted.
128 ~FGExternalReactions(void);
130 bool InitModel(void);
132 /** Sum all the constituent forces for this cycle.
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.
143 bool Load(Element* el);
145 /** Retrieves the total forces defined in the external reactions.
146 @return the total force in pounds.
148 FGColumnVector3 GetForces(void) {return vTotalForces;}
150 /** Retrieves the total moment resulting from the forces defined in the external reactions.
151 @return the total moment in foot-pounds.
153 FGColumnVector3 GetMoments(void) {return vTotalMoments;}
157 vector <FGExternalForce*> Forces;
158 unsigned int numForces;
159 FGColumnVector3 vTotalForces;
160 FGColumnVector3 vTotalMoments;
161 vector <double*> interface_properties;
165 void Debug(int from);
168 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%