1
0
Fork 0

Add support for squared damping coefficients for gears.

This commit is contained in:
ehofman 2008-08-03 13:52:45 +00:00
parent 15bc6dbe21
commit 66eef4dafc
4 changed files with 55 additions and 9 deletions

View file

@ -28,7 +28,6 @@
#include <simgear/compiler.h>
#include <stdio.h> // size_t
#include <string>
#include <simgear/constants.h>

View file

@ -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;

View 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) {

View 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