2000-03-22 22:01:33 +00:00
|
|
|
/**********************************************************************
|
2000-09-06 19:52:37 +00:00
|
|
|
|
|
|
|
FILENAME: uiuc_wrapper.cpp
|
2000-03-22 22:01:33 +00:00
|
|
|
|
2000-09-06 19:52:37 +00:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
DESCRIPTION: A wrapper(interface) between the UIUC Aeromodel (C++ files)
|
|
|
|
and the LaRCsim FDM (C files)
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
STATUS: alpha version
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
REFERENCES:
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
HISTORY: 01/26/2000 initial release
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
AUTHOR(S): Bipin Sehgal <bsehgal@uiuc.edu>
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
VARIABLES:
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
INPUTS: *
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
OUTPUTS: *
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
CALLED BY: *
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
CALLS TO: *
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
**********************************************************************/
|
2000-03-22 22:01:33 +00:00
|
|
|
|
2000-10-02 21:49:04 +00:00
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
2000-03-22 22:01:33 +00:00
|
|
|
#include "uiuc_aircraft.h"
|
|
|
|
#include "uiuc_aircraftdir.h"
|
|
|
|
#include "uiuc_coefficients.h"
|
|
|
|
#include "uiuc_engine.h"
|
|
|
|
#include "uiuc_aerodeflections.h"
|
|
|
|
#include "uiuc_recorder.h"
|
|
|
|
#include "uiuc_menu.h"
|
2000-09-06 19:52:37 +00:00
|
|
|
#include "uiuc_betaprobe.h"
|
2000-09-26 21:44:52 +00:00
|
|
|
#include <FDM/LaRCsim/ls_generic.h>
|
2000-03-22 22:01:33 +00:00
|
|
|
|
2000-10-02 21:49:04 +00:00
|
|
|
FG_USING_STD(cout);
|
|
|
|
FG_USING_STD(endl);
|
|
|
|
|
2000-03-22 22:01:33 +00:00
|
|
|
extern "C" void uiuc_init_aeromodel ();
|
|
|
|
extern "C" void uiuc_force_moment(double dt);
|
|
|
|
extern "C" void uiuc_engine_routine();
|
|
|
|
|
2000-05-23 22:08:00 +00:00
|
|
|
AIRCRAFT *aircraft_ = new AIRCRAFT;
|
|
|
|
AIRCRAFTDIR *aircraftdir_ = new AIRCRAFTDIR;
|
2000-03-22 22:01:33 +00:00
|
|
|
|
|
|
|
void uiuc_init_aeromodel ()
|
|
|
|
{
|
|
|
|
string aircraft;
|
|
|
|
|
|
|
|
if (aircraft_dir != "")
|
|
|
|
aircraft = aircraft_dir + "/";
|
|
|
|
|
|
|
|
aircraft += "aircraft.dat";
|
|
|
|
cout << "We are using "<< aircraft << endl;
|
|
|
|
uiuc_initializemaps(); // Initialize the <string,int> maps
|
|
|
|
uiuc_menu(aircraft); // Read the specified aircraft file
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiuc_force_moment(double dt)
|
|
|
|
{
|
|
|
|
double qS = Dynamic_pressure * Sw;
|
|
|
|
double qScbar = qS * cbar;
|
|
|
|
double qSb = qS * bw;
|
|
|
|
|
2000-09-06 19:52:37 +00:00
|
|
|
uiuc_aerodeflections(dt);
|
2000-03-22 22:01:33 +00:00
|
|
|
uiuc_coefficients();
|
2000-09-06 19:52:37 +00:00
|
|
|
|
2000-03-22 22:01:33 +00:00
|
|
|
/* Calculate the wind axis forces */
|
2000-09-06 19:52:37 +00:00
|
|
|
if (CX && CZ)
|
|
|
|
{
|
|
|
|
CD = -CX * cos(Alpha) - CZ * sin(Alpha);
|
|
|
|
CL = CX * sin(Alpha) - CZ * cos(Alpha);
|
|
|
|
}
|
2000-03-22 22:01:33 +00:00
|
|
|
F_X_wind = -1 * CD * qS;
|
|
|
|
F_Y_wind = CY * qS;
|
|
|
|
F_Z_wind = -1 * CL * qS;
|
2000-09-06 19:52:37 +00:00
|
|
|
|
2000-03-22 22:01:33 +00:00
|
|
|
/* wind-axis to body-axis transformation */
|
|
|
|
F_X_aero = F_X_wind * Cos_alpha * Cos_beta - F_Y_wind * Cos_alpha * Sin_beta - F_Z_wind * Sin_alpha;
|
|
|
|
F_Y_aero = F_X_wind * Sin_beta + F_Y_wind * Cos_beta;
|
|
|
|
F_Z_aero = F_X_wind * Sin_alpha * Cos_beta - F_Y_wind * Sin_alpha * Sin_beta + F_Z_wind * Cos_alpha;
|
2000-09-06 19:52:37 +00:00
|
|
|
|
|
|
|
/* Moment calculations */
|
2000-03-22 22:01:33 +00:00
|
|
|
M_l_aero = Cl * qSb;
|
|
|
|
M_m_aero = Cm * qScbar;
|
2000-09-06 19:52:37 +00:00
|
|
|
M_n_aero = Cn * qSb;
|
2000-03-22 22:01:33 +00:00
|
|
|
|
2000-09-06 19:52:37 +00:00
|
|
|
/* Call fligt data recorder */
|
|
|
|
if (Simtime >= recordStartTime)
|
|
|
|
uiuc_recorder(dt);
|
2000-03-22 22:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void uiuc_engine_routine()
|
|
|
|
{
|
|
|
|
uiuc_engine();
|
|
|
|
}
|
|
|
|
|
|
|
|
//end uiuc_wrapper.cpp
|