From 66eef4dafc89d874995b98628fc1495cba5963ad Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 3 Aug 2008 13:52:45 +0000 Subject: [PATCH] Add support for squared damping coefficients for gears. --- src/FDM/JSBSim/JSBSim.cxx | 1 - src/FDM/JSBSim/input_output/FGXMLElement.cpp | 6 +++ src/FDM/JSBSim/models/FGLGear.cpp | 53 +++++++++++++++++--- src/FDM/JSBSim/models/FGLGear.h | 4 ++ 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 61a51fcf3..4955a0b9f 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -28,7 +28,6 @@ #include #include // size_t - #include #include diff --git a/src/FDM/JSBSim/input_output/FGXMLElement.cpp b/src/FDM/JSBSim/input_output/FGXMLElement.cpp index b683d32b3..fdb98d8e0 100755 --- a/src/FDM/JSBSim/input_output/FGXMLElement.cpp +++ b/src/FDM/JSBSim/input_output/FGXMLElement.cpp @@ -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; diff --git a/src/FDM/JSBSim/models/FGLGear.cpp b/src/FDM/JSBSim/models/FGLGear.cpp index a1e6b14ae..dc4bcc6cb 100644 --- a/src/FDM/JSBSim/models/FGLGear.cpp +++ b/src/FDM/JSBSim/models/FGLGear.cpp @@ -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) { diff --git a/src/FDM/JSBSim/models/FGLGear.h b/src/FDM/JSBSim/models/FGLGear.h index fae36f62c..3dc81b7c1 100644 --- a/src/FDM/JSBSim/models/FGLGear.h +++ b/src/FDM/JSBSim/models/FGLGear.h @@ -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 -- 2.39.5