1
0
Fork 0
flightgear/src/FDM/UIUCModel/uiuc_menu.cpp

481 lines
16 KiB
C++
Raw Normal View History

/**********************************************************************
FILENAME: uiuc_menu.cpp
----------------------------------------------------------------------
DESCRIPTION: reads input file for specified aircraft and creates
approporiate data storage space
----------------------------------------------------------------------
STATUS: alpha version
----------------------------------------------------------------------
REFERENCES: based on "menu reader" format of Michael Selig
----------------------------------------------------------------------
HISTORY: 01/29/2000 initial release
02/18/2000 (JS) added 1D data file capability for
CL(a) and CD(a) -- calls
uiuc_1DdataFileReader
02/22/2000 (JS) added ice map functions
02/29/2000 (JS) added 2D data file capability for
CL(a,de), CD(a,de), Cm(a,de), CY(a,da),
CY(beta,dr), Cl(a,da), Cl(beta,dr),
Cn(a,da), Cn(beta,dr) -- calls
uiuc_2DdataFileReader
02/02/2000 (JS) added record options for 1D and
2D interpolated variables
2000-09-06 19:52:37 +00:00
03/28/2000 (JS) streamlined conversion factors for
file readers -- since they are global
variables, it is not necessary to put
them in the function calls
03/29/2000 (JS) added Cmfa and Weight flags;
added misc map; added Dx_cg (etc) to init
map
04/01/2000 (JS) added throttle, longitudinal, lateral,
and rudder inputs to record map
04/05/2000 (JS) added Altitude to init and record
maps; added zero_Long_trim to
controlSurface map
From: David Megginson <david@megginson.com> I have created a set of patches to provide configurable landing gear for the UIUC models. The patches (including four new files) are available at http://megginson.com/private/fgfs/uiuc-20010309.tar.gz A modified UIUC configuration file for the Twin Otter (DHC-6) is available at http://megginson.com/private/fgfs/aircraft.dat It should be possible to configure appropriate gear for all of the UIUC models now. As a bonus, the models also support braking, both absolute and differential, as well as nose-wheel steering (all of which are currently missing from the UIUC models) -- when you land, you don't have to keep rolling off the end of the runway anymore, and you don't have to bank to steer in a taxi. My sample configuration file contains absolutely bizarre, wild guesses, and many places that I didn't even bother to guess properly. The only actual data I had was the wing-span of the DHC-6 (65ft), which I used for positioning the wing tips. The wing-tips for this model actually work now -- I hit the aileron hard while accelerating for take-off, and the wingtip noticeably strikes the ground and bounces up (quite dramatic in external view using the DHC-6 model from Wolfram's site). Details ------- The UIUC models now support up to 16 gear points each where a gear point is anything in the aircraft that can come in contact with the ground, including the tail and wing-tips. I have added the following new fields to the UIUC configuration files, where <index> is an integer between 0 and 15, and <value> is a real number: gear <index> Dx_gear <value> # x offset from CG [ft] gear <index> Dy_gear <value> # y offset from CG [ft] gear <index> Dz_gear <value> # z offset from CG [ft] gear <index> cgear <value> # spring damping [lbs/ft/sec] gear <index> kgear <value> # springiness [lbs/ft] gear <index> muGear <value> # rolling coefficient gear <index> strutLength <value> # gear travel [ft] (not yet used) Most of these names were already pencilled into the UIUC documentation (as TODO items), but I had to make up Dx_gear, Dy_gear, and Dz_gear -- if those are inappropriate, I'd appreciate suggestions for better names. It will be necessary to modify the other UIUC configuration files to include some kind of gear support as well, or the planes will sink nose-first into the ground down to their CG's (it's actually quite funny to watch with an external view). Background ---------- As I frequently remind everyone here, I have no math background worth spitting at, so I will not even pretend to have done the hard stuff. The UIUC code uses a copy of a very old version of the LaRCsim c172_gear.c -- I wanted to update it with Tony Peden's excellent newer version, which includes differential braking among other goodies (the UIUC models don't support brakes, period). I copied the newer code into uiuc_aero.c, and it compiled and ran, but all of the planes ended up sitting on their tails with their noses in the air. Since Tony made his gear code nicely parameterized, I experimented with different values, and found that it wasn't too hard to balance the Twin Otter by moving the gear back a bit. At first, I used properties to set different values, but then I decided to integrate the whole thing properly into the UIUC configuration framework. Thanks to Tony Peden, who did the real modelling work -- I can take credit only for two or three hours of integration. It turns out that Tony's code is generalized enough to deal with a wide range of different gear structures -- I suspect that it will even work for the 747, when I get around to trying some values.
2001-03-29 03:16:25 +00:00
03/09/2001 (DPM) added support for gear.
06/18/2001 (RD) Added Alpha, Beta, U_body,
V_body, and W_body to init map. Added
aileron_input, rudder_input, pilot_elev_no,
pilot_ail_no, and pilot_rud_no to
controlSurface map. Added Throttle_pct_input
to engine map. Added CZfa to CL map.
07/05/2001 (RD) Changed pilot_elev_no = true to pilot_
elev_no_check=false. This is to allow pilot
to fly aircraft after input files have been
used.
08/27/2001 (RD) Added xxx_init_true and xxx_init for
P_body, Q_body, R_body, Phi, Theta, Psi,
U_body, V_body, and W_body to help in
starting the A/C at an initial condition.
10/25/2001 (RD) Added new variables needed for the non-
linear Twin Otter model at zero flaps
(Cxfxxf0)
11/12/2001 (RD) Added new variables needed for the non-
linear Twin Otter model with flaps
(Cxfxxf). Removed zero flap variables.
Added minmaxfind() which is needed for non-
linear variables
01/11/2002 (AP) Added keywords for bootTime
02/13/2002 (RD) Added variables so linear aero model
values can be recorded
02/18/2002 (RD) Added variables necessary to use the
uiuc_3Dinterp_quick() function. Takes
advantage of data in a "nice" form (data
that are in a rectangular matrix).
03/13/2002 (RD) Added aircraft_directory so full path
is no longer needed in the aircraft.dat file
04/02/2002 (RD) Removed minmaxfind() since it was no
longer needed. Added d_2_to_3(),
d_1_to_2(), and i_1_to_2() so uiuc_menu()
will compile with certain compilers.
08/29/2002 (RD) Separated each primary keyword into its
own function to speed up compile time
2002-09-11 02:31:10 +00:00
08/29/2002 (RD w/ help from CO) Made changes to shorten
compile time. [] RD to add more comments here.
08/29/2003 (MSS) Adding new keywords for new engine model
2002-09-11 02:31:10 +00:00
and slipstream effects on tail.
03/02/2003 (RD) Changed Cxfxxf areas so that there is a
conversion factor for flap angle
03/03/2003 (RD) Added flap_cmd_record
03/16/2003 (RD) Added trigger record flags
04/02/2003 (RD) Tokens are now equal to 0 when no value
is given in the input file
04/04/2003 (RD) To speed up compile time on this file,
each first level token now goes to its
own file uiuc_menu_*.cpp
----------------------------------------------------------------------
AUTHOR(S): Bipin Sehgal <bsehgal@uiuc.edu>
Jeff Scott http://www.jeffscott.net/
Robert Deters <rdeters@uiuc.edu>
Michael Selig <m-selig@uiuc.edu>
From: David Megginson <david@megginson.com> I have created a set of patches to provide configurable landing gear for the UIUC models. The patches (including four new files) are available at http://megginson.com/private/fgfs/uiuc-20010309.tar.gz A modified UIUC configuration file for the Twin Otter (DHC-6) is available at http://megginson.com/private/fgfs/aircraft.dat It should be possible to configure appropriate gear for all of the UIUC models now. As a bonus, the models also support braking, both absolute and differential, as well as nose-wheel steering (all of which are currently missing from the UIUC models) -- when you land, you don't have to keep rolling off the end of the runway anymore, and you don't have to bank to steer in a taxi. My sample configuration file contains absolutely bizarre, wild guesses, and many places that I didn't even bother to guess properly. The only actual data I had was the wing-span of the DHC-6 (65ft), which I used for positioning the wing tips. The wing-tips for this model actually work now -- I hit the aileron hard while accelerating for take-off, and the wingtip noticeably strikes the ground and bounces up (quite dramatic in external view using the DHC-6 model from Wolfram's site). Details ------- The UIUC models now support up to 16 gear points each where a gear point is anything in the aircraft that can come in contact with the ground, including the tail and wing-tips. I have added the following new fields to the UIUC configuration files, where <index> is an integer between 0 and 15, and <value> is a real number: gear <index> Dx_gear <value> # x offset from CG [ft] gear <index> Dy_gear <value> # y offset from CG [ft] gear <index> Dz_gear <value> # z offset from CG [ft] gear <index> cgear <value> # spring damping [lbs/ft/sec] gear <index> kgear <value> # springiness [lbs/ft] gear <index> muGear <value> # rolling coefficient gear <index> strutLength <value> # gear travel [ft] (not yet used) Most of these names were already pencilled into the UIUC documentation (as TODO items), but I had to make up Dx_gear, Dy_gear, and Dz_gear -- if those are inappropriate, I'd appreciate suggestions for better names. It will be necessary to modify the other UIUC configuration files to include some kind of gear support as well, or the planes will sink nose-first into the ground down to their CG's (it's actually quite funny to watch with an external view). Background ---------- As I frequently remind everyone here, I have no math background worth spitting at, so I will not even pretend to have done the hard stuff. The UIUC code uses a copy of a very old version of the LaRCsim c172_gear.c -- I wanted to update it with Tony Peden's excellent newer version, which includes differential braking among other goodies (the UIUC models don't support brakes, period). I copied the newer code into uiuc_aero.c, and it compiled and ran, but all of the planes ended up sitting on their tails with their noses in the air. Since Tony made his gear code nicely parameterized, I experimented with different values, and found that it wasn't too hard to balance the Twin Otter by moving the gear back a bit. At first, I used properties to set different values, but then I decided to integrate the whole thing properly into the UIUC configuration framework. Thanks to Tony Peden, who did the real modelling work -- I can take credit only for two or three hours of integration. It turns out that Tony's code is generalized enough to deal with a wide range of different gear structures -- I suspect that it will even work for the 747, when I get around to trying some values.
2001-03-29 03:16:25 +00:00
David Megginson <david@megginson.com>
Ann Peedikayil <peedikay@uiuc.edu>
----------------------------------------------------------------------
VARIABLES:
----------------------------------------------------------------------
INPUTS: n/a
----------------------------------------------------------------------
OUTPUTS: n/a
----------------------------------------------------------------------
2000-09-06 19:52:37 +00:00
CALLED BY: uiuc_wrapper.cpp
----------------------------------------------------------------------
CALLS TO: aircraft.dat
tabulated data files (if needed)
uiuc_menu_init()
uiuc_menu_geometry()
uiuc_menu_mass()
uiuc_menu_controlSurface()
uiuc_menu_CD()
uiuc_menu_CL()
uiuc_menu_Cm()
uiuc_menu_CY()
uiuc_menu_Cl()
uiuc_menu_Cn()
uiuc_menu_ice()
uiuc_menu_engine()
uiuc_menu_fog()
uiuc_menu_gear()
uiuc_menu_record()
uiuc_menu_misc()
----------------------------------------------------------------------
COPYRIGHT: (C) 2000 by Michael Selig
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.
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 or view http://www.gnu.org/copyleft/gpl.html.
**********************************************************************/
#include <simgear/compiler.h>
#if defined( __MWERKS__ )
// -dw- optimizer chokes (big-time) trying to optimize humongous
// loop/switch statements
#pragma optimization_level 0
#endif
#include <cstdlib>
#include <string>
From: David Megginson <david@megginson.com> I have created a set of patches to provide configurable landing gear for the UIUC models. The patches (including four new files) are available at http://megginson.com/private/fgfs/uiuc-20010309.tar.gz A modified UIUC configuration file for the Twin Otter (DHC-6) is available at http://megginson.com/private/fgfs/aircraft.dat It should be possible to configure appropriate gear for all of the UIUC models now. As a bonus, the models also support braking, both absolute and differential, as well as nose-wheel steering (all of which are currently missing from the UIUC models) -- when you land, you don't have to keep rolling off the end of the runway anymore, and you don't have to bank to steer in a taxi. My sample configuration file contains absolutely bizarre, wild guesses, and many places that I didn't even bother to guess properly. The only actual data I had was the wing-span of the DHC-6 (65ft), which I used for positioning the wing tips. The wing-tips for this model actually work now -- I hit the aileron hard while accelerating for take-off, and the wingtip noticeably strikes the ground and bounces up (quite dramatic in external view using the DHC-6 model from Wolfram's site). Details ------- The UIUC models now support up to 16 gear points each where a gear point is anything in the aircraft that can come in contact with the ground, including the tail and wing-tips. I have added the following new fields to the UIUC configuration files, where <index> is an integer between 0 and 15, and <value> is a real number: gear <index> Dx_gear <value> # x offset from CG [ft] gear <index> Dy_gear <value> # y offset from CG [ft] gear <index> Dz_gear <value> # z offset from CG [ft] gear <index> cgear <value> # spring damping [lbs/ft/sec] gear <index> kgear <value> # springiness [lbs/ft] gear <index> muGear <value> # rolling coefficient gear <index> strutLength <value> # gear travel [ft] (not yet used) Most of these names were already pencilled into the UIUC documentation (as TODO items), but I had to make up Dx_gear, Dy_gear, and Dz_gear -- if those are inappropriate, I'd appreciate suggestions for better names. It will be necessary to modify the other UIUC configuration files to include some kind of gear support as well, or the planes will sink nose-first into the ground down to their CG's (it's actually quite funny to watch with an external view). Background ---------- As I frequently remind everyone here, I have no math background worth spitting at, so I will not even pretend to have done the hard stuff. The UIUC code uses a copy of a very old version of the LaRCsim c172_gear.c -- I wanted to update it with Tony Peden's excellent newer version, which includes differential braking among other goodies (the UIUC models don't support brakes, period). I copied the newer code into uiuc_aero.c, and it compiled and ran, but all of the planes ended up sitting on their tails with their noses in the air. Since Tony made his gear code nicely parameterized, I experimented with different values, and found that it wasn't too hard to balance the Twin Otter by moving the gear back a bit. At first, I used properties to set different values, but then I decided to integrate the whole thing properly into the UIUC configuration framework. Thanks to Tony Peden, who did the real modelling work -- I can take credit only for two or three hours of integration. It turns out that Tony's code is generalized enough to deal with a wide range of different gear structures -- I suspect that it will even work for the 747, when I get around to trying some values.
2001-03-29 03:16:25 +00:00
#include STL_IOSTREAM
#include "uiuc_menu.h"
2001-03-23 22:59:18 +00:00
SG_USING_STD(cerr);
SG_USING_STD(cout);
SG_USING_STD(endl);
2001-01-11 04:54:33 +00:00
#ifndef _MSC_VER
2001-03-23 22:59:18 +00:00
SG_USING_STD(exit);
2001-01-11 04:54:33 +00:00
#endif
void uiuc_menu( string aircraft_name )
{
string aircraft_directory;
stack command_list;
double token_value;
int token_value_recordRate;
int token_value_convert1, token_value_convert2, token_value_convert3;
string linetoken1;
string linetoken2;
string linetoken3;
string linetoken4;
string linetoken5;
string linetoken6;
string linetoken7;
string linetoken8;
string linetoken9;
string linetoken10;
/* the following default setting should eventually be moved to a default or uiuc_init routine */
recordRate = 1; /* record every time step, default */
recordStartTime = 0; /* record from beginning of simulation */
/* set speed at which dynamic pressure terms will be accounted for,
since if velocity is too small, coefficients will go to infinity */
2002-09-11 02:31:10 +00:00
dyn_on_speed = 33; /* 20 kts (33 ft/sec), default */
dyn_on_speed_zero = 0.5 * dyn_on_speed; /* only used if use_dyn_on_speed_curve1 is used */
bootindex = 0; // the index for the bootTime
/* Read the file and get the list of commands */
airplane = new ParseFile(aircraft_name); /* struct that includes all lines of the input file */
command_list = airplane -> getCommands();
/* structs to include all parts included in the input file for specific keyword groups */
initParts = new ParseFile();
geometryParts = new ParseFile();
massParts = new ParseFile();
engineParts = new ParseFile();
aeroDragParts = new ParseFile();
aeroLiftParts = new ParseFile();
aeroPitchParts = new ParseFile();
aeroSideforceParts = new ParseFile();
aeroRollParts = new ParseFile();
aeroYawParts = new ParseFile();
gearParts = new ParseFile();
recordParts = new ParseFile();
if (command_list.begin() == command_list.end())
{
cerr << "UIUC ERROR: File " << aircraft_name <<" does not exist" << endl;
exit(-1);
}
//construct aircraft-directory
aircraft_directory = aircraft_name;
int index_aircraft_dat = aircraft_directory.find("aircraft.dat");
aircraft_directory.erase(index_aircraft_dat,12);
2000-09-06 19:52:37 +00:00
for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
{
cout << *command_line << endl;
2000-09-06 19:52:37 +00:00
linetoken1 = airplane -> getToken (*command_line, 1);
linetoken2 = airplane -> getToken (*command_line, 2);
if (linetoken2=="")
linetoken2="0";
linetoken3 = airplane -> getToken (*command_line, 3);
if (linetoken3=="")
linetoken3="0";
linetoken4 = airplane -> getToken (*command_line, 4);
if (linetoken4=="")
linetoken4="0";
linetoken5 = airplane -> getToken (*command_line, 5);
if (linetoken5=="")
linetoken5="0";
linetoken6 = airplane -> getToken (*command_line, 6);
if (linetoken6=="")
linetoken6="0";
linetoken7 = airplane -> getToken (*command_line, 7);
if (linetoken7=="")
linetoken7="0";
linetoken8 = airplane -> getToken (*command_line, 8);
if (linetoken8=="")
linetoken8="0";
linetoken9 = airplane -> getToken (*command_line, 9);
if (linetoken9=="")
linetoken9="0";
linetoken10 = airplane -> getToken (*command_line, 10);
if (linetoken10=="")
linetoken10="0";
//cout << linetoken1 << endl;
//cout << linetoken2 << endl;
//cout << linetoken3 << endl;
//cout << linetoken4 << endl;
//cout << linetoken5 << endl;
//cout << linetoken6 << endl;
//cout << linetoken7 << endl;
//cout << linetoken8 << endl;
//cout << linetoken9 << endl;
//cout << linetoken10 << endl;
//istrstream token3(linetoken3.c_str());
//istrstream token4(linetoken4.c_str());
//istrstream token5(linetoken5.c_str());
//istrstream token6(linetoken6.c_str());
//istrstream token7(linetoken7.c_str());
//istrstream token8(linetoken8.c_str());
//istrstream token9(linetoken9.c_str());
//istrstream token10(linetoken10.c_str());
switch (Keyword_map[linetoken1])
{
case init_flag:
{
parse_init( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end init map
case geometry_flag:
{
parse_geometry( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end geometry map
case controlSurface_flag:
{
parse_controlSurface( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end controlSurface map
case mass_flag:
{
parse_mass( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end mass map
case engine_flag:
{
parse_engine( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end engine map
case CD_flag:
{
parse_CD( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end CD map
case CL_flag:
{
parse_CL( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end CL map
case Cm_flag:
{
parse_Cm( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end Cm map
case CY_flag:
{
parse_CY( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end CY map
case Cl_flag:
{
parse_Cl( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end Cl map
case Cn_flag:
{
parse_Cn( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end Cn map
case gear_flag:
{
parse_gear( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end gear map
case ice_flag:
{
parse_ice( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end ice map
case fog_flag:
{
parse_fog( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end fog map
case record_flag:
{
static int fout_flag=0;
if (fout_flag==0)
{
fout_flag=-1;
fout.open("uiuc_record.dat");
}
parse_record( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
break;
} // end record map
2000-09-06 19:52:37 +00:00
case misc_flag:
{
parse_misc( linetoken2, linetoken3, linetoken4,
linetoken5, linetoken6, linetoken7,
linetoken8, linetoken9, linetoken10,
aircraft_directory, command_line );
2000-09-06 19:52:37 +00:00
break;
} // end misc map
default:
{
if (linetoken1=="*")
return;
if (ignore_unknown_keywords) {
// do nothing
} else {
// print error message
uiuc_warnings_errors(2, *command_line);
}
break;
}
};
} // end keyword map
delete airplane;
}
// end menu.cpp