]> git.mxchange.org Git - flightgear.git/commitdiff
gyro heading indicator: realism when spin is low
authorThorstenB <brehmt@gmail.com>
Fri, 21 Sep 2012 13:59:04 +0000 (15:59 +0200)
committerThorstenB <brehmt@gmail.com>
Fri, 21 Sep 2012 13:59:04 +0000 (15:59 +0200)
Low spin or switched off gyros result in the indicator being stuck.
When the gyros are repowered, the indication doesn't jump to the correct
indication, but keeps the current error.

src/Instrumentation/heading_indicator_dg.cxx

index 3f64a0c82a37b070f501cdceb14f4bec9a71539d..52fe89834e6dd27d2a68ff32939251f785d60235 100644 (file)
@@ -148,12 +148,17 @@ HeadingIndicatorDG::update (double dt)
         error += 0.033 * g * dt;
     }
 
-    _error_node->setDoubleValue(error);
-
                                 // Next, calculate the indicated heading,
                                 // introducing errors.
-    double factor = 100 * (spin * spin * spin * spin * spin * spin);
+    double factor = spin * spin * spin * spin * spin * spin;
     double heading = _heading_in_node->getDoubleValue();
+    if (spin < 0.9)
+    {
+        // when gyro spin is low, then any heading change results in
+        // increasing the error (spin=0 => indicator is stuck)
+        error += (_last_heading_deg - heading)*(1-factor);
+    }
+    _error_node->setDoubleValue(error);
 
                                 // Now, we have to get the current
                                 // heading and the last heading into
@@ -162,8 +167,7 @@ HeadingIndicatorDG::update (double dt)
         _last_heading_deg += 360;
     while ((heading - _last_heading_deg) < -180)
         _last_heading_deg -= 360;
-
-    heading = fgGetLowPass(_last_heading_deg, heading, dt * factor);
+    heading = fgGetLowPass(_last_heading_deg, heading, dt * factor * 100);
     _last_heading_deg = heading;
 
     heading += offset + align + error;