Skip to content

Commit 1a3a441

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

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
@@ -275,12 +275,15 @@ double Pid::compute_command(double error, double error_dot, const double & dt_s)
275275
gains.i_min_, gains.i_max_);
276276
} else if (!gains.antiwindup_ && gains.antiwindup_strat_ == "none") {
277277
i_term_ += gains.i_gain_ * dt_s * p_error_;
278-
i_term_ = std::clamp(i_term_, gains.i_min_, gains.i_max_);
279278
}
280279

281280
// Compute the command
282281
// Limit i_term so that the limit is meaningful in the output
283-
cmd_unsat_ = p_term + i_term_ + d_term;
282+
if (!gains.antiwindup_ && gains.antiwindup_strat_ == "none") {
283+
cmd_unsat_ = p_term + std::clamp(i_term_, gains.i_min_, gains.i_max_) + d_term;
284+
} else {
285+
cmd_unsat_ = p_term + i_term_ + d_term;
286+
}
284287

285288
if (gains.saturation_ == true) {
286289
// Limit cmd_ if saturation is enabled

0 commit comments

Comments
 (0)