]> git.mxchange.org Git - flightgear.git/commitdiff
05/30/2000 updates from Jon Berdnt. Landing gear code now is beginning to
authorcurt <curt>
Tue, 30 May 2000 16:48:52 +0000 (16:48 +0000)
committercurt <curt>
Tue, 30 May 2000 16:48:52 +0000 (16:48 +0000)
work.

src/FDM/JSBSim.cxx
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGConfigFile.cpp
src/FDM/JSBSim/FGConfigFile.h
src/FDM/JSBSim/FGControls.cpp
src/FDM/JSBSim/FGControls.h
src/FDM/JSBSim/FGLGear.cpp
src/FDM/JSBSim/FGPosition.h
src/FDM/JSBSim/FGTranslation.cpp
src/FDM/JSBSim/FGTrimLong.cpp

index 0714817c7e2f7abfdb52c01d1b876311fbef36d3..25a47a69df43a72ec77d1c7a895cdfd590c24d0a 100644 (file)
@@ -62,7 +62,7 @@
 
 int FGJSBsim::init( double dt ) {
 
-
+  bool result;
 
   FG_LOG( FG_FLIGHT, FG_INFO, "Starting and initializing JSBsim" );
   FG_LOG( FG_FLIGHT, FG_INFO, "  created FDMExec" );
@@ -75,12 +75,17 @@ int FGJSBsim::init( double dt ) {
 
   FDMExec.GetState()->Setdt( dt );
 
-  FDMExec.GetAircraft()->LoadAircraft( aircraft_path.str(),
+  result = FDMExec.GetAircraft()->LoadAircraft( aircraft_path.str(),
                                        engine_path.str(),
                                        current_options.get_aircraft() );
 
-  FG_LOG( FG_FLIGHT, FG_INFO, "  loaded aircraft" <<
-          current_options.get_aircraft() );
+  if (result) {
+    FG_LOG( FG_FLIGHT, FG_INFO, "  loaded aircraft" << current_options.get_aircraft() );
+  } else {
+    FG_LOG( FG_FLIGHT, FG_INFO, "  aircraft" << current_options.get_aircraft()
+                                << " does not exist");
+    return 0;
+  }
 
   FDMExec.GetAtmosphere()->UseInternal();
 
@@ -109,10 +114,12 @@ int FGJSBsim::init( double dt ) {
   fgic->SetRollAngleRadIC(get_Phi());
   fgic->SetPitchAngleRadIC(get_Theta());
   fgic->SetHeadingRadIC(get_Psi());
-  fgic->SetLatitudeRadIC(get_Latitude());
+//  fgic->SetLatitudeRadIC(get_Latitude());
+  fgic->SetLatitudeRadIC(get_Lat_geocentric());
   fgic->SetLongitudeRadIC(get_Longitude());
 
-  FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius);
+  FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
+  FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
 
   FG_LOG( FG_FLIGHT, FG_INFO, "  phi: " <<  get_Phi());
   FG_LOG( FG_FLIGHT, FG_INFO, "  theta: " <<  get_Theta() );
@@ -120,9 +127,9 @@ int FGJSBsim::init( double dt ) {
   FG_LOG( FG_FLIGHT, FG_INFO, "  lat: " <<  get_Latitude() );
   FG_LOG( FG_FLIGHT, FG_INFO, "  lon: " <<  get_Longitude() );
   FG_LOG( FG_FLIGHT, FG_INFO, "  alt: " <<  get_Altitude() );
-  
+
   //must check > 0, != 0 will give bad result if --notrim set
-  if(current_options.get_trim_mode() == true) {
+  if(current_options.get_trim_mode() > 0) {
     FG_LOG( FG_FLIGHT, FG_INFO, "  Starting trim..." );
     FGTrimLong *fgtrim=new FGTrimLong(&FDMExec,fgic);
     fgtrim->DoTrim();
@@ -130,8 +137,10 @@ int FGJSBsim::init( double dt ) {
     fgtrim->TrimStats();
     fgtrim->ReportState();
 
-    controls.set_elevator_trim(FDMExec.GetFCS()->GetPitchTrimCmd());
+    controls.set_elevator_trim(FDMExec.GetFCS()->GetDeCmd());
     controls.set_throttle(FGControls::ALL_ENGINES,FDMExec.GetFCS()->GetThrottleCmd(0)/100);
+    //the trimming routine only knows how to get 1 value for throttle
+
     
     delete fgtrim;
     FG_LOG( FG_FLIGHT, FG_INFO, "  Trim complete." );
@@ -185,7 +194,8 @@ int FGJSBsim::update( int multiloop ) {
 
   // Inform JSBsim of the local terrain altitude; uncommented 5/3/00
   //  FDMExec.GetPosition()->SetRunwayElevation(get_Runway_altitude()); // seems to work
-  FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius);
+  FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET);
+  FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius());
 
   FDMExec.GetAtmosphere()->SetExTemperature(get_Static_temperature());
   FDMExec.GetAtmosphere()->SetExPressure(get_Static_pressure());
index cb885563190d4ae2e0b4b43936591e01f980fe85..316356337b7228e305daa2ac94f3d251f28b8cc8 100644 (file)
@@ -176,6 +176,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
   aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".cfg";
 
   FGConfigFile AC_cfg(aircraftCfgFileName);
+  if (!AC_cfg.IsOpen()) return false;
 
   ReadPrologue(&AC_cfg);
 
index 8016df771b59115fec9e2f6fa26ec00f9d910b09..ae020ec21dad6341d9833a91d14425d48f8ea325 100644 (file)
@@ -30,7 +30,9 @@ FGConfigFile::FGConfigFile(string cfgFileName)
   cfgfile.open(cfgFileName.c_str());
   CommentsOn = false;
   CurrentIndex = 0;
-  GetNextConfigLine();
+  Opened = true;
+  if (cfgfile.is_open()) GetNextConfigLine();
+  else Opened = false;
 }
 
 
index a5c065d031b6c166296ce1fcce94eb918d2de961..e5d1ab32fb5473505f43d90a9e38d349b0eb66a5 100644 (file)
@@ -75,6 +75,7 @@ public:
   string GetValue(string);
   string GetValue(void);
   bool IsCommentLine(void);
+  bool IsOpen(void) {return Opened;}
   FGConfigFile& operator>>(double&);
   FGConfigFile& operator>>(float&);
   FGConfigFile& operator>>(int&);
@@ -87,6 +88,7 @@ private:
   ifstream cfgfile;
   string   CurrentLine;
   bool     CommentsOn;
+  bool     Opened;
   unsigned int      CurrentIndex;
 };
 
index 4ce14792e6de2991d57c4192b51cf0648b1514db..277db5c528cd0bd3b660f74e0944041da87ac06b 100644 (file)
@@ -51,8 +51,9 @@ FGControls::~FGControls() {
 
 
 // $Log$
-// Revision 1.11  2000/05/27 03:48:15  curt
-// 5/26/2000 updated from Jon and Tony.
+// Revision 1.12  2000/05/30 14:48:53  curt
+// 05/30/2000 updates from Jon Berdnt.  Landing gear code now is beginning to
+// work.
 //
 // Revision 1.3  2000/04/26 10:55:57  jsb
 // Made changes as required by Curt to install JSBSim into FGFS
index 3b16b8cf53e32d7fbc7b1d7fd043b2a2af887f0f..a85c4ccb73dcd18044f3748b88d5f5210e56fc88 100644 (file)
@@ -175,8 +175,9 @@ extern FGControls controls;
 
 
 // $Log$
-// Revision 1.10  2000/05/27 03:48:15  curt
-// 5/26/2000 updated from Jon and Tony.
+// Revision 1.11  2000/05/30 14:48:53  curt
+// 05/30/2000 updates from Jon Berdnt.  Landing gear code now is beginning to
+// work.
 //
 // Revision 1.5  2000/05/12 22:45:35  jsb
 // Removed extraneous namespace identifiers and header files
index 865fbe6bf0eca0f54d0eb08169d9915d91f16626..ca7235ca798adcf1866f09b79a070ecc1edb57b9 100644 (file)
@@ -55,7 +55,7 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
   Aircraft    = Exec->GetAircraft();
   Position    = Exec->GetPosition();
   Rotation    = Exec->GetRotation();
-  
+
   WOW = false;
 }
 
@@ -72,14 +72,13 @@ FGColumnVector FGLGear::Force(void)
 {
   static FGColumnVector vForce(3);
   static FGColumnVector vLocalForce(3);
-  static FGColumnVector vLocalGear(3);
-  static FGColumnVector vWhlBodyVec(3);
-  static FGColumnVector vWhlVelVec(3);
+  static FGColumnVector vLocalGear(3);     // Vector: CG to this wheel (Local)
+  static FGColumnVector vWhlBodyVec(3);    // Vector: CG to this wheel (Body)
+  static FGColumnVector vWhlVelVec(3);     // Velocity of this wheel (Local)
 
-  vWhlBodyVec     = vXYZ - Aircraft->GetXYZcg();
+  vWhlBodyVec     = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
   vWhlBodyVec(eX) = -vWhlBodyVec(eX);
   vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
-  vWhlBodyVec     = vWhlBodyVec/12.0;
 
   vLocalGear = State->GetTb2l() * vWhlBodyVec;
 
@@ -89,17 +88,19 @@ FGColumnVector FGLGear::Force(void)
 
     WOW = true;
 
-    vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
-    compressSpeed = vWhlVelVec(eZ) + Position->GetVd();
+    vWhlVelVec      =  State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
+    vWhlVelVec     +=  Position->GetVel();
+    compressSpeed   =  vWhlVelVec(eZ);
 
-    vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
+    vWhlVelVec      = -1.0 * vWhlVelVec.Normalize();
+    vWhlVelVec(eZ)  =  0.00;
 
-    vForce = State->GetTl2b() * vLocalForce ;
+    vLocalForce(eZ) =  min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
+    vLocalForce(eX) =  fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eX);
+    vLocalForce(eY) =  fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eY);
 
-    // currently only aircraft body axis Z-force modeled
-    vMoment(eX) = vForce(eZ) * vWhlBodyVec(eY);
-    vMoment(eY) = -vForce(eZ) * vWhlBodyVec(eX);
-    vMoment(eZ) = 0.0;
+    vForce  = State->GetTl2b() * vLocalForce ;
+    vMoment = vWhlBodyVec * vForce;
 
   } else {
 
index a03d859ec7c44171aa08e3a86a2b2e1ba35bd5be..97c4a7d668824c6703d89d1ad41cad9352824c27 100644 (file)
@@ -74,9 +74,9 @@ public:
 
   inline FGColumnVector GetVel(void) { return vVel; }
   inline FGColumnVector GetUVW(void) { return vUVW; }
-  inline double GetVn(void)  { return vVel(1); }
-  inline double GetVe(void)  { return vVel(2); }
-  inline double GetVd(void)  { return vVel(3); }
+  inline double GetVn(void)  { return vVel(eX); }
+  inline double GetVe(void)  { return vVel(eY); }
+  inline double GetVd(void)  { return vVel(eZ); }
   inline double Geth(void)  { return h; }
   inline double Gethdot(void) { return RadiusDot; }
   inline double GetLatitude(void) { return Latitude; }
index b7e9e90b80f42cfb1b8fbd61c749ead17ca83525..82eff48edefefcdf0d947ab78ad399fea34a3bd3 100644 (file)
@@ -115,18 +115,18 @@ bool FGTranslation::Run(void) {
     mVel(3,3) =  0.0;
 
     vUVWdot = mVel*vPQR + vForces/Mass;
-
-    vNcg = vUVWdot * INVGRAVITY;
+    
+    vNcg=vUVWdot*INVGRAVITY;
 
     vUVW += 0.5*dt*rate*(vlastUVWdot + vUVWdot) + vWindUVW;
-
+    
     Vt = vUVW.Magnitude();
 
     if (vUVW(eW) != 0.0)
       alpha = vUVW(eU)*vUVW(eU) > 0.0 ? atan2(vUVW(eW), vUVW(eU)) : 0.0;
     if (vUVW(eV) != 0.0)
       beta = vUVW(eU)*vUVW(eU)+vUVW(eW)*vUVW(eW) > 0.0 ? atan2(vUVW(eV),
-             (fabs(vUVW(eU))/vUVW(eU))*sqrt(vUVW(eU)*vUVW(eU) + vUVW(eW)*vUVW(eW))) : 0.0;
+             sqrt(vUVW(eU)*vUVW(eU) + vUVW(eW)*vUVW(eW))) : 0.0;
 
     qbar = 0.5*rho*Vt*Vt;
 
index 846a264d35e0fc00d80e79123e245220c83ab580..91f0a29f1b56c5faf54288156646016458eaa71a 100644 (file)
@@ -334,9 +334,9 @@ float FGTrimLong::qdot_func(float x) {
 /******************************************************************************/
 
 bool FGTrimLong::DoTrim(void) {
-  int k=0,j=0,sum=0,trim_failed=0,jmax=Naxis;
+  int k=0;
   int its;
-  float step,temp,min,max;
+  
 
   if(fgic->GetVtrueKtsIC() < 1) {
     cout << "Trim failed, on-ground trimming not yet implemented." << endl;
@@ -345,7 +345,6 @@ bool FGTrimLong::DoTrim(void) {
     return false;
   }
 
-  trimfp fp;
 
   fgic -> SetAlphaDegIC((alphaMin+alphaMax)/2);
   fdmex -> GetFCS() -> SetDeCmd(0);
@@ -402,10 +401,7 @@ bool FGTrimLong::DoTrim(void) {
           total_its=k;
           k=Ncycles; //force the trim to fail
         }
-
-
-
-      }
+     }
       if( udot > Tolerance ) {
         if(checkLimits(udotf,dth,0,1) == false) {
           cout << "    Sorry, udot doesn't appear to be trimmable" << endl;
@@ -414,10 +410,7 @@ bool FGTrimLong::DoTrim(void) {
           total_its=k;
           k=Ncycles; //force the trim to fail
         }
-
-
-
-      }
+     }
       if(qdot > A_Tolerance) {
 
         if(checkLimits(qdotf,fdmex->GetFCS()->GetPitchTrimCmd(),-1,1) == false) {
@@ -425,9 +418,6 @@ bool FGTrimLong::DoTrim(void) {
           total_its=k;
           k=Ncycles; //force the trim to fail
         }
-
-
-
       }
     }
     k++;