]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_controlInput.cpp
Units bug.
[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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
69  USA or view http://www.gnu.org/copyleft/gpl.html.
70
71 **********************************************************************/
72
73 #include <simgear/compiler.h>
74
75 #include "uiuc_controlInput.h"
76
77 #include STL_IOSTREAM
78
79 void uiuc_controlInput()
80 {
81   // elevator step input
82   if (elevator_step)
83     {
84       if (Simtime >= elevator_step_startTime)
85         {
86           elevator = elevator + elevator_step_angle;
87         }
88     }
89
90   // elevator singlet input
91   if (elevator_singlet)
92     {
93       if (Simtime >= elevator_singlet_startTime && 
94           Simtime <= (elevator_singlet_startTime + elevator_singlet_duration))
95         {
96           elevator = elevator + elevator_singlet_angle;
97         }
98     }
99
100   // elevator doublet input
101   if (elevator_doublet)
102     {
103       if (Simtime >= elevator_doublet_startTime && 
104           Simtime <= (elevator_doublet_startTime + elevator_doublet_duration/2))
105         {
106           elevator = elevator + elevator_doublet_angle;
107         }
108       else if (Simtime >= (elevator_doublet_startTime + elevator_doublet_duration/2) && 
109                Simtime <= (elevator_doublet_startTime + elevator_doublet_duration))
110         {
111           elevator = elevator - elevator_doublet_angle;
112         }
113     }
114
115   // elevator input
116   if (elevator_input)
117     {
118       double elevator_input_endTime = elevator_input_timeArray[elevator_input_ntime];
119       if (Simtime >= elevator_input_startTime && 
120           Simtime <= (elevator_input_startTime + elevator_input_endTime))
121         {
122           double time = Simtime - elevator_input_startTime;
123           if (pilot_elev_no_check)
124             {
125               elevator = 0 + elevator_tab;
126               pilot_elev_no = true;
127             }
128           elevator = elevator + 
129             uiuc_1Dinterpolation(elevator_input_timeArray,
130                                  elevator_input_deArray,
131                                  elevator_input_ntime,
132                                  time);
133         }
134     }
135
136   // aileron input
137   if (aileron_input)
138     {
139       double aileron_input_endTime = aileron_input_timeArray[aileron_input_ntime];
140       if (Simtime >= aileron_input_startTime && 
141           Simtime <= (aileron_input_startTime + aileron_input_endTime))
142         {
143           double time = Simtime - aileron_input_startTime;
144           if (pilot_ail_no_check)
145             {
146               aileron = 0;
147               if (Simtime==0)             //7-25-01 (RD) Added because
148                 pilot_ail_no = false;     //segmentation fault is given
149               else                        //with FG 0.7.8
150                 pilot_ail_no = true;
151             }
152           aileron = aileron + 
153             uiuc_1Dinterpolation(aileron_input_timeArray,
154                                  aileron_input_daArray,
155                                  aileron_input_ntime,
156                                  time);
157         }
158     }
159
160   // rudder input
161   if (rudder_input)
162     {
163       double rudder_input_endTime = rudder_input_timeArray[rudder_input_ntime];
164       if (Simtime >= rudder_input_startTime && 
165           Simtime <= (rudder_input_startTime + rudder_input_endTime))
166         {
167           double time = Simtime - rudder_input_startTime;
168           if (pilot_rud_no_check)
169             {
170               rudder = 0;
171               pilot_rud_no = true;
172             }
173           rudder = rudder + 
174             uiuc_1Dinterpolation(rudder_input_timeArray,
175                                  rudder_input_drArray,
176                                  rudder_input_ntime,
177                                  time);
178         }
179     }
180
181   if (flap_pos_input)
182     {
183       double flap_pos_input_endTime = flap_pos_input_timeArray[flap_pos_input_ntime];
184       if (Simtime >= flap_pos_input_startTime && 
185           Simtime <= (flap_pos_input_startTime + flap_pos_input_endTime))
186         {
187           double time = Simtime - flap_pos_input_startTime;
188           flap_pos = uiuc_1Dinterpolation(flap_pos_input_timeArray,
189                                           flap_pos_input_dfArray,
190                                           flap_pos_input_ntime,
191                                           time);
192         }
193     }
194
195   return;
196 }
197
198 // end uiuc_controlInput.cpp