X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGAircraft.cpp;h=a433a56fa8812e30cc3657666452b5864c00a6af;hb=1575fad886a0b18825363d41d53a287e8d36b9c8;hp=fd6f9fce36f3a7336b6ce3648a49b5b47efc268f;hpb=932b38a87e2870d23f9be9461b551f1e1fe556ba;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGAircraft.cpp b/src/FDM/JSBSim/models/FGAircraft.cpp index fd6f9fce3..a433a56fa 100644 --- a/src/FDM/JSBSim/models/FGAircraft.cpp +++ b/src/FDM/JSBSim/models/FGAircraft.cpp @@ -6,23 +6,23 @@ Purpose: Encapsulates an aircraft Called by: FGFDMExec - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- + ------------- Copyright (C) 1999 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 @@ -40,33 +40,14 @@ INCLUDES #include #include - -#ifdef FGFS -# ifndef __BORLANDC__ -# include -# endif -# ifdef SG_HAVE_STD_INCLUDES -# include -# else -# include -# endif -#else -# if defined (sgi) && !defined(__GNUC__) -# include -# else -# include -# endif -#endif +#include +#include #include "FGAircraft.h" -#include "FGMassBalance.h" -#include "FGInertial.h" -#include "FGGroundReactions.h" -#include "FGAerodynamics.h" -#include -#include -#include "FGPropagate.h" -#include +#include "FGFDMExec.h" +#include "input_output/FGPropertyManager.h" + +using namespace std; namespace JSBSim { @@ -78,7 +59,7 @@ DEFINITIONS GLOBAL DATA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -static const char *IdSrc = "$Id$"; +static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.33 2011/08/21 15:06:38 bcoconni Exp $"; static const char *IdHdr = ID_AIRCRAFT; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -89,11 +70,14 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex) { Name = "FGAircraft"; WingSpan = 0.0; + WingArea = 0.0; + cbar = 0.0; HTailArea = VTailArea = 0.0; HTailArm = VTailArm = 0.0; lbarh = lbarv = 0.0; vbarh = vbarv = 0.0; WingIncidence = 0.0; + HoldDown = 0; bind(); @@ -104,44 +88,48 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex) FGAircraft::~FGAircraft() { - unbind(); Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGAircraft::Run(void) +bool FGAircraft::InitModel(void) { - if (FGModel::Run()) return true; - if (FDMExec->Holding()) return false; - - vForces.InitMatrix(); - vForces += Aerodynamics->GetForces(); - vForces += Propulsion->GetForces(); - vForces += GroundReactions->GetForces(); + return true; +} - vMoments.InitMatrix(); - vMoments += Aerodynamics->GetMoments(); - vMoments += Propulsion->GetMoments(); - vMoments += GroundReactions->GetMoments(); +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// printf("%s:%i\n", __FILE__, __LINE__); - vBodyAccel = vForces/MassBalance->GetMass(); +bool FGAircraft::Run(bool Holding) +{ + if (FGModel::Run(Holding)) return true; + if (Holding) return false; -// printf("%s:%i\n", __FILE__, __LINE__); - vNcg = vBodyAccel/Inertial->gravity(); + RunPreFunctions(); - vNwcg = State->GetTb2s() * vNcg; - vNwcg(3) = -1*vNwcg(3) + 1; + vForces.InitMatrix(); + if (!HoldDown) { + vForces += in.AeroForce; + vForces += in.PropForce; + vForces += in.GroundForce; + vForces += in.ExternalForce; + vForces += in.BuoyantForce; + } else { + vForces = in.Tl2b * FGColumnVector3(0,0,-in.Weight); + } - return false; -} + vMoments.InitMatrix(); + if (!HoldDown) { + vMoments += in.AeroMoment; + vMoments += in.PropMoment; + vMoments += in.GroundMoment; + vMoments += in.ExternalMoment; + vMoments += in.BuoyantMoment; + } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + RunPostFunctions(); -double FGAircraft::GetNlf(void) -{ - return -1*Aerodynamics->GetvFs(3)/MassBalance->GetWeight(); + return false; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -151,6 +139,8 @@ bool FGAircraft::Load(Element* el) string element_name; Element* element; + FGModel::Load(el); + if (el->FindElement("wingarea")) WingArea = el->FindElementValueAsNumberConvertTo("wingarea", "FT2"); if (el->FindElement("wingspan")) @@ -158,7 +148,7 @@ bool FGAircraft::Load(Element* el) if (el->FindElement("chord")) cbar = el->FindElementValueAsNumberConvertTo("chord", "FT"); if (el->FindElement("wing_incidence")) - WingIncidence = el->FindElementValueAsNumberConvertTo("wing_incidence", "DEG"); + WingIncidence = el->FindElementValueAsNumberConvertTo("wing_incidence", "RAD"); if (el->FindElement("htailarea")) HTailArea = el->FindElementValueAsNumberConvertTo("htailarea", "FT2"); if (el->FindElement("htailarm")) @@ -188,10 +178,12 @@ bool FGAircraft::Load(Element* el) lbarv = VTailArm/cbar; if (WingArea != 0.0) { vbarh = HTailArm*HTailArea / (cbar*WingArea); - vbarv = VTailArm*VTailArea / (cbar*WingArea); + vbarv = VTailArm*VTailArea / (WingSpan*WingArea); } } + PostLoad(el, PropertyManager); + Debug(2); return true; @@ -202,10 +194,11 @@ bool FGAircraft::Load(Element* el) void FGAircraft::bind(void) { typedef double (FGAircraft::*PMF)(int) const; - PropertyManager->Tie("metrics/Sw-sqft", this, &FGAircraft::GetWingArea); + PropertyManager->Tie("metrics/Sw-sqft", this, &FGAircraft::GetWingArea, &FGAircraft::SetWingArea); PropertyManager->Tie("metrics/bw-ft", this, &FGAircraft::GetWingSpan); PropertyManager->Tie("metrics/cbarw-ft", this, &FGAircraft::Getcbar); - PropertyManager->Tie("metrics/iw-deg", this, &FGAircraft::GetWingIncidence); + PropertyManager->Tie("metrics/iw-rad", this, &FGAircraft::GetWingIncidence); + PropertyManager->Tie("metrics/iw-deg", this, &FGAircraft::GetWingIncidenceDeg); PropertyManager->Tie("metrics/Sh-sqft", this, &FGAircraft::GetHTailArea); PropertyManager->Tie("metrics/lh-ft", this, &FGAircraft::GetHTailArm); PropertyManager->Tie("metrics/Sv-sqft", this, &FGAircraft::GetVTailArea); @@ -214,12 +207,6 @@ void FGAircraft::bind(void) PropertyManager->Tie("metrics/lv-norm", this, &FGAircraft::Getlbarv); PropertyManager->Tie("metrics/vbarh-norm", this, &FGAircraft::Getvbarh); PropertyManager->Tie("metrics/vbarv-norm", this, &FGAircraft::Getvbarv); - PropertyManager->Tie("moments/l-total-lbsft", this, eL, (PMF)&FGAircraft::GetMoments); - PropertyManager->Tie("moments/m-total-lbsft", this, eM, (PMF)&FGAircraft::GetMoments); - PropertyManager->Tie("moments/n-total-lbsft", this, eN, (PMF)&FGAircraft::GetMoments); - PropertyManager->Tie("forces/fbx-total-lbs", this, eX, (PMF)&FGAircraft::GetForces); - PropertyManager->Tie("forces/fby-total-lbs", this, eY, (PMF)&FGAircraft::GetForces); - PropertyManager->Tie("forces/fbz-total-lbs", this, eZ, (PMF)&FGAircraft::GetForces); PropertyManager->Tie("metrics/aero-rp-x-in", this, eX, (PMF)&FGAircraft::GetXYZrp); PropertyManager->Tie("metrics/aero-rp-y-in", this, eY, (PMF)&FGAircraft::GetXYZrp); PropertyManager->Tie("metrics/aero-rp-z-in", this, eZ, (PMF)&FGAircraft::GetXYZrp); @@ -229,39 +216,7 @@ void FGAircraft::bind(void) PropertyManager->Tie("metrics/visualrefpoint-x-in", this, eX, (PMF)&FGAircraft::GetXYZvrp); PropertyManager->Tie("metrics/visualrefpoint-y-in", this, eY, (PMF)&FGAircraft::GetXYZvrp); PropertyManager->Tie("metrics/visualrefpoint-z-in", this, eZ, (PMF)&FGAircraft::GetXYZvrp); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGAircraft::unbind(void) -{ - PropertyManager->Untie("metrics/Sw-sqft"); - PropertyManager->Untie("metrics/bw-ft"); - PropertyManager->Untie("metrics/cbarw-ft"); - PropertyManager->Untie("metrics/iw-deg"); - PropertyManager->Untie("metrics/Sh-sqft"); - PropertyManager->Untie("metrics/lh-ft"); - PropertyManager->Untie("metrics/Sv-sqft"); - PropertyManager->Untie("metrics/lv-ft"); - PropertyManager->Untie("metrics/lh-norm"); - PropertyManager->Untie("metrics/lv-norm"); - PropertyManager->Untie("metrics/vbarh-norm"); - PropertyManager->Untie("metrics/vbarv-norm"); - PropertyManager->Untie("moments/l-total-lbsft"); - PropertyManager->Untie("moments/m-total-lbsft"); - PropertyManager->Untie("moments/n-total-lbsft"); - PropertyManager->Untie("forces/fbx-total-lbs"); - PropertyManager->Untie("forces/fby-total-lbs"); - PropertyManager->Untie("forces/fbz-total-lbs"); - PropertyManager->Untie("metrics/aero-rp-x-in"); - PropertyManager->Untie("metrics/aero-rp-y-in"); - PropertyManager->Untie("metrics/aero-rp-z-in"); - PropertyManager->Untie("metrics/eyepoint-x-in"); - PropertyManager->Untie("metrics/eyepoint-y-in"); - PropertyManager->Untie("metrics/eyepoint-z-in"); - PropertyManager->Untie("metrics/visualrefpoint-x-in"); - PropertyManager->Untie("metrics/visualrefpoint-y-in"); - PropertyManager->Untie("metrics/visualrefpoint-z-in"); + PropertyManager->Tie("forces/hold-down", this, &FGAircraft::GetHoldDown, &FGAircraft::SetHoldDown); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%