]> git.mxchange.org Git - flightgear.git/commitdiff
Latest JSBSim changes.
authordavid <david>
Sun, 17 Feb 2002 21:04:44 +0000 (21:04 +0000)
committerdavid <david>
Sun, 17 Feb 2002 21:04:44 +0000 (21:04 +0000)
src/FDM/JSBSim.cxx
src/FDM/JSBSim.hxx
src/FDM/JSBSim/FGCoefficient.cpp
src/FDM/JSBSim/FGFCS.cpp
src/FDM/JSBSim/FGScript.cpp
src/FDM/JSBSim/FGState.h
src/FDM/JSBSim/filtersjb/FGFilter.cpp
src/FDM/JSBSim/filtersjb/FGGain.cpp
src/FDM/JSBSim/filtersjb/FGKinemat.cpp
src/FDM/JSBSim/filtersjb/FGSummer.cpp

index aba3ad7619fb2b3ff97204d786e776fc7867a7e8..926d9d34fef70ccbbb5d85802a24cd48bb7cce00 100644 (file)
@@ -174,9 +174,7 @@ void FGJSBsim::init() {
     common_init();
     copy_to_JSBsim();
 
-    fdmex->GetState()->Initialize(fgic);
     fdmex->RunIC(fgic); //loop JSBSim once w/o integrating
-    // fdmex->Run();       //loop JSBSim once
     copy_from_JSBsim(); //update the bus
 
     SG_LOG( SG_FLIGHT, SG_INFO, "  Initialized JSBSim with:" );
@@ -320,8 +318,9 @@ bool FGJSBsim::copy_to_JSBsim() {
       eng->SetStarter( globals->get_controls()->get_starter(i) );
     }
 
+    _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET );
     Position->SetSeaLevelRadius( get_Sea_level_radius() );
-    Position->SetRunwayRadius( scenery.get_cur_elev()*SG_METER_TO_FEET
+    Position->SetRunwayRadius( get_Runway_altitude() 
                                + get_Sea_level_radius() );
 
     Atmosphere->SetExTemperature(get_Static_temperature());
@@ -506,21 +505,24 @@ bool FGJSBsim::ToggleDataLogging(bool state) {
 void FGJSBsim::set_Latitude(double lat) {
     static const SGPropertyNode *altitude = fgGetNode("/position/altitude-ft");
     double alt;
+    double sea_level_radius_meters, lat_geoc;
+    
     if ( altitude->getDoubleValue() > -9990 ) {
       alt = altitude->getDoubleValue();
     } else {
       alt = 0.0;
     }
-
-    double sea_level_radius_meters, lat_geoc;
-
+   
+    update_ic();
     SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Latitude: " << lat );
     SG_LOG(SG_FLIGHT,SG_INFO," cur alt (ft) =  " << alt );
 
-    sgGeodToGeoc( lat, alt * SG_FEET_TO_METER, &sea_level_radius_meters, &lat_geoc );
-    
+    sgGeodToGeoc( lat, alt * SG_FEET_TO_METER, 
+                      &sea_level_radius_meters, &lat_geoc );
     _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET  );
-    fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET  );
+    fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET  );    
+    _set_Runway_altitude(  scenery.get_cur_elev() * SG_METER_TO_FEET  );
+    fgic->SetTerrainAltitudeFtIC( scenery.get_cur_elev() * SG_METER_TO_FEET  );
     fgic->SetLatitudeRadIC( lat_geoc );
     needTrim=true;
 }
@@ -528,8 +530,10 @@ void FGJSBsim::set_Latitude(double lat) {
 void FGJSBsim::set_Longitude(double lon) {
 
     SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Longitude: " << lon );
-
+    update_ic();
     fgic->SetLongitudeRadIC( lon );
+    _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET  );
+    fgic->SetTerrainAltitudeFtIC( scenery.get_cur_elev() * SG_METER_TO_FEET  );
     needTrim=true;
 }
 
@@ -540,11 +544,14 @@ void FGJSBsim::set_Altitude(double alt) {
 
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt );
     SG_LOG(SG_FLIGHT,SG_INFO, "  lat (deg) = " << latitude->getDoubleValue() );
-
+    
+    update_ic();
     sgGeodToGeoc( latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS, alt,
-      &sea_level_radius_meters, &lat_geoc);
+                  &sea_level_radius_meters, &lat_geoc);
     _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET  );
     fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
+    _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET  );
+    fgic->SetTerrainAltitudeFtIC( scenery.get_cur_elev() * SG_METER_TO_FEET  );
     fgic->SetLatitudeRadIC( lat_geoc );
     fgic->SetAltitudeFtIC(alt);
     needTrim=true;
@@ -552,14 +559,16 @@ void FGJSBsim::set_Altitude(double alt) {
 
 void FGJSBsim::set_V_calibrated_kts(double vc) {
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_V_calibrated_kts: " <<  vc );
-
+    
+    update_ic();
     fgic->SetVcalibratedKtsIC(vc);
     needTrim=true;
 }
 
 void FGJSBsim::set_Mach_number(double mach) {
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Mach_number: " <<  mach );
-
+    
+    update_ic();
     fgic->SetMachIC(mach);
     needTrim=true;
 }
@@ -567,7 +576,8 @@ void FGJSBsim::set_Mach_number(double mach) {
 void FGJSBsim::set_Velocities_Local( double north, double east, double down ){
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local: "
        << north << ", " <<  east << ", " << down );
-
+    
+    update_ic();
     fgic->SetVnorthFpsIC(north);
     fgic->SetVeastFpsIC(east);
     fgic->SetVdownFpsIC(down);
@@ -577,7 +587,8 @@ void FGJSBsim::set_Velocities_Local( double north, double east, double down ){
 void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Wind_Body: "
        << u << ", " <<  v << ", " <<  w );
-
+    
+    update_ic();
     fgic->SetUBodyFpsIC(u);
     fgic->SetVBodyFpsIC(v);
     fgic->SetWBodyFpsIC(w);
@@ -588,7 +599,8 @@ void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
 void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Euler_Angles: "
        << phi << ", " << theta << ", " << psi );
-
+    
+    update_ic();
     fgic->SetPitchAngleRadIC(theta);
     fgic->SetRollAngleRadIC(phi);
     fgic->SetTrueHeadingRadIC(psi);
@@ -598,40 +610,27 @@ void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
 //Flight Path
 void FGJSBsim::set_Climb_Rate( double roc) {
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Climb_Rate: " << roc );
-
+    
+    update_ic();
     fgic->SetClimbRateFpsIC(roc);
     needTrim=true;
 }
 
 void FGJSBsim::set_Gamma_vert_rad( double gamma) {
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma );
-
+    
+    update_ic();
     fgic->SetFlightPathAngleRadIC(gamma);
     needTrim=true;
 }
 
-//Earth
-void FGJSBsim::set_Sea_level_radius(double slr) {
-    SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr );
-
-    fgic->SetSeaLevelRadiusFtIC(slr);
-    needTrim=true;
-}
-
-void FGJSBsim::set_Runway_altitude(double ralt) {
-    SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt );
-
-    _set_Runway_altitude( ralt );
-    fgic->SetTerrainAltitudeFtIC( ralt );
-    needTrim=true;
-}
-
 void FGJSBsim::set_Static_pressure(double p) {
     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_pressure: " << p );
-
+    
+    update_ic();
     Atmosphere->SetExPressure(p);
     if(Atmosphere->External() == true)
-    needTrim=true;
+      needTrim=true;
 }
 
 void FGJSBsim::set_Static_temperature(double T) {
@@ -639,7 +638,7 @@ void FGJSBsim::set_Static_temperature(double T) {
     
     Atmosphere->SetExTemperature(T);
     if(Atmosphere->External() == true)
-    needTrim=true;
+      needTrim=true;
 }
  
 
@@ -648,7 +647,7 @@ void FGJSBsim::set_Density(double rho) {
     
     Atmosphere->SetExDensity(rho);
     if(Atmosphere->External() == true)
-    needTrim=true;
+      needTrim=true;
 }
   
 void FGJSBsim::set_Velocities_Local_Airmass (double wnorth, 
@@ -658,7 +657,7 @@ void FGJSBsim::set_Velocities_Local_Airmass (double wnorth,
        << wnorth << ", " << weast << ", " << wdown );
     
     _set_Velocities_Local_Airmass( wnorth, weast, wdown );
-    Atmosphere->SetWindNED(wnorth, weast, wdown );
+    fgic->SetWindNEDFpsIC( wnorth, weast, wdown );
     if(Atmosphere->External() == true)
         needTrim=true;
 }     
@@ -726,3 +725,16 @@ void FGJSBsim::do_trim(void) {
     
         SG_LOG( SG_FLIGHT, SG_INFO, "  Trim complete" );
 }          
+
+void FGJSBsim::update_ic(void) {       
+   if( !needTrim ) {
+     fgic->SetLatitudeRadIC(get_Lat_geocentric() );       
+     fgic->SetLongitudeRadIC( get_Longitude() );       
+     fgic->SetAltitudeFtIC( get_Altitude() );       
+     fgic->SetVcalibratedKtsIC( get_V_calibrated_kts() );       
+     fgic->SetPitchAngleRadIC( get_Theta() );       
+     fgic->SetRollAngleRadIC( get_Phi() );       
+     fgic->SetTrueHeadingRadIC( get_Psi() );       
+     fgic->SetClimbRateFpsIC( get_Climb_Rate() );
+   }  
+}
index b2da20edf6d127a574b07be343063e1ac2f5679e..55dcbc453421f16f9ae1de34d3fed87b17224b41 100644 (file)
@@ -176,16 +176,6 @@ public:
     void set_Gamma_vert_rad( double gamma);
     //@}
 
-    /// @name Earth Parameter Set
-    //@{
-    /** Sets the sea level radius in feet.
-        @param slr Sea Level Radius in feet */
-    void set_Sea_level_radius(double slr);
-
-    /** Sets the runway altitude in feet above sea level.
-        @param ralt Runway altitude in feet above sea level. */
-    void set_Runway_altitude(double ralt);
-    //@}
 
     /// @name Atmospheric Parameter Set
     //@{
@@ -219,6 +209,7 @@ public:
     bool ToggleDataLogging(bool state);
     bool ToggleDataLogging(void);
     void do_trim(void);
+    void update_ic(void);
 
 private:
     FGFDMExec *fdmex;
index fa6973a65d9206ad762db94d224c67af38607a2c..55639c31f2a4bb3802c3b16517ecd4469e56d0f6 100644 (file)
@@ -246,7 +246,7 @@ void FGCoefficient::DisplayCoeffFactors(void)
     cout << "none" << endl;
   } else {
     for (i=0; i<multipliers.size(); i++) 
-        cout << FDMExec->GetState()->paramdef[multipliers[i]];
+      cout << State->GetParameterName(multipliers[i]);
   }
   cout << endl;
 }
index d95e3d8c0fffbe9f0deeafb2e8e6903921d98a1b..1e304e2aaf0dbef5b6b73a949caaf81a03bf1fea 100644 (file)
@@ -256,7 +256,7 @@ bool FGFCS::Load(FGConfigFile* AC_cfg)
   while ((token = AC_cfg->GetValue()) != string("/FLIGHT_CONTROL")) {
     if (token == "COMPONENT") {
       token = AC_cfg->GetValue("TYPE");
-      if (debug_lvl > 0) cout << "    Loading Component \""
+      if (debug_lvl > 0) cout << endl << "    Loading Component \""
                               << AC_cfg->GetValue("NAME")
                               << "\" of type: " << token << endl;
       if ((token == "LAG_FILTER") ||
index 19a105039e9a8759c00b90eb39a2844eed3c1651..25e1dc685f0e9783120513fb1f045bb9bedb6fd2 100644 (file)
@@ -338,14 +338,14 @@ void FGScript::Debug(int from)
 
         for (i=0; i<iterConditions->TestValue.size(); i++) {
           if (i>0) cout << " and" << endl << "        ";
-          cout << "(" << State->paramdef[iterConditions->TestParam[i]]
+          cout << "(" << State->GetParameterName(iterConditions->TestParam[i])
                       << iterConditions->Comparison[i] << " "
                       << iterConditions->TestValue[i] << ")";
         }
         cout << ") then {";
 
         for (i=0; i<iterConditions->SetValue.size(); i++) {
-          cout << endl << "      set" << State->paramdef[iterConditions->SetParam[i]]
+          cout << endl << "      set" << State->GetParameterName(iterConditions->SetParam[i])
                << "to " << iterConditions->SetValue[i];
 
           switch (iterConditions->Type[i]) {
index b3e7267e502638d4be7f9fd07fc1d318e3fcbf73..05c9a6025dccbff1065d2333a504f6ccacc1baf4 100644 (file)
@@ -211,6 +211,12 @@ public:
       */
   inline void Seta(double speed) { a = speed; }
 
+  /** Gets the name of the parameter given the index.
+      @param val_idx one of the enumerated JSBSim parameters.
+      @return the name of the parameter pointed to by the index.
+      */
+  string GetParameterName(eParam val_idx) {return paramdef[val_idx];}
+  
   /** Sets the current sim time.
       @param cur_time the current time
       @return the current time.
@@ -303,10 +309,6 @@ public:
   */
   void ReportState(void);
 
-
-  typedef map<eParam, string> ParamMap;
-  ParamMap paramdef;
-
 private:
   double a;                          // speed of sound
   double sim_time, dt;
@@ -340,6 +342,10 @@ private:
 
   typedef map<string, eParam> CoeffMap;
   CoeffMap coeffdef;
+
+  typedef map<eParam, string> ParamMap;
+  ParamMap paramdef;
+
   int ActiveEngine;
   void Debug(int from);
 };
index f1b916196e3137114f4250b9ccfdbfdd6ca83a8b..1af9dc1dd2612675763d0b14c5ec62a03917a942 100644 (file)
@@ -213,7 +213,15 @@ void FGFilter::Debug(int from)
   if (debug_lvl & 1) { // Standard console startup message output
     if (from == 0) { // Constructor
       cout << "      ID: " << ID << endl;
-      cout << "      INPUT: " << InputIdx << endl;
+      switch(InputType) {
+      case itPilotAC:
+        cout << "      INPUT: " << fcs->GetState()->GetParameterName(InputIdx) << endl;
+        break;
+      case itFCS:
+        cout << "      INPUT: FCS Component " << InputIdx << " (" << 
+                                        fcs->GetComponentName(InputIdx) << ")" << endl;
+        break;
+      }
       cout << "      C1: " << C1 << endl;
       cout << "      C2: " << C2 << endl;
       cout << "      C3: " << C3 << endl;
index 89324b59084825b4dd1e0e2682290b147d94e3db..b2548f8d7a7b3e73c2ce94aff6827407fc9b35ff 100644 (file)
@@ -166,7 +166,15 @@ void FGGain::Debug(int from)
   if (debug_lvl & 1) { // Standard console startup message output
     if (from == 0) { // Constructor
       cout << "      ID: " << ID << endl;
-      cout << "      INPUT: " << InputIdx << endl;
+      switch(InputType) {
+      case itPilotAC:
+        cout << "      INPUT: " << State->GetParameterName(InputIdx) << endl;
+        break;
+      case itFCS:
+        cout << "      INPUT: FCS Component " << InputIdx << " (" << 
+                                        fcs->GetComponentName(InputIdx) << ")" << endl;
+        break;
+      }
       cout << "      GAIN: " << Gain << endl;
       if (IsOutput) cout << "      OUTPUT: " << sOutputIdx << endl;
       cout << "      MIN: " << Min << endl;
index 963b135746881957c3f32bd1a815d675b712819e..15375be44773fd9bbbdbb7f560e9173e3c1f1c49 100644 (file)
@@ -146,7 +146,7 @@ bool FGKinemat::Run(void ) {
           else
             output_transit_rate=(Detents[fi] - Detents[fi+1])/5;
         }
-        if(fabs(OutputPos - InputCmd) > dt*output_transit_rate)
+        if(fabs(OutputPos - InputCmd) > fabs(dt*output_transit_rate) )
           OutputPos+=output_transit_rate*dt;
         else {
           InTransit=0;
index dba37c45874f6a06e630f080c2ef13f8a0d2d630..b033e450b7f895a6d95c3ec9b51941e9d307ca7c 100644 (file)
@@ -168,7 +168,18 @@ void FGSummer::Debug(int from)
       cout << "      ID: " << ID << endl;
       cout << "      INPUTS: " << endl;
       for (unsigned i=0;i<InputIndices.size();i++) {
-        cout << "        " << InputIndices[i] << endl;
+        switch (InputTypes[i]) {
+        case itPilotAC:
+          cout << "       " << fcs->GetState()->GetParameterName(InputIndices[i]) << endl;
+          break;
+        case itFCS:
+          cout << "        FCS Component " << InputIndices[i] << " (" << 
+                              fcs->GetComponentName(InputIndices[i]) << ")" << endl;
+          break;
+        case itBias:
+          cout << "        " << "Bias of " << Bias << endl;
+          break;
+        }
       }
       if (clipmax > clipmin) cout << "      CLIPTO: " << clipmin 
                                   << ", " << clipmax << endl;