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

136 lines
3.7 KiB
C++
Raw Normal View History

/**********************************************************************
2000-09-06 19:52:37 +00:00
FILENAME: uiuc_wrapper.cpp
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.
**********************************************************************/
#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"
#include <FDM/LaRCsim/ls_generic.h>
extern "C" void uiuc_init_aeromodel ();
extern "C" void uiuc_force_moment(double dt);
extern "C" void uiuc_engine_routine();
AIRCRAFT *aircraft_ = new AIRCRAFT;
AIRCRAFTDIR *aircraftdir_ = new AIRCRAFTDIR;
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);
uiuc_coefficients();
2000-09-06 19:52:37 +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);
}
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
/* 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 */
M_l_aero = Cl * qSb;
M_m_aero = Cm * qScbar;
2000-09-06 19:52:37 +00:00
M_n_aero = Cn * qSb;
2000-09-06 19:52:37 +00:00
/* Call fligt data recorder */
if (Simtime >= recordStartTime)
uiuc_recorder(dt);
}
void uiuc_engine_routine()
{
uiuc_engine();
}
//end uiuc_wrapper.cpp