]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_wrapper.cpp
- catch exception from readProperties and exit
[flightgear.git] / src / FDM / UIUCModel / uiuc_wrapper.cpp
1 /********************************************************************** 
2  
3  FILENAME:     uiuc_wrapper.cpp 
4
5 ---------------------------------------------------------------------- 
6
7  DESCRIPTION:  A wrapper(interface) between the UIUC Aeromodel (C++ files) 
8                and the LaRCsim FDM (C files)
9
10 ----------------------------------------------------------------------
11  
12  STATUS:       alpha version
13
14 ----------------------------------------------------------------------
15  
16  REFERENCES:   
17  
18 ----------------------------------------------------------------------
19
20  HISTORY:      01/26/2000   initial release
21                03/09/2001   (DPM) added support for gear
22  
23 ----------------------------------------------------------------------
24  
25  AUTHOR(S):    Bipin Sehgal       <bsehgal@uiuc.edu>
26                David Megginson    <david@megginson.com>
27  
28 ----------------------------------------------------------------------
29
30  VARIABLES:
31
32 ----------------------------------------------------------------------
33
34  INPUTS:       *
35
36 ----------------------------------------------------------------------
37
38  OUTPUTS:      *
39
40 ----------------------------------------------------------------------
41  
42  CALLED BY:    *
43  
44 ----------------------------------------------------------------------
45  
46  CALLS TO:     *
47  
48 ----------------------------------------------------------------------
49  
50  COPYRIGHT:    (C) 2000 by Michael Selig
51  
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.
55  
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.
60  
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.
65  
66 **********************************************************************/
67
68 #include <simgear/compiler.h>
69
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>
80
81 #if !defined (SG_HAVE_NATIVE_SGI_COMPILERS)
82 SG_USING_STD(cout);
83 SG_USING_STD(endl);
84 #endif
85
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();
90
91 AIRCRAFT *aircraft_ = new AIRCRAFT;
92 AIRCRAFTDIR *aircraftdir_ = new AIRCRAFTDIR;
93
94 void uiuc_init_aeromodel ()
95 {
96   string aircraft;
97
98   if (aircraft_dir != (string)"")
99     aircraft = aircraft_dir + "/";
100
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 
105 }
106
107 void uiuc_force_moment(double dt)
108 {
109   double qS = Dynamic_pressure * Sw;
110   double qScbar = qS * cbar;
111   double qSb = qS * bw;
112
113   uiuc_aerodeflections(dt);
114   uiuc_coefficients();
115
116   /* Calculate the wind axis forces */
117   if (CX && CZ)
118     {
119       CD = -CX * cos(Alpha) - CZ * sin(Alpha);
120       CL =  CX * sin(Alpha) - CZ * cos(Alpha);
121     }
122   F_X_wind = -1 * CD * qS;
123   F_Y_wind = CY * qS;
124   F_Z_wind = -1 * CL * qS;
125
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;
130
131   /* Moment calculations */
132   M_l_aero = Cl * qSb;
133   M_m_aero = Cm * qScbar;
134   M_n_aero = Cn * qSb;
135
136   /* Call fligt data recorder */
137   if (Simtime >= recordStartTime)
138       uiuc_recorder(dt);
139 }
140
141 void uiuc_engine_routine()
142 {
143   uiuc_engine();
144 }
145
146 void uiuc_gear_routine ()
147 {
148   uiuc_gear();
149 }
150
151 //end uiuc_wrapper.cpp