Latest JSBSim changes, mostly to support yaw and roll trim.
This commit is contained in:
parent
0395a446f7
commit
a4ba46a270
6 changed files with 43 additions and 26 deletions
|
@ -321,7 +321,7 @@ bool FGJSBsim::copy_to_JSBsim() {
|
||||||
FCS->SetDeCmd( globals->get_controls()->get_elevator());
|
FCS->SetDeCmd( globals->get_controls()->get_elevator());
|
||||||
FCS->SetPitchTrimCmd( globals->get_controls()->get_elevator_trim() );
|
FCS->SetPitchTrimCmd( globals->get_controls()->get_elevator_trim() );
|
||||||
FCS->SetDrCmd( -globals->get_controls()->get_rudder() );
|
FCS->SetDrCmd( -globals->get_controls()->get_rudder() );
|
||||||
FCS->SetYawTrimCmd(globals->get_controls()->get_rudder_trim());
|
FCS->SetYawTrimCmd( -globals->get_controls()->get_rudder_trim() );
|
||||||
FCS->SetDfCmd( globals->get_controls()->get_flaps() );
|
FCS->SetDfCmd( globals->get_controls()->get_flaps() );
|
||||||
FCS->SetDsbCmd( 0.0 ); //speedbrakes
|
FCS->SetDsbCmd( 0.0 ); //speedbrakes
|
||||||
FCS->SetDspCmd( 0.0 ); //spoilers
|
FCS->SetDspCmd( 0.0 ); //spoilers
|
||||||
|
|
|
@ -138,9 +138,11 @@ bool FGAerodynamics::Load(FGConfigFile* AC_cfg)
|
||||||
if( token == "COEFFICIENT" ) {
|
if( token == "COEFFICIENT" ) {
|
||||||
ca.push_back( new FGCoefficient(FDMExec) );
|
ca.push_back( new FGCoefficient(FDMExec) );
|
||||||
ca.back()->Load(AC_cfg);
|
ca.back()->Load(AC_cfg);
|
||||||
|
cm[ca.back()->Getname()]=ca.back();
|
||||||
} else if ( token == "GROUP" ) {
|
} else if ( token == "GROUP" ) {
|
||||||
ca.push_back( new FGFactorGroup(FDMExec) );
|
ca.push_back( new FGFactorGroup(FDMExec) );
|
||||||
ca.back()->Load(AC_cfg);
|
ca.back()->Load(AC_cfg);
|
||||||
|
cm[ca.back()->Getname()]=ca.back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Coeff[AxisIdx[axis]] = ca;
|
Coeff[AxisIdx[axis]] = ca;
|
||||||
|
|
|
@ -134,12 +134,16 @@ public:
|
||||||
coefficients */
|
coefficients */
|
||||||
string GetCoefficientValues(void);
|
string GetCoefficientValues(void);
|
||||||
|
|
||||||
|
inline FGCoefficient* GetCoefficient(string name) { return cm[name]; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef map<string,int> AxisIndex;
|
typedef map<string,int> AxisIndex;
|
||||||
AxisIndex AxisIdx;
|
AxisIndex AxisIdx;
|
||||||
typedef vector<FGCoefficient*> CoeffArray;
|
typedef vector<FGCoefficient*> CoeffArray;
|
||||||
CoeffArray* Coeff;
|
CoeffArray* Coeff;
|
||||||
|
typedef map<string,FGCoefficient*> CoeffMap;
|
||||||
|
CoeffMap cm;
|
||||||
FGColumnVector3 vFs;
|
FGColumnVector3 vFs;
|
||||||
FGColumnVector3 vForces;
|
FGColumnVector3 vForces;
|
||||||
FGColumnVector3 vMoments;
|
FGColumnVector3 vMoments;
|
||||||
|
|
|
@ -72,6 +72,9 @@ FGCoefficient::FGCoefficient( FGFDMExec* fdex )
|
||||||
State = FDMExec->GetState();
|
State = FDMExec->GetState();
|
||||||
Table = 0;
|
Table = 0;
|
||||||
|
|
||||||
|
bias=0;
|
||||||
|
gain=1;
|
||||||
|
|
||||||
if (debug_lvl & 2) cout << "Instantiated: FGCoefficient" << endl;
|
if (debug_lvl & 2) cout << "Instantiated: FGCoefficient" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +154,7 @@ bool FGCoefficient::Load(FGConfigFile *AC_cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
AC_cfg->GetNextConfigLine();
|
AC_cfg->GetNextConfigLine();
|
||||||
Debug(2);
|
FGCoefficient::Debug(2);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -168,7 +171,8 @@ double FGCoefficient::Value(double rVal, double cVal)
|
||||||
double Value;
|
double Value;
|
||||||
unsigned int midx;
|
unsigned int midx;
|
||||||
|
|
||||||
SD = Value = Table->GetValue(rVal, cVal);
|
SD = Value = gain*Table->GetValue(rVal, cVal) + bias;
|
||||||
|
|
||||||
|
|
||||||
for (midx=0; midx < multipliers.size(); midx++) {
|
for (midx=0; midx < multipliers.size(); midx++) {
|
||||||
Value *= State->GetParameter(multipliers[midx]);
|
Value *= State->GetParameter(multipliers[midx]);
|
||||||
|
@ -182,7 +186,7 @@ double FGCoefficient::Value(double Val)
|
||||||
{
|
{
|
||||||
double Value;
|
double Value;
|
||||||
|
|
||||||
SD = Value = Table->GetValue(Val);
|
SD = Value = gain*Table->GetValue(Val) + bias;
|
||||||
|
|
||||||
for (unsigned int midx=0; midx < multipliers.size(); midx++)
|
for (unsigned int midx=0; midx < multipliers.size(); midx++)
|
||||||
Value *= State->GetParameter(multipliers[midx]);
|
Value *= State->GetParameter(multipliers[midx]);
|
||||||
|
@ -196,7 +200,7 @@ double FGCoefficient::Value(void)
|
||||||
{
|
{
|
||||||
double Value;
|
double Value;
|
||||||
|
|
||||||
SD = Value = StaticValue;
|
SD = Value = gain*StaticValue + bias;
|
||||||
|
|
||||||
for (unsigned int midx=0; midx < multipliers.size(); midx++)
|
for (unsigned int midx=0; midx < multipliers.size(); midx++)
|
||||||
Value *= State->GetParameter(multipliers[midx]);
|
Value *= State->GetParameter(multipliers[midx]);
|
||||||
|
@ -283,6 +287,7 @@ void FGCoefficient::Debug(int from)
|
||||||
if (debug_lvl <= 0) return;
|
if (debug_lvl <= 0) return;
|
||||||
|
|
||||||
if (debug_lvl & 1) { // Standard console startup message output
|
if (debug_lvl & 1) { // Standard console startup message output
|
||||||
|
|
||||||
if (from == 2) { // Loading
|
if (from == 2) { // Loading
|
||||||
cout << "\n " << highint << underon << name << underoff << normint << endl;
|
cout << "\n " << highint << underon << name << underoff << normint << endl;
|
||||||
cout << " " << description << endl;
|
cout << " " << description << endl;
|
||||||
|
|
|
@ -118,6 +118,11 @@ public:
|
||||||
virtual inline string GetCoefficientStrings(void) { return name; }
|
virtual inline string GetCoefficientStrings(void) { return name; }
|
||||||
virtual string GetCoefficientValues(void);
|
virtual string GetCoefficientValues(void);
|
||||||
|
|
||||||
|
inline void setBias(double b) { bias=b; }
|
||||||
|
inline void setGain(double g) { gain=g; };
|
||||||
|
inline double getBias(void) { return bias; }
|
||||||
|
inline double getGain(void) { return gain; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
|
enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
|
||||||
|
|
||||||
|
@ -133,6 +138,7 @@ private:
|
||||||
double Value(double);
|
double Value(double);
|
||||||
double Value(void);
|
double Value(void);
|
||||||
double StaticValue;
|
double StaticValue;
|
||||||
|
double bias,gain;
|
||||||
eParam LookupR, LookupC;
|
eParam LookupR, LookupC;
|
||||||
MultVec multipliers;
|
MultVec multipliers;
|
||||||
int rows, columns;
|
int rows, columns;
|
||||||
|
|
|
@ -170,27 +170,27 @@ public:
|
||||||
/// @name Pilot input command retrieval
|
/// @name Pilot input command retrieval
|
||||||
//@{
|
//@{
|
||||||
/** Gets the aileron command.
|
/** Gets the aileron command.
|
||||||
@return aileron command in radians */
|
@return aileron command in percent */
|
||||||
inline double GetDaCmd(void) { return DaCmd; }
|
inline double GetDaCmd(void) { return DaCmd; }
|
||||||
|
|
||||||
/** Gets the elevator command.
|
/** Gets the elevator command.
|
||||||
@return elevator command in radians */
|
@return elevator command in percent */
|
||||||
inline double GetDeCmd(void) { return DeCmd; }
|
inline double GetDeCmd(void) { return DeCmd; }
|
||||||
|
|
||||||
/** Gets the rudder command.
|
/** Gets the rudder command.
|
||||||
@return rudder command in radians */
|
@return rudder command in percent */
|
||||||
inline double GetDrCmd(void) { return DrCmd; }
|
inline double GetDrCmd(void) { return DrCmd; }
|
||||||
|
|
||||||
/** Gets the flaps command.
|
/** Gets the flaps command.
|
||||||
@return flaps command in radians */
|
@return flaps command in percent */
|
||||||
inline double GetDfCmd(void) { return DfCmd; }
|
inline double GetDfCmd(void) { return DfCmd; }
|
||||||
|
|
||||||
/** Gets the speedbrake command.
|
/** Gets the speedbrake command.
|
||||||
@return speedbrake command in radians */
|
@return speedbrake command in percent */
|
||||||
inline double GetDsbCmd(void) { return DsbCmd; }
|
inline double GetDsbCmd(void) { return DsbCmd; }
|
||||||
|
|
||||||
/** Gets the spoiler command.
|
/** Gets the spoiler command.
|
||||||
@return spoiler command in radians */
|
@return spoiler command in percent */
|
||||||
inline double GetDspCmd(void) { return DspCmd; }
|
inline double GetDspCmd(void) { return DspCmd; }
|
||||||
|
|
||||||
/** Gets the throttle command.
|
/** Gets the throttle command.
|
||||||
|
@ -209,15 +209,15 @@ public:
|
||||||
inline double GetPropAdvanceCmd(int engine) { return PropAdvanceCmd[engine]; }
|
inline double GetPropAdvanceCmd(int engine) { return PropAdvanceCmd[engine]; }
|
||||||
|
|
||||||
/** Gets the pitch trim command.
|
/** Gets the pitch trim command.
|
||||||
@return pitch trim command in radians */
|
@return pitch trim command in percent */
|
||||||
inline double GetPitchTrimCmd(void) { return PTrimCmd; }
|
inline double GetPitchTrimCmd(void) { return PTrimCmd; }
|
||||||
|
|
||||||
/** Gets the rudder trim command.
|
/** Gets the rudder trim command.
|
||||||
@return rudder trim command in radians */
|
@return rudder trim command in percent */
|
||||||
inline double GetYawTrimCmd(void) { return YTrimCmd; }
|
inline double GetYawTrimCmd(void) { return YTrimCmd; }
|
||||||
|
|
||||||
/** Gets the aileron trim command.
|
/** Gets the aileron trim command.
|
||||||
@return aileron trim command in radians */
|
@return aileron trim command in percent */
|
||||||
inline double GetRollTrimCmd(void) { return RTrimCmd; }
|
inline double GetRollTrimCmd(void) { return RTrimCmd; }
|
||||||
|
|
||||||
/** Get the gear extend/retract command. 0 commands gear up, 1 down.
|
/** Get the gear extend/retract command. 0 commands gear up, 1 down.
|
||||||
|
@ -296,39 +296,39 @@ public:
|
||||||
/// @name Pilot input command setting
|
/// @name Pilot input command setting
|
||||||
//@{
|
//@{
|
||||||
/** Sets the aileron command
|
/** Sets the aileron command
|
||||||
@param cmd aileron command in radians*/
|
@param cmd aileron command in percent*/
|
||||||
inline void SetDaCmd(double cmd) { DaCmd = cmd; }
|
inline void SetDaCmd(double cmd) { DaCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the elevator command
|
/** Sets the elevator command
|
||||||
@param cmd elevator command in radians*/
|
@param cmd elevator command in percent*/
|
||||||
inline void SetDeCmd(double cmd) { DeCmd = cmd; }
|
inline void SetDeCmd(double cmd) { DeCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the rudder command
|
/** Sets the rudder command
|
||||||
@param cmd rudder command in radians*/
|
@param cmd rudder command in percent*/
|
||||||
inline void SetDrCmd(double cmd) { DrCmd = cmd; }
|
inline void SetDrCmd(double cmd) { DrCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the flaps command
|
/** Sets the flaps command
|
||||||
@param cmd flaps command in radians*/
|
@param cmd flaps command in percent*/
|
||||||
inline void SetDfCmd(double cmd) { DfCmd = cmd; }
|
inline void SetDfCmd(double cmd) { DfCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the speedbrake command
|
/** Sets the speedbrake command
|
||||||
@param cmd speedbrake command in radians*/
|
@param cmd speedbrake command in percent*/
|
||||||
inline void SetDsbCmd(double cmd) { DsbCmd = cmd; }
|
inline void SetDsbCmd(double cmd) { DsbCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the spoilers command
|
/** Sets the spoilers command
|
||||||
@param cmd spoilers command in radians*/
|
@param cmd spoilers command in percent*/
|
||||||
inline void SetDspCmd(double cmd) { DspCmd = cmd; }
|
inline void SetDspCmd(double cmd) { DspCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the pitch trim command
|
/** Sets the pitch trim command
|
||||||
@param cmd pitch trim command in radians*/
|
@param cmd pitch trim command in percent*/
|
||||||
inline void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
|
inline void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the rudder trim command
|
/** Sets the rudder trim command
|
||||||
@param cmd rudder trim command in radians*/
|
@param cmd rudder trim command in percent*/
|
||||||
inline void SetYawTrimCmd(double cmd) { YTrimCmd = cmd; }
|
inline void SetYawTrimCmd(double cmd) { YTrimCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the aileron trim command
|
/** Sets the aileron trim command
|
||||||
@param cmd aileron trim command in radians*/
|
@param cmd aileron trim command in percent*/
|
||||||
inline void SetRollTrimCmd(double cmd) { RTrimCmd = cmd; }
|
inline void SetRollTrimCmd(double cmd) { RTrimCmd = cmd; }
|
||||||
|
|
||||||
/** Sets the throttle command for the specified engine
|
/** Sets the throttle command for the specified engine
|
||||||
|
|
Loading…
Add table
Reference in a new issue