From c55874d70e3624d8d559adbda26ad3889b37b45f Mon Sep 17 00:00:00 2001
From: torsten <torsten>
Date: Fri, 19 Mar 2010 20:35:47 +0000
Subject: [PATCH] Fix broken anti windup if the proportional gain runs into the
 nonlinear area and gets clipped. Also fix the wrong debug message.

---
 src/Autopilot/xmlauto.cxx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Autopilot/xmlauto.cxx b/src/Autopilot/xmlauto.cxx
index 9875ba524..2a3349ad8 100644
--- a/src/Autopilot/xmlauto.cxx
+++ b/src/Autopilot/xmlauto.cxx
@@ -615,7 +615,7 @@ void FGPISimpleController::update( double dt ) {
                           << " error = " << error
                           << endl;
 
-        double prop_comp = error * Kp.get_value();
+        double prop_comp = clamp(error * Kp.get_value());
         int_sum += error * Ki.get_value() * dt;
 
 
@@ -628,7 +628,7 @@ void FGPISimpleController::update( double dt ) {
                           << " int_sum = " << int_sum << endl;
 
         set_output_value( clamped_output );
-        if ( debug ) cout << "output = " << output << endl;
+        if ( debug ) cout << "output = " << clamped_output << endl;
     }
 }