]> git.mxchange.org Git - flightgear.git/commitdiff
Jim Wilson:
authorcurt <curt>
Fri, 16 May 2003 17:27:17 +0000 (17:27 +0000)
committercurt <curt>
Fri, 16 May 2003 17:27:17 +0000 (17:27 +0000)
> > Here's a patch to add manual-pitch control to the propeller in YASim.  A new
> > control axis "PROPPITCH" is added.  Requires "manual-pitch" boolean property
> > in the "propeller" tag.
> >
> > Tags and Properties to add in order to enable:
> >
> > manual-pitch="true"
> >
> > <control-input axis="/controls/engines/engine[0]/propeller-pitch"
> > control="PROPPITCH" src0="0" src1="1" dst0="0.40" dst1="0.80"/>
> >
> > Note that for the time being, excessively low RPM or excessively high RPM is
> > brought undercontrol by a scaling range defined in the control-input tag
> > (see "dst0" and "dst1" properties).

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

index e5d3ba19171239fde39ef2cc138411fe908c70bc..17a6e69211e78855ba3f4d847a2fb98e536db600 100644 (file)
@@ -5,6 +5,7 @@
 #include "Gear.hpp"
 #include "Wing.hpp"
 #include "Math.hpp"
+#include "Propeller.hpp"
 
 #include "ControlMap.hpp"
 namespace yasim {
@@ -187,6 +188,7 @@ void ControlMap::applyControls(float dt)
        case STARTER:  ((Thruster*)obj)->setStarter(lval != 0.0);  break;
        case MAGNETOS: ((PropEngine*)obj)->setMagnetos((int)lval); break;
        case ADVANCE:  ((PropEngine*)obj)->setAdvance(lval);       break;
+        case PROPPITCH: ((PropEngine*)obj)->setPropPitch(lval); break;
        case REHEAT:   ((Jet*)obj)->setReheat(lval);               break;
        case VECTOR:   ((Jet*)obj)->setRotation(lval);             break;
        case BRAKE:    ((Gear*)obj)->setBrake(lval);               break;
index 10713e675882034fd34d7f6d9b830f299a102668..c1a3cb6f7765d70bd551f4791de13149fd6e19b1 100644 (file)
@@ -13,7 +13,7 @@ public:
                      ADVANCE, REHEAT, PROP,
                      BRAKE, STEER, EXTEND,
                      INCIDENCE, FLAP0, FLAP1, SLAT, SPOILER, VECTOR,
-                      BOOST, CASTERING };
+                      BOOST, CASTERING, PROPPITCH };
 
     enum { OPT_SPLIT  = 0x01,
            OPT_INVERT = 0x02,
index e43113f5064a665dc3b7d16f0193430dfe8c99f6..073568f749bc98db62b6b4fc90e282f09b4f093c 100644 (file)
@@ -475,6 +475,10 @@ void FGFDM::parsePropeller(XMLAttributes* a)
        thruster->setVariableProp(min, max);
     }
 
+    if(a->hasAttribute("manual-pitch")) {
+       prop->setManualPitch();
+    }
+
     char buf[64];
     sprintf(buf, "/engines/engine[%d]", _nextEngine++);
     EngRec* er = new EngRec();
@@ -525,6 +529,7 @@ int FGFDM::parseOutput(const char* name)
     if(eq(name, "SLAT"))      return ControlMap::SLAT;
     if(eq(name, "SPOILER"))   return ControlMap::SPOILER;
     if(eq(name, "CASTERING")) return ControlMap::CASTERING;
+    if(eq(name, "PROPPITCH")) return ControlMap::PROPPITCH;
     SG_LOG(SG_FLIGHT,SG_ALERT,"Unrecognized control type '"
            << name << "' in YASim aircraft description.");
     exit(1);
index 0fc35582db66039979a73e252aa0a1a2266f91d5..6f3dc5db127735d16dbfc040c965f4d31ae25d8d 100644 (file)
@@ -34,6 +34,12 @@ void PropEngine::setAdvance(float advance)
     _advance = Math::clamp(advance, 0, 1);
 }
 
+void PropEngine::setPropPitch(float proppitch)
+{
+    // update Propeller property
+    _prop->setPropPitch(proppitch);
+}
+
 void PropEngine::setVariableProp(float min, float max)
 {
     _variable = true;
index 3e4cced64a879ff30b453240b6bccf195c85fa91..a0f84dc8c0eab1301edd6b13737713eef038ca26 100644 (file)
@@ -15,6 +15,7 @@ public:
 
     void setMagnetos(int magnetos);
     void setAdvance(float advance);
+    void setPropPitch(float proppitch);
     void setVariableProp(float min, float max);
 
     virtual PropEngine* getPropEngine() { return this; }
index 59e115b6fa9c0a7b28780375c73fb3a7c214785d..091a6942f520485ef04a1b62de9073e70b084450 100644 (file)
@@ -22,6 +22,8 @@ Propeller::Propeller(float radius, float v, float omega,
     _f0 = 2*_etaC*power/(rho*v*V2);
 
     _matchTakeoff = false;
+    _manual = false;
+    _proppitch = 0;
 }
 
 void Propeller::setTakeoff(float omega0, float power0)
@@ -42,10 +44,26 @@ void Propeller::modPitch(float mod)
     if(_j0 > 4*_baseJ0)     _j0 = 4*_baseJ0;
 }
 
+void Propeller::setManualPitch()
+{
+    _manual = true;
+}
+
+void Propeller::setPropPitch(float proppitch)
+{
+    // makes only positive range of axis effective.
+    _proppitch = Math::clamp(proppitch, 0, 1);
+}
 
 void Propeller::calc(float density, float v, float omega,
                     float* thrustOut, float* torqueOut)
 {
+    if (_manual) {
+        float pps = _proppitch * 0.9999f; // avoid singularity
+        pps = 1 + ( Math::pow(pps,-1/(pps-1)) - Math::pow(pps,-pps/(pps-1)) );
+        _j0 = (4*_baseJ0) -  (  ((4*_baseJ0) - (0.26f*_baseJ0)) * pps );
+    }
+
     float tipspd = _r*omega;
     float V2 = v*v + tipspd*tipspd;
 
index beb197a7e79403ce075de986eda50f33aac9bb00..cd6ee547d71fd1f94f52192b02c52e85cf141378 100644 (file)
@@ -20,6 +20,10 @@ public:
 
     void modPitch(float mod);
 
+    void setPropPitch(float proppitch);
+
+    void setManualPitch();
+
     void calc(float density, float v, float omega,
              float* thrustOut, float* torqueOut);
 
@@ -33,6 +37,8 @@ private:
     float _beta;        // constant, ~1.48058;
     float _tc0;         // thrust "coefficient" at takeoff
     bool  _matchTakeoff; // Does _tc0 mean anything?
+    bool  _manual;   // manual pitch mode
+    float _proppitch; // prop pitch control setting (0 ~ 1.0)
 };
 
 }; // namespace yasim