JSBSim Flight Dynamics Model 1.0 (23 February 2013)
An Open Source Flight Dynamics and Control Software Library in C++

FGExternalReactions Class Reference

Manages the external and/or arbitrary forces. More...

#include <FGExternalReactions.h>

Inheritance diagram for FGExternalReactions:
Collaboration diagram for FGExternalReactions:

List of all members.

Public Member Functions

 FGExternalReactions (FGFDMExec *fdmex)
 Constructor.
 ~FGExternalReactions (void)
 Destructor.
const FGColumnVector3GetForces (void) const
 Retrieves the total forces defined in the external reactions.
double GetForces (int idx) const
double GetMoments (int idx) const
const FGColumnVector3GetMoments (void) const
 Retrieves the total moment resulting from the forces defined in the external reactions.
bool InitModel (void)
bool Load (Element *el)
 Loads the external forces from the XML configuration file.
bool Run (bool Holding)
 Sum all the constituent forces for this cycle.

Detailed Description

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 optional external reactions section in the config file is as follows:

<external_reactions>

  <!-- Interface properties, a.k.a. property declarations -->
  <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>

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 interface_properties 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.

Definition at line 120 of file FGExternalReactions.h.


Constructor & Destructor Documentation

Parameters:
fdmexpointer to the main executive class.

Definition at line 63 of file FGExternalReactions.cpp.

                                                         : FGModel(fdmex)
{
  NoneDefined = true;

  Debug(0);
}
~FGExternalReactions ( void  )

Within the destructor the Forces and interface_properties vectors are cleared out and the items pointed to are deleted.

Definition at line 106 of file FGExternalReactions.cpp.

{
  for (unsigned int i=0; i<Forces.size(); i++) delete Forces[i];
  Forces.clear();

  Debug(1);
}

Member Function Documentation

const FGColumnVector3& GetForces ( void  ) const [inline]
Returns:
the total force in pounds.

Definition at line 156 of file FGExternalReactions.h.

{return vTotalForces;}
const FGColumnVector3& GetMoments ( void  ) const [inline]
Returns:
the total moment in foot-pounds.

Definition at line 162 of file FGExternalReactions.h.

{return vTotalMoments;}
bool Load ( Element el) [virtual]

If the external_reactions section is encountered in the vehicle configuration file, this Load() method is called. All external forces will be parsed, and a FGExternalForce object will be instantiated for each force definition.

Parameters:
ela pointer to the XML element holding the external reactions definition.

Reimplemented from FGModel.

Definition at line 72 of file FGExternalReactions.cpp.

References Element::FindElement(), Element::FindNextElement(), Element::GetAttributeValue(), and FGFDMExec::GetFullAircraftPath().

{
  // check if a file attribute was specified
  string fname = el->GetAttributeValue("file");
  if (!fname.empty()) {
    string file = FDMExec->GetFullAircraftPath() + "/" + fname;
    el = LoadXMLDocument(file);
    if (el == 0L) return false;
  }

  FGModel::Load(el); // Call the base class Load() function to load interface properties.

  Debug(2);

  // Parse force elements

  int index=0;
  Element* force_element = el->FindElement("force");
  while (force_element) {
    Forces.push_back( new FGExternalForce(FDMExec, force_element, index) );
    NoneDefined = false;
    index++; 
    force_element = el->FindNextElement("force");
  }

  PostLoad(el, PropertyManager);

  if (!NoneDefined) bind();

  return true;
}

Here is the call graph for this function:

bool Run ( bool  Holding) [virtual]

Can pass in a value indicating if the executive is directing the simulation to Hold.

Parameters:
Holdingif true, the executive has been directed to hold the sim from advancing time. Some models may ignore this flag, such as the Input model, which may need to be active to listen on a socket for the "Resume" command to be given.
Returns:
true always.

Reimplemented from FGModel.

Definition at line 123 of file FGExternalReactions.cpp.

References FGModel::Run().

{
  if (FGModel::Run(Holding)) return true;
  if (Holding) return false; // if paused don't execute
  if (NoneDefined) return true;

  RunPreFunctions();

  vTotalForces.InitMatrix();
  vTotalMoments.InitMatrix();

  for (unsigned int i=0; i<Forces.size(); i++) {
    vTotalForces  += Forces[i]->GetBodyForces();
    vTotalMoments += Forces[i]->GetMoments();
  }

  RunPostFunctions();

  return false;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files: