1 /**********************************************************************
3 FILENAME: uiuc_wrapper.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: A wrapper(interface) between the UIUC Aeromodel (C++ files)
8 and the LaRCsim FDM (C files)
10 ----------------------------------------------------------------------
14 ----------------------------------------------------------------------
18 ----------------------------------------------------------------------
20 HISTORY: 01/26/2000 initial release
21 03/09/2001 (DPM) added support for gear
23 ----------------------------------------------------------------------
25 AUTHOR(S): Bipin Sehgal <bsehgal@uiuc.edu>
26 David Megginson <david@megginson.com>
28 ----------------------------------------------------------------------
32 ----------------------------------------------------------------------
36 ----------------------------------------------------------------------
40 ----------------------------------------------------------------------
44 ----------------------------------------------------------------------
48 ----------------------------------------------------------------------
50 COPYRIGHT: (C) 2000 by Michael Selig
52 This program is free software; you can redistribute it and/or
53 modify it under the terms of the GNU General Public License
54 as published by the Free Software Foundation.
56 This program is distributed in the hope that it will be useful,
57 but WITHOUT ANY WARRANTY; without even the implied warranty of
58 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59 GNU General Public License for more details.
61 You should have received a copy of the GNU General Public License
62 along with this program; if not, write to the Free Software
63 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
64 USA or view http://www.gnu.org/copyleft/gpl.html.
66 **********************************************************************/
68 #include <simgear/compiler.h>
70 #include "uiuc_aircraft.h"
71 #include "uiuc_aircraftdir.h"
72 #include "uiuc_coefficients.h"
73 #include "uiuc_engine.h"
74 #include "uiuc_gear.h"
75 #include "uiuc_aerodeflections.h"
76 #include "uiuc_recorder.h"
77 #include "uiuc_menu.h"
78 #include "uiuc_betaprobe.h"
79 #include <FDM/LaRCsim/ls_generic.h>
81 #if !defined (SG_HAVE_NATIVE_SGI_COMPILERS)
86 extern "C" void uiuc_init_aeromodel ();
87 extern "C" void uiuc_force_moment(double dt);
88 extern "C" void uiuc_engine_routine();
89 extern "C" void uiuc_gear_routine();
91 AIRCRAFT *aircraft_ = new AIRCRAFT;
92 AIRCRAFTDIR *aircraftdir_ = new AIRCRAFTDIR;
94 void uiuc_init_aeromodel ()
98 if (aircraft_dir != (string)"")
99 aircraft = aircraft_dir + "/";
101 aircraft += "aircraft.dat";
102 cout << "We are using "<< aircraft << endl;
103 uiuc_initializemaps(); // Initialize the <string,int> maps
104 uiuc_menu(aircraft); // Read the specified aircraft file
107 void uiuc_force_moment(double dt)
109 double qS = Dynamic_pressure * Sw;
110 double qScbar = qS * cbar;
111 double qSb = qS * bw;
113 uiuc_aerodeflections(dt);
116 /* Calculate the wind axis forces */
119 CD = -CX * cos(Alpha) - CZ * sin(Alpha);
120 CL = CX * sin(Alpha) - CZ * cos(Alpha);
122 F_X_wind = -1 * CD * qS;
124 F_Z_wind = -1 * CL * qS;
126 /* wind-axis to body-axis transformation */
127 F_X_aero = F_X_wind * Cos_alpha * Cos_beta - F_Y_wind * Cos_alpha * Sin_beta - F_Z_wind * Sin_alpha;
128 F_Y_aero = F_X_wind * Sin_beta + F_Y_wind * Cos_beta;
129 F_Z_aero = F_X_wind * Sin_alpha * Cos_beta - F_Y_wind * Sin_alpha * Sin_beta + F_Z_wind * Cos_alpha;
131 /* Moment calculations */
133 M_m_aero = Cm * qScbar;
136 /* Call fligt data recorder */
137 if (Simtime >= recordStartTime)
141 void uiuc_engine_routine()
146 void uiuc_gear_routine ()
151 //end uiuc_wrapper.cpp