]> git.mxchange.org Git - flightgear.git/commitdiff
Add support for squared damping coefficients for gears.
authorehofman <ehofman>
Sun, 3 Aug 2008 13:52:45 +0000 (13:52 +0000)
committerehofman <ehofman>
Sun, 3 Aug 2008 13:52:45 +0000 (13:52 +0000)
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/input_output/FGXMLElement.cpp
src/FDM/JSBSim/models/FGLGear.cpp
src/FDM/JSBSim/models/FGLGear.h

index 61a51fcf3f9fc3153e29e7445d59d15cef0f8c92..4955a0b9fe29d1604c6a01121dcb1e407f4239e0 100644 (file)
@@ -28,7 +28,6 @@
 #include <simgear/compiler.h>
 
 #include <stdio.h>    //    size_t
-
 #include <string>
 
 #include <simgear/constants.h>
index b683d32b3549b4aedbfeb1e97e66974149e05afc..fdb98d8e00fb058b8ee48cac07e78c215e54135e 100755 (executable)
@@ -91,6 +91,9 @@ Element::Element(string nm)
   // Damping force
   convert["LBS/FT/SEC"]["N/M/SEC"] = 14.5939;
   convert["N/M/SEC"]["LBS/FT/SEC"] = 1.0/convert["LBS/FT/SEC"]["N/M/SEC"];
+  // Damping force (Square Law)
+  convert["LBS/FT/SEC2"]["N/M/SEC2"] = 14.5939;
+  convert["N/M/SEC2"]["LBS/FT/SEC2"] = 1.0/convert["LBS/FT/SEC2"]["N/M/SEC2"];
   // Power
   convert["WATTS"]["HP"] = 0.001341022;
   convert["HP"]["WATTS"] = 1.0/convert["WATTS"]["HP"];
@@ -154,6 +157,9 @@ Element::Element(string nm)
   // Damping force
   convert["LBS/FT/SEC"]["LBS/FT/SEC"] = 1.00;
   convert["N/M/SEC"]["N/M/SEC"] = 1.00;
+  // Damping force (Square law)
+  convert["LBS/FT/SEC2"]["LBS/FT/SEC2"] = 1.00;
+  convert["N/M/SEC2"]["N/M/SEC2"] = 1.00;
   // Power
   convert["HP"]["HP"] = 1.00;
   convert["WATTS"]["WATTS"] = 1.00;
index a1e6b14ae03fade4334177496cb64d5642bf22c0..dc4bcc6cb7f8fbc073283c17cead474991fc0917 100644 (file)
@@ -61,11 +61,15 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex),
                  GearNumber(number)
 {
   Element *force_table=0;
+  Element *dampCoeff=0;
+  Element *dampCoeffRebound=0;
   string force_type="";
 
   kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0;
   sSteerType = sBrakeGroup = sSteerType = "";
   isRetractable = 0;
+  eDampType = dtLinear;
+  eDampTypeRebound = dtLinear;
 
   name = el->GetAttributeValue("name");
   sContactType = el->GetAttributeValue("type");
@@ -79,13 +83,28 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex),
 
   if (el->FindElement("spring_coeff"))
     kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
-  if (el->FindElement("damping_coeff"))
-    bDamp   = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
+  if (el->FindElement("damping_coeff")) {
+    dampCoeff = el->FindElement("damping_coeff");
+    if (dampCoeff->GetAttributeValue("type") == "SQUARE") {
+      eDampType = dtSquare; // default is dtLinear
+      bDamp   = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC2");
+    } else {
+      bDamp   = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
+    }
+  }
 
-  if (el->FindElement("damping_coeff_rebound"))
-    bDampRebound   = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
-  else
+  if (el->FindElement("damping_coeff_rebound")) {
+    dampCoeffRebound = el->FindElement("damping_coeff_rebound");
+    if (dampCoeffRebound->GetAttributeValue("type") == "SQUARE") {
+      eDampTypeRebound = dtSquare; // default is dtLinear
+      bDampRebound   = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC2");
+    } else {
+      bDampRebound   = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
+    }
+  } else {
     bDampRebound   = bDamp;
+    eDampTypeRebound = eDampType;
+  }
 
   if (el->FindElement("dynamic_friction"))
     dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
@@ -674,9 +693,17 @@ void FGLGear::ComputeVerticalStrutForce(void)
   springForce = -compressLength * kSpring;
 
   if (compressSpeed >= 0.0) {
-    dampForce   = -compressSpeed * bDamp;
+
+    if (eDampType == dtLinear)   dampForce = -compressSpeed * bDamp;
+    else         dampForce = -compressSpeed * compressSpeed * bDamp;
+
   } else {
-    dampForce   = -compressSpeed * bDampRebound;
+
+    if (eDampTypeRebound == dtLinear)
+      dampForce   = -compressSpeed * bDampRebound;
+    else
+      dampForce   =  compressSpeed * compressSpeed * bDampRebound;
+
   }
   vLocalForce(eZ) =  min(springForce + dampForce, (double)0.0);
 
@@ -779,7 +806,17 @@ void FGLGear::Debug(int from)
       cout << "    " << sContactType << " " << name          << endl;
       cout << "      Location: "         << vXYZ          << endl;
       cout << "      Spring Constant:  " << kSpring       << endl;
-      cout << "      Damping Constant: " << bDamp         << endl;
+
+      if (eDampType == dtLinear)
+        cout << "      Damping Constant: " << bDamp << " (linear)" << endl;
+      else
+        cout << "      Damping Constant: " << bDamp << " (square law)" << endl;
+
+      if (eDampTypeRebound == dtLinear)
+        cout << "      Rebound Damping Constant: " << bDampRebound << " (linear)" << endl;
+      else 
+        cout << "      Rebound Damping Constant: " << bDampRebound << " (square law)" << endl;
+
       cout << "      Dynamic Friction: " << dynamicFCoeff << endl;
       cout << "      Static Friction:  " << staticFCoeff  << endl;
       if (eContactType == ctBOGEY) {
index fae36f62c76ed5f9feb6365739868076c9bed224..3dc81b7c189bd8439df991705917408b8b6c8088 100644 (file)
@@ -210,6 +210,8 @@ public:
   enum ContactType {ctBOGEY, ctSTRUCTURE, ctUNKNOWN};
   /// Report type enumerators
   enum ReportType {erNone=0, erTakeoff, erLand};
+  /// Damping types
+  enum DampType {dtLinear=0, dtSquare};
   /** Constructor
       @param el a pointer to the XML element that contains the CONTACT info.
       @param Executive a pointer to the parent executive object
@@ -348,6 +350,8 @@ private:
   BrakeGroup  eBrakeGrp;
   ContactType eContactType;
   SteerType   eSteerType;
+  DampType    eDampType;
+  DampType    eDampTypeRebound;
   double  maxSteerAngle;
   double RFRV;  // Rolling force relaxation velocity
   double SFRV;  // Side force relaxation velocity