Skip to content

Commit bb3d469

Browse files
committed
Modify cmd eq. to keep the anti-windup behavior
1 parent 2e9e320 commit bb3d469

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/pid.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,15 @@ double Pid::compute_command(double error, double error_dot, const double & dt_s)
251251
gains.i_min_, gains.i_max_);
252252
} else if (!gains.antiwindup_ && gains.antiwindup_strat_ == "none") {
253253
i_term_ += gains.i_gain_ * dt_s * p_error_;
254-
i_term_ = std::clamp(i_term_, gains.i_min_, gains.i_max_);
255254
}
256255

257256
// Compute the command
258257
// Limit i_term so that the limit is meaningful in the output
259-
cmd_unsat_ = p_term + i_term_ + d_term;
258+
if (!gains.antiwindup_ && gains.antiwindup_strat_ == "none") {
259+
cmd_unsat_ = p_term + std::clamp(i_term_, gains.i_min_, gains.i_max_) + d_term;
260+
} else {
261+
cmd_unsat_ = p_term + i_term_ + d_term;
262+
}
260263

261264
if (gains.saturation_ == true) {
262265
// Limit cmd_ if saturation is enabled

0 commit comments

Comments
 (0)