37 const std::string& cfg_name,
38 SGPropertyNode& prop_root )
40 if( cfg_name ==
"config" ) {
45 if (cfg_name ==
"Kp") {
46 _Kp.push_back(
new simgear::Value(prop_root, cfg_node));
50 if (cfg_name ==
"Ki") {
51 _Ki.push_back(
new simgear::Value(prop_root, cfg_node));
65 if (
_debug ) std::cout <<
"Updating " << subsystemId() << std::endl;
69 double error = r_n - y_n;
70 if (
_debug ) std::cout <<
"input = " << y_n
71 <<
" reference = " << r_n
72 <<
" error = " << error
75 double prop_comp =
clamp(error * _Kp.get_value());
76 _int_sum += error * _Ki.get_value() * dt;
79 double output = prop_comp + _int_sum;
80 double clamped_output =
clamp( output );
81 if( output != clamped_output )
82 _int_sum = clamped_output - prop_comp;
84 if (
_debug ) std::cout <<
"prop_comp = " << prop_comp
85 <<
" int_sum = " << _int_sum << std::endl;
88 if (
_debug ) std::cout <<
"output = " << clamped_output << std::endl;
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
double clamp(double value) const
clamp the given value if <min> and/or <max> inputs were given
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)
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< PISimpleController > registrantPISimpleController