Add support for normalized control surface positions
This commit is contained in:
parent
3966e02de0
commit
a073e35c7c
5 changed files with 33 additions and 4 deletions
|
@ -100,7 +100,10 @@ public:
|
||||||
virtual bool Run(void);
|
virtual bool Run(void);
|
||||||
virtual void SetOutput(void);
|
virtual void SetOutput(void);
|
||||||
inline double GetOutput (void) {return Output;}
|
inline double GetOutput (void) {return Output;}
|
||||||
|
inline int GetOutputIdx(void) { return OutputIdx; }
|
||||||
inline string GetName(void) {return Name;}
|
inline string GetName(void) {return Name;}
|
||||||
|
inline string GetType(void) { return Type; }
|
||||||
|
virtual double GetOutputPct(void) { return 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Pilot/Aircraft, FCS, Autopilot inputs
|
/// Pilot/Aircraft, FCS, Autopilot inputs
|
||||||
|
|
|
@ -58,6 +58,8 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
|
||||||
Gain = 1.000;
|
Gain = 1.000;
|
||||||
Rows = 0;
|
Rows = 0;
|
||||||
Min = Max = 0.0;
|
Min = Max = 0.0;
|
||||||
|
OutputPct=0;
|
||||||
|
invert=false;
|
||||||
ScheduledBy = FG_UNDEF;
|
ScheduledBy = FG_UNDEF;
|
||||||
|
|
||||||
Type = AC_cfg->GetValue("TYPE");
|
Type = AC_cfg->GetValue("TYPE");
|
||||||
|
@ -84,6 +86,8 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
|
||||||
*AC_cfg >> Min;
|
*AC_cfg >> Min;
|
||||||
} else if (token == "MAX") {
|
} else if (token == "MAX") {
|
||||||
*AC_cfg >> Max;
|
*AC_cfg >> Max;
|
||||||
|
} else if (token == "INVERT") {
|
||||||
|
invert=true;
|
||||||
} else if (token == "ROWS") {
|
} else if (token == "ROWS") {
|
||||||
*AC_cfg >> Rows;
|
*AC_cfg >> Rows;
|
||||||
Table = new FGTable(Rows);
|
Table = new FGTable(Rows);
|
||||||
|
@ -130,8 +134,15 @@ bool FGGain::Run(void )
|
||||||
SchedGain = Table->GetValue(LookupVal);
|
SchedGain = Table->GetValue(LookupVal);
|
||||||
Output = Gain * SchedGain * Input;
|
Output = Gain * SchedGain * Input;
|
||||||
} else if (Type == "AEROSURFACE_SCALE") {
|
} else if (Type == "AEROSURFACE_SCALE") {
|
||||||
if (Output >= 0.0) Output = Input * Max;
|
if(!invert) {
|
||||||
else Output = Input * (-Min);
|
OutputPct = Input;
|
||||||
|
if (Input >= 0.0) Output = Input * Max;
|
||||||
|
else Output = Input * -Min;
|
||||||
|
} else {
|
||||||
|
OutputPct=-1*Input;
|
||||||
|
if (Input <= 0.0) Output = Input * -Max;
|
||||||
|
else Output = Input * Min;
|
||||||
|
}
|
||||||
Output *= Gain;
|
Output *= Gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +190,7 @@ void FGGain::Debug(int from)
|
||||||
if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl;
|
if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl;
|
||||||
cout << " MIN: " << Min << endl;
|
cout << " MIN: " << Min << endl;
|
||||||
cout << " MAX: " << Max << endl;
|
cout << " MAX: " << Max << endl;
|
||||||
|
if(invert) cout << " Invert mapping" << endl;
|
||||||
if (ScheduledBy != FG_UNDEF) {
|
if (ScheduledBy != FG_UNDEF) {
|
||||||
cout << " Scheduled by parameter: " << ScheduledBy << endl;
|
cout << " Scheduled by parameter: " << ScheduledBy << endl;
|
||||||
Table->Print();
|
Table->Print();
|
||||||
|
|
|
@ -70,7 +70,9 @@ class FGGain : public FGFCSComponent
|
||||||
public:
|
public:
|
||||||
FGGain(FGFCS* fcs, FGConfigFile* AC_cfg);
|
FGGain(FGFCS* fcs, FGConfigFile* AC_cfg);
|
||||||
~FGGain();
|
~FGGain();
|
||||||
|
|
||||||
|
double GetOutputPct() { return OutputPct; }
|
||||||
|
|
||||||
bool Run (void);
|
bool Run (void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -79,6 +81,8 @@ private:
|
||||||
FGState* State;
|
FGState* State;
|
||||||
double Gain;
|
double Gain;
|
||||||
double Min, Max;
|
double Min, Max;
|
||||||
|
double OutputPct;
|
||||||
|
bool invert;
|
||||||
int Rows;
|
int Rows;
|
||||||
eParam ScheduledBy;
|
eParam ScheduledBy;
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ FGKinemat::FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
|
||||||
|
|
||||||
Detents.clear();
|
Detents.clear();
|
||||||
TransitionTimes.clear();
|
TransitionTimes.clear();
|
||||||
|
|
||||||
|
OutputPct=0;
|
||||||
|
|
||||||
Type = AC_cfg->GetValue("TYPE");
|
Type = AC_cfg->GetValue("TYPE");
|
||||||
Name = AC_cfg->GetValue("NAME");
|
Name = AC_cfg->GetValue("NAME");
|
||||||
|
@ -157,7 +159,11 @@ bool FGKinemat::Run(void ) {
|
||||||
lastInputCmd = InputCmd;
|
lastInputCmd = InputCmd;
|
||||||
Output = OutputPos;
|
Output = OutputPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( Detents[NumDetents-1] > 0 ) {
|
||||||
|
OutputPct = Output / Detents[NumDetents-1];
|
||||||
|
}
|
||||||
|
|
||||||
if (IsOutput) SetOutput();
|
if (IsOutput) SetOutput();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -70,6 +70,9 @@ class FGKinemat : public FGFCSComponent {
|
||||||
public:
|
public:
|
||||||
FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg);
|
FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg);
|
||||||
~FGKinemat();
|
~FGKinemat();
|
||||||
|
|
||||||
|
double GetOutputPct() { return OutputPct; }
|
||||||
|
|
||||||
bool Run (void );
|
bool Run (void );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -80,6 +83,7 @@ private:
|
||||||
double lastInputCmd;
|
double lastInputCmd;
|
||||||
double InputCmd;
|
double InputCmd;
|
||||||
double OutputPos;
|
double OutputPos;
|
||||||
|
double OutputPct;
|
||||||
bool InTransit;
|
bool InTransit;
|
||||||
|
|
||||||
void Debug(int from);
|
void Debug(int from);
|
||||||
|
|
Loading…
Add table
Reference in a new issue