]> git.mxchange.org Git - flightgear.git/commitdiff
Updates from Jon and Tony.
authorcurt <curt>
Mon, 10 Jan 2000 21:07:00 +0000 (21:07 +0000)
committercurt <curt>
Mon, 10 Jan 2000 21:07:00 +0000 (21:07 +0000)
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGAircraft.h
src/FDM/JSBSim/FGAuxiliary.cpp
src/FDM/JSBSim/FGAuxiliary.h
src/FDM/JSBSim/FGDefs.h
src/FDM/JSBSim/FGEngine.cpp
src/FDM/JSBSim/FGFCS.h
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGOutput.cpp
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/FGUtility.cpp

index b45efcbbeefcf821174ad7b1051d133ecb0958bf..4b67d947bd4cad9e62f9eaadfa85621e7b9bd225 100644 (file)
@@ -165,7 +165,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
   aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
   ifstream aircraftfile(aircraftDef.c_str());
   cout << "Reading Aircraft Configuration File: " << aircraftDef << endl;
-  Output->SocketStatusOutput("Reading Aircraft Configuration File: " + aircraftDef);
+  // Output->SocketStatusOutput("Reading Aircraft Configuration File: " + aircraftDef);
 
   numTanks = numEngines = 0;
   numSelectedOxiTanks = numSelectedFuelTanks = 0;
@@ -315,7 +315,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
     }
   }
   
-    if(!readAeroRp) {
+  if (!readAeroRp) {
     Xrp = Xcg;
     Yrp = Ycg;
     Zrp = Zcg;
@@ -450,7 +450,7 @@ void FGAircraft::FMAero(void)
   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
     for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++) {
       F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
-      Coeff[axis_ctr][ctr]->DumpSD();
+//      Coeff[axis_ctr][ctr]->DumpSD();
     }
   }
 
@@ -485,7 +485,7 @@ void FGAircraft::FMAero(void)
   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
     for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
       Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue();
-      Coeff[axis_ctr+3][ctr]->DumpSD();
+//      Coeff[axis_ctr+3][ctr]->DumpSD();
     }
   }
 }
index c95762389c8ab4cebca330221c6663ad69eb10e7..12ccf7951122cb6e497e3bec1a1d9deb8963c256 100644 (file)
@@ -154,6 +154,7 @@ public:
   inline float GetIyy(void) {return Iyy;}
   inline float GetIzz(void) {return Izz;}
   inline float GetIxz(void) {return Ixz;}
+  inline float GetXcg(void) {return Xcg;}
   inline int   GetNumEngines(void) {return numEngines;}
 
 private:
index 232e05f09fcbc94c7fcb74db04056a54d9a4ecda..5791b7706d6781a92430a7c2b334182f490d1e67 100644 (file)
@@ -30,6 +30,9 @@ FUNCTIONAL DESCRIPTION
 This class calculates various auxiliary parameters, mostly used by the visual
 system
 
+REFERENCES
+       Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989
+                         pgs. 112-126
 HISTORY
 --------------------------------------------------------------------------------
 01/26/99   JSB   Created
@@ -56,6 +59,8 @@ INCLUDES
 FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
 {
   Name = "FGAuxiliary";
+  vcas=veas=mach=qbar=pt=0;
+  psl=rhosl=1;
 }
 
 
@@ -66,10 +71,38 @@ FGAuxiliary::~FGAuxiliary()
 
 bool FGAuxiliary::Run()
 {
+  float A,B,D;
   if (!FGModel::Run()) {
+       GetState();
+       if(mach < 1)
+           //calculate total pressure assuming isentropic flow
+               pt=p*pow((1 + 0.2*mach*mach),3.5); 
+       else
+       {
+           // shock in front of pitot tube, we'll assume its normal and use
+               // the Rayleigh Pitot Tube Formula, i.e. the ratio of total 
+               // pressure behind the shock to the static pressure in front
+               B=5.76*mach*mach/(5.6*mach*mach - 0.8); 
+               // The denominator above is zero for Mach ~ 0.38, for which 
+               // we'll never be here, so we're safe
+               D=(2.8*mach*mach-0.4)*0.4167;
+               pt=p*pow(B,3.5)*D;
+       }       
+       A=pow(((pt-p)/psl+1),0.28571);
+       vcas=sqrt(7*psl/rhosl*(A-1)); 
+       veas=sqrt(2*qbar/rhosl);
   } else {
   }
   return false;
 }
 
-
+void FGAuxiliary::GetState(void)
+{
+       qbar=State->Getqbar();
+       mach=State->GetMach();
+       p=Atmosphere->GetPressure();
+       rhosl=Atmosphere->GetDensity(0);
+       psl=Atmosphere->GetPressure(0);
+}      
+
+void FGAuxiliary::PutState(void){}
index 87bd97e3a39f3c6992df8053a9e6d9c8547775ae..e80114a742fc67b5dc64092564ab9318455da8c9 100644 (file)
@@ -26,6 +26,7 @@
 HISTORY
 --------------------------------------------------------------------------------
 11/22/98   JSB   Created
+  1/1/00   TP    Added calcs and getters for VTAS, VCAS, VEAS, Vground, in knots
 
 ********************************************************************************
 SENTRY
@@ -57,9 +58,23 @@ public:
    
   bool Run(void);
   
+  
+  inline float GetVcalibratedFPS(void) { return vcas; }
+  inline float GetVcalibratedKTS(void) { return vcas*FPSTOKTS; }
+  inline float GetVequivalentFPS(void) { return veas; }
+  inline float GetVequivalentKTS(void) { return veas*FPSTOKTS; }
+  
+  
 protected:
 
 private:
+  float vcas;
+  float veas;
+  float mach;
+  float qbar,rhosl,rho,p,psl,pt;
+  
+  void GetState(void);
+  void PutState(void);
 
 };
 
index 0447675f4e813bc05f0f5759b1984505d39c3f97..152bbbb8d508397c686fa63365b31ec243f6e81f 100644 (file)
@@ -55,7 +55,7 @@ SENTRY
 #define NEEDED_CFG_VERSION 1.10
 
 #define HPTOFTLBSSEC 550
-
+#define METERS_TO_FEET 3.2808
 
 
 /******************************************************************************/
index c0d5368dd5db60d7dfbfa0049ac2e4696c925aca..2ab29d3b4e45e731c8f3c33d830de654bca49560 100644 (file)
@@ -130,7 +130,7 @@ FGEngine::FGEngine(FGFDMExec* fdex, string enginePath, string engineName, int nu
 
     enginefile.close();
   } else {
-    cerr << "Unable to open engine definition file " << engineName << endl;
+    cerr << "Unable to open engine definition file " << fullpath << endl;
   }
 
   EngineNumber = num;
@@ -172,6 +172,8 @@ float FGEngine::CalcPistonThrust(void)
   float v,h,pa;
 
   Throttle = FCS->GetThrottle(EngineNumber);
+  Throttle /= 100;
   v=State->GetVt();
   h=State->Geth();
   if(v < 10)
index c5226e7852e4b076350c5d9e061a1054e909f90b..1980cd0afcea8460e46dc9a3cf95aa73f77445b5 100644 (file)
@@ -61,9 +61,9 @@ public:
        inline float GetDs(void) {return Ds;}
        inline float GetThrottle(int ii) {return Throttle[ii];}
 
-       inline void SetDa(float tt) {Da = tt*0.17;}
+       inline void SetDa(float tt) {Da = tt*0.30;}
        inline void SetDe(float tt) {De = tt*0.60;}
-       inline void SetDr(float tt) {Dr = tt*1.09;}
+       inline void SetDr(float tt) {Dr = -1*tt*0.50;}
        inline void SetDf(float tt) {Df = tt;}
        inline void SetDs(float tt) {Ds = tt;}
        void SetThrottle(int ii, float tt);
@@ -76,4 +76,4 @@ private:
 };
 
 /******************************************************************************/
-#endif
\ No newline at end of file
+#endif
index 4210e7de7551456be33b56ff4f8728f091ab98d3..942f045189ddca752eb0e2b314c9f490eaa25999 100644 (file)
@@ -119,7 +119,7 @@ FGFDMExec::FGFDMExec(void)
   Schedule(Translation, 1);
   Schedule(Position,    1);
   Schedule(Auxiliary,   1);
-  Schedule(Output,      1);
+  Schedule(Output,     60);
 
   terminate = false;
   frozen = false;
index 014a8de05935aee22a9f749b67a5b6199a5d8642..1cb8d7cfaf6e2033902aa0c8108cb06443fbfb34 100644 (file)
@@ -58,10 +58,10 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
 {
   Name = "FGOutput";
   sFirstPass = dFirstPass = true;
-
-#ifdef FG_WITH_JSBSIM_SOCKET
+  socket = 0;
+//#ifdef FG_WITH_JSBSIM_SOCKET
   socket = new FGfdmSocket("localhost",1138);
-#endif
+//#endif
 }
 
 
@@ -75,7 +75,8 @@ bool FGOutput::Run(void)
 {
   if (!FGModel::Run()) {
 //    SocketOutput();
-    DelimitedOutput("JSBSimData.csv");
+//    DelimitedOutput("JSBSimData.csv");
+//    DelimitedOutput();
   } else {
   }
   return false;
@@ -120,7 +121,13 @@ void FGOutput::DelimitedOutput(void)
     cout << "Throttle,";
     cout << "Aileron,";
     cout << "Elevator,";
-    cout << "Rudder";
+    cout << "Rudder,";
+    cout << "Ixx,";
+    cout << "Iyy,";
+    cout << "Izz,";
+    cout << "Ixz,";
+    cout << "Mass,";
+    cout << "X CG";
     cout << endl;
     dFirstPass = false;
   }
@@ -160,7 +167,13 @@ void FGOutput::DelimitedOutput(void)
   cout << FCS->GetThrottle(0) << ",";
   cout << FCS->GetDa() << ",";
   cout << FCS->GetDe() << ",";
-  cout << FCS->GetDr() << "";
+  cout << FCS->GetDr() << ",";
+  cout << Aircraft->GetIxx() << ",";
+  cout << Aircraft->GetIyy() << ",";
+  cout << Aircraft->GetIzz() << ",";
+  cout << Aircraft->GetIxz() << ",";
+  cout << Aircraft->GetMass() << ",";
+  cout << Aircraft->GetXcg() << "";
   cout << endl;
 
 }
@@ -205,7 +218,13 @@ void FGOutput::DelimitedOutput(string fname)
     datafile << "Throttle,";
     datafile << "Aileron,";
     datafile << "Elevator,";
-    datafile << "Rudder";
+    datafile << "Rudder,";
+    datafile << "Ixx,";
+    datafile << "Iyy,";
+    datafile << "Izz,";
+    datafile << "Ixz,";
+    datafile << "Mass,";
+    datafile << "X CG";
     datafile << endl;
     sFirstPass = false;
   }
@@ -245,7 +264,13 @@ void FGOutput::DelimitedOutput(string fname)
   datafile << FCS->GetThrottle(0) << ",";
   datafile << FCS->GetDa() << ",";
   datafile << FCS->GetDe() << ",";
-  datafile << FCS->GetDr() << "";
+  datafile << FCS->GetDr() << ",";
+  datafile << Aircraft->GetIxx() << ",";
+  datafile << Aircraft->GetIyy() << ",";
+  datafile << Aircraft->GetIzz() << ",";
+  datafile << Aircraft->GetIxz() << ",";
+  datafile << Aircraft->GetMass() << ",";
+  datafile << Aircraft->GetXcg() << "";
   datafile << endl;
   datafile.flush();
 }
@@ -291,6 +316,10 @@ void FGOutput::SocketOutput(void)
     socket->Append("L");
     socket->Append("M");
     socket->Append("N");
+    socket->Append("Throttle");
+    socket->Append("Aileron");
+    socket->Append("Elevator");
+    socket->Append("Rudder");
     sFirstPass = false;
     socket->Send();
   }
@@ -328,6 +357,10 @@ void FGOutput::SocketOutput(void)
   socket->Append(Aircraft->GetL());
   socket->Append(Aircraft->GetM());
   socket->Append(Aircraft->GetN());
+  socket->Append(FCS->GetThrottle(0));
+  socket->Append(FCS->GetDa());
+  socket->Append(FCS->GetDe());
+  socket->Append(FCS->GetDr());
   socket->Send();
 }
 
index a087f08db2a922dc5149641bbd913f6fa6b36a87..59773edb45fdaf6daacf12f6cc0e45f213ca5db3 100644 (file)
@@ -73,7 +73,8 @@ FGState::FGState(FGFDMExec* fdex)
   h = 0.0;
   a = 1000.0;
   qbar = 0.0;
-  sim_time = dt = 0.1;
+  sim_time = 0.0;
+  dt = 1.0/120.0;
 }
 
 
index 4b72f6132558d5d91b2ef4d0b94b25c39aca3f78..f44b29e8802833d894132417f84cbc746bd78e67 100644 (file)
@@ -82,57 +82,10 @@ FGUtility::~FGUtility()
 
 float FGUtility::ToGeodetic()
 {
-  float Latitude, Radius, Altitude;
-  float tanLat, xAlpha, muAlpha, sinmuAlpha, denom, rhoAlpha, dMu;
-  float lPoint, lambdaSL, sinlambdaSL, dLambda, rAlpha;
-
-  Latitude = State->Getlatitude();
-  Radius = State->Geth() + EARTHRAD;
-
-  if (( M_PI_2 - Latitude < ONESECOND) ||
-      ( M_PI_2 + Latitude < ONESECOND)) { // Near a pole
-  } else {
-    tanLat = tan(Latitude);
-    xAlpha = ECCENT*EARTHRAD /
-                                sqrt(tanLat*tanLat + ECCENTSQRD);
-    muAlpha = atan2(sqrt(EARTHRADSQRD - xAlpha*xAlpha), ECCENT*xAlpha);
-
-    if (Latitude < 0.0) muAlpha = -muAlpha;
-
-    sinmuAlpha  = sin(muAlpha);
-    dLambda     = muAlpha - Latitude;
-    rAlpha      = xAlpha / cos(Latitude);
-    lPoint      = Radius - rAlpha;
-    Altitude    = lPoint*cos(dLambda);
-    denom       = sqrt(1-EPS*EPS*sinmuAlpha*sinmuAlpha);
-    rhoAlpha    = EARTHRAD*(1.0 - EPS) / (denom*denom*denom);
-    dMu         = atan2(lPoint*sin(dLambda),rhoAlpha + Altitude);
-    State->SetGeodeticLat(muAlpha - dMu);
-    lambdaSL    = atan(ECCENTSQRD*tan(muAlpha - dMu));
-    sinlambdaSL = sin(lambdaSL);
-    SeaLevelR   = sqrt(EARTHRADSQRD / (1 + INVECCENTSQRDM1* sinlambdaSL*sinlambdaSL));
-  }
-  return 0.0;
 }
 
 
 float FGUtility:: FromGeodetic()
 {
-  float lambdaSL, sinlambdaSL, coslambdaSL, sinMu, cosMu, py, px;
-  float Altitude, SeaLevelR, Radius;
-
-  Radius = State->Geth() + EARTHRAD;
-  lambdaSL = atan(ECCENTSQRD*tan(State->GetGeodeticLat()));
-  sinlambdaSL = sin(lambdaSL);
-  coslambdaSL = cos(lambdaSL);
-  sinMu = sin(State->GetGeodeticLat());
-  cosMu = cos(State->GetGeodeticLat());
-  SeaLevelR = sqrt(EARTHRADSQRD /
-             (1 + INVECCENTSQRDM1*sinlambdaSL*sinlambdaSL));
-  Altitude  = Radius - SeaLevelR;
-  px = SeaLevelR*coslambdaSL + Altitude*cosMu;
-  py = SeaLevelR*sinlambdaSL + Altitude*sinMu;
-  State->Setlatitude(atan2(py,px));
-  return 0.0;
 }