]> git.mxchange.org Git - flightgear.git/commitdiff
Allow YASim flight models to override the hard-coded fine and coarse
authordavid <david>
Sun, 26 Feb 2006 16:46:51 +0000 (16:46 +0000)
committerdavid <david>
Sun, 26 Feb 2006 16:46:51 +0000 (16:46 +0000)
propeller pitch stops for constant speed propellers.  The default
values are the same as the previous hard-coded values.  The new
attributes, "fine-stop" and "coarse-stop", are documented in the base
package, Docs/README.yasim.

src/FDM/YASim/FGFDM.cpp
src/FDM/YASim/PropEngine.cpp
src/FDM/YASim/Propeller.cpp
src/FDM/YASim/Propeller.hpp

index 9fdbecd611d3059f3a1722e382bddc323ee30fc2..c883ebd1fe808aa8dd2a443872992d27f8eff30d 100644 (file)
@@ -762,6 +762,11 @@ void FGFDM::parsePropeller(XMLAttributes* a)
     PropEngine* thruster = new PropEngine(prop, eng, moment);
     _airplane.addThruster(thruster, mass, cg);
 
+    // Set the stops (fine = minimum pitch, coarse = maximum pitch)
+    float fine_stop = attrf(a, "fine-stop", 0.25f);
+    float coarse_stop = attrf(a, "coarse-stop", 4.0f);
+    prop->setStops(fine_stop, coarse_stop);
+
     if(a->hasAttribute("takeoff-power")) {
        float power0 = attrf(a, "takeoff-power") * HP2W;
        float omega0 = attrf(a, "takeoff-rpm") * RPM2RAD;
index ca5e51bf7921e88bf7e8296f0db61692908d8bab..38cb886e8f581f94f645d3b2ac8a4688a2dda60a 100644 (file)
@@ -119,7 +119,9 @@ void PropEngine::stabilize()
 
     bool goingUp = false;
     float step = 10;
-    while(true) {
+
+    // If we cannot manage this in 100 iterations, give up.
+    for (int n = 0; n < 100; n++) {
        float ptau, thrust;
        _prop->calc(_rho, speed, _omega * _gearRatio, &thrust, &ptau);
        _eng->calc(_pressure, _temp, _omega);
index a49f0dad8205b04fb3ceb780b87661d207a63a21..af19e705088467c79f54d15a7c72d3797f10562d 100644 (file)
@@ -37,12 +37,18 @@ void Propeller::setTakeoff(float omega0, float power0)
     float density = Atmosphere::getStdDensity(0);
     _tc0 = (torque * gamma) / (0.5f * density * V2 * _f0);
 }
+
+void Propeller::setStops(float fine_stop, float coarse_stop)
+{
+    _fine_stop = fine_stop;
+    _coarse_stop = coarse_stop;
+}
     
 void Propeller::modPitch(float mod)
 {
     _j0 *= mod;
-    if(_j0 < 0.25f*_baseJ0) _j0 = 0.25f*_baseJ0;
-    if(_j0 > 4*_baseJ0)     _j0 = 4*_baseJ0;
+    if(_j0 < _fine_stop*_baseJ0) _j0 = _fine_stop*_baseJ0;
+    if(_j0 > _coarse_stop*_baseJ0)     _j0 = _coarse_stop*_baseJ0;
 }
 
 void Propeller::setManualPitch()
@@ -68,6 +74,7 @@ void Propeller::calc(float density, float v, float omega,
     // For manual pitch, exponentially modulate the J0 value between
     // 0.25 and 4.  A prop pitch of 0.5 results in no change from the
     // base value.
+    // TODO: integrate with _fine_stop and _coarse_stop variables
     if (_manual) 
         _j0 = _baseJ0 * Math::pow(2, 2 - 4*_proppitch);
     
index 5a5905e2fc26382b7e77198a0b7f5afc75486b9e..3f2b6099eb5de35b6b0ad14473f74565d5ccdab7 100644 (file)
@@ -16,6 +16,8 @@ public:
     // course.
     Propeller(float radius, float v, float omega, float rho, float power);
 
+    void setStops (float fine_stop, float coarse_stop);
+
     void setTakeoff(float omega0, float power0);
 
     void modPitch(float mod);
@@ -38,6 +40,8 @@ private:
     float _lambdaPeak;  // constant, ~0.759835;
     float _beta;        // constant, ~1.48058;
     float _tc0;         // thrust "coefficient" at takeoff
+    float _fine_stop;   // ratio for minimum pitch (high RPM)
+    float _coarse_stop; // ratio for maximum pitch (low RPM)
     bool  _matchTakeoff; // Does _tc0 mean anything?
     bool  _manual;      // manual pitch mode
     float _proppitch;   // prop pitch control setting (0 ~ 1.0)