Skip to content
Snippets Groups Projects
Commit 1d185911 authored by Mirko Wächter's avatar Mirko Wächter
Browse files

PIDController: added conditional integral based on error value

parent d1e7bfed
No related branches found
No related tags found
No related merge requests found
......@@ -127,8 +127,11 @@ void PIDController::update(double deltaSec, double measuredValue, double targetV
// ARMARX_INFO << deactivateSpam() << VAROUT(dt);
if (!firstRun)
{
integral += error * deltaSec;
integral = math::MathUtils::LimitTo(integral, maxIntegral);
if (error < conditionalIntegralErrorTreshold)
{
integral += error * deltaSec;
integral = math::MathUtils::LimitTo(integral, maxIntegral);
}
if (deltaSec > 0.0)
{
derivative = (error - previousError) / deltaSec;
......
......@@ -54,6 +54,7 @@ namespace armarx
float Kp, Ki, Kd;
double integral;
double maxIntegral = std::numeric_limits<double>::max();
double conditionalIntegralErrorTreshold = std::numeric_limits<double>::max(); // anti-windup
double derivative;
double previousError;
double processValue;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment