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"
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 #define ID_EXTERNALREACTIONS "$Id$"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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.
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.
74 The format of the <em>optional</em> external reactions section in the config
80 <!-- Interface properties, a.k.a. property declarations -->
81 <property> ... </property>
83 <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
87 <!-- Additional force definitions may follow -->
88 <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
95 See the FGExternalForce class for more information on the format of the
96 force specification itself.
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.
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.
110 See the FGExternalForce documentation for details on how forces are
114 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
118 class FGExternalReactions : public FGModel
122 @param fdmex pointer to the main executive class.
124 FGExternalReactions(FGFDMExec* fdmex);
127 Within the destructor the Forces and interface_properties vectors are
128 cleared out and the items pointed to are deleted.
130 ~FGExternalReactions(void);
132 bool InitModel(void);
134 /** Sum all the constituent forces for this cycle.
139 /** Loads the external forces from the XML configuration file.
140 If the external_reactions section is encountered in the vehicle configuration
141 file, this Load() method is called. All external forces will be parsed, and
142 a FGExternalForce object will be instantiated for each force definition.
143 @param el a pointer to the XML element holding the external reactions definition.
145 bool Load(Element* el);
147 /** Retrieves the total forces defined in the external reactions.
148 @return the total force in pounds.
150 FGColumnVector3 GetForces(void) {return vTotalForces;}
152 /** Retrieves the total moment resulting from the forces defined in the external reactions.
153 @return the total moment in foot-pounds.
155 FGColumnVector3 GetMoments(void) {return vTotalMoments;}
159 std::vector <FGExternalForce*> Forces;
160 unsigned int numForces;
161 FGColumnVector3 vTotalForces;
162 FGColumnVector3 vTotalMoments;
166 void Debug(int from);
169 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%