Skip to content

Commit 44eaf81

Browse files
Fix integral action for AntiWindupStrategy::NONE (#432) (#433)
Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
1 parent 6d0482f commit 44eaf81

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

control_toolbox/include/control_toolbox/pid.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct AntiWindupStrategy
143143
"{})",
144144
i_min, i_max));
145145
}
146-
if (std::isfinite(i_min) || std::isfinite(i_max))
146+
if (type != LEGACY && (std::isfinite(i_min) || std::isfinite(i_max)))
147147
{
148148
std::cout << "Warning: The i_min and i_max are only valid for the deprecated LEGACY "
149149
"antiwindup strategy. Please use the AntiWindupStrategy::set_type() method to "

control_toolbox/src/pid.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ bool Pid::set_gains(const Gains & gains_in)
237237
std::string error_msg = "";
238238
if (!gains_in.validate(error_msg))
239239
{
240-
std::cerr << "PID: Invalid gains: " << error_msg << ". SKipping new gains." << std::endl;
240+
std::cerr << "PID: Invalid gains: " << error_msg << ". Skipping new gains." << std::endl;
241241
return false;
242242
}
243243
else
@@ -424,6 +424,11 @@ double Pid::compute_command(double error, double error_dot, const double & dt_s)
424424
i_term_ += dt_s * gains_.i_gain_ * error;
425425
}
426426
}
427+
else if (gains_.antiwindup_strat_.type == AntiWindupStrategy::NONE)
428+
{
429+
// No anti-windup strategy, so just integrate the error
430+
i_term_ += dt_s * gains_.i_gain_ * error;
431+
}
427432
}
428433

429434
return cmd_;

0 commit comments

Comments
 (0)