2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
Module: FGAircraft.cpp
|
|
|
|
Author: Jon S. Berndt
|
1999-02-11 21:05:34 +00:00
|
|
|
Date started: 12/12/98
|
1999-02-05 21:26:01 +00:00
|
|
|
Purpose: Encapsulates an aircraft
|
|
|
|
Called by: FGFDMExec
|
2001-06-05 20:58:48 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
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.
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
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.
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
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.
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
FUNCTIONAL DESCRIPTION
|
|
|
|
--------------------------------------------------------------------------------
|
1999-02-11 21:05:34 +00:00
|
|
|
Models the aircraft reactions and forces. This class is instantiated by the
|
2001-07-10 15:56:38 +00:00
|
|
|
FGFDMExec class and scheduled as an FDM entry.
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
12/12/98 JSB Created
|
1999-04-15 23:58:04 +00:00
|
|
|
04/03/99 JSB Changed Aero() method to correct body axis force calculation
|
|
|
|
from wind vector. Fix provided by Tony Peden.
|
1999-05-08 03:19:08 +00:00
|
|
|
05/03/99 JSB Changed (for the better?) the way configurations are read in.
|
1999-12-20 20:24:49 +00:00
|
|
|
9/17/99 TP Combined force and moment functions. Added aero reference
|
|
|
|
point to config file. Added calculations for moments due to
|
2000-04-24 23:49:06 +00:00
|
|
|
difference in cg and aero reference point
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-05 21:26:01 +00:00
|
|
|
COMMENTS, REFERENCES, and NOTES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-05 21:26:01 +00:00
|
|
|
INCLUDES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-05-08 03:19:08 +00:00
|
|
|
|
2000-02-10 23:37:56 +00:00
|
|
|
#include <sys/stat.h>
|
2000-04-24 23:49:06 +00:00
|
|
|
#include <sys/types.h>
|
1999-02-26 22:09:10 +00:00
|
|
|
|
|
|
|
#ifdef FGFS
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
# ifndef __BORLANDC__
|
|
|
|
# include <simgear/compiler.h>
|
|
|
|
# endif
|
2001-06-05 20:58:48 +00:00
|
|
|
# ifdef SG_HAVE_STD_INCLUDES
|
1999-02-26 22:09:10 +00:00
|
|
|
# include <cmath>
|
|
|
|
# else
|
|
|
|
# include <math.h>
|
|
|
|
# endif
|
|
|
|
#else
|
2001-10-05 20:19:59 +00:00
|
|
|
# if defined (sgi) && !defined(__GNUC__)
|
|
|
|
# include <math.h>
|
|
|
|
# else
|
|
|
|
# include <cmath>
|
|
|
|
# endif
|
1999-02-26 22:09:10 +00:00
|
|
|
#endif
|
1999-02-05 21:26:01 +00:00
|
|
|
|
1999-02-11 21:05:34 +00:00
|
|
|
#include "FGAircraft.h"
|
2001-06-05 20:58:48 +00:00
|
|
|
#include "FGMassBalance.h"
|
|
|
|
#include "FGInertial.h"
|
2001-10-05 20:19:59 +00:00
|
|
|
#include "FGGroundReactions.h"
|
2001-06-05 20:58:48 +00:00
|
|
|
#include "FGAerodynamics.h"
|
1999-02-11 21:05:34 +00:00
|
|
|
#include "FGTranslation.h"
|
|
|
|
#include "FGRotation.h"
|
|
|
|
#include "FGAtmosphere.h"
|
|
|
|
#include "FGState.h"
|
|
|
|
#include "FGFDMExec.h"
|
|
|
|
#include "FGFCS.h"
|
|
|
|
#include "FGPosition.h"
|
|
|
|
#include "FGAuxiliary.h"
|
|
|
|
#include "FGOutput.h"
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
DEFINITIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
GLOBAL DATA
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
static const char *IdSrc = "$Id$";
|
2000-10-14 02:10:10 +00:00
|
|
|
static const char *IdHdr = ID_AIRCRAFT;
|
2000-10-13 23:34:54 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS IMPLEMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
vMoments(3),
|
|
|
|
vForces(3),
|
|
|
|
vXYZrp(3),
|
|
|
|
vXYZep(3),
|
2001-04-17 21:19:54 +00:00
|
|
|
vDXYZcg(3),
|
2001-10-05 20:19:59 +00:00
|
|
|
vBodyAccel(3)
|
2000-05-27 05:48:14 +00:00
|
|
|
{
|
1999-02-26 22:09:10 +00:00
|
|
|
Name = "FGAircraft";
|
2000-10-02 23:07:30 +00:00
|
|
|
alphaclmin = alphaclmax = 0;
|
2001-10-05 20:19:59 +00:00
|
|
|
HTailArea = VTailArea = HTailArm = VTailArm = 0.0;
|
|
|
|
lbarh = lbarv = vbarh = vbarv = 0.0;
|
|
|
|
WingIncidence=0;
|
2000-05-27 05:48:14 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
|
|
|
|
|
2001-06-05 20:58:48 +00:00
|
|
|
FGAircraft::~FGAircraft()
|
|
|
|
{
|
2001-03-30 01:04:50 +00:00
|
|
|
if (debug_lvl & 2) cout << "Destroyed: FGAircraft" << endl;
|
2000-10-02 23:07:30 +00:00
|
|
|
}
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
|
2001-07-10 15:56:38 +00:00
|
|
|
bool FGAircraft::Load(FGConfigFile* AC_cfg)
|
|
|
|
{
|
2000-04-24 23:49:06 +00:00
|
|
|
string token;
|
|
|
|
|
2001-07-10 15:56:38 +00:00
|
|
|
ReadPrologue(AC_cfg);
|
2000-04-24 23:49:06 +00:00
|
|
|
|
2001-07-10 15:56:38 +00:00
|
|
|
while ((AC_cfg->GetNextConfigLine() != "EOF") &&
|
|
|
|
(token = AC_cfg->GetValue()) != "/FDM_CONFIG") {
|
2000-04-24 23:49:06 +00:00
|
|
|
if (token == "METRICS") {
|
2001-06-05 20:58:48 +00:00
|
|
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl;
|
2001-07-10 15:56:38 +00:00
|
|
|
ReadMetrics(AC_cfg);
|
2000-04-24 23:49:06 +00:00
|
|
|
} else if (token == "AERODYNAMICS") {
|
2001-06-05 20:58:48 +00:00
|
|
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl;
|
2001-07-10 15:56:38 +00:00
|
|
|
ReadAerodynamics(AC_cfg);
|
2000-04-24 23:49:06 +00:00
|
|
|
} else if (token == "UNDERCARRIAGE") {
|
2001-06-05 20:58:48 +00:00
|
|
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl;
|
2001-07-10 15:56:38 +00:00
|
|
|
ReadUndercarriage(AC_cfg);
|
2000-04-24 23:49:06 +00:00
|
|
|
} else if (token == "PROPULSION") {
|
2001-06-05 20:58:48 +00:00
|
|
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Propulsion" << fgdef << endl;
|
2001-07-10 15:56:38 +00:00
|
|
|
ReadPropulsion(AC_cfg);
|
2000-04-24 23:49:06 +00:00
|
|
|
} else if (token == "FLIGHT_CONTROL") {
|
2001-06-05 20:58:48 +00:00
|
|
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Flight Control" << fgdef << endl;
|
2001-07-10 15:56:38 +00:00
|
|
|
ReadFlightControls(AC_cfg);
|
2000-05-02 18:25:30 +00:00
|
|
|
} else if (token == "OUTPUT") {
|
2001-06-05 20:58:48 +00:00
|
|
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Output directives" << fgdef << endl;
|
2001-07-10 15:56:38 +00:00
|
|
|
ReadOutput(AC_cfg);
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-05 20:19:59 +00:00
|
|
|
|
1999-06-21 05:01:31 +00:00
|
|
|
return true;
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-06-05 20:58:48 +00:00
|
|
|
bool FGAircraft::Run(void)
|
|
|
|
{
|
1999-02-05 21:26:01 +00:00
|
|
|
if (!FGModel::Run()) { // if false then execute this Run()
|
2001-06-05 20:58:48 +00:00
|
|
|
vForces.InitMatrix();
|
2001-10-05 20:19:59 +00:00
|
|
|
vForces += Aerodynamics->GetForces();
|
|
|
|
vForces += Inertial->GetForces();
|
|
|
|
vForces += Propulsion->GetForces();
|
|
|
|
vForces += GroundReactions->GetForces();
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
vMoments.InitMatrix();
|
|
|
|
vMoments += Aerodynamics->GetMoments();
|
|
|
|
vMoments += Propulsion->GetMoments();
|
|
|
|
vMoments += GroundReactions->GetMoments();
|
|
|
|
|
|
|
|
vBodyAccel = vForces/MassBalance->GetMass();
|
|
|
|
|
2001-06-05 20:58:48 +00:00
|
|
|
return false;
|
1999-02-05 21:26:01 +00:00
|
|
|
} else { // skip Run() execution this time
|
2001-06-05 20:58:48 +00:00
|
|
|
return true;
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
1999-02-11 21:05:34 +00:00
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-11 21:05:34 +00:00
|
|
|
|
2001-06-05 20:58:48 +00:00
|
|
|
void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
|
|
|
|
{
|
2000-04-24 23:49:06 +00:00
|
|
|
string token = "";
|
|
|
|
string parameter;
|
2001-06-05 20:58:48 +00:00
|
|
|
float EW, bixx, biyy, bizz, bixz, biyz;
|
2001-10-05 20:19:59 +00:00
|
|
|
FGColumnVector3 vbaseXYZcg(3);
|
2000-04-24 23:49:06 +00:00
|
|
|
|
|
|
|
AC_cfg->GetNextConfigLine();
|
|
|
|
|
2001-06-20 22:29:31 +00:00
|
|
|
while ((token = AC_cfg->GetValue()) != "/METRICS") {
|
2000-04-24 23:49:06 +00:00
|
|
|
*AC_cfg >> parameter;
|
2001-06-20 22:29:31 +00:00
|
|
|
if (parameter == "AC_WINGAREA") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> WingArea;
|
|
|
|
if (debug_lvl > 0) cout << " WingArea: " << WingArea << endl;
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_WINGSPAN") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> WingSpan;
|
|
|
|
if (debug_lvl > 0) cout << " WingSpan: " << WingSpan << endl;
|
2001-10-05 20:19:59 +00:00
|
|
|
} else if (parameter == "AC_WINGINCIDENCE") {
|
|
|
|
*AC_cfg >> WingIncidence;
|
|
|
|
if (debug_lvl > 0) cout << " Chord: " << cbar << endl;
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_CHORD") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> cbar;
|
|
|
|
if (debug_lvl > 0) cout << " Chord: " << cbar << endl;
|
2001-10-05 20:19:59 +00:00
|
|
|
} else if (parameter == "AC_HTAILAREA") {
|
|
|
|
*AC_cfg >> HTailArea;
|
|
|
|
if (debug_lvl > 0) cout << " H. Tail Area: " << HTailArea << endl;
|
|
|
|
} else if (parameter == "AC_HTAILARM") {
|
|
|
|
*AC_cfg >> HTailArm;
|
|
|
|
if (debug_lvl > 0) cout << " H. Tail Arm: " << HTailArm << endl;
|
|
|
|
} else if (parameter == "AC_VTAILAREA") {
|
|
|
|
*AC_cfg >> VTailArea;
|
|
|
|
if (debug_lvl > 0) cout << " V. Tail Area: " << VTailArea << endl;
|
|
|
|
} else if (parameter == "AC_VTAILARM") {
|
|
|
|
*AC_cfg >> VTailArm;
|
|
|
|
if (debug_lvl > 0) cout << " V. Tail Arm: " << VTailArm << endl;
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_IXX") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> bixx;
|
|
|
|
if (debug_lvl > 0) cout << " baseIxx: " << bixx << endl;
|
|
|
|
MassBalance->SetBaseIxx(bixx);
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_IYY") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> biyy;
|
|
|
|
if (debug_lvl > 0) cout << " baseIyy: " << biyy << endl;
|
|
|
|
MassBalance->SetBaseIyy(biyy);
|
|
|
|
} else if (parameter == "AC_IZZ") {
|
|
|
|
*AC_cfg >> bizz;
|
|
|
|
if (debug_lvl > 0) cout << " baseIzz: " << bizz << endl;
|
|
|
|
MassBalance->SetBaseIzz(bizz);
|
|
|
|
} else if (parameter == "AC_IXZ") {
|
|
|
|
*AC_cfg >> bixz;
|
|
|
|
if (debug_lvl > 0) cout << " baseIxz: " << bixz << endl;
|
|
|
|
MassBalance->SetBaseIxz(bixz);
|
|
|
|
} else if (parameter == "AC_IYZ") {
|
|
|
|
*AC_cfg >> biyz;
|
|
|
|
if (debug_lvl > 0) cout << " baseIyz: " << biyz << endl;
|
|
|
|
MassBalance->SetBaseIyz(biyz);
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_EMPTYWT") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> EW;
|
|
|
|
MassBalance->SetEmptyWeight(EW);
|
|
|
|
if (debug_lvl > 0) cout << " EmptyWeight: " << EW << endl;
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_CGLOC") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
|
|
|
|
MassBalance->SetBaseCG(vbaseXYZcg);
|
|
|
|
if (debug_lvl > 0) cout << " CG (x, y, z): " << vbaseXYZcg << endl;
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_EYEPTLOC") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ);
|
|
|
|
if (debug_lvl > 0) cout << " Eyepoint (x, y, z): " << vXYZep << endl;
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_AERORP") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
|
|
|
|
if (debug_lvl > 0) cout << " Ref Pt (x, y, z): " << vXYZrp << endl;
|
2000-07-06 21:02:46 +00:00
|
|
|
} else if (parameter == "AC_ALPHALIMITS") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*AC_cfg >> alphaclmin >> alphaclmax;
|
|
|
|
if (debug_lvl > 0) cout << " Maximum Alpha: " << alphaclmax
|
|
|
|
<< " Minimum Alpha: " << alphaclmin
|
2000-07-06 21:02:46 +00:00
|
|
|
<< endl;
|
2001-06-05 20:58:48 +00:00
|
|
|
}
|
2000-04-24 23:49:06 +00:00
|
|
|
}
|
2001-10-05 20:19:59 +00:00
|
|
|
|
|
|
|
// calculate some derived parameters
|
|
|
|
if (cbar != 0.0) {
|
|
|
|
lbarh = HTailArm/cbar;
|
|
|
|
lbarv = VTailArm/cbar;
|
|
|
|
if (WingArea != 0.0) {
|
|
|
|
vbarh = HTailArm*HTailArea / (cbar*WingArea);
|
|
|
|
vbarv = VTailArm*VTailArea / (cbar*WingArea);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg)
|
|
|
|
{
|
2001-07-10 15:56:38 +00:00
|
|
|
if (!Propulsion->Load(AC_cfg)) {
|
2001-03-30 01:04:50 +00:00
|
|
|
cerr << "Propulsion not successfully loaded" << endl;
|
2000-04-24 23:49:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg)
|
|
|
|
{
|
2001-07-10 15:56:38 +00:00
|
|
|
if (!FCS->Load(AC_cfg)) {
|
2001-03-30 01:04:50 +00:00
|
|
|
cerr << "Flight Controls not successfully loaded" << endl;
|
|
|
|
}
|
2000-04-24 23:49:06 +00:00
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
|
2001-06-05 20:58:48 +00:00
|
|
|
void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg)
|
|
|
|
{
|
2001-07-10 15:56:38 +00:00
|
|
|
if (!Aerodynamics->Load(AC_cfg)) {
|
2001-06-05 20:58:48 +00:00
|
|
|
cerr << "Aerodynamics not successfully loaded" << endl;
|
2000-04-24 23:49:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg)
|
|
|
|
{
|
|
|
|
if (!GroundReactions->Load(AC_cfg)) {
|
|
|
|
cerr << "Ground Reactions not successfully loaded" << endl;
|
2000-04-24 23:49:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
void FGAircraft::ReadOutput(FGConfigFile* AC_cfg)
|
|
|
|
{
|
2000-05-02 18:25:30 +00:00
|
|
|
string token, parameter;
|
|
|
|
int OutRate = 0;
|
|
|
|
int subsystems = 0;
|
|
|
|
|
|
|
|
token = AC_cfg->GetValue("NAME");
|
|
|
|
Output->SetFilename(token);
|
|
|
|
token = AC_cfg->GetValue("TYPE");
|
|
|
|
Output->SetType(token);
|
|
|
|
AC_cfg->GetNextConfigLine();
|
|
|
|
|
2001-06-20 22:29:31 +00:00
|
|
|
while ((token = AC_cfg->GetValue()) != "/OUTPUT") {
|
2000-05-02 18:25:30 +00:00
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "RATE_IN_HZ") *AC_cfg >> OutRate;
|
|
|
|
if (parameter == "SIMULATION") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssSimulation;
|
|
|
|
}
|
|
|
|
if (parameter == "AEROSURFACES") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssAerosurfaces;
|
|
|
|
}
|
|
|
|
if (parameter == "RATES") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssRates;
|
|
|
|
}
|
|
|
|
if (parameter == "VELOCITIES") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssVelocities;
|
|
|
|
}
|
|
|
|
if (parameter == "FORCES") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssForces;
|
|
|
|
}
|
|
|
|
if (parameter == "MOMENTS") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssMoments;
|
|
|
|
}
|
|
|
|
if (parameter == "ATMOSPHERE") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssAtmosphere;
|
|
|
|
}
|
|
|
|
if (parameter == "MASSPROPS") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssMassProps;
|
|
|
|
}
|
|
|
|
if (parameter == "POSITION") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssPosition;
|
|
|
|
}
|
|
|
|
if (parameter == "COEFFICIENTS") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssCoefficients;
|
|
|
|
}
|
2000-05-27 05:48:14 +00:00
|
|
|
if (parameter == "GROUND_REACTIONS") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssGroundReactions;
|
|
|
|
}
|
2000-11-14 20:31:58 +00:00
|
|
|
if (parameter == "FCS") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssFCS;
|
|
|
|
}
|
2001-04-06 22:59:31 +00:00
|
|
|
if (parameter == "PROPULSION") {
|
|
|
|
*AC_cfg >> parameter;
|
|
|
|
if (parameter == "ON") subsystems += ssPropulsion;
|
|
|
|
}
|
2000-05-02 18:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Output->SetSubsystems(subsystems);
|
|
|
|
|
|
|
|
OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
|
|
|
|
Output->SetRate( (int)(0.5 + 1.0/(State->Getdt()*OutRate)) );
|
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-05-02 18:25:30 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
|
|
|
|
{
|
2000-04-24 23:49:06 +00:00
|
|
|
string token = AC_cfg->GetValue();
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
string scratch;
|
2000-04-24 23:49:06 +00:00
|
|
|
AircraftName = AC_cfg->GetValue("NAME");
|
2001-06-05 20:58:48 +00:00
|
|
|
if (debug_lvl > 0) cout << underon << "Reading Aircraft Configuration File"
|
|
|
|
<< underoff << ": " << highint << AircraftName << normint << endl;
|
2001-03-30 01:04:50 +00:00
|
|
|
scratch = AC_cfg->GetValue("VERSION").c_str();
|
2000-04-24 23:49:06 +00:00
|
|
|
|
Updates from the Jon and Tony show.
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.
2000-05-16 21:35:11 +00:00
|
|
|
CFGVersion = AC_cfg->GetValue("VERSION");
|
2001-06-05 20:58:48 +00:00
|
|
|
|
|
|
|
if (debug_lvl > 0)
|
|
|
|
cout << " Version: " << highint << CFGVersion
|
2001-03-30 01:04:50 +00:00
|
|
|
<< normint << endl;
|
2001-06-20 22:29:31 +00:00
|
|
|
if (CFGVersion != NEEDED_CFG_VERSION) {
|
2001-06-05 20:58:48 +00:00
|
|
|
cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
|
|
|
|
" RESULTS WILL BE UNPREDICTABLE !!" << endl;
|
|
|
|
cerr << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
|
|
|
|
cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
|
2000-04-24 23:49:06 +00:00
|
|
|
}
|
2000-05-02 18:25:30 +00:00
|
|
|
}
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-05-27 05:48:14 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
void FGAircraft::Debug(void)
|
|
|
|
{
|
|
|
|
//TODO: Add your source code here
|
|
|
|
}
|
|
|
|
|