1 /**********************************************************************
3 FILENAME: uiuc_aerodeflections.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: determine the aero control surface deflections
12 ----------------------------------------------------------------------
16 ----------------------------------------------------------------------
18 REFERENCES: based on deflection portions of c172_aero.c and
21 ----------------------------------------------------------------------
23 HISTORY: 01/30/2000 initial release
24 04/05/2000 (JS) added zero_Long_trim command
26 ----------------------------------------------------------------------
28 AUTHOR(S): Jeff Scott <jscott@mail.com>
29 Michael Selig <m-selig@uiuc.edu>
31 ----------------------------------------------------------------------
35 ----------------------------------------------------------------------
39 ----------------------------------------------------------------------
43 ----------------------------------------------------------------------
47 ----------------------------------------------------------------------
51 ----------------------------------------------------------------------
53 COPYRIGHT: (C) 2000 by Michael Selig
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.
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.
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.
69 **********************************************************************/
71 #include "uiuc_aerodeflections.h"
73 void uiuc_aerodeflections( double dt )
75 double prevFlapHandle, flap_transit_rate;
76 bool flaps_in_transit;
85 aileron = - Lat_control * damin * DEG_TO_RAD;
87 aileron = - Lat_control * damax * DEG_TO_RAD;
89 if ((Long_control+Long_trim) <= 0)
90 elevator = (Long_control + Long_trim) * demax * DEG_TO_RAD + elevator_tab;
92 elevator = (Long_control + Long_trim) * demin * DEG_TO_RAD + elevator_tab;
94 if (Rudder_pedal <= 0)
95 rudder = - Rudder_pedal * drmin * DEG_TO_RAD;
97 rudder = - Rudder_pedal * drmax * DEG_TO_RAD;
100 // check for lowest flap setting
101 if (Flap_handle < dfArray[1])
103 Flap_handle = dfArray[1];
104 prevFlapHandle = Flap_handle;
107 // check for highest flap setting
108 else if (Flap_handle > dfArray[ndf])
110 Flap_handle = dfArray[ndf];
111 prevFlapHandle = Flap_handle;
114 // otherwise in between
117 if(Flap_handle != prevFlapHandle)
119 flaps_in_transit = true;
124 while (dfArray[iflap] < Flap_handle)
128 if (flap < Flap_handle)
130 if (TimeArray[iflap] > 0)
131 flap_transit_rate = (dfArray[iflap] - dfArray[iflap-1]) / TimeArray[iflap+1];
133 flap_transit_rate = (dfArray[iflap] - dfArray[iflap-1]) / 5;
137 if (TimeArray[iflap+1] > 0)
138 flap_transit_rate = (dfArray[iflap] - dfArray[iflap+1]) / TimeArray[iflap+1];
140 flap_transit_rate = (dfArray[iflap] - dfArray[iflap+1]) / 5;
142 if(fabs (flap - Flap_handle) > dt * flap_transit_rate)
143 flap += flap_transit_rate * dt;
146 flaps_in_transit = false;
151 prevFlapHandle = Flap_handle;
156 // end uiuc_aerodeflections.cpp