]> git.mxchange.org Git - flightgear.git/commitdiff
Sync with latest JSBSim CVS.
authorcurt <curt>
Sat, 24 Nov 2001 22:13:04 +0000 (22:13 +0000)
committercurt <curt>
Sat, 24 Nov 2001 22:13:04 +0000 (22:13 +0000)
15 files changed:
aclocal.m4
src/FDM/JSBSim/FGAtmosphere.cpp
src/FDM/JSBSim/FGAtmosphere.h
src/FDM/JSBSim/FGColumnVector3.cpp
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGInitialCondition.cpp
src/FDM/JSBSim/FGJSBBase.cpp
src/FDM/JSBSim/FGJSBBase.h
src/FDM/JSBSim/FGPiston.cpp
src/FDM/JSBSim/FGPiston.h
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/FGTrim.h
src/FDM/Makefile.am
src/Include/config.h.in
src/Sound/fg_fx.cxx

index 78a4037e5c412f8cbb48479f9e8cf5998f0aad3e..7d5836b91f4d1fbed719541171644fe7ba3a68b6 100644 (file)
@@ -1,4 +1,4 @@
-dnl aclocal.m4 generated automatically by aclocal 1.4
+dnl aclocal.m4 generated automatically by aclocal 1.4-p4
 
 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
index 407d5dfd459ba385f52a663a8878f064eb0bb496..acc7613cb9f1dc2a934bc0466d650248162dcf49 100644 (file)
@@ -69,7 +69,14 @@ CLASS IMPLEMENTATION
 
 
 FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex),
-                                               vWindNED(3)
+                                               vWindNED(3),
+                                               vDirectiondAccelDt(3),
+                                               vDirectionAccel(3),
+                                               vDirection(3),
+                                               vTurbulence(3),
+                                               vTurbulenceGrad(3),
+                                               vBodyTurbGrad(3),
+                                               vTurbPQR(3)
 {
   Name = "FGAtmosphere";
   lastIndex=0;
@@ -83,6 +90,11 @@ FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex),
   htab[6]=200131.234;
   htab[7]=259186.352; //ft.
 
+  MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0;
+//  turbType = ttNone;
+  turbType = ttBerndt; // temporarily disable turbulence until fully tested
+  TurbGain = 100.0;
+
   if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
 }
 
@@ -128,6 +140,11 @@ bool FGAtmosphere::Run(void)
       temperature = exTemperature;
     }
 
+    if (turbType != ttNone) {
+      Turbulence();
+      vWindNED += vTurbulence;
+    }
+
     if (vWindNED(1) != 0.0) psiw = atan2( vWindNED(2), vWindNED(1) );
 
     if (psiw < 0) psiw += 2*M_PI;
@@ -135,6 +152,9 @@ bool FGAtmosphere::Run(void)
     soundspeed = sqrt(SHRatio*Reng*temperature);
 
     State->Seta(soundspeed);
+
+    if (debug_lvl > 1) Debug();
+
   } else {                               // skip Run() execution this time
   }
 
@@ -142,28 +162,31 @@ bool FGAtmosphere::Run(void)
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//
+// See reference 1
 
 void FGAtmosphere::Calculate(double altitude)
 {
-  //see reference [1]
+  double slope, reftemp, refpress;
+  int i = 0;
+  bool lookup = false;
 
-  double slope,reftemp,refpress;
-  int i=0; bool lookup = false;
-  // cout << "Atmosphere:  h=" << altitude << " rho= " << density << endl;
-  i=lastIndex;
-  if(altitude < htab[lastIndex]) {
+  i = lastIndex;
+  if (altitude < htab[lastIndex]) {
     if (altitude <= 0) { 
-      i=0; altitude=0;
+      i = 0;
+      altitude=0;
     } else {
-       i=lastIndex-1;
-       while (htab[i] > altitude) { i--; }
+       i = lastIndex-1;
+       while (htab[i] > altitude) i--;
     }   
   } else if (altitude > htab[lastIndex+1]){
     if (altitude >= htab[7]){
-      i = 7; altitude = htab[7];
+      i = 7;
+      altitude = htab[7];
     } else {
-      i=lastIndex+1;
-      while(htab[i+1] < altitude) { i++; } 
+      i = lastIndex+1;
+      while(htab[i+1] < altitude) i++;
     }  
   } 
 
@@ -235,8 +258,57 @@ void FGAtmosphere::Calculate(double altitude)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+void FGAtmosphere::Turbulence(void)
+{
+  switch (turbType) {
+  case ttBerndt:
+    vDirectiondAccelDt(eX) = 1 - 2.0*(((double)(rand()))/RAND_MAX);
+    vDirectiondAccelDt(eY) = 1 - 2.0*(((double)(rand()))/RAND_MAX);
+    vDirectiondAccelDt(eZ) = 1 - 2.0*(((double)(rand()))/RAND_MAX);
+
+    MagnitudedAccelDt = 1 - 2.0*(((double)(rand()))/RAND_MAX);
+    MagnitudeAccel    += MagnitudedAccelDt*rate*State->Getdt();
+    Magnitude         += MagnitudeAccel*rate*State->Getdt();
+
+    vDirectiondAccelDt.Normalize();
+    vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt();
+    vDirectionAccel.Normalize();
+    vDirection      += vDirectionAccel*rate*State->Getdt();
+    vDirection.Normalize();
+    
+    vTurbulence = TurbGain*Magnitude * vDirection;
+    vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
+
+    vBodyTurbGrad = State->GetTl2b()*vTurbulenceGrad;
+    vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
+    if (Aircraft->GetHTailArm() != 0.0)
+      vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
+    else
+      vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
+
+    if (Aircraft->GetVTailArm())
+      vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
+    else
+      vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
+
+    break;
+  default:
+    break;
+  }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGAtmosphere::Debug(void)
 {
-    //TODO: Add your source code here
+  if (frame == 0) {
+    cout << "vTurbulence(X), vTurbulence(Y), vTurbulence(Z), "
+         << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), "
+         << "vDirection(X), vDirection(Y), vDirection(Z), "
+         << "Magnitude, "
+         << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl;
+  } else {
+    cout << vTurbulence << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
+  }
 }
 
index fe0fe322b008fc0b5084dd76a92fe32eb9d9eb05..faa74ea44c3457ad39b16590919eb9f5d5d922cb 100644 (file)
@@ -142,9 +142,15 @@ public:
       increases counterclockwise. The wind heading is returned in radians.*/
   inline double GetWindPsi(void) { return psiw; }
   
+  inline void SetTurbGain(double tt) {TurbGain = tt;}
+  
+  inline double GetTurbPQR(int idx) {return vTurbPQR(idx);}
+  
 private:
   double rho;
 
+  enum tType {ttBerndt, ttNone} turbType;
+
   int lastIndex;
   double h;
   double htab[8];
@@ -154,10 +160,21 @@ private:
   bool useExternal;
   double exTemperature,exDensity,exPressure;
   
+  double MagnitudedAccelDt, MagnitudeAccel, Magnitude;
+  double TurbGain;
+  FGColumnVector3 vDirectiondAccelDt;
+  FGColumnVector3 vDirectionAccel;
+  FGColumnVector3 vDirection;
+  FGColumnVector3 vTurbulence;
+  FGColumnVector3 vTurbulenceGrad;
+  FGColumnVector3 vBodyTurbGrad;
+  FGColumnVector3 vTurbPQR;
+
   FGColumnVector3 vWindNED;
   double psiw;
 
   void Calculate(double altitude);
+  void Turbulence(void);
   void Debug(void);
 };
 
index 070ea5e71504244c809cf6057c77053138888046..0c27fa4d056eabff7ec20f2838a33fa1436e7485 100644 (file)
@@ -32,8 +32,9 @@ CLASS IMPLEMENTATION
 FGColumnVector3::FGColumnVector3(void)
 {
   rowCtr = 1;
-  //cout << "Allocated: " <<  data << endl;
-  //if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
+  data[0]=0; data[1]=0; data[2]=0; data[3]=0;
+
+  if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -41,16 +42,15 @@ FGColumnVector3::FGColumnVector3(void)
 FGColumnVector3::FGColumnVector3(int m)
 {
   rowCtr = 1;
-  data[1]=0;data[2]=0;data[3]=0;
-  //cout << "Allocated: " <<  data << endl;
-  //if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
+  data[0]=0; data[1]=0; data[2]=0; data[3]=0;
+
+  if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 FGColumnVector3::~FGColumnVector3(void)
 {
-  //cout << "Freed: " << data << endl;
   if (debug_lvl & 2) cout << "Destroyed:    FGColumnVector3" << endl;
 }
 
index f6e10e0ff2a4f75b8e31e74482ca8e6816394faa..1031a17b09fb6f8d3aa3109fac898814ce86956c 100644 (file)
@@ -349,7 +349,7 @@ bool FGFDMExec::Run(void)
     if (model_iterator == 0L) break;
   }
 
-  Frame++;
+  frame = Frame++;
   State->IncrTime();
 
   return true;
index 31be45a1ebdcf0b573aa852b526de1fe542f9f1a..b407f0375fb9e5f96435d11b0d2603c545914a97 100644 (file)
@@ -664,7 +664,8 @@ bool FGInitialCondition::solve(double *y,double x)
   i=0;
   while ((fabs(d) > eps) && (i < 100)) {
     d=(x3-x1)/d0;
-    x2=x1-d*d0*f1/(f3-f1);
+    if (f3-f1 != 0.0) x2 = x1-d*d0*f1/(f3-f1);
+    else              x2 = x1-d*d0*f1/0.01; // TONY: What is correct? This is a WAG.
 
     f2=(this->*sfunc)(x2)-x;
     //cout << "solve x1,x2,x3: " << x1 << "," << x2 << "," << x3 << endl;
index 786b57c31e9d09c031998fe8d563640080f5ff2f..9e1f6763617b51f0608ec43d9b8c69d1e1d96e57 100644 (file)
@@ -70,6 +70,7 @@ const string FGJSBBase::JSBSim_version = "0.9.1";
 queue <struct FGJSBBase::Message*> FGJSBBase::Messages;
 struct FGJSBBase::Message FGJSBBase::localMsg;
 unsigned int FGJSBBase::messageId = 0; 
+unsigned int FGJSBBase::frame = 0;
 
 short FGJSBBase::debug_lvl  = 0;
 
index 6408fa2c7cddea81186e00aca0569ff23e4b1667..93e40fe246a8199f2631b5a7248290a61d62120a 100644 (file)
@@ -94,6 +94,9 @@ enum eParam {
   FG_PITCHRATE,
   FG_ROLLRATE,
   FG_YAWRATE,
+  FG_AEROP,
+  FG_AEROQ,
+  FG_AEROR,
   FG_CL_SQRD,
   FG_MACH,
   FG_ALTITUDE,
@@ -260,7 +263,7 @@ protected:
   virtual void Debug(void) {};
 
   static short debug_lvl;
-  static int frame;
+  static unsigned int frame;
   static unsigned int messageId;
   
   static const double radtodeg;
index 299f225a34c812372f7f4ee88063e540937e1241..1a6a62bc3737e66f1f0d75c99da843c42224c1bd 100644 (file)
@@ -96,6 +96,7 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg)
   }
 
   Type = etPiston;
+  crank_counter = 0;
   EngineNumber = 0;    // FIXME: this should be the actual number
   OilTemp_degK = 298;  // FIXME: should be initialized in FGEngine
 
@@ -211,7 +212,6 @@ void FGPiston::doEngineStartup(void)
   // (spark, fuel, starter motor etc)
   bool spark;
   bool fuel;
-  static int crank_counter = 0;
 
   // Check for spark
   Magneto_Left = false;
index 9e2dc476a1fdda57e040bd17a7b511d245c24fae..7aab17ebbea2b866aa24a069d087456e96b9109d 100644 (file)
@@ -88,6 +88,8 @@ public:
   double GetPowerAvailable(void) {return PowerAvailable;}
 
 private:
+  int crank_counter;
+
   double BrakeHorsePower;
   double SpeedSlope;
   double SpeedIntercept;
index 7a63758fe7d4199c77052657c772796bf8278db3..5a341b329dde59b1fba10f6e635bdb5a73b1cd18 100644 (file)
@@ -47,6 +47,10 @@ INCLUDES
 #  endif
 #endif
 
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
 #include "FGState.h"
 
 static const char *IdSrc = "$Id$";
@@ -115,6 +119,9 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
   RegisterVariable(FG_PITCHRATE,      " pitch_rate "     );
   RegisterVariable(FG_ROLLRATE,       " roll_rate "      );
   RegisterVariable(FG_YAWRATE,        " yaw_rate "       );
+  RegisterVariable(FG_AEROQ,          " aero_pitch_rate ");
+  RegisterVariable(FG_AEROP,          " aero_roll_rate " );
+  RegisterVariable(FG_AEROR,          " aero_yaw_rate "  );
   RegisterVariable(FG_CL_SQRD,        " Clift_sqrd "     );
   RegisterVariable(FG_MACH,           " mach "           );
   RegisterVariable(FG_ALTITUDE,       " altitude "       );
@@ -216,6 +223,12 @@ double FGState::GetParameter(eParam val_idx) {
     return Rotation->GetPQR(eP);
   case FG_YAWRATE:
     return Rotation->GetPQR(eR);
+  case FG_AEROQ:
+    return Rotation->GetPQR(eQ) + Atmosphere->GetTurbPQR(eQ); // add aero turbulence effects
+  case FG_AEROP:
+    return Rotation->GetPQR(eP) + Atmosphere->GetTurbPQR(eP); // add aero turbulence effects
+  case FG_AEROR:
+    return Rotation->GetPQR(eR) + Atmosphere->GetTurbPQR(eR); // add aero turbulence effects
   case FG_CL_SQRD:
     if (Translation->Getqbar() > 0.00)
       scratch = Aerodynamics->GetvLastFs(eLift)/(Aircraft->GetWingArea()*Translation->Getqbar());
index acbff2fba9f3db3de5489906966c81d0574f08f3..810e385d853407469958afe95365936b760daef3 100644 (file)
@@ -72,6 +72,10 @@ DEFINITIONS
 
 typedef enum { tLongitudinal, tFull, tGround, tCustom, tNone } TrimMode;
 
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index 485dbf5d801862b245906b114400176b291df8a1..c711e0b85de32d7d012abef335e5e269dd3dcc41 100644 (file)
@@ -6,6 +6,7 @@ libFlight_a_SOURCES = \
        ADA.cxx ADA.hxx \
        Balloon.cxx Balloon.h \
        External.cxx External.hxx \
+       ExternalNet.cxx ExternalNet.hxx \
        flight.cxx flight.hxx \
        IO360.cxx IO360.hxx \
        JSBSim.cxx JSBSim.hxx \
index 3c18956c748fa862c84648c611c235b2e4acbc17..553a55a5ab56b72ca2443667ba237352e6cec159 100644 (file)
@@ -1,4 +1,4 @@
-/* src/Include/config.h.in.  Generated automatically from configure.in by autoheader.  */
+/* src/Include/config.h.in.  Generated automatically from configure.in by autoheader 2.13.  */
 
 /* Define to empty if the keyword does not work.  */
 #undef const
index bd80790a2e7d747dd61ed24b0ca68281ad89801b..c780807d998e22b15f02df1d0a54b381bf91235b 100644 (file)
@@ -211,7 +211,7 @@ FGFX::update ()
 
   float rel_wind = cur_fdm_state->get_V_rel_wind(); // FPS
   if (rel_wind > 60.0) {       // a little off 30kt
-    float volume = rel_wind/1200.0;    // FIXME!!!
+    float volume = rel_wind/600.0;     // FIXME!!!
     _wind->set_volume(volume);
     set_playing("wind", true);
   } else {
@@ -273,7 +273,7 @@ FGFX::update ()
                                // if the velocity is under 6kt.
   double speed = cur_fdm_state->get_V_equiv_kts();
   if (gearOnGround > 0 && speed >= 6.0) {
-    double volume = (gearOnGround/totalGear) * (speed/60.0);
+    double volume = 2.0 * (gearOnGround/totalGear) * (speed/60.0);
     _rumble->set_volume(volume);
     set_playing("rumble", true);
   } else {