]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/PropEngine.cpp
Constant-speed props were seeking to engine speed, not prop speed.
[flightgear.git] / src / FDM / YASim / PropEngine.cpp
index 0213358fc43d8ceacdb67754634504a51ccc64dc..7930f26cab5f4eecfd079111e5d016aeb528e00f 100644 (file)
@@ -17,6 +17,7 @@ PropEngine::PropEngine(Propeller* prop, Engine* eng, float moment)
     _eng = eng;
     _moment = moment;
     _fuel = true;
+    _contra = false;
 }
 
 PropEngine::~PropEngine()
@@ -41,6 +42,12 @@ void PropEngine::setPropPitch(float proppitch)
     _prop->setPropPitch(proppitch);
 }
 
+void PropEngine::setPropFeather(int state)
+{
+    // toggle prop feathering on/off
+    _prop->setPropFeather(state);
+}
+
 void PropEngine::setVariableProp(float min, float max)
 {
     _variable = true;
@@ -99,6 +106,8 @@ void PropEngine::stabilize()
 
     _eng->setStarter(false);
     _eng->setMagnetos(3);
+
+    bool running_state = _eng->isRunning();
     _eng->setRunning(true);
 
     if(_variable) {
@@ -141,7 +150,7 @@ void PropEngine::stabilize()
     }
 
     // ...and back off
-    _eng->setRunning(false);
+    _eng->setRunning(running_state);
 }
 
 void PropEngine::init()
@@ -184,16 +193,20 @@ void PropEngine::integrate(float dt)
         _omega = 0 - _omega;    // don't allow negative RPM
                                 // FIXME: introduce proper windmilling
 
-    // Store the total angular momentum into _gyro
-    Math::mul3(_omega*momt, _dir, _gyro);
+    // Store the total angular momentum into _gyro, unless the
+    // propeller is a counter-rotating pair (which has zero net
+    // angular momentum, even though it *does* have an MoI for
+    // acceleration purposes).
+    Math::mul3(_contra ? 0 : _omega*momt, _dir, _gyro);
 
     // Accumulate the engine torque, it acts on the body as a whole.
     // (Note: engine torque, not propeller torque.  They can be
     // different, but the difference goes to accelerating the
     // rotation.  It is the engine torque that is felt at the shaft
-    // and works on the body.)
+    // and works on the body.) (Note 2: contra-rotating propellers do
+    // not exert net torque on the aircraft).
     float tau = _moment < 0 ? engTorque : -engTorque;
-    Math::mul3(tau, _dir, _torque);
+    Math::mul3(_contra ? 0 : tau, _dir, _torque);
 
     // Iterate the propeller governor, if we have one.  Since engine
     // torque is basically constant with RPM, we want to make the
@@ -203,7 +216,8 @@ void PropEngine::integrate(float dt)
     // _current_ RPM.  Seek to that.  This is sort of a continuous
     // Newton-Raphson, basically.
     if(_variable) {
-       float targetOmega = _minOmega + _advance*(_maxOmega-_minOmega);
+       float targetPropSpd = _minOmega + _advance*(_maxOmega-_minOmega);
+        float targetOmega = targetPropSpd / _gearRatio; // -> "engine omega"
        float ratio2 = (_omega*_omega)/(targetOmega*targetOmega);
        float targetTorque = engTorque * ratio2;