Skip to content

Commit

Permalink
Fixed i_error saturation when i_gain is negative
Browse files Browse the repository at this point in the history
  • Loading branch information
guihomework authored and Paul Bovbel committed Aug 12, 2015
1 parent e4cd9f8 commit 310bd6f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,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 310bd6f

Please sign in to comment.