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, flap_transit_rate;
78 bool flaps_in_transit;
87 aileron = - Lat_control * damin * DEG_TO_RAD;
89 aileron = - Lat_control * damax * DEG_TO_RAD;
91 if ((Long_control+Long_trim) <= 0)
92 elevator = (Long_control + Long_trim) * demax * DEG_TO_RAD + elevator_tab;
94 elevator = (Long_control + Long_trim) * demin * DEG_TO_RAD + elevator_tab;
96 if (Rudder_pedal <= 0)
97 rudder = - Rudder_pedal * drmin * DEG_TO_RAD;
99 rudder = - Rudder_pedal * drmax * DEG_TO_RAD;
102 // check for lowest flap setting
103 if (Flap_handle < dfArray[1])
105 Flap_handle = dfArray[1];
106 prevFlapHandle = Flap_handle;
109 // check for highest flap setting
110 else if (Flap_handle > dfArray[ndf])
112 Flap_handle = dfArray[ndf];
113 prevFlapHandle = Flap_handle;
116 // otherwise in between
119 if(Flap_handle != prevFlapHandle)
121 flaps_in_transit = true;
126 while (dfArray[iflap] < Flap_handle)
130 if (flap < Flap_handle)
132 if (TimeArray[iflap] > 0)
133 flap_transit_rate = (dfArray[iflap] - dfArray[iflap-1]) / TimeArray[iflap+1];
135 flap_transit_rate = (dfArray[iflap] - dfArray[iflap-1]) / 5;
139 if (TimeArray[iflap+1] > 0)
140 flap_transit_rate = (dfArray[iflap] - dfArray[iflap+1]) / TimeArray[iflap+1];
142 flap_transit_rate = (dfArray[iflap] - dfArray[iflap+1]) / 5;
144 if(fabs (flap - Flap_handle) > dt * flap_transit_rate)
145 flap += flap_transit_rate * dt;
148 flaps_in_transit = false;
153 prevFlapHandle = Flap_handle;
158 // end uiuc_aerodeflections.cpp