1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 Date started: 21 February 2007
7 ------------- Copyright (C) 2006 Jon S. Berndt (jsb@hal-pc.org) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
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 Lesser General Public License for more
19 You should have received a copy of the GNU Lesser 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.
23 Further information about the GNU Lesser General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 #include "FGFCSComponent.h"
41 #include <input_output/FGXMLElement.h>
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 #define ID_ACTUATOR "$Id$"
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 /** Encapsulates an Actuator component for the flight control system.
62 The actuator can be modeled as a "perfect actuator", with the Output
63 being set directly to the input. The actuator can be made more "real"
64 by specifying any/all of the following additional effects that can be
65 applied to the actuator. In order of application to the input signal,
68 - System lag (input lag, really)
71 - Hysteresis (mechanical hysteresis)
72 - Bias (mechanical bias)
73 - Position limiting ("hard stops")
75 There are also several malfunctions that can be applied to the actuator
76 by setting a property to true or false (or 1 or 0).
81 <actuator name="name">
82 <input> {[-]property} </input>
84 <rate_limit> number <rate_limit>
86 <deadband_width> number </deadband_width>
87 <hysteresis_width> number </hysteresis_width>
89 <min> {property name | value} </min>
90 <max> {property name | value} </max>
92 [<output> {property} </output>]
99 <actuator name="fcs/gimbal_pitch_position">
100 <input> fcs/gimbal_pitch_command </input>
102 <rate_limit> 0.085 <rate_limit> <!-- 5 degrees/sec -->
104 <deadband_width> 0.002 </deadband_width>
105 <hysteresis_width> 0.05 </hysteresis_width>
106 <clipto> <!-- +/- 10 degrees -->
113 @author Jon S. Berndt
117 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
121 class FGActuator : public FGFCSComponent
125 FGActuator(FGFCS* fcs, Element* element);
129 /** This function processes the input.
130 It calls private functions if needed to perform the hysteresis, lag,
131 limiting, etc. functions. */
134 // these may need to have the bool argument replaced with a double
135 /** This function fails the actuator to zero. The motion to zero
136 will flow through the lag, hysteresis, and rate limiting
137 functions if those are activated. */
138 inline void SetFailZero(bool set) {fail_zero = set;}
139 inline void SetFailHardover(bool set) {fail_hardover = set;}
140 inline void SetFailStuck(bool set) {fail_stuck = set;}
142 inline bool GetFailZero(void) const {return fail_zero;}
143 inline bool GetFailHardover(void) const {return fail_hardover;}
144 inline bool GetFailStuck(void) const {return fail_stuck;}
151 double hysteresis_width;
152 double deadband_width;
154 double ca; // lag filter coefficient "a"
155 double cb; // lag filter coefficient "b"
156 double PreviousOutput;
157 double PreviousHystOutput;
158 double PreviousRateLimOutput;
159 double PreviousLagInput;
160 double PreviousLagOutput;
165 void Hysteresis(void);
167 void RateLimit(void);
173 void Debug(int from);