]> git.mxchange.org Git - flightgear.git/commitdiff
Here is a wrap-up of the latest changes to JSBSim. It still is flaky, but
authorcurt <curt>
Thu, 30 Dec 1999 18:01:59 +0000 (18:01 +0000)
committercurt <curt>
Thu, 30 Dec 1999 18:01:59 +0000 (18:01 +0000)
much less so due to returning the aero reference point stuff to the config
files. Don't know what happened there ...

Additionally, I have added a new field to the config file: CFG_VERSION. A
version number, currently 1.1, is assigned to the config file and a matching
definition is found in FGDefs.h. The two need to match. Tony has also added
code into FGAircraft.cpp to handle if aero reference point is not specified.

src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGCoefficient.cpp
src/FDM/JSBSim/FGCoefficient.h
src/FDM/JSBSim/FGControls.cpp
src/FDM/JSBSim/FGFDMExec.cpp

index f49e9dd98877db0717f63a95c87c68dea513f93e..b45efcbbeefcf821174ad7b1051d133ecb0958bf 100644 (file)
@@ -159,6 +159,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
   streampos gpos;
   int axis;
   string axis_descript;
+  bool readAeroRp=false;
 
   axis = -1;
   aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
@@ -169,6 +170,8 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
   numTanks = numEngines = 0;
   numSelectedOxiTanks = numSelectedFuelTanks = 0;
 
+  Xcg=Ycg=Zcg=0; //protection for no cg specified in file
+
   while (!aircraftfile.fail()) {
     holding_string.erase();
     aircraftfile >> holding_string;
@@ -218,6 +221,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
         cout << "Aircraft Empty Weight: " << EmptyWeight << endl;
       } else if (holding_string == "AC_AERORP") {
         aircraftfile >> Xrp >> Yrp >> Zrp;
+        readAeroRp=true;
         cout << "Aerodynamic Reference Point: " << Xrp << " " << Yrp << " " << Zrp << endl;
       } else if (holding_string == "AC_CGLOC") {
         aircraftfile >> baseXcg >> baseYcg >> baseZcg;
@@ -310,8 +314,15 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
       aircraftfile.getline(scratch, 127);
     }
   }
-  cout << "End of Configuration File Parsing." << endl;
+  
+    if(!readAeroRp) {
+    Xrp = Xcg;
+    Yrp = Ycg;
+    Zrp = Zcg;
+    cout << "Aerodynamic reference point not found, set to empty weight cg location" << endl;
+  }    
 
+  cout << "End of Configuration File Parsing." << endl;
   return true;
 }
 
@@ -431,32 +442,31 @@ void FGAircraft::MassChange()
 void FGAircraft::FMAero(void)
 {
   float F[3];
-  float Fxaero,Fyaero,Fzaero;
   float dxcg,dycg,dzcg;
+  float ca, cb, sa, sb;
   int axis_ctr,ctr;
   F[0] = F[1] = F[2] = 0.0;
 
-  for (axis_ctr = 0; axis_ctr < 3; axis_ctr++)
-    for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++)
+  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();
+    }
+  }
+
+  ca = cos(alpha);
+  sa = sin(alpha);
+  cb = cos(beta);
+  sb = sin(beta);
 
-  Fxaero = - F[DragCoeff]*cos(alpha)*cos(beta)
-           - F[SideCoeff]*cos(alpha)*sin(beta)
-           + F[LiftCoeff]*sin(alpha);
-  Fyaero =   F[DragCoeff]*sin(beta)
-             + F[SideCoeff]*cos(beta);
-  Fzaero = - F[DragCoeff]*sin(alpha)*cos(beta)
-           - F[SideCoeff]*sin(alpha)*sin(beta)
-           - F[LiftCoeff]*cos(alpha);
-
-  Forces[0] += - F[DragCoeff]*cos(alpha)*cos(beta)
-               - F[SideCoeff]*cos(alpha)*sin(beta)
-               + F[LiftCoeff]*sin(alpha);
-  Forces[1] +=   F[DragCoeff]*sin(beta)
-                 + F[SideCoeff]*cos(beta);
-  Forces[2] += - F[DragCoeff]*sin(alpha)*cos(beta)
-               - F[SideCoeff]*sin(alpha)*sin(beta)
-               - F[LiftCoeff]*cos(alpha);
+  Forces[0] += - F[DragCoeff]*ca*cb
+               - F[SideCoeff]*ca*sb
+               + F[LiftCoeff]*sa;
+  Forces[1] +=   F[DragCoeff]*sb
+                 + F[SideCoeff]*cb;
+  Forces[2] += - F[DragCoeff]*sa*cb
+               - F[SideCoeff]*sa*sb
+               - F[LiftCoeff]*ca;
 
   // 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
@@ -468,13 +478,14 @@ void FGAircraft::FMAero(void)
   dycg =  (Yrp - Ycg)/12;
   dzcg = -(Zrp - Zcg)/12;
 
-  Moments[0] +=  Fzaero*dycg - Fyaero*dzcg; //rolling moment
-  Moments[1] +=  Fxaero*dzcg - Fzaero*dxcg; //pitching moment
-  Moments[2] += -Fxaero*dycg + Fyaero*dxcg; //yawing moment
+  Moments[0] +=  Forces[2]*dycg - Forces[1]*dzcg; //rolling moment
+  Moments[1] +=  Forces[0]*dzcg - Forces[2]*dxcg; //pitching moment
+  Moments[2] += -Forces[0]*dycg + Forces[1]*dxcg; //yawing moment
 
   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();
     }
   }
 }
index 0e69bcb75974c374a923f2ca16ce5ffdfc90ea25..2ed2d69ef9a0b6f129693b140a4a6783f0ba2c78 100644 (file)
@@ -352,7 +352,7 @@ float FGCoefficient::Value(float rVal, float cVal)
   col1temp = rFactor*(Table3D[r][c-1] - Table3D[r-1][c-1]) + Table3D[r-1][c-1];
   col2temp = rFactor*(Table3D[r][c] - Table3D[r-1][c]) + Table3D[r-1][c];
 
-  Value = col1temp + cFactor*(col2temp - col1temp);
+  SD = Value = col1temp + cFactor*(col2temp - col1temp);
 
   for (midx=0;midx<mult_count;midx++) {
     Value *= GetCoeffVal(mult_idx[midx]);
@@ -379,7 +379,7 @@ float FGCoefficient::Value(float Val)
     Factor = 1.0;
   }
 
-  Value = Factor*(Table3D[r][1] - Table3D[r-1][1]) + Table3D[r-1][1];
+  SD = Value = Factor*(Table3D[r][1] - Table3D[r-1][1]) + Table3D[r-1][1];
 
   for (midx=0;midx<mult_count;midx++) {
     Value *= GetCoeffVal(mult_idx[midx]);
@@ -394,7 +394,7 @@ float FGCoefficient::Value(void)
        float Value;
        int midx;
        
-       Value = StaticValue;
+       SD = Value = StaticValue;
 
   for (midx=0;midx<mult_count;midx++) {
     Value *= GetCoeffVal(mult_idx[midx]);
@@ -463,3 +463,8 @@ float FGCoefficient::GetCoeffVal(int val_idx)
   return 0;
 }
 
+
+void FGCoefficient::DumpSD(void)
+{
+  cout << "   " << name << " = " << SD << endl;
+}
index c937c54a657d472f48c914eebb94e970e0632ccf..a1c2ca4af9db8587debd15670a571b766996dd66 100644 (file)
@@ -133,6 +133,9 @@ public:
   float Value(float);
   float Value(void);
   float TotalValue(void);
+  inline float GetSDValue(void) {return SD;}
+  inline void SetSDValue(float tt) {SD = tt;}
+  void DumpSD(void);
   enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
 
 protected:
@@ -153,6 +156,7 @@ private:
   Type type;
   int multipliers;
   int mult_count;
+  float SD; // Actual stability derivative (or other coefficient) value
 
   float GetCoeffVal(int);
 
index 8dde344658455cc319b72910f8022cf3ff449818..c8693a4f7a2d4c6dc0e2f9bbf0e13426c2e10098 100644 (file)
@@ -35,13 +35,13 @@ FGControls::FGControls() :
     elevator_trim( 1.969572E-03 ),
     rudder( 0.0 )
 {
-    for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
-       throttle[engine] = 0.0;
-    }
+  for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
+    throttle[engine] = 0.0;
+  }
 
-    for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
-        brake[wheel] = 0.0;
-    }
+  for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
+    brake[wheel] = 0.0;
+  }
 }
 
 
@@ -51,6 +51,16 @@ FGControls::~FGControls() {
 
 
 // $Log$
+// Revision 1.7  1999/12/30 17:01:59  curt
+// Here is a wrap-up of the latest changes to JSBSim. It still is flaky, but
+// much less so due to returning the aero reference point stuff to the config
+// files. Don't know what happened there ...
+//
+// Additionally, I have added a new field to the config file: CFG_VERSION. A
+// version number, currently 1.1, is assigned to the config file and a matching
+// definition is found in FGDefs.h. The two need to match. Tony has also added
+// code into FGAircraft.cpp to handle if aero reference point is not specified.
+//
 // Revision 1.6  1999/09/07 21:15:45  curt
 // Updates to get engine working.
 //
index ecfe62395b8bd49ccdd26a8fe52fcff56e97663a..4210e7de7551456be33b56ff4f8728f091ab98d3 100644 (file)
@@ -119,7 +119,7 @@ FGFDMExec::FGFDMExec(void)
   Schedule(Translation, 1);
   Schedule(Position,    1);
   Schedule(Auxiliary,   1);
-  Schedule(Output,      120);
+  Schedule(Output,      1);
 
   terminate = false;
   frozen = false;