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,20 +268,20 @@ 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,9 +650,11 @@ 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,9 +666,9 @@ 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

@ -77,24 +77,17 @@ public:
FGColumnVector3& GetMoments(void) {return vMoments;} FGColumnVector3& GetMoments(void) {return vMoments;}
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;
@ -101,6 +105,14 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
cerr << "Improper steering type specification in config file: " cerr << "Improper steering type specification in config file: "
<< 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,31 +200,46 @@ FGLGear::~FGLGear()
FGColumnVector3& FGLGear::Force(void) FGColumnVector3& FGLGear::Force(void)
{ {
double SteerGain; vForce.InitMatrix();
double SinWheel, CosWheel, SideWhlVel, RollingWhlVel; vMoment.InitMatrix();
double RudderPedal, RollingForce, SideForce, FCoeff; if(isRetractable ) {
double WheelSlip; 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 RollingForce, SideForce, FCoeff;
double WheelSlip;
vWhlBodyVec = (vXYZ - MassBalance->GetXYZcg()) / 12.0; vWhlBodyVec = (vXYZ - MassBalance->GetXYZcg()) / 12.0;
vWhlBodyVec(eX) = -vWhlBodyVec(eX); vWhlBodyVec(eX) = -vWhlBodyVec(eX);
vWhlBodyVec(eZ) = -vWhlBodyVec(eZ); vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
// vWhlBodyVec now stores the vector from the cg to this wheel // vWhlBodyVec now stores the vector from the cg to this wheel
vLocalGear = State->GetTb2l() * vWhlBodyVec; vLocalGear = State->GetTb2l() * vWhlBodyVec;
// vLocalGear now stores the vector from the cg to the wheel in local coords. // vLocalGear now stores the vector from the cg to the wheel in local coords.
compressLength = vLocalGear(eZ) - Position->GetDistanceAGL(); compressLength = vLocalGear(eZ) - Position->GetDistanceAGL();
// The compression length is currently measured in the Z-axis, only, at this time. // The compression length is currently measured in the Z-axis, only, at this time.
// It should be measured along the strut axis. If the local-frame gear position // It should be measured along the strut axis. If the local-frame gear position
// "hangs down" below the CG greater than the altitude, then the compressLength // "hangs down" below the CG greater than the altitude, then the compressLength
// will be positive - i.e. the gear will have made contact. // will be positive - i.e. the gear will have made contact.
if (compressLength > 0.00) { if (compressLength > 0.00) {
WOW = true; // Weight-On-Wheels is true WOW = true;// Weight-On-Wheels is true
// The next equation should really use the vector to the contact patch of the tire // The next equation should really use the vector to the contact patch of the tire
// including the strut compression and not vWhlBodyVec. Will fix this later. // including the strut compression and not vWhlBodyVec. Will fix this later.
@ -222,20 +252,20 @@ FGColumnVector3& FGLGear::Force(void)
// (used for calculating damping force) is found by taking the Z-component of the // (used for calculating damping force) is found by taking the Z-component of the
// wheel velocity. // wheel velocity.
vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec); vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
vWhlVelVec += Position->GetVel(); vWhlVelVec += Position->GetVel();
compressSpeed = vWhlVelVec(eZ); compressSpeed = vWhlVelVec(eZ);
// If this is the first time the wheel has made contact, remember some values // If this is the first time the wheel has made contact, remember some values
// for later printout. // for later printout.
if (!FirstContact) { if (!FirstContact) {
FirstContact = true; FirstContact = true;
SinkRate = compressSpeed; SinkRate = compressSpeed;
GroundSpeed = Position->GetVel().Magnitude(); GroundSpeed = Position->GetVel().Magnitude();
} }
// The following needs work regarding friction coefficients and braking and // The following needs work regarding friction coefficients and braking and
// steering The BrakeFCoeff formula assumes that an anti-skid system is used. // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
@ -244,71 +274,71 @@ FGColumnVector3& FGLGear::Force(void)
// [JSB] The braking force coefficients include normal rolling coefficient + // [JSB] The braking force coefficients include normal rolling coefficient +
// a percentage of the static friction coefficient based on braking applied. // a percentage of the static friction coefficient based on braking applied.
switch (eBrakeGrp) { switch (eBrakeGrp) {
case bgLeft: case bgLeft:
SteerGain = -0.10; SteerGain = -0.10;
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) + BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
staticFCoeff*FCS->GetBrake(bgLeft); staticFCoeff*FCS->GetBrake(bgLeft);
break; break;
case bgRight: case bgRight:
SteerGain = -0.10; SteerGain = -0.10;
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) + BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
staticFCoeff*FCS->GetBrake(bgRight); staticFCoeff*FCS->GetBrake(bgRight);
break; break;
case bgCenter: case bgCenter:
SteerGain = -0.10; SteerGain = -0.10;
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) + BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
staticFCoeff*FCS->GetBrake(bgCenter); staticFCoeff*FCS->GetBrake(bgCenter);
break; break;
case bgNose: case bgNose:
SteerGain = 0.10; SteerGain = 0.10;
BrakeFCoeff = rollingFCoeff; BrakeFCoeff = rollingFCoeff;
break; break;
case bgTail: case bgTail:
SteerGain = -0.10; SteerGain = -0.10;
BrakeFCoeff = rollingFCoeff; BrakeFCoeff = rollingFCoeff;
break; break;
case bgNone: case bgNone:
SteerGain = -0.10; SteerGain = -0.10;
BrakeFCoeff = rollingFCoeff; BrakeFCoeff = rollingFCoeff;
break; break;
default: default:
cerr << "Improper brake group membership detected for this gear." << endl; cerr << "Improper brake group membership detected for this gear." << endl;
break; break;
} }
switch (eSteerType) { switch (eSteerType) {
case stSteer: case stSteer:
SteerAngle = SteerGain*FCS->GetDrPos(); SteerAngle = SteerGain*FCS->GetDrPos();
break; break;
case stFixed: case stFixed:
SteerAngle = 0.0; SteerAngle = 0.0;
break; break;
case stCaster: case stCaster:
// Note to Jon: This is not correct for castering gear. I'll fix it later. // Note to Jon: This is not correct for castering gear. I'll fix it later.
SteerAngle = 0.0; SteerAngle = 0.0;
break; break;
default: default:
cerr << "Improper steering type membership detected for this gear." << endl; cerr << "Improper steering type membership detected for this gear." << endl;
break; break;
} }
// Transform the wheel velocities from the local axis system to the wheel axis system. // Transform the wheel velocities from the local axis system to the wheel axis system.
// For now, steering angle is assumed to happen in the Local Z axis, // For now, steering angle is assumed to happen in the Local Z axis,
// not the strut axis as it should be. Will fix this later. // not the strut axis as it should be. Will fix this later.
SinWheel = sin(Rotation->Getpsi() + SteerAngle); SinWheel = sin(Rotation->Getpsi() + SteerAngle);
CosWheel = cos(Rotation->Getpsi() + SteerAngle); CosWheel = cos(Rotation->Getpsi() + SteerAngle);
RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel; RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel; SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
// Calculate tire slip angle. // Calculate tire slip angle.
if (RollingWhlVel == 0.0 && SideWhlVel == 0.0) { if (RollingWhlVel == 0.0 && SideWhlVel == 0.0) {
WheelSlip = 0.0; WheelSlip = 0.0;
} else { } else {
WheelSlip = radtodeg*atan2(SideWhlVel, RollingWhlVel); WheelSlip = radtodeg*atan2(SideWhlVel, RollingWhlVel);
} }
// The following code normalizes the wheel velocity vector, reverses it, and zeroes out // The following code normalizes the wheel velocity vector, reverses it, and zeroes out
// the z component of the velocity. The question is, should the Z axis velocity be zeroed // the z component of the velocity. The question is, should the Z axis velocity be zeroed
@ -325,11 +355,11 @@ FGColumnVector3& FGLGear::Force(void)
// transition from static to dynamic friction. There are more complicated formulations // transition from static to dynamic friction. There are more complicated formulations
// of this that avoid the discrete jump. Will fix this later. // of this that avoid the discrete jump. Will fix this later.
if (fabs(WheelSlip) <= 10.0) { if (fabs(WheelSlip) <= 10.0) {
FCoeff = staticFCoeff*WheelSlip/10.0; FCoeff = staticFCoeff*WheelSlip/10.0;
} else { } else {
FCoeff = dynamicFCoeff*fabs(WheelSlip)/WheelSlip; FCoeff = dynamicFCoeff*fabs(WheelSlip)/WheelSlip;
} }
// Compute the vertical force on the wheel using square-law damping (per comment // Compute the vertical force on the wheel using square-law damping (per comment
// in paper AIAA-2000-4303 - see header prologue comments). We might consider // in paper AIAA-2000-4303 - see header prologue comments). We might consider
@ -337,24 +367,24 @@ FGColumnVector3& FGLGear::Force(void)
// possibly give a "rebound damping factor" that differs from the compression // possibly give a "rebound damping factor" that differs from the compression
// case. NOTE: SQUARE LAW DAMPING NO GOOD! // case. NOTE: SQUARE LAW DAMPING NO GOOD!
vLocalForce(eZ) = min(-compressLength * kSpring vLocalForce(eZ) = min(-compressLength * kSpring
- compressSpeed * bDamp, (double)0.0); - compressSpeed * bDamp, (double)0.0);
MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ))); MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength)); MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
// Compute the forces in the wheel ground plane. // Compute the forces in the wheel ground plane.
RollingForce = 0; RollingForce = 0;
if (fabs(RollingWhlVel) > 1E-3) { if (fabs(RollingWhlVel) > 1E-3) {
RollingForce = vLocalForce(eZ) * BrakeFCoeff * fabs(RollingWhlVel)/RollingWhlVel; RollingForce = vLocalForce(eZ) * BrakeFCoeff * fabs(RollingWhlVel)/RollingWhlVel;
} }
SideForce = vLocalForce(eZ) * FCoeff; SideForce = vLocalForce(eZ) * FCoeff;
// Transform these forces back to the local reference frame. // Transform these forces back to the local reference frame.
vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel; vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
vLocalForce(eY) = SideForce*CosWheel + RollingForce*SinWheel; vLocalForce(eY) = SideForce*CosWheel + RollingForce*SinWheel;
// Note to Jon: At this point the forces will be too big when the airplane is // Note to Jon: At this point the forces will be too big when the airplane is
// stopped or rolling to a stop. We need to make sure that the gear forces just // stopped or rolling to a stop. We need to make sure that the gear forces just
@ -370,52 +400,53 @@ FGColumnVector3& FGLGear::Force(void)
// Transform the forces back to the body frame and compute the moment. // Transform the forces back to the body frame and compute the moment.
vForce = State->GetTl2b() * vLocalForce; vForce = State->GetTl2b() * vLocalForce;
vMoment = vWhlBodyVec * vForce; vMoment = vWhlBodyVec * vForce;
} else { } else {
WOW = false; WOW = false;
if (Position->GetDistanceAGL() > 200.0) { if (Position->GetDistanceAGL() > 200.0) {
FirstContact = false; FirstContact = false;
Reported = false; Reported = false;
DistanceTraveled = 0.0; DistanceTraveled = 0.0;
MaximumStrutForce = MaximumStrutTravel = 0.0; MaximumStrutForce = MaximumStrutTravel = 0.0;
}
compressLength = 0.0;// reset compressLength to zero for data output validity
} }
compressLength = 0.0; // reset compressLength to zero for data output validity if (FirstContact) {
DistanceTraveled += Position->GetVel().Magnitude()*State->Getdt()*Aircraft->GetRate();
vForce.InitMatrix(); }
vMoment.InitMatrix();
}
if (FirstContact) {
DistanceTraveled += Position->GetVel().Magnitude()*State->Getdt()*Aircraft->GetRate();
}
if (ReportEnable && Position->GetVel().Magnitude() <= 0.05 && !Reported) {
if (debug_lvl > 0) Report();
}
if (lastWOW != WOW) {
PutMessage("GEAR_CONTACT", WOW);
}
lastWOW = WOW;
// Crash detection logic (really out-of-bounds detection)
if (compressLength > 500.0 || if (ReportEnable && Position->GetVel().Magnitude() <= 0.05 && !Reported) {
vForce.Magnitude() > 100000000.0 || if (debug_lvl > 0) Report();
vMoment.Magnitude() > 5000000000.0 || }
SinkRate > 1.4666*30)
{
PutMessage("Crash Detected");
Exec->Freeze();
}
return vForce; if (lastWOW != WOW) {
PutMessage("GEAR_CONTACT", WOW);
}
lastWOW = WOW;
// Crash detection logic (really out-of-bounds detection)
if (compressLength > 500.0 ||
vForce.Magnitude() > 100000000.0 ||
vMoment.Magnitude() > 5000000000.0 ||
SinkRate > 1.4666*30)
{
PutMessage("Crash Detected");
Exec->Freeze();
}
}
return vForce;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -231,7 +231,11 @@ 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,22 +50,27 @@ 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), CONVERT_CUBIC_INCHES_TO_METERS_CUBED(1.638706e-5),
Displacement(360), R_air(287.3),
MaxHP(200), rho_fuel(800), // estimate
Cycles(2), calorific_value_fuel(47.3e6),
IdleRPM(600), Cp_air(1005),
// Set constants Cp_fuel(1700)
CONVERT_CUBIC_INCHES_TO_METERS_CUBED(1.638706e-5),
R_air(287.3),
rho_fuel(800), // estimate
calorific_value_fuel(47.3e6),
Cp_air(1005),
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,11 +143,12 @@ 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 " );
RegisterVariable(FG_MAGNETO_CMD, " magneto_cmd " ); RegisterVariable(FG_MAGNETO_CMD, " magneto_cmd " );
RegisterVariable(FG_STARTER_CMD, " starter_cmd " ); RegisterVariable(FG_STARTER_CMD, " starter_cmd " );
RegisterVariable(FG_ACTIVE_ENGINE, " active_engine " ); RegisterVariable(FG_ACTIVE_ENGINE, " active_engine " );
RegisterVariable(FG_HOVERB, " height/span " ); RegisterVariable(FG_HOVERB, " height/span " );
RegisterVariable(FG_PITCH_TRIM_CMD, " pitch_trim_cmd " ); RegisterVariable(FG_PITCH_TRIM_CMD, " pitch_trim_cmd " );
@ -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,182 +1,182 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: JSBSim.cpp Module: JSBSim.cpp
Author: Jon S. Berndt Author: Jon S. Berndt
Date started: 08/17/99 Date started: 08/17/99
Purpose: Standalone version of JSBSim. Purpose: Standalone version of JSBSim.
Called by: The USER. Called by: The USER.
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under 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 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 Foundation; either version 2 of the License, or (at your option) any later
version. version.
This program is distributed in the hope that it will be useful, but WITHOUT 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 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details. details.
You should have received a copy of the GNU General Public License along with 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA. Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU General Public License can also be found on Further information about the GNU General Public License can also be found on
the world wide web at http://www.gnu.org. the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION FUNCTIONAL DESCRIPTION
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
This class Handles calling JSBSim standalone. It is set up for compilation under This class Handles calling JSBSim standalone. It is set up for compilation under
Borland C+Builder or other compiler. Borland C+Builder or other compiler.
HISTORY HISTORY
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
08/17/99 JSB Created 08/17/99 JSB Created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFDMExec.h" #include "FGFDMExec.h"
#include "FGRotation.h" #include "FGRotation.h"
#include "FGAtmosphere.h" #include "FGAtmosphere.h"
#include "FGState.h" #include "FGState.h"
#include "FGFCS.h" #include "FGFCS.h"
#include "FGAircraft.h" #include "FGAircraft.h"
#include "FGTranslation.h" #include "FGTranslation.h"
#include "FGPosition.h" #include "FGPosition.h"
#include "FGAuxiliary.h" #include "FGAuxiliary.h"
#include "FGOutput.h" #include "FGOutput.h"
#include "FGConfigFile.h" #include "FGConfigFile.h"
#ifdef FGFS #ifdef FGFS
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include STL_IOSTREAM #include STL_IOSTREAM
# ifdef SG_HAVE_STD_INCLUDES # ifdef SG_HAVE_STD_INCLUDES
# include <ctime> # include <ctime>
# else # else
# include <time.h> # include <time.h>
# endif # endif
#else #else
# if defined(sgi) && !defined(__GNUC__) # if defined(sgi) && !defined(__GNUC__)
# include <iostream.h> # include <iostream.h>
# include <time.h> # include <time.h>
# else # else
# include <iostream> # include <iostream>
# include <ctime> # include <ctime>
# endif # endif
#endif #endif
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GLOBAL DATA GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
static const char *IdSrc = "$Id$"; static const char *IdSrc = "$Id$";
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DOCUMENTATION DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Standalone JSBSim main program /** Standalone JSBSim main program
This is the wrapper program used to instantiate the JSBSim system and control This is the wrapper program used to instantiate the JSBSim system and control
it. Use this program to build a version of JSBSim that can be run from the it. Use this program to build a version of JSBSim that can be run from the
command line. To get any use out of this, you will have to create a script command line. To get any use out of this, you will have to create a script
to run a test case and specify what kind of output you would like. to run a test case and specify what kind of output you would like.
@author Jon S. Berndt @author Jon S. Berndt
@version $Id$ @version $Id$
@see - @see -
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
IMPLEMENTATION IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
FGFDMExec* FDMExec; FGFDMExec* FDMExec;
float cmd = 0.0; float cmd = 0.0;
bool result = false; bool result = false;
bool scripted = false; bool scripted = false;
if (argc == 2) { if (argc == 2) {
FGConfigFile testFile(argv[1]); FGConfigFile testFile(argv[1]);
if (!testFile.IsOpen()) { if (!testFile.IsOpen()) {
cout << "Script file not opened" << endl; cout << "Script file not opened" << endl;
exit(-1); exit(-1);
} }
testFile.GetNextConfigLine(); testFile.GetNextConfigLine();
if (testFile.GetValue("runscript").length() <= 0) { if (testFile.GetValue("runscript").length() <= 0) {
cout << "File: " << argv[1] << " is not a script file" << endl; cout << "File: " << argv[1] << " is not a script file" << endl;
exit(-1); exit(-1);
} }
scripted = true; scripted = true;
} else if (argc != 3) { } else if (argc != 3) {
cout << endl cout << endl
<< " You must enter the name of a registered aircraft and reset point:" << " You must enter the name of a registered aircraft and reset point:"
<< endl << endl << " FDM <aircraft name> <reset file>" << endl; << endl << endl << " FDM <aircraft name> <reset file>" << endl;
cout << endl << " Alternatively, you may specify only the name of a script file:" cout << endl << " Alternatively, you may specify only the name of a script file:"
<< endl << endl << " FDM <script file>" << endl << endl; << endl << endl << " FDM <script file>" << endl << endl;
exit(0); exit(0);
} }
FDMExec = new FGFDMExec(); FDMExec = new FGFDMExec();
if (scripted) { // form jsbsim <scriptfile> if (scripted) { // form jsbsim <scriptfile>
result = FDMExec->LoadScript(argv[1]); result = FDMExec->LoadScript(argv[1]);
if (!result) { if (!result) {
cerr << "Script file " << argv[1] << " was not successfully loaded" << endl; cerr << "Script file " << argv[1] << " was not successfully loaded" << endl;
exit(-1); exit(-1);
} }
} else { // form jsbsim <acname> <resetfile> } else { // form jsbsim <acname> <resetfile>
if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) { if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) {
cerr << " JSBSim could not be started" << endl << endl; cerr << " JSBSim could not be started" << endl << endl;
exit(-1); exit(-1);
} }
FGInitialCondition IC(FDMExec); FGInitialCondition IC(FDMExec);
if ( ! IC.Load("aircraft",string(argv[1]),string(argv[2]))) { if ( ! IC.Load("aircraft",string(argv[1]),string(argv[2]))) {
cerr << "Initialization unsuccessful" << endl; cerr << "Initialization unsuccessful" << endl;
exit(-1); exit(-1);
} }
} }
FGJSBBase::Message* msg; FGJSBBase::Message* msg;
while (FDMExec->Run()) { while (FDMExec->Run()) {
while (FDMExec->ReadMessage()) { while (FDMExec->ReadMessage()) {
msg = FDMExec->ProcessMessage(); msg = FDMExec->ProcessMessage();
switch (msg->type) { switch (msg->type) {
case FGJSBBase::Message::eText: case FGJSBBase::Message::eText:
cout << msg->messageId << ": " << msg->text << endl; cout << msg->messageId << ": " << msg->text << endl;
break; break;
case FGJSBBase::Message::eBool: case FGJSBBase::Message::eBool:
cout << msg->messageId << ": " << msg->text << " " << msg->bVal << endl; cout << msg->messageId << ": " << msg->text << " " << msg->bVal << endl;
break; break;
case FGJSBBase::Message::eInteger: case FGJSBBase::Message::eInteger:
cout << msg->messageId << ": " << msg->text << " " << msg->iVal << endl; cout << msg->messageId << ": " << msg->text << " " << msg->iVal << endl;
break; break;
case FGJSBBase::Message::eDouble: case FGJSBBase::Message::eDouble:
cout << msg->messageId << ": " << msg->text << " " << msg->dVal << endl; cout << msg->messageId << ": " << msg->text << " " << msg->dVal << endl;
break; break;
default: default:
cerr << "Unrecognized message type." << endl; cerr << "Unrecognized message type." << endl;
break; break;
} }
} }
} }
delete FDMExec; delete FDMExec;
return 0; return 0;
} }

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