Skip to content

Commit

Permalink
Merge pull request #1 from ubi-agni/antiwindup-fix-neg-gain
Browse files Browse the repository at this point in the history
Fixed i_error saturation when i_gain is negative
  • Loading branch information
paulbovbel committed Jun 22, 2015
2 parents 8b63dee + 903b53e commit 5633b61
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pid.cpp
Expand Up @@ -363,7 +363,7 @@ double Pid::computeCommand(double error, double error_dot, ros::Duration dt)
if(antiwindup_)
{
// Prevent i_error_ from climbing higher than permitted by i_max_/i_min_
i_error_ = std::max(gains.i_min_ / gains.i_gain_, std::min(i_error_, gains.i_max_ / gains.i_gain_));
i_error_ = std::max(gains.i_min_ / std::fabs(gains.i_gain_), std::min(i_error_, gains.i_max_ / std::fabs(gains.i_gain_)));
}

// Calculate integral contribution to command
Expand Down

0 comments on commit 5633b61

Please sign in to comment.