Go to the documentation of this file.
44 #include <boost/algorithm/clamp.hpp>
45 #include <boost/algorithm/minmax.hpp>
51 Pid::Pid(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup)
52 : dynamic_reconfig_initialized_(false)
54 setGains(p,i,d,i_max,i_min,antiwindup);
60 : dynamic_reconfig_initialized_(false)
63 gains_buffer_ = source.gains_buffer_;
73 void Pid::initPid(
double p,
double i,
double d,
double i_max,
double i_min,
83 void Pid::initPid(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup,
86 initPid(p, i,
d, i_max, i_min, antiwindup);
93 void Pid::initPid(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup)
103 return init(nh, quiet);
126 nh.
param(
"i_clamp", i_clamp, 0.0);
127 gains.
i_max_ = std::abs(i_clamp);
128 gains.
i_min_ = -std::abs(i_clamp);
163 i_clamp = config->Attribute(
"iClamp") ? atof(config->Attribute(
"iClamp")) : 0.0;
166 config->Attribute(
"p") ? atof(config->Attribute(
"p")) : 0.0,
167 config->Attribute(
"i") ? atof(config->Attribute(
"i")) : 0.0,
168 config->Attribute(
"d") ? atof(config->Attribute(
"d")) : 0.0,
171 config->Attribute(
"antiwindup") ? atof(config->Attribute(
"antiwindup")) :
false
203 void Pid::reset(
double d_error,
double i_error)
213 void Pid::getGains(
double &p,
double &i,
double &d,
double &i_max,
double &i_min)
216 getGains(p, i,
d, i_max, i_min, antiwindup);
219 void Pid::getGains(
double &p,
double &i,
double &d,
double &i_max,
double &i_min,
bool &antiwindup)
226 i_max = gains.i_max_;
227 i_min = gains.i_min_;
228 antiwindup = gains.antiwindup_;
236 void Pid::setGains(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup)
238 Gains gains(p,i,
d,i_max,i_min, antiwindup);
258 control_toolbox::ParametersConfig config;
261 getGains(config.p, config.i, config.d, config.i_clamp_max, config.i_clamp_min, config.antiwindup);
272 control_toolbox::ParametersConfig config;
275 config.p = gains_config.p_gain_;
276 config.i = gains_config.i_gain_;
277 config.d = gains_config.d_gain_;
278 config.i_clamp_max = gains_config.i_max_;
279 config.i_clamp_min = gains_config.i_min_;
280 config.antiwindup = gains_config.antiwindup_;
302 setGains(config.p, config.i, config.d, config.i_clamp_max, config.i_clamp_min, config.antiwindup);
308 if (dt ==
ros::Duration(0.0) || std::isnan(error) || std::isinf(error))
314 if (dt.
toSec() > 0.0)
336 double p_term, d_term, i_term;
340 if (dt ==
ros::Duration(0.0) || std::isnan(error) || std::isinf(error) || std::isnan(error_dot) || std::isinf(error_dot))
349 if(gains.antiwindup_ && gains.i_gain_!=0)
352 boost::tuple<double, double> bounds = boost::minmax<double>(gains.i_min_ / gains.i_gain_, gains.i_max_ / gains.i_gain_);
359 if(!gains.antiwindup_)
369 cmd_ = p_term + i_term + d_term;
426 <<
" P Gain: " << gains.p_gain_ <<
"\n"
427 <<
" I Gain: " << gains.i_gain_ <<
"\n"
428 <<
" D Gain: " << gains.d_gain_ <<
"\n"
429 <<
" I_Max: " << gains.i_max_ <<
"\n"
430 <<
" I_Min: " << gains.i_min_ <<
"\n"
431 <<
" Antiwindup: " << gains.antiwindup_ <<
"\n"
436 <<
" Command: " <<
cmd_
#define ROS_DEBUG_STREAM_NAMED(name, args)
bool getParam(const std::string &key, bool &b) const
static const T & clamp(const T &a, const T &b, const T &c)
bool hasParam(const std::string &key) const
T param(const std::string ¶m_name, const T &default_val) const
#define ROS_INFO_STREAM_NAMED(name, args)
const std::string & getNamespace() const
control_toolbox
Author(s): Melonee Wise, Sachin Chitta, John Hsu
autogenerated on Wed May 11 2022 02:09:47