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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 #include "FGExternalForce.h"
44 #include "input_output/FGXMLFileRead.h"
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 #define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.13 2011/07/20 12:16:34 jberndt Exp $"
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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.
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.
76 The format of the <em>optional</em> external reactions section in the config
82 <!-- Interface properties, a.k.a. property declarations -->
83 <property> ... </property>
85 <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
89 <!-- Additional force definitions may follow -->
90 <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
97 See the FGExternalForce class for more information on the format of the
98 force specification itself.
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.
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.
112 See the FGExternalForce documentation for details on how forces are
116 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
120 class FGExternalReactions : public FGModel, public FGXMLFileRead
124 @param fdmex pointer to the main executive class.
126 FGExternalReactions(FGFDMExec* fdmex);
129 Within the destructor the Forces and interface_properties vectors are
130 cleared out and the items pointed to are deleted.
132 ~FGExternalReactions(void);
134 bool InitModel(void);
136 /** Sum all the constituent forces for this cycle.
137 Can pass in a value indicating if the executive is directing the simulation to Hold.
138 @param Holding if true, the executive has been directed to hold the sim from
139 advancing time. Some models may ignore this flag, such as the Input
140 model, which may need to be active to listen on a socket for the
141 "Resume" command to be given.
142 @return true always. */
143 bool Run(bool Holding);
145 /** Loads the external forces from the XML configuration file.
146 If the external_reactions section is encountered in the vehicle configuration
147 file, this Load() method is called. All external forces will be parsed, and
148 a FGExternalForce object will be instantiated for each force definition.
149 @param el a pointer to the XML element holding the external reactions definition.
151 bool Load(Element* el);
153 /** Retrieves the total forces defined in the external reactions.
154 @return the total force in pounds.
156 FGColumnVector3 GetForces(void) const {return vTotalForces;}
157 double GetForces(int idx) const {return vTotalForces(idx);}
159 /** Retrieves the total moment resulting from the forces defined in the external reactions.
160 @return the total moment in foot-pounds.
162 FGColumnVector3 GetMoments(void) const {return vTotalMoments;}
163 double GetMoments(int idx) const {return vTotalMoments(idx);}
167 std::vector <FGExternalForce*> Forces;
168 unsigned int numForces;
169 FGColumnVector3 vTotalForces;
170 FGColumnVector3 vTotalMoments;
175 void Debug(int from);
178 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%