42 startup_current( false ),
107 else if (elapsedTime <= desiredTs ) {
115 double Ts = elapsedTime;
125 double td = Td.get_value();
126 double ti = Ti.get_value();
132 double ep_n = beta * r_n - y_n;
133 double e_n = r_n - y_n;
134 double ed_n = gamma * r_n - y_n;
135 double Tf = alpha * td;
139 edf_n = edf_n_1 / (Ts/Tf + 1)
140 + ed_n * (Ts/Tf) / (Ts/Tf + 1);
144 if (startup_current) {
160 double delta_u_n = 0.0;
162 delta_u_n = Kp.get_value() * (
165 + ((td/Ts) * (edf_n - 2*edf_n_1 + edf_n_2))
169 const char* saturation =
"";
172 if (iteration > startup_its) {
176 u_n = u_n_1 + delta_u_n;
180 saturation =
" max_saturation";
182 else if (u_n < u_min) {
184 saturation =
" min_saturation";
192 cout << subsystemId()
193 <<
": doing nothing."
194 <<
" startup_its=" << startup_its
195 <<
" iteration=" << iteration
203 <<
"Updating " << subsystemId()
204 <<
" startup_its=" << startup_its
205 <<
" startup_current=" << startup_current
206 <<
" firstTime=" << firstTime
207 <<
" iteration=" << iteration
212 <<
" ep_n_1=" << ep_n_1
216 <<
" edf_n=" << edf_n
217 <<
" edf_n_1=" << edf_n_1
218 <<
" edf_n_2=" << edf_n_2
220 <<
" delta_u_n=" << delta_u_n
221 <<
" P=" << Kp.get_value() * (ep_n - ep_n_1)
222 <<
" I=" << Kp.get_value() * ((Ts/ti) * e_n)
223 <<
" D=" << Kp.get_value() * ((td/Ts) * (edf_n - 2*edf_n_1 + edf_n_2))
225 <<
" u_n_1=" << u_n_1
226 <<
" delta_u_n=" << delta_u_n
240 const std::string& cfg_name,
241 SGPropertyNode& prop_root )
243 if( cfg_name ==
"config" ) {
248 if (cfg_name ==
"Ts") {
249 desiredTs = cfg_node.getDoubleValue();
253 if (cfg_name ==
"Kp") {
254 Kp.push_back(
new simgear::Value(prop_root, cfg_node));
258 if (cfg_name ==
"Ti") {
259 Ti.push_back(
new simgear::Value(prop_root, cfg_node));
263 if (cfg_name ==
"Td") {
264 Td.push_back(
new simgear::Value(prop_root, cfg_node));
268 if (cfg_name ==
"beta") {
269 beta = cfg_node.getDoubleValue();
273 if (cfg_name ==
"alpha") {
274 alpha = cfg_node.getDoubleValue();
278 if (cfg_name ==
"gamma") {
279 gamma = cfg_node.getDoubleValue();
283 if (cfg_name ==
"startup-its") {
284 startup_its = cfg_node.getIntValue();
288 if (cfg_name ==
"startup-current") {
289 startup_current = cfg_node.getBoolValue();
void set_output_value(double value)
simgear::ValueList _valueInput
the value input
bool configure(SGPropertyNode &cfg_node, const std::string &cfg_name, SGPropertyNode &prop_root) override
This method configures this analog component from a property node.
AnalogComponent()
A constructor for an analog component.
simgear::ValueList _referenceInput
the reference input
simgear::ValueList _minInput
the minimum output clamp input
double get_output_value() const
return the current double value of the output property
simgear::ValueList _maxInput
the maximum output clamp input
virtual bool configure(SGPropertyNode &cfg_node, const std::string &cfg_name, SGPropertyNode &prop_root)
bool _debug
debug flag, true if this component should generate some useful output on every iteration
void update(bool firstTime, double dt) override
pure virtual function to be implemented by the derived classes.
virtual bool configure(SGPropertyNode &cfg_node, const std::string &cfg_name, SGPropertyNode &prop_root)
This method configures this analog component from a property node.
SGSubsystemMgr::Registrant< PIDController > registrantPIDController