Skip to content

Commit fc07bd3

Browse files
committed
Modify cmd eq. to keep the anti-windup behavior
1 parent e2190ac commit fc07bd3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

control_toolbox/src/pid.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,15 @@ double Pid::compute_command(double error, double error_dot, const double & dt_s)
278278
gains.i_min_, gains.i_max_);
279279
} else if (!gains.antiwindup_ && gains.antiwindup_strat_ == "none") {
280280
i_term_ += gains.i_gain_ * dt_s * p_error_;
281-
i_term_ = std::clamp(i_term_, gains.i_min_, gains.i_max_);
282281
}
283282

284283
// Compute the command
285284
// Limit i_term so that the limit is meaningful in the output
286-
cmd_unsat_ = p_term + i_term_ + d_term;
285+
if (!gains.antiwindup_ && gains.antiwindup_strat_ == "none") {
286+
cmd_unsat_ = p_term + std::clamp(i_term_, gains.i_min_, gains.i_max_) + d_term;
287+
} else {
288+
cmd_unsat_ = p_term + i_term_ + d_term;
289+
}
287290

288291
if (gains.saturation_ == true) {
289292
// Limit cmd_ if saturation is enabled

0 commit comments

Comments
 (0)