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 **********************************************************************/
73 #include "uiuc_aerodeflections.h"
75 void uiuc_aerodeflections( double dt )
77 double prevFlapHandle = 0.0f;
78 double flap_transit_rate;
79 bool flaps_in_transit = false;
88 aileron = - Lat_control * damin * DEG_TO_RAD;
90 aileron = - Lat_control * damax * DEG_TO_RAD;
92 if ((Long_control+Long_trim) <= 0)
93 elevator = (Long_control + Long_trim) * demax * DEG_TO_RAD + elevator_tab;
95 elevator = (Long_control + Long_trim) * demin * DEG_TO_RAD + elevator_tab;
97 if (Rudder_pedal <= 0)
98 rudder = - Rudder_pedal * drmin * DEG_TO_RAD;
100 rudder = - Rudder_pedal * drmax * DEG_TO_RAD;
103 // check for lowest flap setting
104 if (Flap_handle < dfArray[1])
106 Flap_handle = dfArray[1];
107 prevFlapHandle = Flap_handle;
110 // check for highest flap setting
111 else if (Flap_handle > dfArray[ndf])
113 Flap_handle = dfArray[ndf];
114 prevFlapHandle = Flap_handle;
117 // otherwise in between
120 if(Flap_handle != prevFlapHandle)
122 flaps_in_transit = true;
127 while (dfArray[iflap] < Flap_handle)
131 if (flap < Flap_handle)
133 if (TimeArray[iflap] > 0)
134 flap_transit_rate = (dfArray[iflap] - dfArray[iflap-1]) / TimeArray[iflap+1];
136 flap_transit_rate = (dfArray[iflap] - dfArray[iflap-1]) / 5;
140 if (TimeArray[iflap+1] > 0)
141 flap_transit_rate = (dfArray[iflap] - dfArray[iflap+1]) / TimeArray[iflap+1];
143 flap_transit_rate = (dfArray[iflap] - dfArray[iflap+1]) / 5;
145 if(fabs (flap - Flap_handle) > dt * flap_transit_rate)
146 flap += flap_transit_rate * dt;
149 flaps_in_transit = false;
154 prevFlapHandle = Flap_handle;
159 // end uiuc_aerodeflections.cpp