]> git.mxchange.org Git - flightgear.git/commitdiff
Nov. 14, 2000 JSBSim updates
authorcurt <curt>
Tue, 14 Nov 2000 20:31:58 +0000 (20:31 +0000)
committercurt <curt>
Tue, 14 Nov 2000 20:31:58 +0000 (20:31 +0000)
14 files changed:
src/FDM/JSBSim.cxx
src/FDM/JSBSim.hxx
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGAircraft.h
src/FDM/JSBSim/FGCoefficient.cpp
src/FDM/JSBSim/FGCoefficient.h
src/FDM/JSBSim/FGControls.cpp
src/FDM/JSBSim/FGControls.h
src/FDM/JSBSim/FGFCS.cpp
src/FDM/JSBSim/FGFCS.h
src/FDM/JSBSim/FGOutput.cpp
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/JSBSim.cpp
src/FDM/JSBSim/filtersjb/FGGain.cpp

index 68997a3424f31b35727eae8bcbd45ab1fed87632..998f23b30ffba6ab5df585a7be030f1a455af314 100644 (file)
@@ -202,7 +202,7 @@ bool FGJSBsim::update( int multiloop ) {
     int i;
   
     double save_alt = 0.0;
+    
   
     // lets try to avoid really screwing up the JSBsim model
     if ( get_Altitude() < -9000 ) {
@@ -210,7 +210,11 @@ bool FGJSBsim::update( int multiloop ) {
        set_Altitude( 0.0 );
     }
 
+    copy_to_JSBsim();
+    
     if(needTrim && (globals->get_options()->get_trim_mode() > 0)) {
+       //fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
+       //fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * METER_TO_FEET );
        FGTrim *fgtrim;
        if(fgic->GetVcalibratedKtsIC() < 10 ) {
                fgic->SetVcalibratedKtsIC(0.0);
@@ -242,7 +246,7 @@ bool FGJSBsim::update( int multiloop ) {
        get_engine(i)->set_RPM( controls.get_throttle(i)*2700 );
        get_engine(i)->set_Throttle( controls.get_throttle(i) );
     }
-    copy_to_JSBsim();
+    
   
     for ( int i = 0; i < multiloop; i++ ) {
        fdmex->Run();
@@ -289,9 +293,10 @@ bool FGJSBsim::copy_to_JSBsim() {
     fdmex->GetFCS()->SetRBrake( controls.get_brake( 1 ) );
     fdmex->GetFCS()->SetCBrake( controls.get_brake( 2 ) );
 
-    fdmex->GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
-    fdmex->GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
-
+    fdmex->GetPosition()->SetSeaLevelRadius( get_Sea_level_radius() );
+    fdmex->GetPosition()->SetRunwayRadius( scenery.cur_elev*METER_TO_FEET
+                                               + get_Sea_level_radius() );
+    
     fdmex->GetAtmosphere()->SetExTemperature(get_Static_temperature());
     fdmex->GetAtmosphere()->SetExPressure(get_Static_pressure());
     fdmex->GetAtmosphere()->SetExDensity(get_Density());
@@ -555,6 +560,7 @@ void FGJSBsim::set_Runway_altitude(double ralt) {
     
     snap_shot();
     _set_Runway_altitude( ralt );
+    fgic->SetTerrainAltitudeFtIC( ralt );
     fdmex->RunIC(fgic); //loop JSBSim once
     copy_from_JSBsim(); //update the bus 
     needTrim=true;  
index 7c56e1cf52b7312a9a89731045a2e16774a4ac83..90cd30a8294365123b05880e4b414d8a9e50f96b 100644 (file)
@@ -77,17 +77,6 @@ CLASS DECLARATION
 
 class FGJSBsim: public FGInterface {
 
-#if 0
-    // The aircraft for this instance
-    FGFDMExec *fdmex;
-    FGInitialCondition *fgic;
-    bool needTrim;
-    
-    bool trimmed;
-    float trim_elev;
-    float trim_throttle;
-#endif
-
 public:
     /// Constructor
     FGJSBsim::FGJSBsim(void);
index ccf5bfc46ed4e1b492ff2501b20df04234bd5b11..1c06fc673814e3e3e7a57272bfc8d66fe0604e0d 100644 (file)
@@ -381,12 +381,8 @@ void FGAircraft::FMAero(void) {
   vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
   vForces += vAeroBodyForces;
 
-  // The d*cg distances below, given in inches, are the distances FROM the c.g.
-  // TO the reference point. Since the c.g. and ref point are given in inches in
-  // the structural system (X positive rearwards) and the body coordinate system
-  // is given with X positive out the nose, the dxcg and dzcg values are
-  // *rotated* 180 degrees about the Y axis.
-
+  // see http://home.earthlink.net/~apeden/jsbsim_moments_due_to_forces.txt
+  // for details on this
   vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0;  //cg and rp values are in inches
   vDXYZcg(eY) =  (vXYZrp(eY) - vXYZcg(eY))/12.0;
   vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
@@ -636,6 +632,10 @@ void FGAircraft::ReadOutput(FGConfigFile* AC_cfg) {
       *AC_cfg >> parameter;
       if (parameter == "ON") subsystems += ssGroundReactions;
     }
+    if (parameter == "FCS") {
+      *AC_cfg >> parameter;
+      if (parameter == "ON") subsystems += ssFCS;
+    }
   }
 
   Output->SetSubsystems(subsystems);
@@ -717,7 +717,6 @@ string FGAircraft::GetCoefficientValues(void) {
   }
 
   return SDValues;
-  ;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 05c9de0b4cec5b6846c2af737a6f123e64090029..f1cb4c96691faa0f47706f28b808602ab3a22b75 100644 (file)
@@ -201,7 +201,8 @@ public:
     /** Subsystem: Mass Properties (= 128)   */ ssMassProps       = 128,
     /** Subsystem: Coefficients (= 256)      */ ssCoefficients    = 256,
     /** Subsystem: Position (= 512)          */ ssPosition        = 512,
-    /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024
+    /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
+    /** Subsystem: Ground Reactions (= 2048) */ ssFCS             = 2048
   } subsystems;
 
 private:
index 3f66bee0a5620bf5f2aa07fb6466a481cb63e16f..d29812e62587a43f56033e1680d98e04986e4282 100644 (file)
@@ -48,6 +48,8 @@ INCLUDES
 #include "FGState.h"
 #include "FGFDMExec.h"
 
+#include <iomanip.h>
+
 static const char *IdSrc = "$Header$";
 static const char *IdHdr = "ID_COEFFICIENT";
 
@@ -60,7 +62,11 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
   int r, c, start, end, n;
   float ftrashcan;
   string multparms;
-
+  char nullstring[13] = "            ";
+  
+  bias =0.0;
+  gain = 1.0;
+  
   FDMExec     = fdex;
   State       = FDMExec->GetState();
   Table = 0;
@@ -72,7 +78,22 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
     AC_cfg->GetNextConfigLine();
     *AC_cfg >> description;
 
-    cout << "   " << name << endl;
+    char bolden[5];
+    char unbolden[5];
+
+    bolden[0] = 27;
+    bolden[1] = '[';
+    bolden[2] = '1';
+    bolden[3] = 'm';
+    bolden[4] = '\0';
+
+    unbolden[0] = 27;
+    unbolden[1] = '[';
+    unbolden[2] = '0';
+    unbolden[3] = 'm';
+    unbolden[4] = '\0';
+
+    cout << "   " << bolden << name << unbolden << endl;
     cout << "   " << description << endl;
     cout << "   " << method << endl;
 
@@ -150,19 +171,41 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
       Allocate(rows, columns);
 
       Table[0][0] = 0.0;
-      for (c=1;c<=columns;c++) {
+
+      // Read the table in -- it should be in matrix format with the row
+      // independents as the first column and the column independents in
+      // the first row.  The implication of this layout is that there should
+      // be no value in the upper left corner of the matrix e.g:
+      //      0  10  20 30 ...
+      // -5   1  2   3  4  ...
+      //  ...
+
+      for (r=0; r<=rows; r++) {
+        for (c=0; c <= columns; c++) {
+          if ( !((r == 0) && (c == 0)) ) {
+            *AC_cfg >> Table[r][c];
+          }
+        }
+      }   
+      
+      /* for (c=1;c<=columns;c++) {
         *AC_cfg >> Table[0][c];
         for (r=1;r<=rows;r++) {
           if ( c==1 ) *AC_cfg >> Table[r][0];
           else *AC_cfg >> ftrashcan;
           *AC_cfg >> Table[r][c];
         }
-      }
-
+      } */
+      
       for (r=0;r<=rows;r++) {
         cout << "      ";
         for (c=0;c<=columns;c++) {
-          cout << Table[r][c] << "     ";
+          if( ((r == 0) && (c == 0)) ) {
+             cout << nullstring;
+          } else {
+             cout.flags(ios::left);
+             cout << setw(12) << Table[r][c];
+          }
         }
         cout << endl;
       }
@@ -219,7 +262,8 @@ float FGCoefficient::Value(float rVal, float cVal)
 
   for (r=1;r<=rows;r++) if (Table[r][0] >= rVal) break;
   for (c=1;c<=columns;c++) if (Table[0][c] >= cVal) break;
-
+  //cout << "Value(): rVal: " << rVal << " cVal: " << cVal << endl;
+  //cout << "Value(): r: " << r << " c: " << c << endl;
   c = c < 2 ? 2 : (c > columns ? columns : c);
   r = r < 2 ? 2 : (r > rows    ? rows    : r);
 
@@ -229,8 +273,10 @@ float FGCoefficient::Value(float rVal, float cVal)
   col1temp = rFactor*(Table[r][c-1] - Table[r-1][c-1]) + Table[r-1][c-1];
   col2temp = rFactor*(Table[r][c] - Table[r-1][c]) + Table[r-1][c];
 
-  SD = Value = col1temp + cFactor*(col2temp - col1temp);
-
+  Value = col1temp + cFactor*(col2temp - col1temp);
+  Value = (Value + bias)*gain;
+  SD = Value;
+  
   for (midx=0; midx < multipliers.size(); midx++) {
     Value *= State->GetParameter(multipliers[midx]);
   }
@@ -260,7 +306,10 @@ float FGCoefficient::Value(float Val)
     Factor = 1.0;
   }
 
-  SD = Value = Factor*(Table[r][1] - Table[r-1][1]) + Table[r-1][1];
+  Value = Factor*(Table[r][1] - Table[r-1][1]) + Table[r-1][1];
+  Value = (Value + bias)*gain;
+  SD = Value;
+
   for (midx=0; midx < multipliers.size(); midx++) {
     Value *= State->GetParameter(multipliers[midx]);
 
@@ -276,7 +325,9 @@ float FGCoefficient::Value(void)
        float Value;
        unsigned midx;
 
-       SD = Value = StaticValue;
+       Value = StaticValue;
+  Value = (Value + bias)*gain;
+  SD = Value;
 
   for (midx=0; midx < multipliers.size(); midx++) {
     Value *= State->GetParameter(multipliers[midx]);
index ce8a21daf27c334b1b92db562754be2c0cbcb2cf..9c8bdf3ad235a499887100998693bfad00c672b7 100644 (file)
@@ -111,6 +111,7 @@ class FGCoefficient
   int rows, columns;
   Type type;
   float SD; // Actual stability derivative (or other coefficient) value
+  float gain,bias;
 
   FGFDMExec*      FDMExec;
   FGState*        State;
@@ -138,6 +139,12 @@ public:
   inline float GetSD(void) {return SD;}
   inline MultVec Getmultipliers(void) {return multipliers;}
   void DumpSD(void);
+  
+  inline float GetGain(void) { return gain; }
+  inline float GetBias(void) { return bias; }
+  inline void SetGain(float tt) { gain = tt; }
+  inline void SetBias(float tt) { bias = tt; }
+  inline void ResetGB(void) { gain = 1.0; bias = 0.0; }
 
 };
 
index 59bef9079bf26abc460c2e711d20c009403da085..d1206f92101caeed4ed1a96ffc62cf95208d9538 100644 (file)
@@ -53,8 +53,8 @@ FGControls::~FGControls() {
 
 
 // $Log$
-// Revision 1.20  2000/11/03 22:02:48  curt
-// Sync with current JSBSim devel code.
+// Revision 1.21  2000/11/14 19:32:03  curt
+// Nov. 14, 2000 JSBSim updates
 //
 // Revision 1.4  2000/10/13 19:21:02  jsb
 // ** JSB ** Added version identifiers for all files
index 04097f911ad3175999338964e9ddd6aa1757039f..52a5a557f4f2c44b88ec9720f5e9b59133f0d8fe 100644 (file)
@@ -178,8 +178,8 @@ extern FGControls controls;
 
 
 // $Log$
-// Revision 1.19  2000/11/03 22:02:48  curt
-// Sync with current JSBSim devel code.
+// Revision 1.20  2000/11/14 19:32:03  curt
+// Nov. 14, 2000 JSBSim updates
 //
 // Revision 1.7  2000/10/13 19:21:02  jsb
 // ** JSB ** Added version identifiers for all files
index 5e4f4259c6a8f920b1ddfb42b22cf0ade8e9fc41..e434759fb14ce91d603bee58285b9e2d9ada11a6 100644 (file)
@@ -87,7 +87,9 @@ bool FGFCS::Run(void) {
 
     for (unsigned int i=0; i<Aircraft->GetNumEngines(); i++) ThrottlePos[i]=ThrottleCmd[i];
 
-    for (unsigned int i=0; i<Components.size(); i++) Components[i]->Run();
+    for (unsigned int i=0; i<Components.size(); i++) {
+      Components[i]->Run();
+    }
 
   } else {}
 
@@ -183,3 +185,37 @@ float FGFCS::GetBrake(FGLGear::eBrakeGroup bg) {
     cerr << "GetBrake asked to return a bogus brake value" << endl;
   }
 }
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGFCS::GetComponentStrings(void){
+  string CompStrings = "";
+  bool firstime = true;
+
+  for (unsigned int comp = 0; comp < Components.size(); comp++) {
+    if (firstime) firstime = false;
+    else          CompStrings += ", ";
+
+    CompStrings += Components[comp]->GetName();
+  }
+
+  return CompStrings;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGFCS::GetComponentValues(void){
+  string CompValues = "";
+  char buffer[10];
+  bool firstime = true;
+
+  for (unsigned int comp = 0; comp < Components.size(); comp++) {
+    if (firstime) firstime = false;
+    else          CompValues += ", ";
+
+    sprintf(buffer, "%9.6f", Components[comp]->GetOutput());
+    CompValues += string(buffer);
+  }
+
+  return CompValues;
+}
index c334935f09b66cd11cf4a5b6f1c9702ce4722c6a..2ed40eb91d52093c8f4aab3425da6203e3387f7f 100644 (file)
@@ -234,6 +234,10 @@ public:
       @param idx the index of the component (the component ID)
       @return name of the component */
   string GetComponentName(int idx);
+  /** Retrieves all component names for inclusion in output stream */
+  string GetComponentStrings(void);
+  /** Retrieves all component outputs for inclusion in output stream */
+  string GetComponentValues(void);
 
   /// @name Pilot input command setting
   //@{
@@ -314,7 +318,7 @@ public:
       @param AC_cfg pointer to the config file instance
       @return true if succesful */
   bool LoadFCS(FGConfigFile* AC_cfg);
-  
+
   /** The name of the flight control laws for this aircraft.
       This is given in the config file, and is not used for anything currently.*/
   string FCSName;
index 8f28db2032abf9c6a61e2b5ce51939aa37064ade..b85c0e574a285e6ad278fb20c44305823157eea8 100644 (file)
@@ -338,6 +338,10 @@ void FGOutput::DelimitedOutput(string fname)
       datafile << ", ";
       datafile << Aircraft->GetGroundReactionStrings();
     }
+    if (SubSystems & FGAircraft::ssFCS) {
+      datafile << ", ";
+      datafile << FCS->GetComponentStrings();
+    }
     datafile << endl;
     sFirstPass = false;
   }
@@ -406,6 +410,10 @@ void FGOutput::DelimitedOutput(string fname)
     datafile << ", ";
     datafile << Aircraft->GetGroundReactionValues();
   }
+  if (SubSystems & FGAircraft::ssFCS) {
+    datafile << ", ";
+    datafile << FCS->GetComponentValues();
+  }
   datafile << endl;
   datafile.flush();
 }
index 454de5b2b062a35b6e03c3d0a837edd292635ddf..ce666ecbb210e3b3eb85034c0b89a1cb6889ced3 100644 (file)
@@ -260,7 +260,7 @@ bool FGState::Reset(string path, string acname, string fname) {
   float phi, tht, psi;
   float latitude, longitude, h;
 
-  resetDef = path + "/" + acname + "/" + fname;
+  resetDef = path + "/" + acname + "/" + fname + ".xml";
 
   ifstream resetfile(resetDef.c_str());
 
index ad4a167db806a1d33b56c09f667fbf32df9235c2..21bd1261496b747729d44a4db5b02e548a80aa06 100644 (file)
@@ -180,15 +180,15 @@ int main(int argc, char** argv)
     if (FDMExec->GetState()->Getsim_time() >= 1.00 &&
         FDMExec->GetState()->Getsim_time() < 2.0)
     {
-      cmd = -(FDMExec->GetState()->Getsim_time() - 1.00)/2.0;
+      cmd = -(FDMExec->GetState()->Getsim_time() - 1.00)/4.0;
     } else if (FDMExec->GetState()->Getsim_time() >= 2.00 &&
         FDMExec->GetState()->Getsim_time() < 6.0)
     {
-      cmd = -1.00/2.0;
+      cmd = -1.00/4.0;
     } else if (FDMExec->GetState()->Getsim_time() >= 6.00 &&
         FDMExec->GetState()->Getsim_time() < 7.0)
     {
-      cmd = -(7.0 - FDMExec->GetState()->Getsim_time())/2.0;
+      cmd = -(7.0 - FDMExec->GetState()->Getsim_time())/4.0;
     } else {
       cmd = 0.00;
     }
index c5b54c7e2d3b1156ccc71669793b13a5100197d8..52f8d66a1fdea7d173232aace40c21f2ae92ad9a 100644 (file)
@@ -112,6 +112,7 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
       AC_cfg->ResetLineIndexToZero();
       lookup = new float[2];
       *AC_cfg >> lookup[0] >> lookup[1];
+      cout << "        " << lookup[0] << "  " << lookup[1] << endl;
       Schedule.push_back(lookup);
     }
   }
@@ -140,8 +141,8 @@ bool FGGain::Run(void )
     float lowVal = Schedule[0][0], hiVal = Schedule[last][0];
     float factor = 1.0;
 
-    if (LookupVal <= lowVal) Output = Gain * Schedule[0][1];
-    else if (LookupVal >= hiVal) Output = Gain * Schedule[last][1];
+    if (LookupVal <= lowVal) Output = Gain * Schedule[0][1] * Input;
+    else if (LookupVal >= hiVal) Output = Gain * Schedule[last][1] * Input;
     else {
       for (unsigned int ctr = 1; ctr < last; ctr++) {
         if (LookupVal < Schedule[ctr][0]) {