]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/flight_control/FGFilter.h
sync. with JSBSim v. 2.0
[flightgear.git] / src / FDM / JSBSim / models / flight_control / 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 <input_output/FGXMLElement.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 \</input>
67   \<c1> value \<c/1>
68   [\<c2> value \<c/2>]
69   [\<c3> value \<c/3>]
70   [\<c4> value \<c/4>]
71   [\<c5> value \<c/5>]
72   [\<c6> value \<c/6>]
73   [\<output> property \<output>]
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 \</input>
87   \<c1> value \<c/1>
88   [\<output> property \<output>]
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="Heading Roll Error Lag" type="LAG_FILTER">
100   \<input> fcs/heading-command \</input>
101   \<c1> 600 \</c1>
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 \</input>
114   \<c1> value \<c/1>
115   \<c2> value \<c/2>
116   \<c3> value \<c/3>
117   \<c4> value \<c/4>
118   [\<output> property \<output>]
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 \</input>
131   \<c1> value \</c1>
132   [\<output> property \<output>]
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 \</input>
145   \<c1> value \<c/1>
146   \<c2> value \<c/2>
147   \<c3> value \<c/3>
148   \<c4> value \<c/4>
149   \<c5> value \<c/5>
150   \<c6> value \<c/6>
151   [\<output> property \<output>]
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 \</input>
164   \<c1> value \<c/1>
165   [\<trigger> property \</trigger>]
166   [\<output> property \<output>]
167 \</component>
168 </pre>
169 For the integrator, the trigger features the following behavior. If the trigger
170 property value is:
171   - 0: no action is taken - the output is calculated normally
172   - not 0: (or simply greater than zero), all current and previous inputs will
173            be set to 0.0
174
175 In all the filter specifications above, an \<output> element is also seen.  This
176 is so that the last component in a "string" can copy its value to the appropriate
177 output, such as the elevator, or speedbrake, etc.
178
179 @author Jon S. Berndt
180 @version $Id$
181 */
182
183 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 CLASS DECLARATION
185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
186
187 class FGFilter  : public FGFCSComponent
188 {
189 public:
190   FGFilter(FGFCS* fcs, Element* element);
191   ~FGFilter();
192
193   bool Run (void);
194
195   /** When true, causes previous values to be set to current values. This
196       is particularly useful for first pass. */
197   bool Initialize;
198
199   enum {eLag, eLeadLag, eOrder2, eWashout, eIntegrator, eUnknown} FilterType;
200
201 private:
202   double dt;
203   double ca;
204   double cb;
205   double cc;
206   double cd;
207   double ce;
208   double C1;
209   double C2;
210   double C3;
211   double C4;
212   double C5;
213   double C6;
214   double PreviousInput1;
215   double PreviousInput2;
216   double PreviousOutput1;
217   double PreviousOutput2;
218   FGPropertyManager* Trigger;
219   void Debug(int from);
220 };
221 }
222 #endif
223