Jim Wilson:
> > 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).
This commit is contained in:
parent
ff7408fdf2
commit
e9f4fc5972
7 changed files with 39 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue