> > 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).
#include "Gear.hpp"
#include "Wing.hpp"
#include "Math.hpp"
+#include "Propeller.hpp"
#include "ControlMap.hpp"
namespace yasim {
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;
ADVANCE, REHEAT, PROP,
BRAKE, STEER, EXTEND,
INCIDENCE, FLAP0, FLAP1, SLAT, SPOILER, VECTOR,
- BOOST, CASTERING };
+ BOOST, CASTERING, PROPPITCH };
enum { OPT_SPLIT = 0x01,
OPT_INVERT = 0x02,
thruster->setVariableProp(min, max);
}
+ if(a->hasAttribute("manual-pitch")) {
+ prop->setManualPitch();
+ }
+
char buf[64];
sprintf(buf, "/engines/engine[%d]", _nextEngine++);
EngRec* er = new EngRec();
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);
_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;
void setMagnetos(int magnetos);
void setAdvance(float advance);
+ void setPropPitch(float proppitch);
void setVariableProp(float min, float max);
virtual PropEngine* getPropEngine() { return this; }
_f0 = 2*_etaC*power/(rho*v*V2);
_matchTakeoff = false;
+ _manual = false;
+ _proppitch = 0;
}
void Propeller::setTakeoff(float omega0, float power0)
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;
void modPitch(float mod);
+ void setPropPitch(float proppitch);
+
+ void setManualPitch();
+
void calc(float density, float v, float omega,
float* thrustOut, float* torqueOut);
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