Tony submitted: JSBsim: Added trimming routine, it is longitudinal & in-air only at this point Added support for taking wind & weather data from external source Added support for flaps. Added independently settable pitch trim Added alphamin and max to config file, stall modeling and warning to follow c172.cfg: Flaps! Adjusted Cmo, model should be speed stable now FG: Hooked up Christian's weather code, should be using it soon. Hooked up the trimming routine. Note that the X-15 will not trim. This is not a model or trimming routine deficiency, just the nature of the X-15 The trimming routine sets the pitch trim and and throttle at startup. The throttle is set using Norman's code for the autothrottle so the autothrottle is on by default. --notrim will turn it off. Added --vc, --mach, and --notrim switches (vc is airspeed in knots) uBody, vBody, and wBody are still supported, last one entered on the command line counts, i.e. you can set vc or mach or u,v, and w but any combination will be ignored.
151 lines
4.4 KiB
C++
151 lines
4.4 KiB
C++
/*******************************************************************************
|
|
|
|
Module: JSBSim.cpp
|
|
Author: Jon S. Berndt
|
|
Date started: 08/17/99
|
|
Purpose: Standalone version of JSBSim.
|
|
Called by: The USER.
|
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
|
|
|
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
|
|
--------------------------------------------------------------------------------
|
|
|
|
This class Handles calling JSBSim standalone. It is set up for compilation under
|
|
Borland C+Builder or other compiler.
|
|
|
|
HISTORY
|
|
--------------------------------------------------------------------------------
|
|
08/17/99 JSB Created
|
|
|
|
********************************************************************************
|
|
INCLUDES
|
|
*******************************************************************************/
|
|
|
|
#if __BCPLUSPLUS__ == 0x0540 // If compiling under Borland C++Builder
|
|
#pragma hdrstop
|
|
#include <condefs.h>
|
|
USEUNIT("FGUtility.cpp");
|
|
USEUNIT("FGAtmosphere.cpp");
|
|
USEUNIT("FGAuxiliary.cpp");
|
|
USEUNIT("FGCoefficient.cpp");
|
|
USEUNIT("FGConfigFile.cpp");
|
|
USEUNIT("FGControls.cpp");
|
|
USEUNIT("FGEngine.cpp");
|
|
USEUNIT("FGFCS.cpp");
|
|
USEUNIT("FGFDMExec.cpp");
|
|
USEUNIT("FGfdmSocket.cpp");
|
|
USEUNIT("FGInitialCondition.cpp");
|
|
USEUNIT("FGLGear.cpp");
|
|
USEUNIT("FGMatrix.cpp");
|
|
USEUNIT("FGModel.cpp");
|
|
USEUNIT("FGOutput.cpp");
|
|
USEUNIT("FGPosition.cpp");
|
|
USEUNIT("FGRotation.cpp");
|
|
USEUNIT("FGState.cpp");
|
|
USEUNIT("FGTank.cpp");
|
|
USEUNIT("FGTranslation.cpp");
|
|
USEUNIT("FGAircraft.cpp");
|
|
USERES("JSBSim.res");
|
|
USEUNIT("filtersjb\FGfcsComponent.cpp");
|
|
USEUNIT("filtersjb\FGSwitch.cpp");
|
|
USEUNIT("filtersjb\FGFilter.cpp");
|
|
USEUNIT("filtersjb\FGGain.cpp");
|
|
USEUNIT("filtersjb\FGGradient.cpp");
|
|
USEUNIT("filtersjb\FGSummer.cpp");
|
|
USEUNIT("filtersjb\FGDeadBand.cpp");
|
|
USEUNIT("FGTrimLong.cpp");
|
|
USEUNIT("filtersjb\FGFlaps.cpp");
|
|
//---------------------------------------------------------------------------
|
|
#pragma argsused
|
|
#endif
|
|
|
|
#include "FGFDMExec.h"
|
|
#include "FGRotation.h"
|
|
#include "FGAtmosphere.h"
|
|
#include "FGState.h"
|
|
#include "FGFCS.h"
|
|
#include "FGAircraft.h"
|
|
#include "FGTranslation.h"
|
|
#include "FGPosition.h"
|
|
#include "FGAuxiliary.h"
|
|
#include "FGOutput.h"
|
|
|
|
#ifdef FGFS
|
|
#include <simgear/compiler.h>
|
|
#include STL_IOSTREAM
|
|
# ifdef FG_HAVE_STD_INCLUDES
|
|
# include <ctime>
|
|
# else
|
|
# include <time.h>
|
|
# endif
|
|
#else
|
|
#include <iostream>
|
|
#include <ctime>
|
|
#endif
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
FGFDMExec* FDMExec;
|
|
|
|
if (argc != 3) {
|
|
cout << endl
|
|
<< " You must enter the name of a registered aircraft and reset point:"
|
|
<< endl << endl << " FDM <aircraft name> <reset file>" << endl;
|
|
exit(0);
|
|
}
|
|
|
|
FDMExec = new FGFDMExec();
|
|
|
|
FDMExec->GetAircraft()->LoadAircraft("aircraft", "engine", string(argv[1]));
|
|
if ( ! FDMExec->GetState()->Reset("aircraft", string(argv[1]), string(argv[2])))
|
|
FDMExec->GetState()->Initialize(2000,0,0,0,0,0,0.5,0.5,40000);
|
|
|
|
float cmd = 0.0;
|
|
|
|
while (FDMExec->GetState()->Getsim_time() <= 5.0)
|
|
{
|
|
// Fake an elevator ramp here after 1 second, hold for one second, ramp down
|
|
|
|
if (FDMExec->GetState()->Getsim_time() >= 1.00 &&
|
|
FDMExec->GetState()->Getsim_time() < 2.0)
|
|
{
|
|
cmd = FDMExec->GetState()->Getsim_time() - 1.00;
|
|
} else if (FDMExec->GetState()->Getsim_time() >= 2.00 &&
|
|
FDMExec->GetState()->Getsim_time() < 3.0)
|
|
{
|
|
cmd = 1.00;
|
|
} else if (FDMExec->GetState()->Getsim_time() >= 3.00 &&
|
|
FDMExec->GetState()->Getsim_time() < 4.0)
|
|
{
|
|
cmd = 4.0 - FDMExec->GetState()->Getsim_time();
|
|
} else {
|
|
cmd = 0.00;
|
|
}
|
|
FDMExec->GetFCS()->SetDeCmd(cmd); // input between -1 and 1
|
|
|
|
FDMExec->Run();
|
|
}
|
|
|
|
delete FDMExec;
|
|
|
|
return 0;
|
|
}
|
|
|