]> git.mxchange.org Git - flightgear.git/commitdiff
Tweaks relating to autopilot heading hold.
authorcurt <curt>
Sun, 25 Feb 2001 04:45:26 +0000 (04:45 +0000)
committercurt <curt>
Sun, 25 Feb 2001 04:45:26 +0000 (04:45 +0000)
Working on better modeling of nav radio needles.

src/Cockpit/radiostack.cxx
src/Cockpit/radiostack.hxx
src/Cockpit/steam.cxx
src/Cockpit/steam.hxx
src/Main/bfi.cxx
src/Main/keyboard.cxx

index da20288aa0302ed2a85f5abb55dcd2237090f318..30140293351446a96190398737f06a2337a3c04e 100644 (file)
@@ -113,6 +113,10 @@ FGRadioStack::bind ()
     fgTie("/radios/nav1/dme/distance", this, &FGRadioStack::get_nav1_dme_dist);
     fgTie("/radios/nav1/dme/in-range", this,
          &FGRadioStack::get_nav1_dme_inrange);
+    fgTie("/radios/nav1/heading-needle-deflection", this,
+         &FGRadioStack::get_nav1_heading_needle_deflection);
+    fgTie("/radios/nav1/gs-needle-deflection", this,
+         &FGRadioStack::get_nav1_gs_needle_deflection);
 
                                // User inputs
     fgTie("/radios/nav2/frequencies/selected", this,
@@ -131,6 +135,10 @@ FGRadioStack::bind ()
     fgTie("/radios/nav2/dme/distance", this, &FGRadioStack::get_nav2_dme_dist);
     fgTie("/radios/nav2/dme/in-range", this,
          &FGRadioStack::get_nav2_dme_inrange);
+    fgTie("/radios/nav1/heading-needle-deflection", this,
+         &FGRadioStack::get_nav2_heading_needle_deflection);
+    fgTie("/radios/nav1/gs-needle-deflection", this,
+         &FGRadioStack::get_nav2_gs_needle_deflection);
 
                                // User inputs
     fgTie("/radios/adf/frequencies/selected", this,
@@ -153,6 +161,8 @@ FGRadioStack::unbind ()
     fgUntie("/radios/nav1/in-range");
     fgUntie("/radios/nav1/dme/distance");
     fgUntie("/radios/nav1/dme/in-range");
+    fgUntie("/radios/nav1/heading-needle-deflection");
+    fgUntie("/radios/nav1/gs-needle-deflection");
 
     fgUntie("/radios/nav2/frequencies/selected");
     fgUntie("/radios/nav2/frequencies/standby");
@@ -163,6 +173,8 @@ FGRadioStack::unbind ()
     fgUntie("/radios/nav2/in-range");
     fgUntie("/radios/nav2/dme/distance");
     fgUntie("/radios/nav2/dme/in-range");
+    fgUntie("/radios/nav2/heading-needle-deflection");
+    fgUntie("/radios/nav2/gs-needle-deflection");
 
     fgUntie("/radios/adf/frequencies/selected");
     fgUntie("/radios/adf/frequencies/standby");
@@ -433,6 +445,84 @@ void FGRadioStack::search ()
 }
 
 
+// return the amount of heading needle deflection, returns a value
+// clamped to the range of ( -10 , 10 )
+double FGRadioStack::get_nav1_heading_needle_deflection() const {
+    double r;
+
+    if ( nav1_inrange ) {
+        r = nav1_heading - nav1_radial;
+       // cout << "Radial = " << nav1_radial 
+       //      << "  Bearing = " << nav1_heading << endl;
+    
+       while (r> 180.0) r-=360.0;
+       while (r<-180.0) r+=360.0;
+       if ( fabs(r) > 90.0 )
+           r = ( r<0.0 ? -r-180.0 : -r+180.0 );
+       // According to Robin Peel, the ILS is 4x more sensitive than a vor
+       if ( nav1_loc ) r *= 4.0;
+       if ( r < -10.0 ) r = -10.0;
+       if ( r > 10.0 ) r = 10.0;
+    } else {
+       r = 0.0;
+    }
+
+    return r;
+}
+
+// return the amount of heading needle deflection, returns a value
+// clamped to the range of ( -10 , 10 )
+double FGRadioStack::get_nav2_heading_needle_deflection() const {
+    double r;
+
+    if ( nav2_inrange ) {
+        r = nav2_heading - nav2_radial;
+       // cout << "Radial = " << nav1_radial 
+       //      << "  Bearing = " << nav1_heading << endl;
+    
+       while (r> 180.0) r-=360.0;
+       while (r<-180.0) r+=360.0;
+       if ( fabs(r) > 90.0 )
+           r = ( r<0.0 ? -r-180.0 : -r+180.0 );
+       // According to Robin Peel, the ILS is 4x more sensitive than a vor
+       if ( nav1_loc ) r *= 4.0;
+       if ( r < -10.0 ) r = -10.0;
+       if ( r > 10.0 ) r = 10.0;
+    } else {
+       r = 0.0;
+    }
+
+    return r;
+}
+
+// return the amount of glide slope needle deflection (.i.e. the
+// number of degrees we are off the glide slope * 5.0
+double FGRadioStack::get_nav1_gs_needle_deflection() const {
+    if ( nav1_inrange && nav1_has_gs ) {
+       double x = nav1_gs_dist;
+       double y = (FGBFI::getAltitude() - nav1_elev) * FEET_TO_METER;
+       double angle = atan2( y, x ) * RAD_TO_DEG;
+       return (nav1_target_gs - angle) * 5.0;
+    } else {
+       return 0.0;
+    }
+}
+
+
+// return the amount of glide slope needle deflection (.i.e. the
+// number of degrees we are off the glide slope * 5.0
+double FGRadioStack::get_nav2_gs_needle_deflection() const {
+    if ( nav2_inrange && nav2_has_gs ) {
+       double x = nav2_gs_dist;
+       double y = (FGBFI::getAltitude() - nav2_elev) * FEET_TO_METER;
+       double angle = atan2( y, x ) * RAD_TO_DEG;
+       return (nav2_target_gs - angle) * 5.0;
+    } else {
+       return 0.0;
+    }
+}
+
+
 /**
  * Return true if the NAV1 TO flag should be active.
  */
@@ -444,7 +534,7 @@ FGRadioStack::get_nav1_to_flag () const
     if (nav1_loc)
       return (offset <= 8.0 || offset >= 352.0);
     else
-      return (offset <= 20.0 || offset >= 340.0);
+      return (offset <= 90.0 || offset >= 270.0);
   } else {
     return false;
   }
@@ -462,7 +552,7 @@ FGRadioStack::get_nav1_from_flag () const
     if (nav1_loc)
       return (offset >= 172.0 && offset <= 188.0);
     else
-      return (offset >= 160.0 && offset <= 200.0);
+      return (offset > 90.0 && offset < 270.0);
   } else {
     return false;
   }
@@ -480,7 +570,7 @@ FGRadioStack::get_nav2_to_flag () const
     if (nav2_loc)
       return (offset <= 8.0 || offset >= 352.0);
     else
-      return (offset <= 20.0 || offset >= 340.0);
+      return (offset <= 90.0 || offset >= 270.0);
   } else {
     return false;
   }
@@ -498,7 +588,7 @@ FGRadioStack::get_nav2_from_flag () const
     if (nav2_loc)
       return (offset >= 172.0 && offset <= 188.0);
     else
-      return (offset >= 160.0 && offset <= 200.0);
+      return (offset > 90.0 && offset < 270.0);
   } else {
     return false;
   }
index 4014943185924daef911f0f4fdcee2e5e5d0bd28..c2031790322f9a2ffc9de23e89dbbd0fe9c6368d 100644 (file)
@@ -203,6 +203,8 @@ public:
     inline double get_nav1_radial() const { return nav1_radial; }
     inline double get_nav1_target_gs() const { return nav1_target_gs; }
     inline double get_nav1_magvar() const { return nav1_magvar; }
+    double get_nav1_heading_needle_deflection() const;
+    double get_nav1_gs_needle_deflection() const;
 
     inline bool get_nav2_inrange() const { return nav2_inrange; }
     bool get_nav2_to_flag () const;
@@ -227,6 +229,8 @@ public:
     inline double get_nav2_radial() const { return nav2_radial; }
     inline double get_nav2_target_gs() const { return nav2_target_gs; }
     inline double get_nav2_magvar() const { return nav2_magvar; }
+    double get_nav2_heading_needle_deflection() const;
+    double get_nav2_gs_needle_deflection() const;
 
     inline bool get_adf_inrange() const { return adf_inrange; }
     inline double get_adf_lon() const { return adf_lon; }
index 1132e0859debead34e9fa43d5f24d08f58e123e4..ebd8c593c121c604c01005bf4ff9e00a9abe7744 100644 (file)
@@ -118,9 +118,9 @@ void FGSteam::update ( int timesteps )
          fgTie("/steam/slip-skid", FGSteam::get_TC_rad);
          fgTie("/steam/vertical-speed", FGSteam::get_VSI_fps);
          fgTie("/steam/gyro-compass", FGSteam::get_DG_deg);
-         fgTie("/steam/vor1", FGSteam::get_HackVOR1_deg);
-         fgTie("/steam/vor2", FGSteam::get_HackVOR2_deg);
-         fgTie("/steam/glidescope1", FGSteam::get_HackGS_deg);
+         // fgTie("/steam/vor1", FGSteam::get_HackVOR1_deg);
+         // fgTie("/steam/vor2", FGSteam::get_HackVOR2_deg);
+         // fgTie("/steam/glidescope1", FGSteam::get_HackGS_deg);
          fgTie("/steam/adf", FGSteam::get_HackADF_deg);
          fgTie("/steam/gyro-compass-error",
                FGSteam::get_DG_err, FGSteam::set_DG_err,
@@ -413,6 +413,8 @@ void FGSteam::_CatchUp()
 ////////////////////////////////////////////////////////////////////////
 
 
+#if 0
+
 double FGSteam::get_HackGS_deg () {
     if ( current_radiostack->get_nav1_inrange() && 
         current_radiostack->get_nav1_has_gs() )
@@ -471,6 +473,7 @@ double FGSteam::get_HackVOR2_deg () {
 
     return r;
 }
+#endif
 
 
 double FGSteam::get_HackOBS1_deg () {
index ed31f803bd936adb9facbca7b4aeb6fc817853b6..b2ffda9ff6634b8f517cba93f3b107f468ebba97 100644 (file)
@@ -77,10 +77,10 @@ public:
   static void set_ALT_datum_mb(double datum_mb);
 
                                // Hacks ... temporary stuff
-  static double get_HackVOR1_deg ();
+  // static double get_HackVOR1_deg ();
   static double get_HackOBS1_deg ();
-  static double get_HackGS_deg ();
-  static double get_HackVOR2_deg ();
+  // static double get_HackGS_deg ();
+  // static double get_HackVOR2_deg ();
   static double get_HackOBS2_deg ();
   static double get_HackADF_deg ();
 
index 63687fea0d9cc513f6d956a59fd5e9543fbd1c6d..5c8aedf904c852831bb98bed3331b47d5e5d74d6 100644 (file)
@@ -1005,7 +1005,7 @@ FGBFI::getAPHeadingLock ()
 {
     return
       (current_autopilot->get_HeadingEnabled() &&
-       current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
+       current_autopilot->get_HeadingMode() == FGAutopilot::FG_DG_HEADING_LOCK);
 }
 
 
@@ -1021,11 +1021,11 @@ FGBFI::setAPHeadingLock (bool lock)
                                // heading other than the current
                                // heading.
     double heading = getAPHeadingMag();
-    current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
+    current_autopilot->set_HeadingMode(FGAutopilot::FG_DG_HEADING_LOCK);
     current_autopilot->set_HeadingEnabled(true);
     setAPHeadingMag(heading);
   } else if (current_autopilot->get_HeadingMode() ==
-            FGAutopilot::FG_HEADING_LOCK) {
+            FGAutopilot::FG_DG_HEADING_LOCK) {
     current_autopilot->set_HeadingEnabled(false);
   }
 }
index 22c937da7c98a4d716b51b47020d0eeec758b895..faf28ecdef80d1ccafca55f9b38c935ef4977d31 100644 (file)
@@ -559,7 +559,7 @@ void GLUTspecialkey(int k, int x, int y) {
                current_autopilot->set_HeadingEnabled( true );
            } else {
                current_autopilot->set_HeadingMode(
-                   FGAutopilot::FG_HEADING_LOCK );
+                   FGAutopilot::FG_DG_HEADING_LOCK );
            }
            return;
        case GLUT_KEY_F8: {// F8 toggles fog ... off fastest nicest...