Maik: add ROTORELTARGET and ROTORENGINEMAXRELTORQUE input axes
This commit is contained in:
parent
46ccdeffd4
commit
1a5bbec83b
5 changed files with 43 additions and 11 deletions
|
@ -211,8 +211,13 @@ void ControlMap::applyControls(float dt)
|
|||
case COLLECTIVE: ((Rotor*)obj)->setCollective(lval); break;
|
||||
case CYCLICAIL: ((Rotor*)obj)->setCyclicail(lval,rval); break;
|
||||
case CYCLICELE: ((Rotor*)obj)->setCyclicele(lval,rval); break;
|
||||
case ROTORBRAKE: ((Rotorgear*)obj)->setRotorBrake(lval); break;
|
||||
case ROTORENGINEON: ((Rotorgear*)obj)->setEngineOn((int)lval); break;
|
||||
case ROTORBRAKE: ((Rotorgear*)obj)->setRotorBrake(lval); break;
|
||||
case ROTORENGINEON:
|
||||
((Rotorgear*)obj)->setEngineOn((int)lval); break;
|
||||
case ROTORENGINEMAXRELTORQUE:
|
||||
((Rotorgear*)obj)->setRotorEngineMaxRelTorque(lval); break;
|
||||
case ROTORELTARGET:
|
||||
((Rotorgear*)obj)->setRotorRelTarget(lval); break;
|
||||
case REVERSE_THRUST: ((Jet*)obj)->setReverse(lval != 0); break;
|
||||
case BOOST:
|
||||
((PistonEngine*)((Thruster*)obj)->getEngine())->setBoost(lval);
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
INCIDENCE, FLAP0, FLAP1, SLAT, SPOILER, VECTOR,
|
||||
BOOST, CASTERING, PROPPITCH, PROPFEATHER,
|
||||
COLLECTIVE, CYCLICAIL, CYCLICELE, ROTORENGINEON,
|
||||
ROTORBRAKE,
|
||||
ROTORBRAKE, ROTORENGINEMAXRELTORQUE, ROTORELTARGET,
|
||||
REVERSE_THRUST, WASTEGATE,
|
||||
WINCHRELSPEED, HITCHOPEN, PLACEWINCH, FINDAITOW};
|
||||
|
||||
|
|
|
@ -949,6 +949,9 @@ int FGFDM::parseOutput(const char* name)
|
|||
if(eq(name, "CYCLICELE")) return ControlMap::CYCLICELE;
|
||||
if(eq(name, "ROTORGEARENGINEON")) return ControlMap::ROTORENGINEON;
|
||||
if(eq(name, "ROTORBRAKE")) return ControlMap::ROTORBRAKE;
|
||||
if(eq(name, "ROTORENGINEMAXRELTORQUE"))
|
||||
return ControlMap::ROTORENGINEMAXRELTORQUE;
|
||||
if(eq(name, "ROTORELTARGET")) return ControlMap::ROTORELTARGET;
|
||||
if(eq(name, "REVERSE_THRUST")) return ControlMap::REVERSE_THRUST;
|
||||
if(eq(name, "WASTEGATE")) return ControlMap::WASTEGATE;
|
||||
if(eq(name, "WINCHRELSPEED")) return ControlMap::WINCHRELSPEED;
|
||||
|
|
|
@ -184,6 +184,13 @@ void Rotor::inititeration(float dt,float omegarel,float ddt_omegarel,float *rot)
|
|||
|
||||
Math::mul3(Math::sin(_roll),side,help);
|
||||
Math::add3(_normal_with_yaw_roll,help,_normal_with_yaw_roll);
|
||||
|
||||
//update balance
|
||||
if ((_balance1*_balance2 < 0.97) && (_balance1>-1))
|
||||
{
|
||||
_balance1-=(0.97-_balance1*_balance2)*(0.97-_balance1*_balance2)*0.00001;
|
||||
if (_balance1<-1) _balance1=-1;
|
||||
}
|
||||
}
|
||||
|
||||
float Rotor::calcStall(float incidence,float speed)
|
||||
|
@ -247,11 +254,11 @@ int Rotor::getValueforFGSet(int j,char *text,float *f)
|
|||
if (j==0)
|
||||
{
|
||||
sprintf(text,"/rotors/%s/cone-deg", _name);
|
||||
*f=( ((Rotorpart*)getRotorpart(0))->getrealAlpha()
|
||||
*f=(_balance1>-1)?( ((Rotorpart*)getRotorpart(0))->getrealAlpha()
|
||||
+((Rotorpart*)getRotorpart(1*(_number_of_parts>>2)))->getrealAlpha()
|
||||
+((Rotorpart*)getRotorpart(2*(_number_of_parts>>2)))->getrealAlpha()
|
||||
+((Rotorpart*)getRotorpart(3*(_number_of_parts>>2)))->getrealAlpha()
|
||||
)/4*180/pi;
|
||||
)/4*180/pi:0;
|
||||
}
|
||||
else
|
||||
if (j==1)
|
||||
|
@ -260,7 +267,7 @@ int Rotor::getValueforFGSet(int j,char *text,float *f)
|
|||
_roll = ( ((Rotorpart*)getRotorpart(0))->getrealAlpha()
|
||||
-((Rotorpart*)getRotorpart(2*(_number_of_parts>>2)))->getrealAlpha()
|
||||
)/2*(_ccw?-1:1);
|
||||
*f=_roll *180/pi;
|
||||
*f=(_balance1>-1)?_roll *180/pi:0;
|
||||
}
|
||||
else
|
||||
if (j==2)
|
||||
|
@ -269,7 +276,7 @@ int Rotor::getValueforFGSet(int j,char *text,float *f)
|
|||
_yaw=( ((Rotorpart*)getRotorpart(1*(_number_of_parts>>2)))->getrealAlpha()
|
||||
-((Rotorpart*)getRotorpart(3*(_number_of_parts>>2)))->getrealAlpha()
|
||||
)/2;
|
||||
*f=_yaw*180/pi;
|
||||
*f=(_balance1>-1)?_yaw*180/pi:0;
|
||||
}
|
||||
else
|
||||
if (j==3)
|
||||
|
@ -350,6 +357,16 @@ void Rotorgear::setEngineOn(int value)
|
|||
_engineon=value;
|
||||
}
|
||||
|
||||
void Rotorgear::setRotorEngineMaxRelTorque(float lval)
|
||||
{
|
||||
fgGetNode("/rotors/gear/max-rel-torque", true)->setDoubleValue(lval);
|
||||
}
|
||||
|
||||
void Rotorgear::setRotorRelTarget(float lval)
|
||||
{
|
||||
fgGetNode("/rotors/gear/target-rel-rpm", true)->setDoubleValue(lval);
|
||||
}
|
||||
|
||||
void Rotor::setAlpha0(float f)
|
||||
{
|
||||
_alpha0=f;
|
||||
|
@ -1358,13 +1375,16 @@ void Rotorgear::calcForces(float* torqueOut)
|
|||
total_torque+=r->getTorque()*omegan;
|
||||
}
|
||||
float max_torque_of_engine=0;
|
||||
SGPropertyNode * node=fgGetNode("/rotors/gear", true);
|
||||
float target_rel_rpm=node->getDoubleValue("target-rel-rpm",1);
|
||||
if (_engineon)
|
||||
{
|
||||
max_torque_of_engine=_max_power_engine;
|
||||
float df=1-omegarel;
|
||||
float max_rel_torque=node->getDoubleValue("max-rel-torque",1);
|
||||
max_torque_of_engine=_max_power_engine*max_rel_torque;
|
||||
float df=target_rel_rpm-omegarel;
|
||||
df/=_engine_prop_factor;
|
||||
df = Math::clamp(df, 0, 1);
|
||||
max_torque_of_engine = df * _max_power_engine;
|
||||
max_torque_of_engine = df * _max_power_engine*max_rel_torque;
|
||||
}
|
||||
total_torque*=-1;
|
||||
_ddt_omegarel=0;
|
||||
|
@ -1391,7 +1411,7 @@ void Rotorgear::calcForces(float* torqueOut)
|
|||
|
||||
//change the rotation of the rotors
|
||||
if ((max_torque_of_engine<total_torque) //decreasing rotation
|
||||
||((max_torque_of_engine>total_torque)&&(omegarel<1))
|
||||
||((max_torque_of_engine>total_torque)&&(omegarel<target_rel_rpm))
|
||||
//increasing rotation due to engine
|
||||
||(total_torque<0) ) //increasing rotation due to autorotation
|
||||
{
|
||||
|
@ -1453,6 +1473,8 @@ void Rotorgear::compile()
|
|||
Rotor* r = (Rotor*)_rotors.get(j);
|
||||
r->compile();
|
||||
}
|
||||
fgGetNode("/rotors/gear/target-rel-rpm", true)->setDoubleValue(1);
|
||||
fgGetNode("/rotors/gear/max-rel-torque", true)->setDoubleValue(1);
|
||||
}
|
||||
|
||||
void Rotorgear::getDownWash(float *pos, float * v_heli, float *downwash)
|
||||
|
|
|
@ -243,6 +243,8 @@ public:
|
|||
void setEngineOn(int value);
|
||||
int getEngineon();
|
||||
void setRotorBrake(float lval);
|
||||
void setRotorEngineMaxRelTorque(float lval);
|
||||
void setRotorRelTarget(float lval);
|
||||
float getYasimDragFactor() { return _yasimdragfactor;}
|
||||
float getYasimLiftFactor() { return _yasimliftfactor;}
|
||||
float getMaxPowerEngine() { return _max_power_engine;}
|
||||
|
|
Loading…
Reference in a new issue