]> git.mxchange.org Git - flightgear.git/commitdiff
Fixed a typo preventing the nav2 heading needle from moving.
authorcurt <curt>
Sun, 25 Feb 2001 16:26:48 +0000 (16:26 +0000)
committercurt <curt>
Sun, 25 Feb 2001 16:26:48 +0000 (16:26 +0000)
DG heading bug initializes to a random setting.
Activating heading hold doesn't touch the DG heading bug any more.
Max autopilot decent rate is now -1000.

src/Autopilot/newauto.cxx
src/Cockpit/radiostack.cxx
src/Main/bfi.cxx

index 407f10ab971ce6647ad637642aaf32572fcd2aee..71b1009bd5998a6d84fb4b18cdb0148d9d6106de 100644 (file)
@@ -32,6 +32,7 @@
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/sg_geodesy.hxx>
+#include <simgear/math/sg_random.h>
 
 #include <Cockpit/steam.hxx>
 #include <Cockpit/radiostack.hxx>
@@ -51,6 +52,7 @@ FGAutopilot *current_autopilot;
 const double min_climb = 70.0; // kts
 const double best_climb = 75.0;        // kts
 const double ideal_climb_rate = 500.0 * FEET_TO_METER; // fpm -> mpm
+const double ideal_decent_rate = 1000.0 * FEET_TO_METER; // fpm -> mpm
 
 /// These statics will eventually go into the class
 /// they are just here while I am experimenting -- NHV :-)
@@ -208,6 +210,9 @@ void FGAutopilot::init() {
     altitude_hold = false ;     // turn the altitude hold off
     auto_throttle = false ;    // turn the auto throttle off
 
+    sg_srandom_time();
+    DGTargetHeading = sg_random() * 360.0;
+
     // Initialize target location to startup location
     old_lat = FGBFI::getLatitude();
     old_lon = FGBFI::getLongitude();
@@ -638,13 +643,15 @@ int FGAutopilot::run() {
            TargetClimbRate = max_climb;
        }
 
-       if ( TargetClimbRate < -ideal_climb_rate ) {
-           TargetClimbRate = -ideal_climb_rate;
+       if ( TargetClimbRate < -ideal_decent_rate ) {
+           TargetClimbRate = -ideal_decent_rate;
        }
+       // cout << "Target climb = " << TargetClimbRate * METER_TO_FEET 
+       //      << " fpm" << endl;
 
        error = FGBFI::getVerticalSpeed() * FEET_TO_METER - TargetClimbRate;
-       // cout << "climb rate = " << fgAPget_climb() 
-       //      << "  error = " << error << endl;
+       cout << "climb rate = " << FGBFI::getVerticalSpeed()
+            << "  vsi rate = " << FGSteam::get_VSI_fps() << endl;
 
        // accumulate the error under the curve ... this really should
        // be *= delta t
@@ -761,7 +768,9 @@ void FGAutopilot::set_HeadingMode( fgAutoHeadingMode mode ) {
 
     if ( heading_mode == FG_DG_HEADING_LOCK ) {
        // set heading hold to current heading (as read from DG)
-       DGTargetHeading = FGSteam::get_DG_deg();
+       // ... no, leave target heading along ... just use the current
+       // heading bug value
+        //  DGTargetHeading = FGSteam::get_DG_deg();
     } else if ( heading_mode == FG_HEADING_LOCK ) {
        // set heading hold to current heading
        TargetHeading = FGBFI::getHeading();
index 30140293351446a96190398737f06a2337a3c04e..62096af5d809bddc671c5c3f9b9a071ee1e67214 100644 (file)
@@ -135,9 +135,9 @@ 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,
+    fgTie("/radios/nav2/heading-needle-deflection", this,
          &FGRadioStack::get_nav2_heading_needle_deflection);
-    fgTie("/radios/nav1/gs-needle-deflection", this,
+    fgTie("/radios/nav2/gs-needle-deflection", this,
          &FGRadioStack::get_nav2_gs_needle_deflection);
 
                                // User inputs
@@ -477,15 +477,15 @@ double FGRadioStack::get_nav2_heading_needle_deflection() const {
 
     if ( nav2_inrange ) {
         r = nav2_heading - nav2_radial;
-       // cout << "Radial = " << nav1_radial 
-       //      << "  Bearing = " << nav1_heading << endl;
+       // cout << "Radial = " << nav2_radial 
+       //      << "  Bearing = " << nav2_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 ( nav2_loc ) r *= 4.0;
        if ( r < -10.0 ) r = -10.0;
        if ( r > 10.0 ) r = 10.0;
     } else {
@@ -532,7 +532,7 @@ FGRadioStack::get_nav1_to_flag () const
   if (nav1_inrange) {
     double offset = fabs(nav1_heading - nav1_radial);
     if (nav1_loc)
-      return (offset <= 8.0 || offset >= 352.0);
+      return true;
     else
       return (offset <= 90.0 || offset >= 270.0);
   } else {
@@ -550,7 +550,7 @@ FGRadioStack::get_nav1_from_flag () const
   if (nav1_inrange) {
     double offset = fabs(nav1_heading - nav1_radial);
     if (nav1_loc)
-      return (offset >= 172.0 && offset <= 188.0);
+      return false;
     else
       return (offset > 90.0 && offset < 270.0);
   } else {
@@ -568,7 +568,7 @@ FGRadioStack::get_nav2_to_flag () const
   if (nav2_inrange) {
     double offset = fabs(nav2_heading - nav2_radial);
     if (nav2_loc)
-      return (offset <= 8.0 || offset >= 352.0);
+      return true;
     else
       return (offset <= 90.0 || offset >= 270.0);
   } else {
@@ -586,7 +586,7 @@ FGRadioStack::get_nav2_from_flag () const
   if (nav2_inrange) {
     double offset = fabs(nav2_heading - nav2_radial);
     if (nav2_loc)
-      return (offset >= 172.0 && offset <= 188.0);
+      return false;
     else
       return (offset > 90.0 && offset < 270.0);
   } else {
@@ -594,4 +594,3 @@ FGRadioStack::get_nav2_from_flag () const
   }
 }
 
-
index 5c8aedf904c852831bb98bed3331b47d5e5d74d6..84619534383c3365000b807b5271d1e7be157ac8 100644 (file)
@@ -167,6 +167,7 @@ _set_view_from_axes ()
 // Local functions
 ////////////////////////////////////////////////////////////////////////
 
+
 /**
  * Initialize the BFI by binding its functions to properties.
  *
@@ -197,7 +198,7 @@ FGBFI::init ()
   fgTie("/autopilot/settings/altitude", getAPAltitude, setAPAltitude);
   fgTie("/autopilot/locks/heading", getAPHeadingLock, setAPHeadingLock);
   fgTie("/autopilot/settings/heading", getAPHeading, setAPHeading);
-  fgTie("/autopilot/settings/heading-dg", getAPHeadingDG, setAPHeadingDG);
+  fgTie("/autopilot/settings/heading-dg", getAPHeadingDG, setAPHeadingDG, false);
   fgTie("/autopilot/settings/heading-magnetic",
              getAPHeadingMag, setAPHeadingMag);
   fgTie("/autopilot/locks/nav1", getAPNAV1Lock, setAPNAV1Lock);