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);
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)
95 setGains(p,i,d,i_max,i_min, 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 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)
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_;
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))
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" 436 <<
" Command: " <<
cmd_
#define ROS_DEBUG_STREAM_NAMED(name, args)
#define ROS_INFO_STREAM_NAMED(name, args)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
bool getParam(const std::string &key, std::string &s) const
static const T & clamp(const T &a, const T &b, const T &c)
bool hasParam(const std::string &key) const
const std::string & getNamespace() const