Skip to content

Commit

Permalink
Merge pull request ros-controls#21 from jbohren-forks/quiet-pid
Browse files Browse the repository at this point in the history
pid: Adding quiet flag to suppress error message
  • Loading branch information
Adolfo Rodriguez Tsouroukdissian committed May 28, 2014
2 parents 9fb3219 + 2fcbf53 commit 64a8ab2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions include/control_toolbox/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,18 @@ class Pid
* Initializes dynamic reconfigure for PID gains
*
* \param prefix The namespace prefix.
* \param quiet If true, no error messages will be emitted on failure.
*/
bool initParam(const std::string& prefix);
bool initParam(const std::string& prefix, const bool quiet=false);

/*!
* \brief Initialize PID with the parameters in a NodeHandle namespace
* Initializes dynamic reconfigure for PID gains
*
* \param n The NodeHandle which should be used to query parameters.
* \param quiet If true, no error messages will be emitted on failure.
*/
bool init(const ros::NodeHandle &n);
bool init(const ros::NodeHandle &n, const bool quiet=false);

/*!
* \brief Initialize PID with the parameters in an XML element
Expand Down
10 changes: 6 additions & 4 deletions src/pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ void Pid::initPid(double p, double i, double d, double i_max, double i_min)
reset();
}

bool Pid::initParam(const std::string& prefix)
bool Pid::initParam(const std::string& prefix, const bool quiet)
{
ros::NodeHandle nh(prefix);
return init(nh);
return init(nh, quiet);
}

bool Pid::init(const ros::NodeHandle &node)
bool Pid::init(const ros::NodeHandle &node, const bool quiet)
{
ros::NodeHandle nh(node);

Expand All @@ -99,7 +99,9 @@ bool Pid::init(const ros::NodeHandle &node)
// Load PID gains from parameter server
if (!nh.getParam("p", gains.p_gain_))
{
ROS_ERROR("No p gain specified for pid. Namespace: %s", nh.getNamespace().c_str());
if (!quiet) {
ROS_ERROR("No p gain specified for pid. Namespace: %s", nh.getNamespace().c_str());
}
return false;
}
// Only the P gain is required, the I and D gains are optional and default to 0:
Expand Down

0 comments on commit 64a8ab2

Please sign in to comment.