]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGActuator.cpp
Merge branch 'next' of git://gitorious.org/fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGActuator.cpp
old mode 100755 (executable)
new mode 100644 (file)
index ae2aa38..52faac0
@@ -43,7 +43,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGActuator.cpp,v 1.19 2011/06/18 13:30:27 bcoconni Exp $";
 static const char *IdHdr = ID_ACTUATOR;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -143,7 +143,10 @@ void FGActuator::Lag(void)
   // "Output" on the right side of the "=" is the current frame input
   // for this Lag filter
   double input = Output;
-  Output = ca * (input + PreviousLagInput) + PreviousLagOutput * cb;
+
+  if (!fcs->GetTrimStatus())
+    Output = ca * (input + PreviousLagInput) + PreviousLagOutput * cb;
+
   PreviousLagInput = input;
   PreviousLagOutput = Output;
 }
@@ -157,10 +160,11 @@ void FGActuator::Hysteresis(void)
   // method.
   double input = Output;
   
-  if (input > PreviousHystOutput) {
-    Output = max(PreviousHystOutput, input-0.5*hysteresis_width);
-  } else if (input < PreviousHystOutput) {
-    Output = min(PreviousHystOutput, input+0.5*hysteresis_width);
+  if (!fcs->GetTrimStatus()) {
+    if (input > PreviousHystOutput)
+      Output = max(PreviousHystOutput, input-0.5*hysteresis_width);
+    else if (input < PreviousHystOutput)
+      Output = min(PreviousHystOutput, input+0.5*hysteresis_width);
   }
 
   PreviousHystOutput = Output;
@@ -174,7 +178,7 @@ void FGActuator::RateLimit(void)
   // is - for the purposes of this RateLimit method - really the input to the
   // method.
   double input = Output;
-  if (dt > 0.0) {
+  if (!fcs->GetTrimStatus()) {
     double rate = (input - PreviousRateLimOutput)/dt;
     if (fabs(rate) > rate_limit) {
       Output = PreviousRateLimOutput + (rate_limit*fabs(rate)/rate)*dt;
@@ -187,6 +191,18 @@ void FGActuator::RateLimit(void)
 
 void FGActuator::Deadband(void)
 {
+  // Note: this function acts cumulatively on the "Output" parameter. So, "Output"
+  // is - for the purposes of this Deadband method - really the input to the
+  // method.
+  double input = Output;
+
+  if (input < -deadband_width/2.0) {
+    Output = (input + deadband_width/2.0);
+  } else if (input > deadband_width/2.0) {
+    Output = (input - deadband_width/2.0);
+  } else {
+    Output = 0.0;
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -232,9 +248,9 @@ void FGActuator::Debug(int from)
   if (debug_lvl & 1) { // Standard console startup message output
     if (from == 0) { // Constructor
       if (InputSigns[0] < 0)
-        cout << "      INPUT: -" << InputNodes[0]->getName() << endl;
+        cout << "      INPUT: -" << InputNames[0] << endl;
       else
-        cout << "      INPUT: " << InputNodes[0]->getName() << endl;
+        cout << "      INPUT: " << InputNames[0] << endl;
 
       if (IsOutput) {
         for (unsigned int i=0; i<OutputNodes.size(); i++)