]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGAircraft.cpp
Make yasim accept the launchbar and hook properties. They are not tied to anything...
[flightgear.git] / src / FDM / JSBSim / FGAircraft.cpp
index f3e242b326b001f5ecd0c258805c83c1f2ab57c5..aa56cc7e8361de13d9e0d307cb108e596850a11a 100644 (file)
@@ -1,49 +1,49 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
  Module:       FGAircraft.cpp
  Author:       Jon S. Berndt
- Date started: 12/12/98                                   
+ Date started: 12/12/98
  Purpose:      Encapsulates an aircraft
  Called by:    FGFDMExec
 
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.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
  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
  details.
+
  You should have received a copy of the GNU 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
  the world wide web at http://www.gnu.org.
+
 FUNCTIONAL DESCRIPTION
 --------------------------------------------------------------------------------
 Models the aircraft reactions and forces. This class is instantiated by the
-FGFDMExec class and scheduled as an FDM entry. 
+FGFDMExec class and scheduled as an FDM entry.
+
 HISTORY
 --------------------------------------------------------------------------------
 12/12/98   JSB   Created
 04/03/99   JSB   Changed Aero() method to correct body axis force calculation
                  from wind vector. Fix provided by Tony Peden.
 05/03/99   JSB   Changed (for the better?) the way configurations are read in.
-9/17/99     TP   Combined force and moment functions. Added aero reference 
-                 point to config file. Added calculations for moments due to 
+9/17/99     TP   Combined force and moment functions. Added aero reference
+                 point to config file. Added calculations for moments due to
                  difference in cg and aero reference point
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 COMMENTS, REFERENCES,  and NOTES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -73,17 +73,13 @@ INCLUDES
 #include "FGInertial.h"
 #include "FGGroundReactions.h"
 #include "FGAerodynamics.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGAtmosphere.h"
 #include "FGState.h"
 #include "FGFDMExec.h"
-#include "FGFCS.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
+#include "FGPropagate.h"
 #include "FGPropertyManager.h"
 
+namespace JSBSim {
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -101,14 +97,13 @@ CLASS IMPLEMENTATION
 
 FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
 {
-  
   Name = "FGAircraft";
-  alphaclmin = alphaclmax = 0;
-  HTailArea = VTailArea = HTailArm = VTailArm = 0.0;
-  lbarh = lbarv = vbarh = vbarv = 0.0;
-  WingIncidence=0;
-  impending_stall = 0;
-  bi2vel=ci2vel=alphaw=0;
+  WingSpan = 0.0;
+  HTailArea = VTailArea = 0.0;
+  HTailArm  = VTailArm  = 0.0;
+  lbarh = lbarv = 0.0;
+  vbarh = vbarv = 0.0;
+  WingIncidence = 0.0;
 
   bind();
 
@@ -127,12 +122,9 @@ FGAircraft::~FGAircraft()
 
 bool FGAircraft::Run(void)
 {
-  double twovel;
-  
   if (!FGModel::Run()) {                 // if false then execute this Run()
     vForces.InitMatrix();
     vForces += Aerodynamics->GetForces();
-    vForces += Inertial->GetForces();
     vForces += Propulsion->GetForces();
     vForces += GroundReactions->GetForces();
 
@@ -140,30 +132,14 @@ bool FGAircraft::Run(void)
     vMoments += Aerodynamics->GetMoments();
     vMoments += Propulsion->GetMoments();
     vMoments += GroundReactions->GetMoments();
-    
+
     vBodyAccel = vForces/MassBalance->GetMass();
-    
+
     vNcg = vBodyAccel/Inertial->gravity();
 
     vNwcg = State->GetTb2s() * vNcg;
     vNwcg(3) = -1*vNwcg(3) + 1;
-    
-    twovel=2*Translation->GetVt();
-    if(twovel > 0) {
-      bi2vel = WingSpan / twovel;
-      ci2vel = cbar / twovel;
-    }  
-    
-    alphaw = Translation->Getalpha() + WingIncidence;
-    
-    if (alphaclmax != 0) {
-      if (Translation->Getalpha() > 0.85*alphaclmax) {
-        impending_stall = 10*(Translation->Getalpha()/alphaclmax - 0.85);
-      } else {
-        impending_stall = 0;
-      }
-    }      
-    
+
     return false;
   } else {                               // skip Run() execution this time
     return true;
@@ -183,10 +159,12 @@ bool FGAircraft::Load(FGConfigFile* AC_cfg)
 {
   string token = "";
   string parameter;
-  double EW, bixx, biyy, bizz, bixy, bixz;
+  double EW, bixx, biyy, bizz, bixy, bixz, biyz;
   double pmWt, pmX, pmY, pmZ;
   FGColumnVector3 vbaseXYZcg;
 
+  bixx = biyy = bizz = bixy = bixz = biyz = 0.0;
+
   AC_cfg->GetNextConfigLine();
 
   while ((token = AC_cfg->GetValue()) != string("/METRICS")) {
@@ -199,7 +177,7 @@ bool FGAircraft::Load(FGConfigFile* AC_cfg)
       if (debug_lvl > 0) cout << "    WingSpan: " << WingSpan  << endl;
     } else if (parameter == "AC_WINGINCIDENCE") {
       *AC_cfg >> WingIncidence;
-      if (debug_lvl > 0) cout << "    Chord: " << cbar << endl;
+      if (debug_lvl > 0) cout << "    Incidence: " << WingIncidence << endl;
     } else if (parameter == "AC_CHORD") {
       *AC_cfg >> cbar;
       if (debug_lvl > 0) cout << "    Chord: " << cbar << endl;
@@ -217,28 +195,26 @@ bool FGAircraft::Load(FGConfigFile* AC_cfg)
       if (debug_lvl > 0) cout << "    V. Tail Arm: " << VTailArm << endl;
     } else if (parameter == "AC_IXX") {
       *AC_cfg >> bixx;
-      if (debug_lvl > 0) cout << "    baseIxx: " << bixx << endl;
-      MassBalance->SetBaseIxx(bixx);
+      if (debug_lvl > 0) cout << "    baseIxx: " << bixx << " slug-ft2" << endl;
     } else if (parameter == "AC_IYY") {
       *AC_cfg >> biyy;
-      if (debug_lvl > 0) cout << "    baseIyy: " << biyy << endl;
-      MassBalance->SetBaseIyy(biyy);
+      if (debug_lvl > 0) cout << "    baseIyy: " << biyy << " slug-ft2" << endl;
     } else if (parameter == "AC_IZZ") {
       *AC_cfg >> bizz;
-      if (debug_lvl > 0) cout << "    baseIzz: " << bizz << endl;
-      MassBalance->SetBaseIzz(bizz);
+      if (debug_lvl > 0) cout << "    baseIzz: " << bizz << " slug-ft2" << endl;
     } else if (parameter == "AC_IXY") {
       *AC_cfg >> bixy;
-      if (debug_lvl > 0) cout << "    baseIxy: " << bixy  << endl;
-      MassBalance->SetBaseIxy(bixy);
+      if (debug_lvl > 0) cout << "    baseIxy: " << bixy << " slug-ft2" << endl;
     } else if (parameter == "AC_IXZ") {
       *AC_cfg >> bixz;
-      if (debug_lvl > 0) cout << "    baseIxz: " << bixz  << endl;
-      MassBalance->SetBaseIxz(bixz);
+      if (debug_lvl > 0) cout << "    baseIxz: " << bixz << " slug-ft2" << endl;
+    } else if (parameter == "AC_IYZ") {
+      *AC_cfg >> biyz;
+      if (debug_lvl > 0) cout << "    baseIyz: " << biyz << " slug-ft2" << endl;
     } else if (parameter == "AC_EMPTYWT") {
       *AC_cfg >> EW;
       MassBalance->SetEmptyWeight(EW);
-      if (debug_lvl > 0) cout << "    EmptyWeight: " << EW  << endl;
+      if (debug_lvl > 0) cout << "    EmptyWeight: " << EW << " lbm" << endl;
     } else if (parameter == "AC_CGLOC") {
       *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
       MassBalance->SetBaseCG(vbaseXYZcg);
@@ -249,11 +225,9 @@ bool FGAircraft::Load(FGConfigFile* AC_cfg)
     } else if (parameter == "AC_AERORP") {
       *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
       if (debug_lvl > 0) cout << "    Ref Pt (x, y, z): " << vXYZrp << endl;
-    } else if (parameter == "AC_ALPHALIMITS") {
-      *AC_cfg >> alphaclmin >> alphaclmax;
-      if (debug_lvl > 0) cout << "    Maximum Alpha: " << alphaclmax
-             << "    Minimum Alpha: " << alphaclmin
-             << endl;
+    } else if (parameter == "AC_VRP") {
+      *AC_cfg >> vXYZvrp(eX) >> vXYZvrp(eY) >> vXYZvrp(eZ);
+      if (debug_lvl > 0) cout << "    Visual Ref Pt (x, y, z): " << vXYZvrp << endl;
     } else if (parameter == "AC_POINTMASS") {
       *AC_cfg >> pmWt >> pmX >> pmY >> pmZ;
       MassBalance->AddPointMass(pmWt, pmX, pmY, pmZ);
@@ -262,7 +236,11 @@ bool FGAircraft::Load(FGConfigFile* AC_cfg)
                          << endl;
     }
   }
-  
+
+  MassBalance->SetAircraftBaseInertias(FGMatrix33(  bixx,  -bixy,  -bixz,
+                                                    -bixy,  biyy,  -biyz,
+                                                    -bixz,  -biyz,  bizz ));
+
   // calculate some derived parameters
   if (cbar != 0.0) {
     lbarh = HTailArm/cbar;
@@ -271,56 +249,15 @@ bool FGAircraft::Load(FGConfigFile* AC_cfg)
       vbarh = HTailArm*HTailArea / (cbar*WingArea);
       vbarv = VTailArm*VTailArea / (cbar*WingArea);
     }
-  }     
+  }
   return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-//    The bitmasked value choices are as follows:
-//    unset: In this case (the default) JSBSim would only print
-//       out the normally expected messages, essentially echoing
-//       the config files as they are read. If the environment
-//       variable is not set, debug_lvl is set to 1 internally
-//    0: This requests JSBSim not to output any messages
-//       whatsoever.
-//    1: This value explicity requests the normal JSBSim
-//       startup messages
-//    2: This value asks for a message to be printed out when
-//       a class is instantiated
-//    4: When this value is set, a message is displayed when a
-//       FGModel object executes its Run() method
-//    8: When this value is set, various runtime state variables
-//       are printed out periodically
-//    16: When set various parameters are sanity checked and
-//       a message is printed out when they go out of bounds
 
-void FGAircraft::Debug(int from)
+void FGAircraft::bind(void)
 {
-  if (debug_lvl <= 0) return;
-
-  if (debug_lvl & 1) { // Standard console startup message output
-    if (from == 0) { // Constructor
-    }
-  }
-  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
-    if (from == 0) cout << "Instantiated: FGAircraft" << endl;
-    if (from == 1) cout << "Destroyed:    FGAircraft" << endl;
-  }
-  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
-  }
-  if (debug_lvl & 8 ) { // Runtime state variables
-  }
-  if (debug_lvl & 16) { // Sanity checking
-  }
-  if (debug_lvl & 64) {
-    if (from == 0) { // Constructor
-      cout << IdSrc << endl;
-      cout << IdHdr << endl;
-    }
-  }
-}
-
-void FGAircraft::bind(void){
+  typedef double (FGAircraft::*PMF)(int) const;
   PropertyManager->Tie("metrics/Sw-sqft", this,
                        &FGAircraft::GetWingArea);
   PropertyManager->Tie("metrics/bw-ft", this,
@@ -346,48 +283,41 @@ void FGAircraft::bind(void){
   PropertyManager->Tie("metrics/vbarv-norm", this,
                        &FGAircraft::Getvbarv);
   PropertyManager->Tie("moments/l-total-lbsft", this,1,
-                       &FGAircraft::GetMoments);
+                       (PMF)&FGAircraft::GetMoments);
   PropertyManager->Tie("moments/m-total-lbsft", this,2,
-                       &FGAircraft::GetMoments);
+                       (PMF)&FGAircraft::GetMoments);
   PropertyManager->Tie("moments/n-total-lbsft", this,3,
-                       &FGAircraft::GetMoments);
+                       (PMF)&FGAircraft::GetMoments);
   PropertyManager->Tie("forces/fbx-total-lbs", this,1,
-                       &FGAircraft::GetForces);
+                       (PMF)&FGAircraft::GetForces);
   PropertyManager->Tie("forces/fby-total-lbs", this,2,
-                       &FGAircraft::GetForces);
+                       (PMF)&FGAircraft::GetForces);
   PropertyManager->Tie("forces/fbz-total-lbs", this,3,
-                       &FGAircraft::GetForces);
-  PropertyManager->Tie("metrics/aero-rp-x-ft", this,1,
-                       &FGAircraft::GetXYZrp);
-  PropertyManager->Tie("metrics/aero-rp-y-ft", this,2,
-                       &FGAircraft::GetXYZrp);
-  PropertyManager->Tie("metrics/aero-rp-z-ft", this,3,
-                       &FGAircraft::GetXYZrp);
-  PropertyManager->Tie("metrics/eyepoint-x-ft", this,1,
-                       &FGAircraft::GetXYZep);
-  PropertyManager->Tie("metrics/eyepoint-y-ft", this,2,
-                       &FGAircraft::GetXYZep);
-  PropertyManager->Tie("metrics/eyepoint-z-ft", this,3,
-                       &FGAircraft::GetXYZep);
-  PropertyManager->Tie("metrics/alpha-max-deg", this,
-                       &FGAircraft::GetAlphaCLMax,
-                       &FGAircraft::SetAlphaCLMax,
-                       true);
-  PropertyManager->Tie("metrics/alpha-min-deg", this,
-                       &FGAircraft::GetAlphaCLMin,
-                       &FGAircraft::SetAlphaCLMin,
-                       true);
-  PropertyManager->Tie("aero/bi2vel", this,
-                       &FGAircraft::GetBI2Vel);
-  PropertyManager->Tie("aero/ci2vel", this,
-                       &FGAircraft::GetCI2Vel);
-  PropertyManager->Tie("aero/alpha-wing-rad", this,
-                       &FGAircraft::GetAlphaW);
-  PropertyManager->Tie("systems/stall-warn-norm", this,
-                        &FGAircraft::GetStallWarn);
+                       (PMF)&FGAircraft::GetForces);
+  PropertyManager->Tie("metrics/aero-rp-x-in", this,1,
+                       (PMF)&FGAircraft::GetXYZrp);
+  PropertyManager->Tie("metrics/aero-rp-y-in", this,2,
+                       (PMF)&FGAircraft::GetXYZrp);
+  PropertyManager->Tie("metrics/aero-rp-z-in", this,3,
+                       (PMF)&FGAircraft::GetXYZrp);
+  PropertyManager->Tie("metrics/eyepoint-x-in", this,1,
+                       (PMF)&FGAircraft::GetXYZep);
+  PropertyManager->Tie("metrics/eyepoint-y-in", this,2,
+                       (PMF)&FGAircraft::GetXYZep);
+  PropertyManager->Tie("metrics/eyepoint-z-in", this,3,
+                       (PMF)&FGAircraft::GetXYZep);
+  PropertyManager->Tie("metrics/visualrefpoint-x-in", this,1,
+                       (PMF)&FGAircraft::GetXYZvrp);
+  PropertyManager->Tie("metrics/visualrefpoint-y-in", this,2,
+                       (PMF)&FGAircraft::GetXYZvrp);
+  PropertyManager->Tie("metrics/visualrefpoint-z-in", this,3,
+                       (PMF)&FGAircraft::GetXYZvrp);
 }
 
-void FGAircraft::unbind(void){
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGAircraft::unbind(void)
+{
   PropertyManager->Untie("metrics/Sw-sqft");
   PropertyManager->Untie("metrics/bw-ft");
   PropertyManager->Untie("metrics/cbarw-ft");
@@ -406,16 +336,60 @@ void FGAircraft::unbind(void){
   PropertyManager->Untie("forces/fbx-total-lbs");
   PropertyManager->Untie("forces/fby-total-lbs");
   PropertyManager->Untie("forces/fbz-total-lbs");
-  PropertyManager->Untie("metrics/aero-rp-x-ft");
-  PropertyManager->Untie("metrics/aero-rp-y-ft");
-  PropertyManager->Untie("metrics/aero-rp-z-ft");
-  PropertyManager->Untie("metrics/eyepoint-x-ft");
-  PropertyManager->Untie("metrics/eyepoint-y-ft");
-  PropertyManager->Untie("metrics/eyepoint-z-ft");
-  PropertyManager->Untie("metrics/alpha-max-deg");
-  PropertyManager->Untie("metrics/alpha-min-deg");
-  PropertyManager->Untie("aero/bi2vel");
-  PropertyManager->Untie("aero/ci2vel");
-  PropertyManager->Untie("aero/alpha-wing-rad");
-  PropertyManager->Untie("systems/stall-warn-norm");
+  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");
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//    The bitmasked value choices are as follows:
+//    unset: In this case (the default) JSBSim would only print
+//       out the normally expected messages, essentially echoing
+//       the config files as they are read. If the environment
+//       variable is not set, debug_lvl is set to 1 internally
+//    0: This requests JSBSim not to output any messages
+//       whatsoever.
+//    1: This value explicity requests the normal JSBSim
+//       startup messages
+//    2: This value asks for a message to be printed out when
+//       a class is instantiated
+//    4: When this value is set, a message is displayed when a
+//       FGModel object executes its Run() method
+//    8: When this value is set, various runtime state variables
+//       are printed out periodically
+//    16: When set various parameters are sanity checked and
+//       a message is printed out when they go out of bounds
+
+void FGAircraft::Debug(int from)
+{
+  if (debug_lvl <= 0) return;
+
+  if (debug_lvl & 1) { // Standard console startup message output
+    if (from == 0) { // Constructor
+    }
+  }
+  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+    if (from == 0) cout << "Instantiated: FGAircraft" << endl;
+    if (from == 1) cout << "Destroyed:    FGAircraft" << endl;
+  }
+  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+  }
+  if (debug_lvl & 8 ) { // Runtime state variables
+  }
+  if (debug_lvl & 16) { // Sanity checking
+  }
+  if (debug_lvl & 64) {
+    if (from == 0) { // Constructor
+      cout << IdSrc << endl;
+      cout << IdHdr << endl;
+    }
+  }
 }
+
+} // namespace JSBSim