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
22 ----------------------------------------------------------------------
24 AUTHOR(S): Bipin Sehgal <bsehgal@uiuc.edu>
26 ----------------------------------------------------------------------
30 ----------------------------------------------------------------------
34 ----------------------------------------------------------------------
38 ----------------------------------------------------------------------
42 ----------------------------------------------------------------------
46 ----------------------------------------------------------------------
48 COPYRIGHT: (C) 2000 by Michael Selig
50 This program is free software; you can redistribute it and/or
51 modify it under the terms of the GNU General Public License
52 as published by the Free Software Foundation.
54 This program is distributed in the hope that it will be useful,
55 but WITHOUT ANY WARRANTY; without even the implied warranty of
56 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 GNU General Public License for more details.
59 You should have received a copy of the GNU General Public License
60 along with this program; if not, write to the Free Software
61 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
62 USA or view http://www.gnu.org/copyleft/gpl.html.
64 **********************************************************************/
66 #include "uiuc_aircraft.h"
67 #include "uiuc_aircraftdir.h"
68 #include "uiuc_coefficients.h"
69 #include "uiuc_engine.h"
70 #include "uiuc_aerodeflections.h"
71 #include "uiuc_recorder.h"
72 #include "uiuc_menu.h"
73 #include "uiuc_betaprobe.h"
74 #include <FDM/LaRCsim/ls_generic.h>
76 extern "C" void uiuc_init_aeromodel ();
77 extern "C" void uiuc_force_moment(double dt);
78 extern "C" void uiuc_engine_routine();
80 AIRCRAFT *aircraft_ = new AIRCRAFT;
81 AIRCRAFTDIR *aircraftdir_ = new AIRCRAFTDIR;
83 void uiuc_init_aeromodel ()
87 if (aircraft_dir != "")
88 aircraft = aircraft_dir + "/";
90 aircraft += "aircraft.dat";
91 cout << "We are using "<< aircraft << endl;
92 uiuc_initializemaps(); // Initialize the <string,int> maps
93 uiuc_menu(aircraft); // Read the specified aircraft file
96 void uiuc_force_moment(double dt)
98 double qS = Dynamic_pressure * Sw;
99 double qScbar = qS * cbar;
100 double qSb = qS * bw;
102 uiuc_aerodeflections(dt);
105 /* Calculate the wind axis forces */
108 CD = -CX * cos(Alpha) - CZ * sin(Alpha);
109 CL = CX * sin(Alpha) - CZ * cos(Alpha);
111 F_X_wind = -1 * CD * qS;
113 F_Z_wind = -1 * CL * qS;
115 /* wind-axis to body-axis transformation */
116 F_X_aero = F_X_wind * Cos_alpha * Cos_beta - F_Y_wind * Cos_alpha * Sin_beta - F_Z_wind * Sin_alpha;
117 F_Y_aero = F_X_wind * Sin_beta + F_Y_wind * Cos_beta;
118 F_Z_aero = F_X_wind * Sin_alpha * Cos_beta - F_Y_wind * Sin_alpha * Sin_beta + F_Z_wind * Cos_alpha;
120 /* Moment calculations */
122 M_m_aero = Cm * qScbar;
125 /* Call fligt data recorder */
126 if (Simtime >= recordStartTime)
130 void uiuc_engine_routine()
135 //end uiuc_wrapper.cpp