1
0
Fork 0

Syncing with latest JSBSim code with retractable landing gear support.

This commit is contained in:
curt 2001-12-03 22:24:40 +00:00
parent b3d2d2cd00
commit 408742c48c
30 changed files with 551 additions and 687 deletions

View file

@ -54,6 +54,7 @@
#include <FDM/JSBSim/FGAtmosphere.h> #include <FDM/JSBSim/FGAtmosphere.h>
#include <FDM/JSBSim/FGMassBalance.h> #include <FDM/JSBSim/FGMassBalance.h>
#include <FDM/JSBSim/FGAerodynamics.h> #include <FDM/JSBSim/FGAerodynamics.h>
#include <FDM/JSBSim/FGLGear.h>
#include "JSBSim.hxx" #include "JSBSim.hxx"
/******************************************************************************/ /******************************************************************************/
@ -218,6 +219,9 @@ void FGJSBsim::init() {
SG_LOG( SG_FLIGHT, SG_INFO, "Finished initializing JSBSim" ); SG_LOG( SG_FLIGHT, SG_INFO, "Finished initializing JSBSim" );
SG_LOG( SG_FLIGHT, SG_INFO, "FGControls::get_gear_down()= " <<
globals->get_controls()->get_gear_down() );
} }
@ -264,19 +268,19 @@ bool FGJSBsim::update( int multiloop ) {
msg = fdmex->ProcessMessage(); msg = fdmex->ProcessMessage();
switch (msg->type) { switch (msg->type) {
case FGJSBBase::Message::eText: case FGJSBBase::Message::eText:
cout << msg->messageId << ": " << msg->text << endl; SG_LOG( SG_FLIGHT, SG_INFO, msg->messageId << ": " << msg->text );
break; break;
case FGJSBBase::Message::eBool: case FGJSBBase::Message::eBool:
cout << msg->messageId << ": " << msg->text << " " << msg->bVal << endl; SG_LOG( SG_FLIGHT, SG_INFO, msg->messageId << ": " << msg->text << " " << msg->bVal );
break; break;
case FGJSBBase::Message::eInteger: case FGJSBBase::Message::eInteger:
cout << msg->messageId << ": " << msg->text << " " << msg->iVal << endl; SG_LOG( SG_FLIGHT, SG_INFO, msg->messageId << ": " << msg->text << " " << msg->iVal );
break; break;
case FGJSBBase::Message::eDouble: case FGJSBBase::Message::eDouble:
cout << msg->messageId << ": " << msg->text << " " << msg->dVal << endl; SG_LOG( SG_FLIGHT, SG_INFO, msg->messageId << ": " << msg->text << " " << msg->dVal );
break; break;
default: default:
cerr << "Unrecognized message type." << endl; SG_LOG( SG_FLIGHT, SG_INFO, "Unrecognized message type." );
break; break;
} }
} }
@ -322,9 +326,11 @@ bool FGJSBsim::copy_to_JSBsim() {
FCS->SetLBrake( globals->get_controls()->get_brake( 0 ) ); FCS->SetLBrake( globals->get_controls()->get_brake( 0 ) );
FCS->SetRBrake( globals->get_controls()->get_brake( 1 ) ); FCS->SetRBrake( globals->get_controls()->get_brake( 1 ) );
FCS->SetCBrake( globals->get_controls()->get_brake( 2 ) ); FCS->SetCBrake( globals->get_controls()->get_brake( 2 ) );
FCS->SetGearCmd( globals->get_controls()->get_gear_down());
for (int i = 0; i < get_num_engines(); i++) { for (int i = 0; i < get_num_engines(); i++) {
FCS->SetThrottleCmd(i, globals->get_controls()->get_throttle(i)); FCS->SetThrottleCmd(i, globals->get_controls()->get_throttle(i));
FCS->SetMixtureCmd(i, globals->get_controls()->get_mixture(i)); FCS->SetMixtureCmd(i, globals->get_controls()->get_mixture(i));
FCS->SetPropPitchCmd(i, globals->get_controls()->get_prop_advance(i));
} }
Position->SetSeaLevelRadius( get_Sea_level_radius() ); Position->SetSeaLevelRadius( get_Sea_level_radius() );
@ -644,8 +650,10 @@ void FGJSBsim::init_gear(void ) {
if ( gr->GetGearUnit(i)->GetBrakeGroup() > 0 ) { if ( gr->GetGearUnit(i)->GetBrakeGroup() > 0 ) {
gear->SetBrake(true); gear->SetBrake(true);
} }
if ( gr->GetGearUp() ) { if ( gr->GetGearUnit(i)->GetRetractable() ) {
gear->SetPosition( 0.0 ); gear->SetPosition( FCS->GetGearPos() );
} else {
gear->SetPosition( 1.0 );
} }
} }
} }
@ -658,8 +666,8 @@ void FGJSBsim::update_gear(void) {
for (int i=0;i<Ngear;i++) { for (int i=0;i<Ngear;i++) {
gear=get_gear_unit(i); gear=get_gear_unit(i);
gear->SetWoW( gr->GetGearUnit(i)->GetWOW() ); gear->SetWoW( gr->GetGearUnit(i)->GetWOW() );
if ( gr->GetGearUp() ) { if ( gr->GetGearUnit(i)->GetRetractable() ) {
gear->SetPosition( 0.0 ); gear->SetPosition( FCS->GetGearPos() );
} }
} }
} }

View file

@ -49,9 +49,9 @@ CLASS IMPLEMENTATION
FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec), FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec),
vMoments(3),
vForces(3),
vFs(3), vFs(3),
vForces(3),
vMoments(3),
vLastFs(3), vLastFs(3),
vDXYZcg(3) vDXYZcg(3)
{ {
@ -182,7 +182,6 @@ string FGAerodynamics::GetCoefficientStrings(void)
string FGAerodynamics::GetCoefficientValues(void) string FGAerodynamics::GetCoefficientValues(void)
{ {
string SDValues = ""; string SDValues = "";
char buffer[10];
bool firstime = true; bool firstime = true;
for (unsigned int axis = 0; axis < 6; axis++) { for (unsigned int axis = 0; axis < 6; axis++) {
@ -203,8 +202,6 @@ string FGAerodynamics::GetCoefficientValues(void)
double FGAerodynamics::GetLoD(void) double FGAerodynamics::GetLoD(void)
{ {
double LoD;
if (vFs(1) != 0.00) return vFs(3)/vFs(1); if (vFs(1) != 0.00) return vFs(3)/vFs(1);
else return 0.00; else return 0.00;
} }

View file

@ -69,14 +69,14 @@ CLASS IMPLEMENTATION
FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex), FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex),
vWindNED(3),
vDirectiondAccelDt(3), vDirectiondAccelDt(3),
vDirectionAccel(3), vDirectionAccel(3),
vDirection(3), vDirection(3),
vTurbulence(3), vTurbulence(3),
vTurbulenceGrad(3), vTurbulenceGrad(3),
vBodyTurbGrad(3), vBodyTurbGrad(3),
vTurbPQR(3) vTurbPQR(3),
vWindNED(3)
{ {
Name = "FGAtmosphere"; Name = "FGAtmosphere";
lastIndex=0; lastIndex=0;
@ -169,7 +169,6 @@ void FGAtmosphere::Calculate(double altitude)
{ {
double slope, reftemp, refpress; double slope, reftemp, refpress;
int i = 0; int i = 0;
bool lookup = false;
i = lastIndex; i = lastIndex;
if (altitude < htab[lastIndex]) { if (altitude < htab[lastIndex]) {
@ -191,12 +190,6 @@ void FGAtmosphere::Calculate(double altitude)
} }
switch(i) { switch(i) {
case 0: // sea level
slope = -0.00356616; // R/ft.
reftemp = 518.67; // R
refpress = 2116.22; // psf
//refdens = 0.00237767; // slugs/cubic ft.
break;
case 1: // 36089 ft. case 1: // 36089 ft.
slope = 0; slope = 0;
reftemp = 389.97; reftemp = 389.97;
@ -239,6 +232,14 @@ void FGAtmosphere::Calculate(double altitude)
refpress = 0.000122276; refpress = 0.000122276;
//refdens = 2.19541e-10; //refdens = 2.19541e-10;
break; break;
case 0:
default: // sea level
slope = -0.00356616; // R/ft.
reftemp = 518.67; // R
refpress = 2116.22; // psf
//refdens = 0.00237767; // slugs/cubic ft.
break;
} }
if (slope == 0) { if (slope == 0) {

View file

@ -60,7 +60,7 @@ FGConfigFile::~FGConfigFile()
string FGConfigFile::GetNextConfigLine(void) string FGConfigFile::GetNextConfigLine(void)
{ {
int deblank, not_found = string::npos;
int comment_starts_at; int comment_starts_at;
int comment_ends_at; int comment_ends_at;
int comment_length; int comment_length;

View file

@ -54,7 +54,7 @@ INCLUDES
#include "filtersjb/FGGradient.h" #include "filtersjb/FGGradient.h"
#include "filtersjb/FGSwitch.h" #include "filtersjb/FGSwitch.h"
#include "filtersjb/FGSummer.h" #include "filtersjb/FGSummer.h"
#include "filtersjb/FGFlaps.h" #include "filtersjb/FGKinemat.h"
static const char *IdSrc = "$Id$"; static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_FCS; static const char *IdHdr = ID_FCS;
@ -69,6 +69,7 @@ FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = PTrimCmd = 0.0; DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = PTrimCmd = 0.0;
DaPos = DePos = DrPos = DfPos = DsbPos = DspPos = 0.0; DaPos = DePos = DrPos = DfPos = DsbPos = DspPos = 0.0;
GearCmd = GearPos = 1; // default to gear down
LeftBrake = RightBrake = CenterBrake = 0.0; LeftBrake = RightBrake = CenterBrake = 0.0;
if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
@ -82,6 +83,8 @@ FGFCS::~FGFCS()
ThrottlePos.clear(); ThrottlePos.clear();
MixtureCmd.clear(); MixtureCmd.clear();
MixturePos.clear(); MixturePos.clear();
PropPitchCmd.clear();
PropPitchPos.clear();
unsigned int i; unsigned int i;
@ -98,6 +101,7 @@ bool FGFCS::Run(void)
if (!FGModel::Run()) { if (!FGModel::Run()) {
for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i]; for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i]; for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
for (i=0; i<PropPitchPos.size(); i++) PropPitchPos[i] = PropPitchCmd[i];
for (i=0; i<Components.size(); i++) Components[i]->Run(); for (i=0; i<Components.size(); i++) Components[i]->Run();
} else { } else {
} }
@ -158,6 +162,7 @@ double FGFCS::GetThrottleCmd(int engineNum)
<< " engines exist, but throttle setting for engine " << engineNum << " engines exist, but throttle setting for engine " << engineNum
<< " is selected" << endl; << " is selected" << endl;
} }
return 0.0;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -175,6 +180,7 @@ double FGFCS::GetThrottlePos(int engineNum)
<< " engines exist, but attempted throttle position setting is for engine " << " engines exist, but attempted throttle position setting is for engine "
<< engineNum << endl; << engineNum << endl;
} }
return 0.0;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -209,6 +215,36 @@ void FGFCS::SetMixturePos(int engineNum, double setting)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetPropPitchCmd(int engineNum, double setting)
{
unsigned int ctr;
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (ctr=0;ctr<PropPitchCmd.size();ctr++) PropPitchCmd[ctr] = setting;
} else {
PropPitchCmd[engineNum] = setting;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetPropPitchPos(int engineNum, double setting)
{
unsigned int ctr;
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (ctr=0;ctr<=PropPitchCmd.size();ctr++) PropPitchPos[ctr] = PropPitchCmd[ctr];
} else {
PropPitchPos[engineNum] = setting;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFCS::Load(FGConfigFile* AC_cfg) bool FGFCS::Load(FGConfigFile* AC_cfg)
{ {
string token; string token;
@ -242,8 +278,8 @@ bool FGFCS::Load(FGConfigFile* AC_cfg)
Components.push_back(new FGGradient(this, AC_cfg)); Components.push_back(new FGGradient(this, AC_cfg));
} else if (token == "SWITCH") { } else if (token == "SWITCH") {
Components.push_back(new FGSwitch(this, AC_cfg)); Components.push_back(new FGSwitch(this, AC_cfg));
} else if (token == "FLAPS") { } else if (token == "KINEMAT") {
Components.push_back(new FGFlaps(this, AC_cfg)); Components.push_back(new FGKinemat(this, AC_cfg));
} else { } else {
cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl; cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
return false; return false;
@ -330,6 +366,8 @@ void FGFCS::AddThrottle(void)
ThrottlePos.push_back(0.0); ThrottlePos.push_back(0.0);
MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
MixturePos.push_back(0.0); MixturePos.push_back(0.0);
PropPitchCmd.push_back(0.0); // assume throttle and prop pitch are coupled
PropPitchPos.push_back(0.0);
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -203,9 +203,19 @@ public:
@return mixture command in percent ( 0 - 100) for the given engine */ @return mixture command in percent ( 0 - 100) for the given engine */
inline double GetMixtureCmd(int engine) { return MixtureCmd[engine]; } inline double GetMixtureCmd(int engine) { return MixtureCmd[engine]; }
/** Gets the prop pitch command.
@param engine engine ID number
@return pitch command in percent ( 0.0 - 1.0) for the given engine */
inline double GetPropPitchCmd(int engine) { return PropPitchCmd[engine]; }
/** Gets the pitch trim command. /** Gets the pitch trim command.
@return pitch trim command in radians */ @return pitch trim command in radians */
inline double GetPitchTrimCmd(void) { return PTrimCmd; } inline double GetPitchTrimCmd(void) { return PTrimCmd; }
/** Get the gear extend/retract command. 0 commands gear up, 1 down.
defaults to down.
@return the current value of the gear extend/retract command*/
inline double GetGearCmd(void) { return GearCmd; }
//@} //@}
/// @name Aerosurface position retrieval /// @name Aerosurface position retrieval
@ -243,6 +253,15 @@ public:
@param engine engine ID number @param engine engine ID number
@return mixture position for the given engine in percent ( 0 - 100)*/ @return mixture position for the given engine in percent ( 0 - 100)*/
inline double GetMixturePos(int engine) { return MixturePos[engine]; } inline double GetMixturePos(int engine) { return MixturePos[engine]; }
/** Gets the gear position (0 up, 1 down), defaults to down
@return gear position (0 up, 1 down) */
inline double GetGearPos(void) { return GearPos; }
/** Gets the prop pitch position.
@param engine engine ID number
@return prop pitch position for the given engine in percent ( 0.0-1.0)*/
inline double GetPropPitchPos(int engine) { return PropPitchPos[engine]; }
//@} //@}
/** Retrieves the State object pointer. /** Retrieves the State object pointer.
@ -305,6 +324,15 @@ public:
@param engine engine ID number @param engine engine ID number
@param cmd mixture command in percent (0 - 100)*/ @param cmd mixture command in percent (0 - 100)*/
void SetMixtureCmd(int engine, double cmd); void SetMixtureCmd(int engine, double cmd);
/** Set the gear extend/retract command, defaults to down
@param gear command 0 for up, 1 for down */
void SetGearCmd(double gearcmd) { GearCmd = gearcmd; }
/** Sets the propeller pitch command for the specified engine
@param engine engine ID number
@param cmd mixture command in percent (0.0 - 1.0)*/
void SetPropPitchCmd(int engine, double cmd);
//@} //@}
/// @name Aerosurface position setting /// @name Aerosurface position setting
@ -342,6 +370,16 @@ public:
@param engine engine ID number @param engine engine ID number
@param cmd mixture setting in percent (0 - 100)*/ @param cmd mixture setting in percent (0 - 100)*/
void SetMixturePos(int engine, double cmd); void SetMixturePos(int engine, double cmd);
/** Set the gear extend/retract position, defaults to down
@param gear position 0 up, 1 down */
void SetGearPos(double gearpos) { GearPos = gearpos; }
/** Sets the actual prop pitch setting for the specified engine
@param engine engine ID number
@param cmd prop pitch setting in percent (0.0 - 1.0)*/
void SetPropPitchPos(int engine, double cmd);
//@} //@}
/// @name Landing Gear brakes /// @name Landing Gear brakes
@ -382,7 +420,10 @@ private:
vector <double> ThrottlePos; vector <double> ThrottlePos;
vector <double> MixtureCmd; vector <double> MixtureCmd;
vector <double> MixturePos; vector <double> MixturePos;
vector <double> PropPitchCmd;
vector <double> PropPitchPos;
double LeftBrake, RightBrake, CenterBrake; // Brake settings double LeftBrake, RightBrake, CenterBrake; // Brake settings
double GearCmd,GearPos;
vector <FGFCSComponent*> Components; vector <FGFCSComponent*> Components;
void Debug(void); void Debug(void);

View file

@ -415,7 +415,7 @@ bool FGFDMExec::LoadScript(string script)
string initialize=""; string initialize="";
bool result=false; bool result=false;
double dt=0.0; double dt=0.0;
int i; unsigned i;
struct condition *newCondition; struct condition *newCondition;
if (!Script.IsOpen()) return false; if (!Script.IsOpen()) return false;
@ -594,14 +594,12 @@ bool FGFDMExec::LoadScript(string script)
void FGFDMExec::RunScript(void) void FGFDMExec::RunScript(void)
{ {
vector <struct condition>::iterator iC = Conditions.begin(); vector <struct condition>::iterator iC = Conditions.begin();
bool truth; bool truth = false;
bool WholeTruth; bool WholeTruth = false;
int i; unsigned i;
int count=0;
double currentTime = State->Getsim_time(); double currentTime = State->Getsim_time();
double newSetValue; double newSetValue = 0;
while (iC < Conditions.end()) { while (iC < Conditions.end()) {
// determine whether the set of conditional tests for this condition equate // determine whether the set of conditional tests for this condition equate

View file

@ -77,7 +77,7 @@ FGFactorGroup::FGFactorGroup( FGFDMExec* fdmex ) : FGCoefficient( fdmex)
FGFactorGroup::~FGFactorGroup() FGFactorGroup::~FGFactorGroup()
{ {
int i; unsigned i;
for (i=0; i<sum.size(); i++) { for (i=0; i<sum.size(); i++) {
delete sum[i]; delete sum[i];
} }
@ -115,7 +115,7 @@ bool FGFactorGroup::Load(FGConfigFile *AC_cfg) {
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
double FGFactorGroup::TotalValue(void) { double FGFactorGroup::TotalValue(void) {
int i; unsigned i;
double totalsum=0; double totalsum=0;
SDtotal=0.0; SDtotal=0.0;
for(i=0;i<sum.size();i++) { for(i=0;i<sum.size();i++) {

View file

@ -54,17 +54,18 @@ static const char *IdHdr = ID_FORCE;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGForce::FGForce(FGFDMExec *FDMExec) : FGForce::FGForce(FGFDMExec *FDMExec) :
ttype(tNone),
fdmex(FDMExec),
vFn(3), vFn(3),
vMn(3), vMn(3),
fdmex(FDMExec), vH(3),
vFb(3), vFb(3),
vM(3), vM(3),
vXYZn(3), vXYZn(3),
vDXYZ(3), vDXYZ(3),
mT(3,3),
vH(3),
vSense(3), vSense(3),
ttype(tNone) mT(3,3)
{ {
mT(1,1) = 1; //identity matrix mT(1,1) = 1; //identity matrix
mT(2,2) = 1; mT(2,2) = 1;

View file

@ -287,10 +287,11 @@ public:
FGMatrix33 Transform(void); FGMatrix33 Transform(void);
protected: protected:
FGFDMExec *fdmex;
FGColumnVector3 vFn; FGColumnVector3 vFn;
FGColumnVector3 vMn; FGColumnVector3 vMn;
FGColumnVector3 vH; FGColumnVector3 vH;
FGFDMExec *fdmex;
virtual void Debug(void); virtual void Debug(void);
private: private:

View file

@ -53,7 +53,6 @@ FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex),
{ {
Name = "FGGroundReactions"; Name = "FGGroundReactions";
GearUp = false;
if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
} }
@ -69,7 +68,7 @@ bool FGGroundReactions::Run(void)
vMoments.InitMatrix(); vMoments.InitMatrix();
// Only execute gear force code below 300 feet // Only execute gear force code below 300 feet
if ( !GearUp && Position->GetDistanceAGL() < 300.0 ) { if ( Position->GetDistanceAGL() < 300.0 ) {
vector <FGLGear>::iterator iGear = lGear.begin(); vector <FGLGear>::iterator iGear = lGear.begin();
// Sum forces and moments for all gear, here. // Sum forces and moments for all gear, here.
// Some optimizations may be made here - or rather in the gear code itself. // Some optimizations may be made here - or rather in the gear code itself.

View file

@ -78,23 +78,16 @@ public:
string GetGroundReactionStrings(void); string GetGroundReactionStrings(void);
string GetGroundReactionValues(void); string GetGroundReactionValues(void);
/** Gets the gear status
@return true if gear is not deployed */
inline bool GetGearUp(void) { return GearUp; }
/** Gets the number of gear units defined for the aircraft
@return number of gear units defined */
inline int GetNumGearUnits(void) { return lGear.size(); } inline int GetNumGearUnits(void) { return lGear.size(); }
/** Gets a gear instance /** Gets a gear instance
@param gear index of gear instance @param gear index of gear instance
@return a pointer to the FGLGear instance of the gear unit requested */ @return a pointer to the FGLGear instance of the gear unit requested */
inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); } inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
inline void SetGear(bool tt) { GearUp = tt; }
inline void SetGearUp(void) { GearUp = true; }
inline void SetGearDown(bool tt) { GearUp = false; }
private: private:
vector <FGLGear> lGear; vector <FGLGear> lGear;
bool GearUp;
FGColumnVector3 vForces; FGColumnVector3 vForces;
FGColumnVector3 vMoments; FGColumnVector3 vMoments;
FGColumnVector3 vMaxStaticGrip; FGColumnVector3 vMaxStaticGrip;

View file

@ -48,8 +48,8 @@ CLASS IMPLEMENTATION
FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex), FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex),
vForces(3),
vOmegaLocal(3), vOmegaLocal(3),
vForces(3),
vRadius(3), vRadius(3),
vGravity(3) vGravity(3)
{ {

View file

@ -536,7 +536,7 @@ bool FGInitialCondition::getTheta(void) {
//****************************************************************************** //******************************************************************************
double FGInitialCondition::GammaEqOfTheta(double Theta) { double FGInitialCondition::GammaEqOfTheta(double Theta) {
double a,b,c,d; double a,b,c;
double sTheta,cTheta; double sTheta,cTheta;
//theta=Theta; stheta=sin(theta); ctheta=cos(theta); //theta=Theta; stheta=sin(theta); ctheta=cos(theta);
@ -551,7 +551,7 @@ double FGInitialCondition::GammaEqOfTheta(double Theta) {
//****************************************************************************** //******************************************************************************
double FGInitialCondition::GammaEqOfAlpha(double Alpha) { double FGInitialCondition::GammaEqOfAlpha(double Alpha) {
double a,b,c,d; double a,b,c;
double sAlpha,cAlpha; double sAlpha,cAlpha;
sAlpha=sin(Alpha); cAlpha=cos(Alpha); sAlpha=sin(Alpha); cAlpha=cos(Alpha);
@ -654,7 +654,7 @@ bool FGInitialCondition::solve(double *y,double x)
//initializations //initializations
d=1; d=1;
x2 = 0;
x1=xlo;x3=xhi; x1=xlo;x3=xhi;
f1=(this->*sfunc)(x1)-x; f1=(this->*sfunc)(x1)-x;
f3=(this->*sfunc)(x3)-x; f3=(this->*sfunc)(x3)-x;

View file

@ -64,7 +64,7 @@ const double FGJSBBase::ktstofps = 1.68781;
const double FGJSBBase::inchtoft = 0.08333333; const double FGJSBBase::inchtoft = 0.08333333;
const double FGJSBBase::Reng = 1716.0; const double FGJSBBase::Reng = 1716.0;
const double FGJSBBase::SHRatio = 1.40; const double FGJSBBase::SHRatio = 1.40;
const string FGJSBBase::needed_cfg_version = "1.56"; const string FGJSBBase::needed_cfg_version = "1.57";
const string FGJSBBase::JSBSim_version = "0.9.1"; const string FGJSBBase::JSBSim_version = "0.9.1";
queue <FGJSBBase::Message*> FGJSBBase::Messages; queue <FGJSBBase::Message*> FGJSBBase::Messages;

View file

@ -136,7 +136,9 @@ enum eParam {
FG_HTAILAREA, FG_HTAILAREA,
FG_VTAILAREA, FG_VTAILAREA,
FG_VBARH, //horizontal tail volume FG_VBARH, //horizontal tail volume
FG_VBARV //vertical tail volume FG_VBARV, //vertical tail volume
FG_GEAR_CMD,
FG_GEAR_POS
}; };
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -66,9 +66,12 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
Exec(fdmex) Exec(fdmex)
{ {
string tmp; string tmp;
string Retractable;
*AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3) *AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3)
>> kSpring >> bDamp>> dynamicFCoeff >> staticFCoeff >> kSpring >> bDamp>> dynamicFCoeff >> staticFCoeff
>> rollingFCoeff >> sSteerType >> sBrakeGroup >> maxSteerAngle; >> rollingFCoeff >> sSteerType >> sBrakeGroup
>> maxSteerAngle >> Retractable;
if (debug_lvl > 0) { if (debug_lvl > 0) {
cout << " Name: " << name << endl; cout << " Name: " << name << endl;
@ -81,6 +84,7 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
cout << " Steering Type: " << sSteerType << endl; cout << " Steering Type: " << sSteerType << endl;
cout << " Grouping: " << sBrakeGroup << endl; cout << " Grouping: " << sBrakeGroup << endl;
cout << " Max Steer Angle: " << maxSteerAngle << endl; cout << " Max Steer Angle: " << maxSteerAngle << endl;
cout << " Retractable: " << Retractable << endl;
} }
if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft; if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
@ -102,6 +106,14 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
<< sSteerType << " is undefined." << endl; << sSteerType << " is undefined." << endl;
} }
if( Retractable == "RETRACT" ) {
isRetractable=true;
} else {
isRetractable=false;
}
GearUp=false; GearDown=true;
// Add some AI here to determine if gear is located properly according to its // Add some AI here to determine if gear is located properly according to its
// brake group type ?? // brake group type ??
@ -172,6 +184,9 @@ FGLGear::FGLGear(const FGLGear& lgear)
sBrakeGroup = lgear.sBrakeGroup; sBrakeGroup = lgear.sBrakeGroup;
eBrakeGrp = lgear.eBrakeGrp; eBrakeGrp = lgear.eBrakeGrp;
maxSteerAngle = lgear.maxSteerAngle; maxSteerAngle = lgear.maxSteerAngle;
isRetractable = lgear.isRetractable;
GearUp = lgear.GearUp;
GearDown = lgear.GearDown;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -185,9 +200,24 @@ FGLGear::~FGLGear()
FGColumnVector3& FGLGear::Force(void) FGColumnVector3& FGLGear::Force(void)
{ {
double SteerGain; vForce.InitMatrix();
vMoment.InitMatrix();
if(isRetractable ) {
if( FCS->GetGearPos() < 0.01 ) {
GearUp=true;GearDown=false;
} else if(FCS->GetGearPos() > 0.99) {
GearDown=true;GearUp=false;
} else {
GearUp=false; GearDown=false;
}
} else {
GearUp=false; GearDown=true;
}
if( GearDown ) {
double SteerGain = 0;
double SinWheel, CosWheel, SideWhlVel, RollingWhlVel; double SinWheel, CosWheel, SideWhlVel, RollingWhlVel;
double RudderPedal, RollingForce, SideForce, FCoeff; double RollingForce, SideForce, FCoeff;
double WheelSlip; double WheelSlip;
vWhlBodyVec = (vXYZ - MassBalance->GetXYZcg()) / 12.0; vWhlBodyVec = (vXYZ - MassBalance->GetXYZcg()) / 12.0;
@ -386,8 +416,7 @@ FGColumnVector3& FGLGear::Force(void)
compressLength = 0.0;// reset compressLength to zero for data output validity compressLength = 0.0;// reset compressLength to zero for data output validity
vForce.InitMatrix();
vMoment.InitMatrix();
} }
if (FirstContact) { if (FirstContact) {
@ -415,6 +444,8 @@ FGColumnVector3& FGLGear::Force(void)
Exec->Freeze(); Exec->Freeze();
} }
}
return vForce; return vForce;
} }

View file

@ -232,6 +232,10 @@ public:
inline int GetBrakeGroup(void) { return (int)eBrakeGrp; } inline int GetBrakeGroup(void) { return (int)eBrakeGrp; }
inline int GetSteerType(void) { return (int)eSteerType; } inline int GetSteerType(void) { return (int)eSteerType; }
inline bool GetRetractable(void) { return isRetractable; }
inline bool GetGearUnitUp(void) { return GearUp; }
inline bool GetGearUnitDown(void) { return GearDown; }
private: private:
FGColumnVector3 vXYZ; FGColumnVector3 vXYZ;
FGColumnVector3 vMoment; FGColumnVector3 vMoment;
@ -259,9 +263,12 @@ private:
bool FirstContact; bool FirstContact;
bool Reported; bool Reported;
bool ReportEnable; bool ReportEnable;
bool isRetractable;
bool GearUp, GearDown;
string name; string name;
string sSteerType; string sSteerType;
string sBrakeGroup; string sBrakeGroup;
BrakeGroup eBrakeGrp; BrakeGroup eBrakeGrp;
SteerType eSteerType; SteerType eSteerType;
double maxSteerAngle; double maxSteerAngle;

View file

@ -50,13 +50,7 @@ CLASS IMPLEMENTATION
FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg)
: FGEngine(exec), : FGEngine(exec),
MinManifoldPressure_inHg(6.5), //these must be initialized this way as they are declared const
MaxManifoldPressure_inHg(28.5),
Displacement(360),
MaxHP(200),
Cycles(2),
IdleRPM(600),
// Set constants
CONVERT_CUBIC_INCHES_TO_METERS_CUBED(1.638706e-5), CONVERT_CUBIC_INCHES_TO_METERS_CUBED(1.638706e-5),
R_air(287.3), R_air(287.3),
rho_fuel(800), // estimate rho_fuel(800), // estimate
@ -64,8 +58,19 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg)
Cp_air(1005), Cp_air(1005),
Cp_fuel(1700) Cp_fuel(1700)
{ {
string token; string token;
MinManifoldPressure_inHg=6.5;
MaxManifoldPressure_inHg=28.5;
Displacement=360;
MaxHP=200;
Cycles=2;
IdleRPM=600;
// Set constants
Name = Eng_cfg->GetValue("NAME"); Name = Eng_cfg->GetValue("NAME");
Eng_cfg->GetNextConfigLine(); Eng_cfg->GetNextConfigLine();
while (Eng_cfg->GetValue() != string("/FG_PISTON")) { while (Eng_cfg->GetValue() != string("/FG_PISTON")) {
@ -159,7 +164,6 @@ FGPiston::~FGPiston()
double FGPiston::Calculate(double PowerRequired) double FGPiston::Calculate(double PowerRequired)
{ {
double h,EngineMaxPower;
// FIXME: calculate from actual fuel flow // FIXME: calculate from actual fuel flow
ConsumeFuel(); ConsumeFuel();

View file

@ -99,7 +99,7 @@ FGRocket::~FGRocket()
double FGRocket::Calculate(double pe) double FGRocket::Calculate(double pe)
{ {
double Cf; double Cf=0;
ConsumeFuel(); ConsumeFuel();

View file

@ -77,12 +77,12 @@ CLASS IMPLEMENTATION
FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex), FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex),
vPQR(3), vPQR(3),
vAeroPQR(3),
vPQRdot(3), vPQRdot(3),
vMoments(3), vMoments(3),
vEuler(3), vEuler(3),
vEulerRates(3), vEulerRates(3),
vlastPQRdot(3), vlastPQRdot(3)
vAeroPQR(3)
{ {
Name = "FGRotation"; Name = "FGRotation";
cTht=cPhi=cPsi=1.0; cTht=cPhi=cPsi=1.0;

View file

@ -73,18 +73,19 @@ CLASS IMPLEMENTATION
// entry in the enum eParam definition in FGJSBBase.h. The ID is what must be used // entry in the enum eParam definition in FGJSBBase.h. The ID is what must be used
// in any config file entry which references that item. // in any config file entry which references that item.
FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3), FGState::FGState(FGFDMExec* fdex) :
mTb2l(3,3),
mTl2b(3,3), mTl2b(3,3),
mTs2b(3,3), mTs2b(3,3),
mTb2s(3,3), mTb2s(3,3),
vQtrn(4), vQtrn(4),
vlastQdot(4), vlastQdot(4),
vQdot(4), vQdot(4),
vTmp(4),
vEuler(3),
vUVW(3), vUVW(3),
vLocalVelNED(3), vLocalVelNED(3),
vLocalEuler(3) vLocalEuler(3),
vTmp(4),
vEuler(3)
{ {
FDMExec = fdex; FDMExec = fdex;
@ -134,6 +135,7 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
RegisterVariable(FG_SPDBRAKE_POS, " speedbrake_pos " ); RegisterVariable(FG_SPDBRAKE_POS, " speedbrake_pos " );
RegisterVariable(FG_SPOILERS_POS, " spoiler_pos " ); RegisterVariable(FG_SPOILERS_POS, " spoiler_pos " );
RegisterVariable(FG_FLAPS_POS, " flaps_pos " ); RegisterVariable(FG_FLAPS_POS, " flaps_pos " );
RegisterVariable(FG_GEAR_POS, " gear_pos " );
RegisterVariable(FG_ELEVATOR_CMD, " elevator_cmd " ); RegisterVariable(FG_ELEVATOR_CMD, " elevator_cmd " );
RegisterVariable(FG_AILERON_CMD, " aileron_cmd " ); RegisterVariable(FG_AILERON_CMD, " aileron_cmd " );
RegisterVariable(FG_RUDDER_CMD, " rudder_cmd " ); RegisterVariable(FG_RUDDER_CMD, " rudder_cmd " );
@ -141,6 +143,7 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
RegisterVariable(FG_SPOILERS_CMD, " spoiler_cmd " ); RegisterVariable(FG_SPOILERS_CMD, " spoiler_cmd " );
RegisterVariable(FG_FLAPS_CMD, " flaps_cmd " ); RegisterVariable(FG_FLAPS_CMD, " flaps_cmd " );
RegisterVariable(FG_THROTTLE_CMD, " throttle_cmd " ); RegisterVariable(FG_THROTTLE_CMD, " throttle_cmd " );
RegisterVariable(FG_GEAR_CMD, " gear_cmd " );
RegisterVariable(FG_THROTTLE_POS, " throttle_pos " ); RegisterVariable(FG_THROTTLE_POS, " throttle_pos " );
RegisterVariable(FG_MIXTURE_CMD, " mixture_cmd " ); RegisterVariable(FG_MIXTURE_CMD, " mixture_cmd " );
RegisterVariable(FG_MIXTURE_POS, " mixture_pos " ); RegisterVariable(FG_MIXTURE_POS, " mixture_pos " );
@ -301,6 +304,10 @@ double FGState::GetParameter(eParam val_idx) {
return Position->GetHOverBMAC(); return Position->GetHOverBMAC();
case FG_PITCH_TRIM_CMD: case FG_PITCH_TRIM_CMD:
return FCS->GetPitchTrimCmd(); return FCS->GetPitchTrimCmd();
case FG_GEAR_CMD:
return FCS->GetGearCmd();
case FG_GEAR_POS:
return FCS->GetGearPos();
default: default:
cerr << "FGState::GetParameter() - No handler for parameter " << paramdef[val_idx] << endl; cerr << "FGState::GetParameter() - No handler for parameter " << paramdef[val_idx] << endl;
return 0.0; return 0.0;
@ -374,7 +381,7 @@ void FGState::SetParameter(eParam val_idx, double val) {
FCS->SetMixtureCmd(ActiveEngine,val); FCS->SetMixtureCmd(ActiveEngine,val);
break; break;
case FG_MAGNETO_CMD: case FG_MAGNETO_CMD:
Propulsion->GetEngine(ActiveEngine)->SetMagnetos(val); // need to account for -1 Propulsion->GetEngine(ActiveEngine)->SetMagnetos((int)val); // need to account for -1
break; break;
case FG_STARTER_CMD: case FG_STARTER_CMD:
if (val < 0.001) if (val < 0.001)
@ -395,7 +402,12 @@ void FGState::SetParameter(eParam val_idx, double val) {
case FG_RIGHT_BRAKE_CMD: case FG_RIGHT_BRAKE_CMD:
FCS->SetRBrake(val); FCS->SetRBrake(val);
break; break;
case FG_GEAR_CMD:
FCS->SetGearCmd(val);
break;
case FG_GEAR_POS:
FCS->SetGearPos(val);
break;
case FG_SET_LOGGING: case FG_SET_LOGGING:
if (val < -0.01) Output->Disable(); if (val < -0.01) Output->Disable();
else if (val > 0.01) Output->Enable(); else if (val > 0.01) Output->Enable();
@ -734,7 +746,7 @@ FGMatrix33& FGState::GetTb2s(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGState::ReportState(void) { void FGState::ReportState(void) {
char out[80], flap[10], gear[10]; char out[80], flap[10], gear[12];
cout << endl << " JSBSim State" << endl; cout << endl << " JSBSim State" << endl;
snprintf(out,80," Weight: %7.0f lbs. CG: %5.1f, %5.1f, %5.1f inches\n", snprintf(out,80," Weight: %7.0f lbs. CG: %5.1f, %5.1f, %5.1f inches\n",
@ -747,11 +759,13 @@ void FGState::ReportState(void) {
snprintf(flap,10,"Up"); snprintf(flap,10,"Up");
else else
snprintf(flap,10,"%2.0f",FCS->GetDfPos()); snprintf(flap,10,"%2.0f",FCS->GetDfPos());
if(GroundReactions->GetGearUp() == true) if(FCS->GetGearPos() < 0.01)
snprintf(gear,10,"Up"); snprintf(gear,12,"Up");
else if(FCS->GetGearPos() > 0.99)
snprintf(gear,12,"Down");
else else
snprintf(gear,10,"Down"); snprintf(gear,12,"In Transit");
snprintf(out,80, " Flaps: %3s Gear: %4s\n",flap,gear); snprintf(out,80, " Flaps: %3s Gear: %12s\n",flap,gear);
cout << out; cout << out;
snprintf(out,80, " Speed: %4.0f KCAS Mach: %5.2f\n", snprintf(out,80, " Speed: %4.0f KCAS Mach: %5.2f\n",
FDMExec->GetAuxiliary()->GetVcalibratedKTS(), FDMExec->GetAuxiliary()->GetVcalibratedKTS(),

View file

@ -319,10 +319,11 @@ private:
FGMatrix33 mTb2s; FGMatrix33 mTb2s;
FGColumnVector4 vQtrn; FGColumnVector4 vQtrn;
FGColumnVector4 vlastQdot; FGColumnVector4 vlastQdot;
FGColumnVector4 vQdot;
FGColumnVector3 vUVW; FGColumnVector3 vUVW;
FGColumnVector3 vLocalVelNED; FGColumnVector3 vLocalVelNED;
FGColumnVector3 vLocalEuler; FGColumnVector3 vLocalEuler;
FGColumnVector4 vQdot;
FGColumnVector4 vTmp; FGColumnVector4 vTmp;
FGColumnVector3 vEuler; FGColumnVector3 vEuler;

View file

@ -102,8 +102,8 @@ private:
enum type {tt1D, tt2D} Type; enum type {tt1D, tt2D} Type;
double** Data; double** Data;
int nRows, nCols; int nRows, nCols;
unsigned int colCounter; int colCounter;
unsigned int rowCounter; int rowCounter;
double** Allocate(void); double** Allocate(void);
void Debug(void); void Debug(void);
}; };

View file

@ -147,7 +147,7 @@ class FGTrim : public FGJSBBase
private: private:
vector<FGTrimAxis*> TrimAxes; vector<FGTrimAxis*> TrimAxes;
int current_axis; unsigned int current_axis;
int N, Nsub; int N, Nsub;
TrimMode mode; TrimMode mode;
int DebugLevel, Debug; int DebugLevel, Debug;
@ -163,7 +163,7 @@ private:
bool trimudot; bool trimudot;
bool gamma_fallback; bool gamma_fallback;
bool trim_failed; bool trim_failed;
int axis_count; unsigned int axis_count;
int solutionDomain; int solutionDomain;
double xlo,xhi,alo,ahi; double xlo,xhi,alo,ahi;
double targetNlf; double targetNlf;

View file

@ -1,184 +0,0 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGFlap.cpp
Author: Tony Peden, for flight control system authored by Jon S. Berndt
Date started: 5/11/00
------------- Copyright (C) 2000 Anthony K. Peden -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
HISTORY
--------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFlaps.h"
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_FLAPS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGFlaps::FGFlaps(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
AC_cfg(AC_cfg) {
string token;
double tmpDetent;
double tmpTime;
Detents.clear();
TransitionTimes.clear();
Type = AC_cfg->GetValue("TYPE");
Name = AC_cfg->GetValue("NAME");
AC_cfg->GetNextConfigLine();
while ((token = AC_cfg->GetValue()) != string("/COMPONENT")) {
*AC_cfg >> token;
if (token == "ID") {
*AC_cfg >> ID;
} else if (token == "INPUT") {
token = AC_cfg->GetValue("INPUT");
if (token.find("FG_") != token.npos) {
*AC_cfg >> token;
InputIdx = fcs->GetState()->GetParameterIndex(token);
InputType = itPilotAC;
}
} else if ( token == "DETENTS" ) {
*AC_cfg >> NumDetents;
for(int i=0;i<NumDetents;i++) {
*AC_cfg >> tmpDetent;
*AC_cfg >> tmpTime;
Detents.push_back(tmpDetent);
TransitionTimes.push_back(tmpTime);
}
} else if (token == "OUTPUT") {
IsOutput = true;
*AC_cfg >> sOutputIdx;
OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx);
}
}
if (debug_lvl > 1) {
cout << " ID: " << ID << endl;
cout << " INPUT: " << InputIdx << endl;
cout << " DETENTS: " << NumDetents << endl;
for(int i=0;i<NumDetents;i++) {
cout << " " << Detents[i] << " " << TransitionTimes[i] << endl;
}
if (IsOutput) cout << " OUTPUT: " <<sOutputIdx << endl;
}
if (debug_lvl & 2) cout << "Instantiated: FGFlaps" << endl;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGFlaps::~FGFlaps()
{
if (debug_lvl & 2) cout << "Destroyed: FGFlaps" << endl;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFlaps::Run(void ) {
double dt=fcs->GetState()->Getdt();
double flap_transit_rate=0;
FGFCSComponent::Run(); // call the base class for initialization of Input
Flap_Handle = Input*Detents[NumDetents-1];
Flap_Position = fcs->GetState()->GetParameter(OutputIdx);
if(Flap_Handle < Detents[0]) {
fi=0;
Flap_Handle=Detents[0];
lastFlapHandle=Flap_Handle;
Flap_Position=Detents[0];
Output=Flap_Position;
} else if(Flap_Handle > Detents[NumDetents-1]) {
fi=NumDetents-1;
Flap_Handle=Detents[fi];
lastFlapHandle=Flap_Handle;
Flap_Position=Detents[fi];
Output=Flap_Position;
} else {
//cout << "FGFlaps::Run Handle: " << Flap_Handle << " Position: " << Flap_Position << endl;
if(dt <= 0)
Flap_Position=Flap_Handle;
else {
if(Flap_Handle != lastFlapHandle) {
Flaps_In_Transit=1;
}
if(Flaps_In_Transit) {
//fprintf(stderr,"Flap_Handle: %g, Flap_Position: %g\n",Flap_Handle,Flap_Position);
fi=0;
while(Detents[fi] < Flap_Handle) {
fi++;
}
if(Flap_Position < Flap_Handle) {
if(TransitionTimes[fi] > 0)
flap_transit_rate=(Detents[fi] - Detents[fi-1])/TransitionTimes[fi];
else
flap_transit_rate=(Detents[fi] - Detents[fi-1])/5;
} else {
if(TransitionTimes[fi+1] > 0)
flap_transit_rate=(Detents[fi] - Detents[fi+1])/TransitionTimes[fi+1];
else
flap_transit_rate=(Detents[fi] - Detents[fi+1])/5;
}
if(fabs(Flap_Position - Flap_Handle) > dt*flap_transit_rate)
Flap_Position+=flap_transit_rate*dt;
else {
Flaps_In_Transit=0;
Flap_Position=Flap_Handle;
}
}
}
lastFlapHandle=Flap_Handle;
Output=Flap_Position;
}
//cout << "FGFlaps::Run Handle: " << Flap_Handle << " Position: " << Flap_Position << " Output: " << Output << endl;
if (IsOutput) {
//cout << "Calling SetOutput()" << endl;
SetOutput();
}
//cout << "Out FGFlap::Run" << endl;
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFlaps::Debug(void)
{
//TODO: Add your source code here
}

View file

@ -1,88 +0,0 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGFlaps.h
Author: Tony Peden, for flight control system authored by Jon S. Berndt
Date started: 5/11/00
------------- Copyright (C) Anthony K. Peden -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGFLAPS_H
#define FGFLAPS_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifdef FGFS
# include <simgear/compiler.h>
# ifdef SG_HAVE_STD_INCLUDES
# include <vector>
# else
# include <vector.h>
# endif
#else
# include <vector>
#endif
#include <string>
#include "FGFCSComponent.h"
#include "../FGConfigFile.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FLAPS "$Id$"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGFlaps : public FGFCSComponent {
public:
FGFlaps(FGFCS* fcs, FGConfigFile* AC_cfg);
~FGFlaps();
bool Run (void );
private:
FGConfigFile* AC_cfg;
vector<double> Detents;
vector<double> TransitionTimes;
int NumDetents,fi;
double lastFlapHandle;
double Flap_Handle;
double Flap_Position;
bool Flaps_In_Transit;
void Debug(void);
};
#endif

View file

@ -93,7 +93,7 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
if (debug_lvl > 0) { if (debug_lvl > 0) {
cout << " ID: " << ID << endl; cout << " ID: " << ID << endl;
cout << " INPUTS: " << endl; cout << " INPUTS: " << endl;
for (int i=0;i<InputIndices.size();i++) { for (unsigned i=0;i<InputIndices.size();i++) {
cout << " " << InputIndices[i] << endl; cout << " " << InputIndices[i] << endl;
} }
if (clipmax > clipmin) cout << " CLIPTO: " << clipmin if (clipmax > clipmin) cout << " CLIPTO: " << clipmin

View file

@ -6,9 +6,9 @@ libfiltersjb_a_SOURCES = \
FGDeadBand.cpp FGDeadBand.h \ FGDeadBand.cpp FGDeadBand.h \
FGFCSComponent.cpp FGFCSComponent.h \ FGFCSComponent.cpp FGFCSComponent.h \
FGFilter.cpp FGFilter.h \ FGFilter.cpp FGFilter.h \
FGFlaps.cpp FGFlaps.h \
FGGain.cpp FGGain.h \ FGGain.cpp FGGain.h \
FGGradient.cpp FGGradient.h \ FGGradient.cpp FGGradient.h \
FGKinemat.cpp FGKinemat.h \
FGSummer.cpp FGSummer.h \ FGSummer.cpp FGSummer.h \
FGSwitch.cpp FGSwitch.h FGSwitch.cpp FGSwitch.h