]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_aerodeflections.cpp
Sep 1 2000 updates from the UIUC team.
[flightgear.git] / src / FDM / UIUCModel / uiuc_aerodeflections.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_aerodeflections.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  determine the aero control surface deflections
8                elevator [rad]
9                aileron [rad]
10                rudder [rad]
11                
12 ----------------------------------------------------------------------
13
14  STATUS:       alpha version
15
16 ----------------------------------------------------------------------
17
18  REFERENCES:   based on deflection portions of c172_aero.c and 
19                uiuc_aero.c
20
21 ----------------------------------------------------------------------
22
23  HISTORY:      01/30/2000   initial release
24                04/05/2000   (JS) added zero_Long_trim command
25
26 ----------------------------------------------------------------------
27
28  AUTHOR(S):    Jeff Scott         <jscott@mail.com>
29                Michael Selig      <m-selig@uiuc.edu>
30
31 ----------------------------------------------------------------------
32
33  VARIABLES:
34
35 ----------------------------------------------------------------------
36
37  INPUTS:       *
38
39 ----------------------------------------------------------------------
40
41  OUTPUTS:      *
42
43 ----------------------------------------------------------------------
44
45  CALLED BY:    *
46
47 ----------------------------------------------------------------------
48
49  CALLS TO:     *
50
51 ----------------------------------------------------------------------
52
53  COPYRIGHT:    (C) 2000 by Michael Selig
54
55  This program is free software; you can redistribute it and/or
56  modify it under the terms of the GNU General Public License
57  as published by the Free Software Foundation.
58
59  This program is distributed in the hope that it will be useful,
60  but WITHOUT ANY WARRANTY; without even the implied warranty of
61  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
62  GNU General Public License for more details.
63
64  You should have received a copy of the GNU General Public License
65  along with this program; if not, write to the Free Software
66  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
67  USA or view http://www.gnu.org/copyleft/gpl.html.
68
69 **********************************************************************/
70
71 #include "uiuc_aerodeflections.h"
72
73 void uiuc_aerodeflections( double dt )
74 {
75   double prevFlapHandle, flap_transit_rate;
76   bool flaps_in_transit;
77
78   if (zero_Long_trim)
79     {
80       Long_trim = 0;
81       //elevator_tab = 0;
82     }
83
84   if (Lat_control <= 0)
85     aileron = - Lat_control * damin * DEG_TO_RAD;
86   else
87     aileron = - Lat_control * damax * DEG_TO_RAD;
88
89   if ((Long_control+Long_trim) <= 0)
90     elevator = (Long_control + Long_trim) * demax * DEG_TO_RAD + elevator_tab;
91   else
92     elevator = (Long_control + Long_trim) * demin * DEG_TO_RAD + elevator_tab;
93
94   if (Rudder_pedal <= 0)
95     rudder = - Rudder_pedal * drmin * DEG_TO_RAD;
96   else
97     rudder = - Rudder_pedal * drmax * DEG_TO_RAD;
98
99   // flap routine
100   // check for lowest flap setting
101   if (Flap_handle < dfArray[1])
102     {
103       Flap_handle    = dfArray[1];
104       prevFlapHandle = Flap_handle;
105       flap           = Flap_handle;
106     }
107   // check for highest flap setting
108   else if (Flap_handle > dfArray[ndf])
109     {
110       Flap_handle      = dfArray[ndf];
111       prevFlapHandle   = Flap_handle;
112       flap             = Flap_handle;
113     }
114   // otherwise in between
115   else          
116     {
117       if(Flap_handle != prevFlapHandle)
118         {
119           flaps_in_transit = true;
120         }
121       if(flaps_in_transit)
122         {
123           int iflap = 0;
124           while (dfArray[iflap] < Flap_handle)
125             {
126               iflap++;
127             }
128           if (flap < Flap_handle)
129             {
130               if (TimeArray[iflap] > 0)
131                 flap_transit_rate = (dfArray[iflap] - dfArray[iflap-1]) / TimeArray[iflap+1];
132               else
133                 flap_transit_rate = (dfArray[iflap] - dfArray[iflap-1]) / 5;
134             }
135           else 
136             {
137               if (TimeArray[iflap+1] > 0)
138                 flap_transit_rate = (dfArray[iflap] - dfArray[iflap+1]) / TimeArray[iflap+1];
139               else
140                 flap_transit_rate = (dfArray[iflap] - dfArray[iflap+1]) / 5;
141             }
142           if(fabs (flap - Flap_handle) > dt * flap_transit_rate)
143             flap += flap_transit_rate * dt;
144           else
145             {
146               flaps_in_transit = false;
147               flap = Flap_handle;
148             }
149         }
150     }
151   prevFlapHandle = Flap_handle;
152
153   return;
154 }
155
156 // end uiuc_aerodeflections.cpp