Skip to content

Commit 2a77d33

Browse files
committed
Apply integral clamping to all strategies
1 parent 86e2a58 commit 2a77d33

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

control_toolbox/src/pid.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,12 @@ double Pid::compute_command(double error, double error_dot, const double & dt_s)
306306
{
307307
i_term_ += dt_s * (gains_.i_gain_ * error +
308308
1 / gains_.antiwindup_strat_.tracking_time_constant * (cmd_ - cmd_unsat_));
309-
310-
i_term_ = std::clamp(i_term_, gains_.i_min_, gains_.i_max_);
311309
}
312310
else if (gains_.antiwindup_strat_.type == AntiWindupStrategy::CONDITIONAL_INTEGRATION)
313311
{
314312
if (!(!is_zero(cmd_unsat_ - cmd_) && error * cmd_unsat_ > 0))
315313
{
316314
i_term_ += dt_s * gains_.i_gain_ * error;
317-
318-
i_term_ = std::clamp(i_term_, gains_.i_min_, gains_.i_max_);
319315
}
320316
}
321317
else if (gains_.antiwindup_strat_.type == AntiWindupStrategy::NONE)
@@ -325,6 +321,8 @@ double Pid::compute_command(double error, double error_dot, const double & dt_s)
325321
}
326322
}
327323

324+
i_term_ = std::clamp(i_term_, gains_.i_min_, gains_.i_max_);
325+
328326
return cmd_;
329327
}
330328

0 commit comments

Comments
 (0)