]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/filtersjb/FGFilter.h
Curt Olson:
[flightgear.git] / src / FDM / JSBSim / filtersjb / FGFilter.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGFilter.h
4  Author:       Jon S. Berndt
5  Date started: 4/2000
6
7  ------------- Copyright (C)  -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 SENTRY
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32
33 #ifndef FGFILTER_H
34 #define FGFILTER_H
35
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 INCLUDES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40 #include "FGFCSComponent.h"
41 #include "../FGConfigFile.h"
42
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 DEFINITIONS
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47 #define ID_FILTER "$Id$"
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 namespace JSBSim {
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 CLASS DOCUMENTATION
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 /** Encapsulates a filter for the flight control system.
60 The filter component can simulate any filter up to second order. The
61 Tustin substitution is used to take filter definitions from LaPlace space to the
62 time domain. The general format for a filter specification is:
63
64 <pre>
65 \<COMPONENT NAME="name" TYPE="type">
66   INPUT \<property>
67   C1  \<value>
68   [C2 \<value>]
69   [C3 \<value>]
70   [C4 \<value>]
71   [C5 \<value>]
72   [C6 \<value>]
73   [OUTPUT \<property>]
74 \</COMPONENT>
75 </pre>
76
77 For a lag filter of the form,
78 <pre>
79   C1
80 ------
81 s + C1 
82 </pre>
83 the corresponding filter definition is:
84 <pre>
85 \<COMPONENT NAME="name" TYPE="LAG_FILTER">
86   INPUT \<property>
87   C1 \<value>
88   [OUTPUT \<property>]
89 \</COMPONENT>
90 </pre>
91 As an example, for the specific filter:
92 <pre>
93   600
94 ------
95 s + 600 
96 </pre>
97 the corresponding filter definition could be:
98 <pre>
99 \<COMPONENT NAME="LAG_1" TYPE="LAG_FILTER">
100   INPUT aileron_cmd
101   C1 600
102 \</COMPONENT>
103 </pre>
104 For a lead-lag filter of the form:
105 <pre>
106 C1*s + C2
107 ---------
108 C3*s + C4 
109 </pre>
110 The corresponding filter definition is:
111 <pre>
112 \<COMPONENT NAME="name" TYPE="LEAD_LAG_FILTER">
113   INPUT \<property>
114   C1 \<value>
115   C2 \<value>
116   C3 \<value>
117   C4 \<value>
118   [OUTPUT \<property>]
119 \</COMPONENT>
120 </pre>
121 For a washout filter of the form:
122 <pre>
123   s
124 ------
125 s + C1 
126 </pre>
127 The corresponding filter definition is:
128 <pre>
129 \<COMPONENT NAME="name" TYPE="WASHOUT_FILTER">
130   INPUT \<property>
131   C1 \<value>
132   [OUTPUT \<property>]
133 \</COMPONENT>
134 </pre>
135 For a second order filter of the form:
136 <pre>
137 C1*s^2 + C2*s + C3
138 ------------------
139 C4*s^2 + C5*s + C6
140 </pre>
141 The corresponding filter definition is:
142 <pre>
143 \<COMPONENT NAME="name" TYPE="SECOND_ORDER_FILTER">
144   INPUT \<property>
145   C1 \<value>
146   C2 \<value>
147   C3 \<value>
148   C4 \<value>
149   C5 \<value>
150   C6 \<value>
151   [OUTPUT \<property>]
152 \</COMPONENT>
153 </pre>
154 For an integrator of the form:
155 <pre>
156  C1
157  ---
158   s
159 </pre>
160 The corresponding filter definition is:
161 <pre>
162 \<COMPONENT NAME="name" TYPE="INTEGRATOR">
163   INPUT \<property>
164   C1 \<value>
165   [OUTPUT \<property>]
166   [TRIGGER \<property>]
167 \</COMPONENT>
168 </pre>
169 For the integrator, the TRIGGER features the following behavior, if the TRIGGER property value is:
170   - -1 (or simply less than zero), all previous inputs and outputs are set to 0.0
171   - 0, no action is taken - the output is calculated normally
172   - +1 (or simply greater than zero), all previous outputs (only) will be set to 0.0
173   
174     @author Jon S. Berndt
175     @version $Id$
176     */
177    
178 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 CLASS DECLARATION
180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
181
182 class FGFilter  : public FGFCSComponent         
183 {
184 public:
185   FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg);
186   ~FGFilter();
187
188   bool Run (void);
189
190   /** When true, causes previous values to be set to current values. This
191       is particularly useful for first pass. */
192   bool Initialize;
193
194   enum {eLag, eLeadLag, eOrder2, eWashout, eIntegrator, eUnknown} FilterType;
195
196 private:
197   double dt;
198   double ca;
199   double cb;
200   double cc;
201   double cd;
202   double ce;
203   double C1;
204   double C2;
205   double C3;
206   double C4;
207   double C5;
208   double C6;
209   double PreviousInput1;
210   double PreviousInput2;
211   double PreviousOutput1;
212   double PreviousOutput2;
213   FGConfigFile* AC_cfg;
214   FGPropertyManager* Trigger;
215   void Debug(int from);
216 };
217 }
218 #endif
219