From: Bertrand <bco...@us...> - 2017-06-04 21:06:12
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31273/src/models Modified Files: FGExternalForce.cpp FGExternalForce.h FGExternalReactions.cpp FGExternalReactions.h Log Message: New feature: external moments can now be specified in addition to external forces. Index: FGExternalForce.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGExternalForce.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** FGExternalForce.cpp 4 Jun 2017 17:39:57 -0000 1.21 --- FGExternalForce.cpp 4 Jun 2017 21:06:08 -0000 1.22 *************** *** 49,52 **** --- 49,63 ---- </force> + <moment name="name" frame="BODY|LOCAL|WIND"> + + <function> ... </function> + + <direction> <!-- optional for initial direction vector --> + <x> value </x> + <y> value </y> + <z> value </z> + </direction> + </force> + </external_reactions> *************** *** 80,83 **** --- 91,96 ---- } + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + FGParameter* FGExternalForce::bind(Element *el, FGPropertyManager* pm, const string& magName, FGPropertyVector3& v) *************** *** 130,133 **** --- 143,148 ---- } + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + void FGExternalForce::setForce(Element *el) { *************** *** 156,160 **** &FGForce::GetLocationZ, &FGForce::SetLocationZ); } ! //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --- 171,189 ---- &FGForce::GetLocationZ, &FGForce::SetLocationZ); } ! ! //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! ! void FGExternalForce::setMoment(Element *el) ! { ! FGPropertyManager* PropertyManager = fdmex->GetPropertyManager(); ! Name = el->GetAttributeValue("name"); ! string BasePropertyName = "external_reactions/" + Name; ! ! momentDirection = FGPropertyVector3(PropertyManager, BasePropertyName, ! "l", "m", "n"); ! momentMagnitude = bind(el, PropertyManager, BasePropertyName + "/magnitude-lbsft", ! momentDirection); ! } ! //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% *************** *** 162,165 **** --- 191,195 ---- { delete forceMagnitude; + delete momentMagnitude; Debug(1); } *************** *** 169,173 **** const FGColumnVector3& FGExternalForce::GetBodyForces(void) { ! vFn = forceMagnitude->GetValue() * forceDirection; return FGForce::GetBodyForces(); } --- 199,208 ---- const FGColumnVector3& FGExternalForce::GetBodyForces(void) { ! if (forceMagnitude) ! vFn = forceMagnitude->GetValue() * forceDirection; ! ! if (momentMagnitude) ! vMn = Transform() * (momentMagnitude->GetValue() * momentDirection); ! return FGForce::GetBodyForces(); } Index: FGExternalForce.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGExternalForce.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** FGExternalForce.h 4 Jun 2017 17:39:57 -0000 1.18 --- FGExternalForce.h 4 Jun 2017 21:06:08 -0000 1.19 *************** *** 66,71 **** %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ ! /** Encapsulates code that models an individual arbitrary force. ! This class encapsulates an individual force applied at the specified location on the vehicle, and oriented as specified in one of three frames: --- 66,71 ---- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ ! /** Encapsulates code that models an individual arbitrary force, moment or a combination thereof. ! This class encapsulates an individual reaction applied at the specified location on the vehicle, and oriented as specified in one of three frames: *************** *** 106,109 **** --- 106,134 ---- @endcode + The location of the force vector, in structural coordinates, can be set at + runtime through the following properties: + + @code + external_reactions/{force name}/location-x-in + external_reactions/{force name}/location-y-in + external_reactions/{force name}/location-z-in + @endcode + + The XML definition of a moment (optional items are in []) is a bit simpler + because you do not need to specify the location: + + @code + <moment name="name" frame="BODY | LOCAL | WIND"> + + [<function> ... </function>] + + [<direction> <!-- optional initial direction vector --> + <x> {number} </x> + <y> {number} </y> + <z> {number} </z> + </direction>] + </moment> + @endcode + The initial direction can optionally be set by specifying a unit vector in the chosen frame (body, local, or wind). *************** *** 114,123 **** those could be handled in the calling application. ! The force direction is not actually required to be specified as a unit ! vector, but prior to the force vector being calculated, the direction ! vector is normalized when initialized. ! The direction can be specified at runtime through setting any/all of the ! following properties: @code --- 139,148 ---- those could be handled in the calling application. ! The force (or moment) direction is not actually required to be specified as ! a unit vector, but prior to the force (or moment) vector being calculated, ! the direction vector is normalized when initialized. ! The force direction can be specified at runtime through setting any/all of ! the following properties: @code *************** *** 127,133 **** @endcode However in that case, the direction is no longer normalized. ! When no <function> has been provided in the definition, the force magnitude can be specified through the following property: --- 152,167 ---- @endcode + The moment direction can be specified at runtime through setting any/all of + the following properties: + + @code + external_reactions/{moment name}/l + external_reactions/{moment name}/m + external_reactions/{moment name}/n + @endcode + However in that case, the direction is no longer normalized. ! When no <function> has been provided in the force definition, its magnitude can be specified through the following property: *************** *** 136,148 **** @endcode ! The location of the force vector, in structural coordinates, can be set at ! runtime through the following properties: @code ! external_reactions/{force name}/location-x-in ! external_reactions/{force name}/location-y-in ! external_reactions/{force name}/location-z-in @endcode - */ --- 170,179 ---- @endcode ! When no <function> has been provided in the moment definition, its magnitude ! can be specified through the following property: @code ! external_reactions/{moment name}/magnitude-lbsft @endcode */ *************** *** 190,194 **** @param el pointer to the XML element defining an individual force. */ ! FGExternalForce(FGFDMExec *FDMExec) : FGForce(FDMExec) { Debug(0); } /** Copy Constructor --- 221,227 ---- @param el pointer to the XML element defining an individual force. */ ! FGExternalForce(FGFDMExec *FDMExec) ! : FGForce(FDMExec), forceMagnitude(NULL), momentMagnitude(NULL) ! { Debug(0); } /** Copy Constructor *************** *** 201,204 **** --- 234,238 ---- void setForce(Element* el); + void setMoment(Element* el); const FGColumnVector3& GetBodyForces(void); *************** *** 208,213 **** std::string Name; ! FGParameter* forceMagnitude; ! FGPropertyVector3 forceDirection; void Debug(int from); }; --- 242,247 ---- std::string Name; ! FGParameter *forceMagnitude, *momentMagnitude; ! FGPropertyVector3 forceDirection, momentDirection; void Debug(int from); }; Index: FGExternalReactions.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGExternalReactions.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** FGExternalReactions.cpp 4 Jun 2017 17:39:57 -0000 1.24 --- FGExternalReactions.cpp 4 Jun 2017 21:06:08 -0000 1.25 *************** *** 87,90 **** --- 87,99 ---- } + // Parse moment elements + + Element* moment_element = el->FindElement("moment"); + while (moment_element) { + Forces.push_back(new FGExternalForce(FDMExec)); + Forces.back()->setMoment(moment_element); + moment_element = el->FindNextElement("moment"); + } + PostLoad(el, PropertyManager); Index: FGExternalReactions.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGExternalReactions.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** FGExternalReactions.h 3 Jun 2017 19:49:20 -0000 1.19 --- FGExternalReactions.h 4 Jun 2017 21:06:08 -0000 1.20 *************** *** 62,75 **** %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ ! /** Manages the external and/or arbitrary forces. The external reactions capability in JSBSim really should be named ! "arbitrary forces", because this feature can be used to model a wide ! variety of forces that act on a vehicle. Some examples include: parachutes, ! catapult, arresting hook, and tow line. ! ! This class acts similarly to the other "manager classes" (FGPropulsion, ! FGFCS, FGGroundReactions, FGAerodynamics) because it manages collections ! of constituent forces. The individual forces are implemented with the ! FGExternalForce class. The format of the <em>optional</em> external reactions section in the config --- 62,76 ---- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ ! /** Manages the external and/or arbitrary forces and moments. ! The external reactions capability in JSBSim really should be named ! "arbitrary forces and moments", because this feature can be used to model a ! wide variety of forces and moments that act on a vehicle. Some examples ! include: parachutes, catapult, arresting hook, and tow line. ! ! This class acts similarly to the other "manager classes" (FGPropulsion, ! FGFCS, FGGroundReactions, FGAerodynamics) because it manages collections of ! constituent elements. The individual forces and moments are implemented with ! the FGExternalForce class. The format of the <em>optional</em> external reactions section in the config *************** *** 82,93 **** <property> ... </property> ! <force name="name" frame="BODY | LOCAL | WIND" unit="unit"> ... </force> ! <!-- Additional force definitions may follow --> ! <force name="name" frame="BODY | LOCAL | WIND" unit="unit"> ... </force> </external_reactions> --- 83,100 ---- <property> ... </property> ! <force name="name" frame="BODY | LOCAL | WIND"> ... </force> + <moment name="name" frame="BODY | LOCAL | WIND"> + ... + </moment> ! <!-- Additional force and moment definitions may follow --> ! <force name="name" frame="BODY | LOCAL | WIND"> ... </force> + <moment name="name" frame="BODY | LOCAL | WIND"> + ... + </moment> </external_reactions> *************** *** 95,114 **** See the FGExternalForce class for more information on the format of the ! force specification itself. ! When force elements are encountered in the configuration file, a new instance ! of the FGExternalForce class is created and a pointer to the class is pushed ! onto the Forces vector. ! This class is one of a few of the manager classes that allows properties ! to be "declared". In code, these are represented by the <em>interface_properties</em> vector. Properties that have not yet been created in an already parsed section of the configuration file and that are ! used in the definition of an external force should be declared in the ! external_reactions section because they will not be created automatically, ! and so would cause an error, since the property cannot be found to exist. ! See the FGExternalForce documentation for details on how forces are ! actually calculated. */ --- 102,122 ---- See the FGExternalForce class for more information on the format of the ! force and moment specifications. ! When force or moment elements are encountered in the configuration file, a ! new instance of the FGExternalForce class is created and a pointer to the ! class is pushed onto the Forces vector. ! This class is one of a few of the manager classes that allows properties to ! be "declared". In code, these are represented by the <em>interface_properties</em> vector. Properties that have not yet been created in an already parsed section of the configuration file and that are ! used in the definition of an external force or moment should be declared in ! the external_reactions section because they will not be created ! automatically, and so would cause an error, since the property cannot be ! found to exist. ! See the FGExternalForce documentation for details on how forces and moments ! are actually calculated. */ |