]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_controlInput.cpp
Reset: work with threaded OSG modes
[flightgear.git] / src / FDM / UIUCModel / uiuc_controlInput.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_controlInput.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  sets control surface deflections for specified input 
8                modes
9
10 ----------------------------------------------------------------------
11
12  STATUS:       alpha version
13
14 ----------------------------------------------------------------------
15
16  REFERENCES:   
17
18 ----------------------------------------------------------------------
19
20  HISTORY:      04/08/2000   initial release
21                06/18/2001   (RD) Added aileron_input and rudder_input
22                07/05/2001   (RD) Code added to allow the pilot to fly
23                             aircraft after the control surface input
24                             files have been used.
25
26 ----------------------------------------------------------------------
27
28  AUTHOR(S):    Jeff Scott         <jscott@mail.com>
29                Robert Deters      <rdeters@uiuc.edu>
30
31 ----------------------------------------------------------------------
32
33  VARIABLES:
34
35 ----------------------------------------------------------------------
36
37  INPUTS:       -Simtime
38                -deflection times
39                -deflection angles
40
41 ----------------------------------------------------------------------
42
43  OUTPUTS:      -elevator deflection
44
45 ----------------------------------------------------------------------
46
47  CALLED BY:    uiuc_coefficients.cpp
48
49 ----------------------------------------------------------------------
50
51  CALLS TO:     none
52
53 ----------------------------------------------------------------------
54
55  COPYRIGHT:    (C) 2000 by Michael Selig
56
57  This program is free software; you can redistribute it and/or
58  modify it under the terms of the GNU General Public License
59  as published by the Free Software Foundation.
60
61  This program is distributed in the hope that it will be useful,
62  but WITHOUT ANY WARRANTY; without even the implied warranty of
63  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
64  GNU General Public License for more details.
65
66  You should have received a copy of the GNU General Public License
67  along with this program; if not, write to the Free Software
68  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
69
70 **********************************************************************/
71
72 #include <simgear/compiler.h>
73
74 #include "uiuc_controlInput.h"
75
76 #include <iostream>
77
78 void uiuc_controlInput()
79 {
80   // elevator step input
81   if (elevator_step)
82     {
83       if (Simtime >= elevator_step_startTime)
84         {
85           elevator = elevator + elevator_step_angle;
86         }
87     }
88
89   // elevator singlet input
90   if (elevator_singlet)
91     {
92       if (Simtime >= elevator_singlet_startTime && 
93           Simtime <= (elevator_singlet_startTime + elevator_singlet_duration))
94         {
95           elevator = elevator + elevator_singlet_angle;
96         }
97     }
98
99   // elevator doublet input
100   if (elevator_doublet)
101     {
102       if (Simtime >= elevator_doublet_startTime && 
103           Simtime <= (elevator_doublet_startTime + elevator_doublet_duration/2))
104         {
105           elevator = elevator + elevator_doublet_angle;
106         }
107       else if (Simtime >= (elevator_doublet_startTime + elevator_doublet_duration/2) && 
108                Simtime <= (elevator_doublet_startTime + elevator_doublet_duration))
109         {
110           elevator = elevator - elevator_doublet_angle;
111         }
112     }
113
114   // elevator input
115   if (elevator_input)
116     {
117       double elevator_input_endTime = elevator_input_timeArray[elevator_input_ntime];
118       if (Simtime >= elevator_input_startTime && 
119           Simtime <= (elevator_input_startTime + elevator_input_endTime))
120         {
121           double time = Simtime - elevator_input_startTime;
122           if (pilot_elev_no_check)
123             {
124               elevator = 0 + elevator_tab;
125               pilot_elev_no = true;
126             }
127           elevator = elevator + 
128             uiuc_1Dinterpolation(elevator_input_timeArray,
129                                  elevator_input_deArray,
130                                  elevator_input_ntime,
131                                  time);
132         }
133     }
134
135   // aileron input
136   if (aileron_input)
137     {
138       double aileron_input_endTime = aileron_input_timeArray[aileron_input_ntime];
139       if (Simtime >= aileron_input_startTime && 
140           Simtime <= (aileron_input_startTime + aileron_input_endTime))
141         {
142           double time = Simtime - aileron_input_startTime;
143           if (pilot_ail_no_check)
144             {
145               aileron = 0;
146               if (Simtime==0)             //7-25-01 (RD) Added because
147                 pilot_ail_no = false;     //segmentation fault is given
148               else                        //with FG 0.7.8
149                 pilot_ail_no = true;
150             }
151           aileron = aileron + 
152             uiuc_1Dinterpolation(aileron_input_timeArray,
153                                  aileron_input_daArray,
154                                  aileron_input_ntime,
155                                  time);
156         }
157     }
158
159   // rudder input
160   if (rudder_input)
161     {
162       double rudder_input_endTime = rudder_input_timeArray[rudder_input_ntime];
163       if (Simtime >= rudder_input_startTime && 
164           Simtime <= (rudder_input_startTime + rudder_input_endTime))
165         {
166           double time = Simtime - rudder_input_startTime;
167           if (pilot_rud_no_check)
168             {
169               rudder = 0;
170               pilot_rud_no = true;
171             }
172           rudder = rudder + 
173             uiuc_1Dinterpolation(rudder_input_timeArray,
174                                  rudder_input_drArray,
175                                  rudder_input_ntime,
176                                  time);
177         }
178     }
179
180   if (flap_pos_input)
181     {
182       double flap_pos_input_endTime = flap_pos_input_timeArray[flap_pos_input_ntime];
183       if (Simtime >= flap_pos_input_startTime && 
184           Simtime <= (flap_pos_input_startTime + flap_pos_input_endTime))
185         {
186           double time = Simtime - flap_pos_input_startTime;
187           flap_pos = uiuc_1Dinterpolation(flap_pos_input_timeArray,
188                                           flap_pos_input_dfArray,
189                                           flap_pos_input_ntime,
190                                           time);
191         }
192     }
193
194   return;
195 }
196
197 // end uiuc_controlInput.cpp