Latest JSBSim changes, including a kludge from Tony to keep the
slip/skid ball still when the plane is stationary.
This commit is contained in:
parent
7666c88e23
commit
c5d537394d
8 changed files with 396 additions and 382 deletions
|
@ -373,9 +373,9 @@ bool FGJSBsim::copy_from_JSBsim() {
|
||||||
Aircraft->GetNcg()(2),
|
Aircraft->GetNcg()(2),
|
||||||
Aircraft->GetNcg()(3) );
|
Aircraft->GetNcg()(3) );
|
||||||
|
|
||||||
_set_Accels_Pilot_Body( Auxiliary->GetNpilot()(1),
|
_set_Accels_Pilot_Body( Auxiliary->GetPilotAccel()(1),
|
||||||
Auxiliary->GetNpilot()(2),
|
Auxiliary->GetPilotAccel()(2),
|
||||||
Auxiliary->GetNpilot()(3) );
|
Auxiliary->GetPilotAccel()(3) );
|
||||||
|
|
||||||
// _set_Accels_Pilot_Body_N( Auxiliary->GetPilotAccel()(1)/32.1739,
|
// _set_Accels_Pilot_Body_N( Auxiliary->GetPilotAccel()(1)/32.1739,
|
||||||
// Auxiliary->GetNpilot(2)/32.1739,
|
// Auxiliary->GetNpilot(2)/32.1739,
|
||||||
|
|
|
@ -145,7 +145,9 @@ public:
|
||||||
inline double Getvbarh(void) { return vbarh; } // H. Tail Volume
|
inline double Getvbarh(void) { return vbarh; } // H. Tail Volume
|
||||||
inline double Getvbarv(void) { return vbarv; } // V. Tail Volume
|
inline double Getvbarv(void) { return vbarv; } // V. Tail Volume
|
||||||
inline FGColumnVector3& GetMoments(void) { return vMoments; }
|
inline FGColumnVector3& GetMoments(void) { return vMoments; }
|
||||||
|
inline double GetMoments(int idx) { return vMoments(idx); }
|
||||||
inline FGColumnVector3& GetForces(void) { return vForces; }
|
inline FGColumnVector3& GetForces(void) { return vForces; }
|
||||||
|
inline double GetForces(int idx) { return vForces(idx); }
|
||||||
inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
|
inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
|
||||||
inline FGColumnVector3& GetNcg (void) { return vNcg; }
|
inline FGColumnVector3& GetNcg (void) { return vNcg; }
|
||||||
inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
|
inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
|
||||||
|
|
|
@ -145,14 +145,18 @@ bool FGAuxiliary::Run()
|
||||||
// mass, the acceleration vector is calculated. The term wdot is equivalent
|
// mass, the acceleration vector is calculated. The term wdot is equivalent
|
||||||
// to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
|
// to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
|
||||||
// The radius R is calculated below in the vector vToEyePt.
|
// The radius R is calculated below in the vector vToEyePt.
|
||||||
|
|
||||||
vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
|
vPilotAccel.InitMatrix();
|
||||||
|
if( Translation->GetVt() > 1 ) {
|
||||||
vPilotAccel = Aircraft->GetBodyAccel()
|
vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
|
||||||
+ Rotation->GetPQRdot() * vToEyePt
|
|
||||||
+ Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt)
|
|
||||||
+ Inertial->GetGravity();
|
|
||||||
|
|
||||||
|
vPilotAccel = Aerodynamics->GetForces()
|
||||||
|
+ Propulsion->GetForces()
|
||||||
|
+ GroundReactions->GetForces();
|
||||||
|
vPilotAccel /= MassBalance->GetMass();
|
||||||
|
vPilotAccel += Rotation->GetPQRdot() * vToEyePt;
|
||||||
|
vPilotAccel += Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt);
|
||||||
|
}
|
||||||
earthPosAngle += State->Getdt()*Inertial->omega();
|
earthPosAngle += State->Getdt()*Inertial->omega();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -671,7 +671,6 @@ bool FGInitialCondition::solve(double *y,double x)
|
||||||
i=0;
|
i=0;
|
||||||
while ((fabs(d) > eps) && (i < 100)) {
|
while ((fabs(d) > eps) && (i < 100)) {
|
||||||
d=(x3-x1)/d0;
|
d=(x3-x1)/d0;
|
||||||
cout << "f3-f1= " << f3-f1 << endl;
|
|
||||||
x2 = x1-d*d0*f1/(f3-f1);
|
x2 = x1-d*d0*f1/(f3-f1);
|
||||||
|
|
||||||
f2=(this->*sfunc)(x2)-x;
|
f2=(this->*sfunc)(x2)-x;
|
||||||
|
|
|
@ -69,9 +69,6 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
|
||||||
SubSystems = 0;
|
SubSystems = 0;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
|
||||||
#ifdef FG_WITH_JSBSIM_SOCKET
|
|
||||||
socket = new FGfdmSocket("localhost",1138);
|
|
||||||
#endif
|
|
||||||
Debug(0);
|
Debug(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,8 +299,9 @@ void FGOutput::DelimitedOutput(string fname)
|
||||||
void FGOutput::SocketOutput(void)
|
void FGOutput::SocketOutput(void)
|
||||||
{
|
{
|
||||||
string asciiData;
|
string asciiData;
|
||||||
/*
|
|
||||||
if (socket == NULL) return;
|
if (socket == NULL) return;
|
||||||
|
if (!socket->GetConnectStatus()) return;
|
||||||
|
|
||||||
socket->Clear();
|
socket->Clear();
|
||||||
if (sFirstPass) {
|
if (sFirstPass) {
|
||||||
|
@ -343,10 +341,10 @@ void FGOutput::SocketOutput(void)
|
||||||
socket->Append("L");
|
socket->Append("L");
|
||||||
socket->Append("M");
|
socket->Append("M");
|
||||||
socket->Append("N");
|
socket->Append("N");
|
||||||
socket->Append("Throttle");
|
socket->Append("Throttle Position");
|
||||||
socket->Append("Aileron");
|
socket->Append("Aileron Position");
|
||||||
socket->Append("Elevator");
|
socket->Append("Elevator Position");
|
||||||
socket->Append("Rudder");
|
socket->Append("Rudder Position");
|
||||||
sFirstPass = false;
|
sFirstPass = false;
|
||||||
socket->Send();
|
socket->Send();
|
||||||
}
|
}
|
||||||
|
@ -368,30 +366,30 @@ void FGOutput::SocketOutput(void)
|
||||||
socket->Append(Position->GetVn());
|
socket->Append(Position->GetVn());
|
||||||
socket->Append(Position->GetVe());
|
socket->Append(Position->GetVe());
|
||||||
socket->Append(Position->GetVd());
|
socket->Append(Position->GetVd());
|
||||||
socket->Append(Translation->GetUdot());
|
socket->Append(Translation->GetUVWdot(eU));
|
||||||
socket->Append(Translation->GetVdot());
|
socket->Append(Translation->GetUVWdot(eV));
|
||||||
socket->Append(Translation->GetWdot());
|
socket->Append(Translation->GetUVWdot(eW));
|
||||||
socket->Append(Rotation->GetP());
|
socket->Append(Rotation->GetPQR(eP));
|
||||||
socket->Append(Rotation->GetQ());
|
socket->Append(Rotation->GetPQR(eQ));
|
||||||
socket->Append(Rotation->GetR());
|
socket->Append(Rotation->GetPQR(eR));
|
||||||
socket->Append(Rotation->GetPdot());
|
socket->Append(Rotation->GetPQRdot(eP));
|
||||||
socket->Append(Rotation->GetQdot());
|
socket->Append(Rotation->GetPQRdot(eQ));
|
||||||
socket->Append(Rotation->GetRdot());
|
socket->Append(Rotation->GetPQRdot(eR));
|
||||||
socket->Append(Aircraft->GetFx());
|
socket->Append(Aircraft->GetForces(eX));
|
||||||
socket->Append(Aircraft->GetFy());
|
socket->Append(Aircraft->GetForces(eY));
|
||||||
socket->Append(Aircraft->GetFz());
|
socket->Append(Aircraft->GetForces(eZ));
|
||||||
socket->Append(Position->GetLatitude());
|
socket->Append(Position->GetLatitude());
|
||||||
socket->Append(Position->GetLongitude());
|
socket->Append(Position->GetLongitude());
|
||||||
socket->Append(Translation->Getqbar());
|
socket->Append(Translation->Getqbar());
|
||||||
socket->Append(Translation->Getalpha());
|
socket->Append(Translation->Getalpha());
|
||||||
socket->Append(Aircraft->GetL());
|
socket->Append(Aircraft->GetMoments(eL));
|
||||||
socket->Append(Aircraft->GetM());
|
socket->Append(Aircraft->GetMoments(eM));
|
||||||
socket->Append(Aircraft->GetN());
|
socket->Append(Aircraft->GetMoments(eN));
|
||||||
socket->Append(FCS->GetThrottle(0));
|
socket->Append(FCS->GetThrottlePos(0));
|
||||||
socket->Append(FCS->GetDa());
|
socket->Append(FCS->GetDaPos());
|
||||||
socket->Append(FCS->GetDe());
|
socket->Append(FCS->GetDePos());
|
||||||
socket->Append(FCS->GetDr());
|
socket->Append(FCS->GetDrPos());
|
||||||
socket->Send(); */
|
socket->Send();
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
@ -419,6 +417,13 @@ bool FGOutput::Load(FGConfigFile* AC_cfg)
|
||||||
Output->SetFilename(token);
|
Output->SetFilename(token);
|
||||||
token = AC_cfg->GetValue("TYPE");
|
token = AC_cfg->GetValue("TYPE");
|
||||||
Output->SetType(token);
|
Output->SetType(token);
|
||||||
|
|
||||||
|
#if defined( FG_WITH_JSBSIM_SOCKET ) || !defined( FGFS )
|
||||||
|
if (token == "SOCKET") {
|
||||||
|
socket = new FGfdmSocket("localhost",1138);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
AC_cfg->GetNextConfigLine();
|
AC_cfg->GetNextConfigLine();
|
||||||
|
|
||||||
while ((token = AC_cfg->GetValue()) != string("/OUTPUT")) {
|
while ((token = AC_cfg->GetValue()) != string("/OUTPUT")) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ CLASS IMPLEMENTATION
|
||||||
FGfdmSocket::FGfdmSocket(string address, int port)
|
FGfdmSocket::FGfdmSocket(string address, int port)
|
||||||
{
|
{
|
||||||
size = 0;
|
size = 0;
|
||||||
|
connected = false;
|
||||||
|
|
||||||
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
|
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
|
@ -80,6 +81,7 @@ FGfdmSocket::FGfdmSocket(string address, int port)
|
||||||
int len = sizeof(struct sockaddr_in);
|
int len = sizeof(struct sockaddr_in);
|
||||||
if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful
|
if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful
|
||||||
cout << "Successfully connected to socket ..." << endl;
|
cout << "Successfully connected to socket ..." << endl;
|
||||||
|
connected = true;
|
||||||
} else { // unsuccessful
|
} else { // unsuccessful
|
||||||
cout << "Could not connect to socket ..." << endl;
|
cout << "Could not connect to socket ..." << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,7 @@ public:
|
||||||
void Append(double);
|
void Append(double);
|
||||||
void Append(long);
|
void Append(long);
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
|
bool GetConnectStatus(void) {return connected;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int sckt;
|
int sckt;
|
||||||
|
@ -107,6 +108,7 @@ private:
|
||||||
struct sockaddr_in scktName;
|
struct sockaddr_in scktName;
|
||||||
struct hostent *host;
|
struct hostent *host;
|
||||||
string buffer;
|
string buffer;
|
||||||
|
bool connected;
|
||||||
void Debug(int from);
|
void Debug(int from);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,343 +1,343 @@
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
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"
|
||||||
#include "FGScript.h"
|
#include "FGScript.h"
|
||||||
#include "FGJSBBase.h"
|
#include "FGJSBBase.h"
|
||||||
|
|
||||||
#ifdef FGFS
|
#ifdef FGFS
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include STL_IOSTREAM
|
#include STL_IOSTREAM
|
||||||
#else
|
#else
|
||||||
# if defined(sgi) && !defined(__GNUC__)
|
# if defined(sgi) && !defined(__GNUC__)
|
||||||
# include <iostream.h>
|
# include <iostream.h>
|
||||||
# else
|
# else
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __BCPLUSPLUS__ == 0x540
|
#if __BCPLUSPLUS__ == 0x540
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#include <condefs.h>
|
#include <condefs.h>
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
USERES("JSBSim.res");
|
USERES("JSBSim.res");
|
||||||
USEUNIT("FGUtility.cpp");
|
USEUNIT("FGUtility.cpp");
|
||||||
USEUNIT("FGAircraft.cpp");
|
USEUNIT("FGAircraft.cpp");
|
||||||
USEUNIT("FGAtmosphere.cpp");
|
USEUNIT("FGAtmosphere.cpp");
|
||||||
USEUNIT("FGAuxiliary.cpp");
|
USEUNIT("FGAuxiliary.cpp");
|
||||||
USEUNIT("FGCoefficient.cpp");
|
USEUNIT("FGCoefficient.cpp");
|
||||||
USEUNIT("FGColumnVector3.cpp");
|
USEUNIT("FGColumnVector3.cpp");
|
||||||
USEUNIT("FGColumnVector4.cpp");
|
USEUNIT("FGColumnVector4.cpp");
|
||||||
USEUNIT("FGConfigFile.cpp");
|
USEUNIT("FGConfigFile.cpp");
|
||||||
USEUNIT("FGEngine.cpp");
|
USEUNIT("FGEngine.cpp");
|
||||||
USEUNIT("FGFactorGroup.cpp");
|
USEUNIT("FGFactorGroup.cpp");
|
||||||
USEUNIT("FGFCS.cpp");
|
USEUNIT("FGFCS.cpp");
|
||||||
USEUNIT("FGFDMExec.cpp");
|
USEUNIT("FGFDMExec.cpp");
|
||||||
USEUNIT("FGfdmSocket.cpp");
|
USEUNIT("FGfdmSocket.cpp");
|
||||||
USEUNIT("FGForce.cpp");
|
USEUNIT("FGForce.cpp");
|
||||||
USEUNIT("FGGroundReactions.cpp");
|
USEUNIT("FGGroundReactions.cpp");
|
||||||
USEUNIT("FGInertial.cpp");
|
USEUNIT("FGInertial.cpp");
|
||||||
USEUNIT("FGInitialCondition.cpp");
|
USEUNIT("FGInitialCondition.cpp");
|
||||||
USEUNIT("FGJSBBase.cpp");
|
USEUNIT("FGJSBBase.cpp");
|
||||||
USEUNIT("FGLGear.cpp");
|
USEUNIT("FGLGear.cpp");
|
||||||
USEUNIT("FGMassBalance.cpp");
|
USEUNIT("FGMassBalance.cpp");
|
||||||
USEUNIT("FGMatrix33.cpp");
|
USEUNIT("FGMatrix33.cpp");
|
||||||
USEUNIT("FGModel.cpp");
|
USEUNIT("FGModel.cpp");
|
||||||
USEUNIT("FGNozzle.cpp");
|
USEUNIT("FGNozzle.cpp");
|
||||||
USEUNIT("FGOutput.cpp");
|
USEUNIT("FGOutput.cpp");
|
||||||
USEUNIT("FGPiston.cpp");
|
USEUNIT("FGPiston.cpp");
|
||||||
USEUNIT("FGPosition.cpp");
|
USEUNIT("FGPosition.cpp");
|
||||||
USEUNIT("FGPropeller.cpp");
|
USEUNIT("FGPropeller.cpp");
|
||||||
USEUNIT("FGPropulsion.cpp");
|
USEUNIT("FGPropulsion.cpp");
|
||||||
USEUNIT("FGRocket.cpp");
|
USEUNIT("FGRocket.cpp");
|
||||||
USEUNIT("FGRotation.cpp");
|
USEUNIT("FGRotation.cpp");
|
||||||
USEUNIT("FGRotor.cpp");
|
USEUNIT("FGRotor.cpp");
|
||||||
USEUNIT("FGScript.cpp");
|
USEUNIT("FGScript.cpp");
|
||||||
USEUNIT("FGState.cpp");
|
USEUNIT("FGState.cpp");
|
||||||
USEUNIT("FGTable.cpp");
|
USEUNIT("FGTable.cpp");
|
||||||
USEUNIT("FGTank.cpp");
|
USEUNIT("FGTank.cpp");
|
||||||
USEUNIT("FGThruster.cpp");
|
USEUNIT("FGThruster.cpp");
|
||||||
USEUNIT("FGTranslation.cpp");
|
USEUNIT("FGTranslation.cpp");
|
||||||
USEUNIT("FGTrim.cpp");
|
USEUNIT("FGTrim.cpp");
|
||||||
USEUNIT("FGTrimAxis.cpp");
|
USEUNIT("FGTrimAxis.cpp");
|
||||||
USEUNIT("FGTurboJet.cpp");
|
USEUNIT("FGTurboJet.cpp");
|
||||||
USEUNIT("FGTurboProp.cpp");
|
USEUNIT("FGTurboProp.cpp");
|
||||||
USEUNIT("FGTurboShaft.cpp");
|
USEUNIT("FGTurboShaft.cpp");
|
||||||
USEUNIT("FGAerodynamics.cpp");
|
USEUNIT("FGAerodynamics.cpp");
|
||||||
USEUNIT("filtersjb\FGSwitch.cpp");
|
USEUNIT("filtersjb\FGSwitch.cpp");
|
||||||
USEUNIT("filtersjb\FGFCSComponent.cpp");
|
USEUNIT("filtersjb\FGFCSComponent.cpp");
|
||||||
USEUNIT("filtersjb\FGFilter.cpp");
|
USEUNIT("filtersjb\FGFilter.cpp");
|
||||||
USEUNIT("filtersjb\FGGain.cpp");
|
USEUNIT("filtersjb\FGGain.cpp");
|
||||||
USEUNIT("filtersjb\FGGradient.cpp");
|
USEUNIT("filtersjb\FGGradient.cpp");
|
||||||
USEUNIT("filtersjb\FGKinemat.cpp");
|
USEUNIT("filtersjb\FGKinemat.cpp");
|
||||||
USEUNIT("filtersjb\FGSummer.cpp");
|
USEUNIT("filtersjb\FGSummer.cpp");
|
||||||
USEUNIT("filtersjb\FGDeadBand.cpp");
|
USEUNIT("filtersjb\FGDeadBand.cpp");
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#pragma argsused
|
#pragma argsused
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
DEFINITIONS
|
DEFINITIONS
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
GLOBAL DATA
|
GLOBAL DATA
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
static const char *IdSrc = "$Id$";
|
static const char *IdSrc = "$Id$";
|
||||||
|
|
||||||
string ScriptName;
|
string ScriptName;
|
||||||
string AircraftName;
|
string AircraftName;
|
||||||
string ResetName;
|
string ResetName;
|
||||||
string LogOutputName;
|
string LogOutputName;
|
||||||
string LogDirectiveName;
|
string LogDirectiveName;
|
||||||
FGFDMExec* FDMExec;
|
FGFDMExec* FDMExec;
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
|
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
FORWARD DECLARATIONS
|
FORWARD DECLARATIONS
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
void options(int, char**);
|
void options(int, char**);
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
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[])
|
||||||
{
|
{
|
||||||
ScriptName = "";
|
ScriptName = "";
|
||||||
AircraftName = "";
|
AircraftName = "";
|
||||||
ResetName = "";
|
ResetName = "";
|
||||||
LogOutputName = "";
|
LogOutputName = "";
|
||||||
LogDirectiveName = "";
|
LogDirectiveName = "";
|
||||||
bool result = false;
|
bool result = false;
|
||||||
bool Scripted = false;
|
bool Scripted = false;
|
||||||
FGScript* Script;
|
FGScript* Script;
|
||||||
|
|
||||||
options(argc, argv);
|
options(argc, argv);
|
||||||
|
|
||||||
FDMExec = new FGFDMExec();
|
FDMExec = new FGFDMExec();
|
||||||
|
|
||||||
if (!ScriptName.empty()) { // SCRIPTED CASE
|
if (!ScriptName.empty()) { // SCRIPTED CASE
|
||||||
|
|
||||||
Script = new FGScript(FDMExec);
|
Script = new FGScript(FDMExec);
|
||||||
result = Script->LoadScript(ScriptName);
|
result = Script->LoadScript(ScriptName);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
cerr << "Script file " << ScriptName << " was not successfully loaded" << endl;
|
cerr << "Script file " << ScriptName << " was not successfully loaded" << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scripted = true;
|
Scripted = true;
|
||||||
|
|
||||||
} else if (!AircraftName.empty() || !ResetName.empty()) { // form jsbsim <acname> <resetfile>
|
} else if (!AircraftName.empty() || !ResetName.empty()) { // form jsbsim <acname> <resetfile>
|
||||||
|
|
||||||
if ( ! FDMExec->LoadModel("aircraft", "engine", AircraftName)) {
|
if ( ! FDMExec->LoadModel("aircraft", "engine", AircraftName)) {
|
||||||
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",AircraftName,ResetName)) {
|
if ( ! IC.Load("aircraft",AircraftName,ResetName)) {
|
||||||
cerr << "Initialization unsuccessful" << endl;
|
cerr << "Initialization unsuccessful" << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cout << " No Aircraft, Script, or Reset information given" << endl << endl;
|
cout << " No Aircraft, Script, or Reset information given" << endl << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// RUN loop. MESSAGES are read inside the Run() loop and output as necessary.
|
// RUN loop. MESSAGES are read inside the Run() loop and output as necessary.
|
||||||
//
|
//
|
||||||
|
|
||||||
FGJSBBase::Message* msg;
|
FGJSBBase::Message* msg;
|
||||||
result = FDMExec->Run();
|
result = FDMExec->Run();
|
||||||
while (result) {
|
while (result) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Scripted) {
|
if (Scripted) {
|
||||||
if (!Script->RunScript()) break;
|
if (!Script->RunScript()) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = FDMExec->Run();
|
result = FDMExec->Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete FDMExec;
|
delete FDMExec;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void options(int count, char **arg)
|
void options(int count, char **arg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
cout << endl << " JSBSim version " << FDMExec->GetVersion() << endl << endl;
|
cout << endl << " JSBSim version " << FDMExec->GetVersion() << endl << endl;
|
||||||
cout << " Usage: jsbsim <options>" << endl << endl;
|
cout << " Usage: jsbsim <options>" << endl << endl;
|
||||||
cout << " options:" << endl;
|
cout << " options:" << endl;
|
||||||
cout << " --help returns this message" << endl;
|
cout << " --help returns this message" << endl;
|
||||||
cout << " --version returns the version number" << endl;
|
cout << " --version returns the version number" << endl;
|
||||||
cout << " --outputlogfile=<filename> sets the name of the data output file" << endl;
|
cout << " --outputlogfile=<filename> sets the name of the data output file" << endl;
|
||||||
cout << " --logdirectivefile=<filename> specifies the name of the data logging directives file" << endl;
|
cout << " --logdirectivefile=<filename> specifies the name of the data logging directives file" << endl;
|
||||||
cout << " --aircraft=<filename> specifies the name of the aircraft to be modeled" << endl;
|
cout << " --aircraft=<filename> specifies the name of the aircraft to be modeled" << endl;
|
||||||
cout << " --script=<filename> specifies a script to run" << endl;
|
cout << " --script=<filename> specifies a script to run" << endl;
|
||||||
cout << " --initfile=<filename> specifies an initilization file" << endl << endl;
|
cout << " --initfile=<filename> specifies an initilization file" << endl << endl;
|
||||||
cout << " NOTE: There can be no spaces around the = sign when" << endl;
|
cout << " NOTE: There can be no spaces around the = sign when" << endl;
|
||||||
cout << " an option is followed by a filename" << endl << endl;
|
cout << " an option is followed by a filename" << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=1; i<count; i++) {
|
for (i=1; i<count; i++) {
|
||||||
string argument = string(arg[i]);
|
string argument = string(arg[i]);
|
||||||
int n=0;
|
int n=0;
|
||||||
if (argument.find("--help") != string::npos) {
|
if (argument.find("--help") != string::npos) {
|
||||||
cout << endl << " JSBSim version " << FDMExec->GetVersion() << endl << endl;
|
cout << endl << " JSBSim version " << FDMExec->GetVersion() << endl << endl;
|
||||||
cout << " Usage: jsbsim <options>" << endl << endl;
|
cout << " Usage: jsbsim <options>" << endl << endl;
|
||||||
cout << " options:" << endl;
|
cout << " options:" << endl;
|
||||||
cout << " --help returns this message" << endl;
|
cout << " --help returns this message" << endl;
|
||||||
cout << " --version returns the version number" << endl;
|
cout << " --version returns the version number" << endl;
|
||||||
cout << " --outputlogfile=<filename> sets the name of the data output file" << endl;
|
cout << " --outputlogfile=<filename> sets the name of the data output file" << endl;
|
||||||
cout << " --logdirectivefile=<filename> specifies the name of the data logging directives file" << endl;
|
cout << " --logdirectivefile=<filename> specifies the name of the data logging directives file" << endl;
|
||||||
cout << " --aircraft=<filename> specifies the name of the aircraft to be modeled" << endl;
|
cout << " --aircraft=<filename> specifies the name of the aircraft to be modeled" << endl;
|
||||||
cout << " --script=<filename> specifies a script to run" << endl;
|
cout << " --script=<filename> specifies a script to run" << endl;
|
||||||
cout << " --initfile=<filename> specifies an initilization file" << endl << endl;
|
cout << " --initfile=<filename> specifies an initilization file" << endl << endl;
|
||||||
cout << " NOTE: There can be no spaces around the = sign when" << endl;
|
cout << " NOTE: There can be no spaces around the = sign when" << endl;
|
||||||
cout << " an option is followed by a filename" << endl << endl;
|
cout << " an option is followed by a filename" << endl << endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (argument.find("--version") != string::npos) {
|
} else if (argument.find("--version") != string::npos) {
|
||||||
cout << endl << " JSBSim Version: " << FDMExec->GetVersion() << endl << endl;
|
cout << endl << " JSBSim Version: " << FDMExec->GetVersion() << endl << endl;
|
||||||
exit (0);
|
exit (0);
|
||||||
} else if (argument.find("--outputlogfile") != string::npos) {
|
} else if (argument.find("--outputlogfile") != string::npos) {
|
||||||
n = argument.find("=")+1;
|
n = argument.find("=")+1;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
LogOutputName = argument.substr(argument.find("=")+1);
|
LogOutputName = argument.substr(argument.find("=")+1);
|
||||||
} else {
|
} else {
|
||||||
LogOutputName = "JSBout.csv";
|
LogOutputName = "JSBout.csv";
|
||||||
cerr << " Output log file name not valid or not understood. Using JSBout.csv as default";
|
cerr << " Output log file name not valid or not understood. Using JSBout.csv as default";
|
||||||
}
|
}
|
||||||
} else if (argument.find("--logdirectivefile") != string::npos) {
|
} else if (argument.find("--logdirectivefile") != string::npos) {
|
||||||
n = argument.find("=")+1;
|
n = argument.find("=")+1;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
LogDirectiveName = argument.substr(argument.find("=")+1);
|
LogDirectiveName = argument.substr(argument.find("=")+1);
|
||||||
} else {
|
} else {
|
||||||
cerr << " Log directives file not valid or not understood." << endl << endl;
|
cerr << " Log directives file not valid or not understood." << endl << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else if (argument.find("--aircraft") != string::npos) {
|
} else if (argument.find("--aircraft") != string::npos) {
|
||||||
n = argument.find("=")+1;
|
n = argument.find("=")+1;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
AircraftName = argument.substr(argument.find("=")+1);
|
AircraftName = argument.substr(argument.find("=")+1);
|
||||||
} else {
|
} else {
|
||||||
cerr << " Aircraft name not valid or not understood." << endl << endl;
|
cerr << " Aircraft name not valid or not understood." << endl << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else if (argument.find("--script") != string::npos) {
|
} else if (argument.find("--script") != string::npos) {
|
||||||
n = argument.find("=")+1;
|
n = argument.find("=")+1;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
ScriptName = argument.substr(argument.find("=")+1);
|
ScriptName = argument.substr(argument.find("=")+1);
|
||||||
} else {
|
} else {
|
||||||
cerr << " Script name not valid or not understood." << endl << endl;
|
cerr << " Script name not valid or not understood." << endl << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else if (argument.find("--initfile") != string::npos) {
|
} else if (argument.find("--initfile") != string::npos) {
|
||||||
n = argument.find("=")+1;
|
n = argument.find("=")+1;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
ResetName = argument.substr(argument.find("=")+1);
|
ResetName = argument.substr(argument.find("=")+1);
|
||||||
} else {
|
} else {
|
||||||
cerr << " Reset name not valid or not understood." << endl << endl;
|
cerr << " Reset name not valid or not understood." << endl << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cerr << endl << " Parameter: " << argument << " not understood" << endl;
|
cerr << endl << " Parameter: " << argument << " not understood" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue