]> git.mxchange.org Git - flightgear.git/commitdiff
Additional changes including updates to JSBSim to try to get interface and
authorcurt <curt>
Mon, 29 Oct 2001 19:00:24 +0000 (19:00 +0000)
committercurt <curt>
Mon, 29 Oct 2001 19:00:24 +0000 (19:00 +0000)
initial trimming to work.

src/FDM/JSBSim.cxx
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGAircraft.h
src/FDM/JSBSim/FGGroundReactions.h
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/FGState.h
src/FDM/JSBSim/FGTrim.cpp
src/FDM/JSBSim/FGTrimAxis.cpp
src/Sound/fg_fx.cxx

index ed26bd8e0bbd8aa8e606ea36fcf67bae70e6758c..8dbd2eced1eb18e850a77ee74c4aa829df90179a 100644 (file)
@@ -113,9 +113,9 @@ FGJSBsim::FGJSBsim( double dt )
         add_engine( FGEngInterface() );
     }  
     
-    if ( fdmex->GetAircraft()->GetNumGearUnits() <= 0 ) {
+    if ( fdmex->GetGroundReactions()->GetNumGearUnits() <= 0 ) {
         SG_LOG( SG_FLIGHT, SG_ALERT, "num gear units = "
-                << fdmex->GetAircraft()->GetNumGearUnits() );
+                << fdmex->GetGroundReactions()->GetNumGearUnits() );
         SG_LOG( SG_FLIGHT, SG_ALERT, "This is a very bad thing because with 0 gear units, the ground trimming");
          SG_LOG( SG_FLIGHT, SG_ALERT, "routine (coming up later in the code) will core dump.");
          SG_LOG( SG_FLIGHT, SG_ALERT, "Halting the sim now, and hoping a solution will present itself soon!");
@@ -225,7 +225,7 @@ bool FGJSBsim::update( int multiloop ) {
     trimmed->setBoolValue(false);
 
     if ( needTrim && startup_trim->getBoolValue() ) {
-        cout << "num gear units = " << fdmex->GetAircraft()->GetNumGearUnits() << endl;
+        cout << "num gear units = " << fdmex->GetGroundReactions()->GetNumGearUnits() << endl;
         //fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
         //fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
 
index 6daa3d42578e9e60fc4334ca0141b09982d6b98d..0701474f36b173fbd8bdfa051df494f6c92777de 100644 (file)
@@ -107,7 +107,6 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
     vBodyAccel(3)
 {
   Name = "FGAircraft";
-  GearUp = false;
   alphaclmin = alphaclmax = 0;
   HTailArea = VTailArea = HTailArm = VTailArm = 0.0;
   lbarh = lbarv = vbarh = vbarv = 0.0;
index ae306b0072e74588f16432505f4d21a753f1847b..055373cc18301d069d87adf5e9ed43fba5b00b57 100644 (file)
@@ -171,16 +171,6 @@ public:
       @return the name of the aircraft as a string type */
   inline string GetAircraftName(void) { return AircraftName; }
   
-  /** Gets the gear status
-      @return true if gear is not deployed */
-  inline bool GetGearUp(void) { return GearUp; }
-  /** Gets the number of gear units defined for the aircraft
-      @return number of gear units defined */
-  inline int GetNumGearUnits(void) { return lGear.size(); }
-  /** Gets a gear instance
-      @param gear index of gear instance
-      @return a pointer to the FGLGear instance of the gear unit requested */
-  inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
   /// Gets the wing area
   inline float GetWingArea(void) { return WingArea; }
   /// Gets the wing span
@@ -206,9 +196,6 @@ public:
   inline float GetAlphaCLMax(void) { return alphaclmax; }
   inline float GetAlphaCLMin(void) { return alphaclmin; }
 
-  inline void SetGear(bool tt) { GearUp = tt; }
-  inline void SetGearUp(void) { GearUp = true; }
-  inline void SetGearDown(bool tt) { GearUp = false; }
   inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
   inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
 
@@ -244,10 +231,6 @@ private:
   string CFGVersion;
   string AircraftName;
 
-  bool GearUp;
-
-  vector <FGLGear> lGear;
-
   void ReadMetrics(FGConfigFile*);
   void ReadPropulsion(FGConfigFile*);
   void ReadFlightControls(FGConfigFile*);
index e24d1727732320fbd32303891963836feac4dcb8..5a7685ea9276ca642371487bde41624ac57646b3 100644 (file)
@@ -78,6 +78,20 @@ public:
   string GetGroundReactionStrings(void);
   string GetGroundReactionValues(void);
 
+  /** Gets the gear status
+      @return true if gear is not deployed */
+  inline bool GetGearUp(void) { return GearUp; }
+  /** Gets the number of gear units defined for the aircraft
+      @return number of gear units defined */
+  inline int GetNumGearUnits(void) { return lGear.size(); }
+  /** Gets a gear instance
+      @param gear index of gear instance
+      @return a pointer to the FGLGear instance of the gear unit requested */
+  inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
+  inline void SetGear(bool tt) { GearUp = tt; }
+  inline void SetGearUp(void) { GearUp = true; }
+  inline void SetGearDown(bool tt) { GearUp = false; }
+  
 private:
   vector <FGLGear> lGear;
   bool GearUp;
index 3e023aa6276ddb32a4f2ff25ea6f86c94ac80658..dc05a21bf3c7ba6f016e6eb7c2828f02d6ff2133 100644 (file)
@@ -96,6 +96,7 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
   Output       = FDMExec->GetOutput();
   Atmosphere   = FDMExec->GetAtmosphere();
   Aerodynamics = FDMExec->GetAerodynamics();
+  GroundReactions = FDMExec->GetGroundReactions();
 
   RegisterVariable(FG_TIME,           " time "           );
   RegisterVariable(FG_QBAR,           " qbar "           );
@@ -663,7 +664,7 @@ void FGState::ReportState(void) {
     snprintf(flap,10,"Up");
   else
     snprintf(flap,10,"%2.0f",FCS->GetDfPos());
-  if(Aircraft->GetGearUp() == true)
+  if(GroundReactions->GetGearUp() == true)
     snprintf(gear,10,"Up");
   else
     snprintf(gear,10,"Down");
index a2e70450dd3ceaaaf356f222663ea626dfb9052e..6e24822b1318916cdd25491ce91ebd745e268b82 100644 (file)
@@ -82,6 +82,7 @@ class FGAtmosphere;
 class FGOutput;
 class FGPosition;
 class FGFDMExec;
+class FGGroundReactions;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
@@ -329,6 +330,7 @@ private:
   FGAtmosphere* Atmosphere;
   FGFCS* FCS;
   FGAerodynamics* Aerodynamics;
+  FGGroundReactions* GroundReactions;
 
   typedef map<string, eParam> CoeffMap;
   CoeffMap coeffdef;
@@ -347,6 +349,7 @@ private:
 #include "FGAerodynamics.h"
 #include "FGOutput.h"
 #include "FGAircraft.h"
+#include "FGGroundReactions.h"
 
 #endif
 
index 55ed69a0d9edf42223549e1afecefedf2371c74c..1d7fb0c28ee6ec140798330f83ee1cadcad450d6 100644 (file)
@@ -172,7 +172,7 @@ void FGTrim::ReportState(void) {
     snprintf(flap,10,"Up");
   else
     snprintf(flap,10,"%2.0f",fdmex->GetFCS()->GetDfPos());
-  if(fdmex->GetAircraft()->GetGearUp() == true)
+  if(fdmex->GetGroundReactions()->GetGearUp() == true)
     snprintf(gear,10,"Up");
   else
     snprintf(gear,10,"Down");
@@ -329,8 +329,8 @@ bool FGTrim::DoTrim(void) {
   trim_failed=false;
   int i;
 
-  for(i=0;i < fdmex->GetAircraft()->GetNumGearUnits();i++){
-    fdmex->GetAircraft()->GetGearUnit(i)->SetReport(false);
+  for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
+    fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false);
   }
 
   fdmex->GetOutput()->Disable();
@@ -425,8 +425,8 @@ bool FGTrim::DoTrim(void) {
     total_its=N;
     cout << endl << "  Trim failed" << endl;
   }
-  for(i=0;i < fdmex->GetAircraft()->GetNumGearUnits();i++){
-    fdmex->GetAircraft()->GetGearUnit(i)->SetReport(true);
+  for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
+    fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true);
   }
   fdmex->GetOutput()->Enable();
   return !trim_failed;
index d580a756dbab9b08ee0f388f7097df0a05b5bc8c..221a8ce30af8972daca4bcaf1fd2fab867c9f7a2 100644 (file)
@@ -242,9 +242,9 @@ void FGTrimAxis::SetThetaOnGround(float ff) {
   // pitch and roll.  An on-center unit is used (for pitch)if that's all 
   // that's in contact with the ground.
   i=0; ref=-1; center=-1;
-  while( (ref < 0) && (i < fdmex->GetAircraft()->GetNumGearUnits()) ) {
-    if(fdmex->GetAircraft()->GetGearUnit(i)->GetWOW()) {
-      if(fabs(fdmex->GetAircraft()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01)
+  while( (ref < 0) && (i < fdmex->GetGroundReactions()->GetNumGearUnits()) ) {
+    if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetWOW()) {
+      if(fabs(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01)
         ref=i;
       else
         center=i;
@@ -258,9 +258,9 @@ void FGTrimAxis::SetThetaOnGround(float ff) {
   if(ref >= 0) {
     float sp=fdmex->GetRotation()->GetSinphi();
     float cp=fdmex->GetRotation()->GetCosphi();
-    float lx=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(1);
-    float ly=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(2);
-    float lz=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(3);
+    float lx=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
+    float ly=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
+    float lz=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
     float hagl = -1*lx*sin(ff) +
                     ly*sp*cos(ff) +
                     lz*cp*cos(ff);
@@ -284,27 +284,27 @@ bool FGTrimAxis::initTheta(void) {
   fgic->SetAltitudeAGLFtIC(100);
   
   
-  N=fdmex->GetAircraft()->GetNumGearUnits();
+  N=fdmex->GetGroundReactions()->GetNumGearUnits();
   
   //find the first wheel unit forward of the cg
   //the list is short so a simple linear search is fine
   for( i=0; i<N; i++ ) {
-    if(fdmex->GetAircraft()->GetGearUnit(i)->GetBodyLocation(1) > 0 ) {
+    if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(1) > 0 ) {
         iForward=i;
         break;
     }
   }
   //now find the first wheel unit aft of the cg
   for( i=0; i<N; i++ ) {
-    if(fdmex->GetAircraft()->GetGearUnit(i)->GetBodyLocation(1) < 0 ) {
+    if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(1) < 0 ) {
         iAft=i;
         break;
     }
   }
          
   // now adjust theta till the wheels are the same distance from the ground
-  zAft=fdmex->GetAircraft()->GetGearUnit(1)->GetLocalGear(3);
-  zForward=fdmex->GetAircraft()->GetGearUnit(0)->GetLocalGear(3);
+  zAft=fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear(3);
+  zForward=fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear(3);
   zDiff = zForward - zAft;
   level=false;
   theta=fgic->GetPitchAngleDegIC(); 
@@ -312,12 +312,12 @@ bool FGTrimAxis::initTheta(void) {
        theta+=2.0*zDiff;
        fgic->SetPitchAngleDegIC(theta);   
        fdmex->RunIC(fgic);
-       zAft=fdmex->GetAircraft()->GetGearUnit(1)->GetLocalGear(3);
-        zForward=fdmex->GetAircraft()->GetGearUnit(0)->GetLocalGear(3);
+       zAft=fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear(3);
+        zForward=fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear(3);
         zDiff = zForward - zAft;
        //cout << endl << theta << "  " << zDiff << endl;
-       //cout << "0: " << fdmex->GetAircraft()->GetGearUnit(0)->GetLocalGear() << endl;
-       //cout << "1: " << fdmex->GetAircraft()->GetGearUnit(1)->GetLocalGear() << endl;
+       //cout << "0: " << fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear() << endl;
+       //cout << "1: " << fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear() << endl;
 
        if(fabs(zDiff ) < 0.1) 
            level=true;
@@ -341,18 +341,18 @@ void FGTrimAxis::SetPhiOnGround(float ff) {
 
   i=0; ref=-1;
   //must have an off-center unit here 
-  while( (ref < 0) && (i < fdmex->GetAircraft()->GetNumGearUnits()) ) {
-    if( (fdmex->GetAircraft()->GetGearUnit(i)->GetWOW()) && 
-      (fabs(fdmex->GetAircraft()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01))
+  while( (ref < 0) && (i < fdmex->GetGroundReactions()->GetNumGearUnits()) ) {
+    if( (fdmex->GetGroundReactions()->GetGearUnit(i)->GetWOW()) && 
+      (fabs(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01))
         ref=i;
     i++; 
   }
   if(ref >= 0) {
     float st=fdmex->GetRotation()->GetSintht();
     float ct=fdmex->GetRotation()->GetCostht();
-    float lx=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(1);
-    float ly=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(2);
-    float lz=fdmex->GetAircraft()->GetGearUnit(ref)->GetBodyLocation(3);
+    float lx=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
+    float ly=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
+    float lz=fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
     float hagl = -1*lx*st +
                     ly*sin(ff)*ct +
                     lz*cos(ff)*ct;
index 675a6c0571617dd53f6cb2903e1075143274326f..5c60801d0d69038afc5749f5d364106467fcd8aa 100644 (file)
@@ -152,7 +152,7 @@ FGFX::update ()
          // volume corresponds to manifold pressure
 
     double rpm_factor;
-    if (cur_fdm_state->get_engine(0) != NULL)
+    if ( cur_fdm_state->get_num_engines() > 0 )
       rpm_factor = cur_fdm_state->get_engine(0)->get_RPM() / 2500.0;
     else
       rpm_factor = 1.0;
@@ -167,7 +167,7 @@ FGFX::update ()
       pitch = 5.0;
 
     double mp_factor;
-    if (cur_fdm_state->get_engine(0) != NULL)
+    if ( cur_fdm_state->get_num_engines() > 0 )
       mp_factor = cur_fdm_state->get_engine(0)->get_Manifold_Pressure() / 100;
     else
       mp_factor = 0.3;