From: curt Date: Sun, 25 Feb 2001 04:45:26 +0000 (+0000) Subject: Tweaks relating to autopilot heading hold. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=75a538f5b920acf3db0bd6a54c1dfb4bc73eaea5;p=flightgear.git Tweaks relating to autopilot heading hold. Working on better modeling of nav radio needles. --- diff --git a/src/Cockpit/radiostack.cxx b/src/Cockpit/radiostack.cxx index da20288aa..301402933 100644 --- a/src/Cockpit/radiostack.cxx +++ b/src/Cockpit/radiostack.cxx @@ -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; } diff --git a/src/Cockpit/radiostack.hxx b/src/Cockpit/radiostack.hxx index 401494318..c20317903 100644 --- a/src/Cockpit/radiostack.hxx +++ b/src/Cockpit/radiostack.hxx @@ -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; } diff --git a/src/Cockpit/steam.cxx b/src/Cockpit/steam.cxx index 1132e0859..ebd8c593c 100644 --- a/src/Cockpit/steam.cxx +++ b/src/Cockpit/steam.cxx @@ -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 () { diff --git a/src/Cockpit/steam.hxx b/src/Cockpit/steam.hxx index ed31f803b..b2ffda9ff 100644 --- a/src/Cockpit/steam.hxx +++ b/src/Cockpit/steam.hxx @@ -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 (); diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 63687fea0..5c8aedf90 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -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); } } diff --git a/src/Main/keyboard.cxx b/src/Main/keyboard.cxx index 22c937da7..faf28ecde 100644 --- a/src/Main/keyboard.cxx +++ b/src/Main/keyboard.cxx @@ -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...