Date started: 09/13/00
Purpose: Encapsulates the ground reaction forces (gear and collision)
- ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
#include <iomanip>
#include "FGGroundReactions.h"
-#include <input_output/FGPropertyManager.h>
+#include "FGLGear.h"
+#include "input_output/FGPropertyManager.h"
+
+using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.39 2012/04/01 17:05:51 bcoconni Exp $";
static const char *IdHdr = ID_GROUNDREACTIONS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex)
{
Name = "FGGroundReactions";
FGGroundReactions::~FGGroundReactions(void)
{
- for (int i=0; i<lGear.size();i++) lGear[i].unbind();
+ for (unsigned int i=0; i<lGear.size();i++) delete lGear[i];
lGear.clear();
- unbind();
Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGGroundReactions::Run(void)
+bool FGGroundReactions::InitModel(void)
{
- if (FGModel::Run()) return true;
- if (FDMExec->Holding()) return false;
+ return true;
+}
- vForces.InitMatrix();
- vMoments.InitMatrix();
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- if ( Propagate->GetDistanceAGL() < 300.0 ) { // Only execute gear code below 300 feet
- vector <FGLGear>::iterator iGear = lGear.begin();
+bool FGGroundReactions::Run(bool Holding)
+{
+ if (FGModel::Run(Holding)) return true;
+ if (Holding) return false;
- // Sum forces and moments for all gear, here.
- // Some optimizations may be made here - or rather in the gear code itself.
- // The gear ::Run() method is called several times - once for each gear.
- // Perhaps there is some commonality for things which only need to be
- // calculated once.
+ RunPreFunctions();
- while (iGear != lGear.end()) {
- vForces += iGear->Force();
- vMoments += iGear->Moment();
- iGear++;
- }
+ vForces.InitMatrix();
+ vMoments.InitMatrix();
+ multipliers.clear();
+
+ // Sum forces and moments for all gear, here.
+ // Some optimizations may be made here - or rather in the gear code itself.
+ // The gear ::Run() method is called several times - once for each gear.
+ // Perhaps there is some commonality for things which only need to be
+ // calculated once.
+ for (unsigned int i=0; i<lGear.size(); i++) {
+ vForces += lGear[i]->GetBodyForces();
+ vMoments += lGear[i]->GetMoments();
}
+ RunPostFunctions();
+
return false;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGGroundReactions::GetWOW(void)
+bool FGGroundReactions::GetWOW(void) const
{
bool result = false;
- for (int i=0; i<lGear.size(); i++) {
- if (lGear[i].IsBogey() && lGear[i].GetWOW()) {
+ for (unsigned int i=0; i<lGear.size(); i++) {
+ if (lGear[i]->IsBogey() && lGear[i]->GetWOW()) {
result = true;
break;
}
Debug(2);
+ unsigned int numContacts = el->GetNumElements("contact");
+ lGear.resize(numContacts);
Element* contact_element = el->FindElement("contact");
- while (contact_element) {
- lGear.push_back(FGLGear(contact_element, FDMExec, num++));
- FCS->AddGear(); // make the FCS aware of the landing gear
+ for (unsigned int idx=0; idx<numContacts; idx++) {
+ lGear[idx] = new FGLGear(contact_element, FDMExec, num++, in);
contact_element = el->FindNextElement("contact");
}
- for (int i=0; i<lGear.size();i++) lGear[i].bind();
+ FGModel::Load(el); // Perform base class Load
+
+ for (unsigned int i=0; i<lGear.size();i++) lGear[i]->bind();
+
+ PostLoad(el, PropertyManager);
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGGroundReactions::GetGroundReactionStrings(string delimeter)
+string FGGroundReactions::GetGroundReactionStrings(string delimeter) const
{
std::ostringstream buf;
for (unsigned int i=0;i<lGear.size();i++) {
- string name = lGear[i].GetName();
- buf << name << "_WOW" << delimeter
- << name << "_stroke" << delimeter
- << name << "_strokeVel" << delimeter
- << name << "_CompressForce" << delimeter
- << name << "_WhlSideForce" << delimeter
- << name << "_WhlVelVecX" << delimeter
- << name << "_WhlVelVecY" << delimeter
- << name << "_WhlRollForce" << delimeter
- << name << "_BodyXForce" << delimeter
- << name << "_BodyYForce" << delimeter
- << name << "_WhlSlipDegrees" << delimeter;
+ if (lGear[i]->IsBogey()) {
+ string name = lGear[i]->GetName();
+ buf << name << " WOW" << delimeter
+ << name << " stroke (ft)" << delimeter
+ << name << " stroke velocity (ft/sec)" << delimeter
+ << name << " compress force (lbs)" << delimeter
+ << name << " wheel side force (lbs)" << delimeter
+ << name << " wheel roll force (lbs)" << delimeter
+ << name << " body X force (lbs)" << delimeter
+ << name << " body Y force (lbs)" << delimeter
+ << name << " wheel velocity vec X (ft/sec)" << delimeter
+ << name << " wheel velocity vec Y (ft/sec)" << delimeter
+ << name << " wheel rolling velocity (ft/sec)" << delimeter
+ << name << " wheel side velocity (ft/sec)" << delimeter
+ << name << " wheel slip (deg)" << delimeter;
+ }
}
- buf << "TotalGearForce_X" << delimeter
- << "TotalGearForce_Y" << delimeter
- << "TotalGearForce_Z" << delimeter
- << "TotalGearMoment_L" << delimeter
- << "TotalGearMoment_M" << delimeter
- << "TotalGearMoment_N";
+ buf << " Total Gear Force_X (lbs)" << delimeter
+ << " Total Gear Force_Y (lbs)" << delimeter
+ << " Total Gear Force_Z (lbs)" << delimeter
+ << " Total Gear Moment_L (ft-lbs)" << delimeter
+ << " Total Gear Moment_M (ft-lbs)" << delimeter
+ << " Total Gear Moment_N (ft-lbs)";
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGGroundReactions::GetGroundReactionValues(string delimeter)
+string FGGroundReactions::GetGroundReactionValues(string delimeter) const
{
std::ostringstream buf;
for (unsigned int i=0;i<lGear.size();i++) {
- FGLGear& gear = lGear[i];
- buf << (gear.GetWOW() ? "1, " : "0, ")
- << setprecision(5) << gear.GetCompLen() << delimeter
- << setprecision(6) << gear.GetCompVel() << delimeter
- << setprecision(10) << gear.GetCompForce() << delimeter
- << setprecision(6) << gear.GetWheelVel(eX) << delimeter
- << gear.GetWheelVel(eY) << delimeter
- << gear.GetWheelSideForce() << delimeter
- << gear.GetWheelRollForce() << delimeter
- << gear.GetBodyXForce() << delimeter
- << gear.GetBodyYForce() << delimeter
- << gear.GetWheelSlipAngle() << delimeter;
+ if (lGear[i]->IsBogey()) {
+ FGLGear *gear = lGear[i];
+ buf << (gear->GetWOW() ? "1" : "0") << delimeter
+ << setprecision(5) << gear->GetCompLen() << delimeter
+ << setprecision(6) << gear->GetCompVel() << delimeter
+ << setprecision(10) << gear->GetCompForce() << delimeter
+ << gear->GetWheelSideForce() << delimeter
+ << gear->GetWheelRollForce() << delimeter
+ << gear->GetBodyXForce() << delimeter
+ << gear->GetBodyYForce() << delimeter
+ << setprecision(6) << gear->GetWheelVel(eX) << delimeter
+ << gear->GetWheelVel(eY) << delimeter
+ << gear->GetWheelRollVel() << delimeter
+ << gear->GetWheelSideVel() << delimeter
+ << gear->GetWheelSlipAngle() << delimeter;
+ }
}
buf << vForces(eX) << delimeter
{
typedef double (FGGroundReactions::*PMF)(int) const;
PropertyManager->Tie("gear/num-units", this, &FGGroundReactions::GetNumGearUnits);
- PropertyManager->Tie("moments/l-gear-lbsft", this, eL, (PMF)&FGGroundReactions::GetMoments);
- PropertyManager->Tie("moments/m-gear-lbsft", this, eM, (PMF)&FGGroundReactions::GetMoments);
- PropertyManager->Tie("moments/n-gear-lbsft", this, eN, (PMF)&FGGroundReactions::GetMoments);
- PropertyManager->Tie("forces/fbx-gear-lbs", this, eX, (PMF)&FGGroundReactions::GetForces);
- PropertyManager->Tie("forces/fby-gear-lbs", this, eY, (PMF)&FGGroundReactions::GetForces);
- PropertyManager->Tie("forces/fbz-gear-lbs", this, eZ, (PMF)&FGGroundReactions::GetForces);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGGroundReactions::unbind(void)
-{
- PropertyManager->Untie("gear/num-units");
- PropertyManager->Untie("moments/l-gear-lbsft");
- PropertyManager->Untie("moments/m-gear-lbsft");
- PropertyManager->Untie("moments/n-gear-lbsft");
- PropertyManager->Untie("forces/fbx-gear-lbs");
- PropertyManager->Untie("forces/fby-gear-lbs");
- PropertyManager->Untie("forces/fbz-gear-lbs");
+ PropertyManager->Tie("gear/wow", this, &FGGroundReactions::GetWOW);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%