From: John Denker Date: Wed, 24 Feb 2010 00:50:02 +0000 (-0700) Subject: Implement gs-direct-deg property. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=54fb3b64d09adf4f981b270c0a4598927172b1ca;p=flightgear.git Implement gs-direct-deg property. Useful when posing aircraft for pictures, not quite on glideslope. --- diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 4be95c416..f5c964581 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -231,6 +231,7 @@ FGNavRadio::init () gs_deflection_node = node->getChild("gs-needle-deflection", 0, true); gs_deflection_deg_node = node->getChild("gs-needle-deflection-deg", 0, true); gs_deflection_norm_node = node->getChild("gs-needle-deflection-norm", 0, true); + gs_direct_node = node->getChild("gs-direct-deg", 0, true); gs_rate_of_climb_node = node->getChild("gs-rate-of-climb", 0, true); gs_rate_of_climb_fpm_node = node->getChild("gs-rate-of-climb-fpm", 0, true); gs_dist_node = node->getChild("gs-distance", 0, true); @@ -393,6 +394,7 @@ void FGNavRadio::clearOutputs() gs_deflection_node->setDoubleValue( 0.0 ); gs_deflection_deg_node->setDoubleValue(0.0); gs_deflection_norm_node->setDoubleValue(0.0); + gs_direct_node->setDoubleValue(0.0); gs_inrange_node->setBoolValue( false ); loc_node->setBoolValue( false ); has_gs_node->setBoolValue(false); @@ -592,19 +594,15 @@ void FGNavRadio::updateGlideSlope(double dt, const SGVec3d& aircraft, double sig bool gsInRange = (gsDist < (_gs->get_range() * SG_NM_TO_METER)); gs_inrange_node->setBoolValue(gsInRange); - if (!gsInRange) { - _gsNeedleDeflection = 0.0; - _gsNeedleDeflectionNorm = 0.0; - return; - } + if (!gsInRange) return; SGVec3d pos = aircraft - _gsCart; // relative vector from gs antenna to aircraft // The positive GS axis points along the runway in the landing direction, // toward the far end, not toward the approach area, so we need a - sign here: double dot_h = -dot(pos, _gsAxis); double dot_v = dot(pos, _gsVertical); - double angle = atan2(dot_v, dot_h) * SGD_RADIANS_TO_DEGREES; - double deflectionAngle = target_gs - angle; + _gsDirect = atan2(dot_v, dot_h) * SGD_RADIANS_TO_DEGREES; + double deflectionAngle = target_gs - _gsDirect; if (falseCoursesEnabledNode->getBoolValue()) { // Construct false glideslopes. The scale factor of 1.5 @@ -633,11 +631,11 @@ void FGNavRadio::updateGlideSlope(double dt, const SGVec3d& aircraft, double sig ////////////////////////////////////////////////////////// // Calculate desired rate of climb for intercepting the GS ////////////////////////////////////////////////////////// - double gs_diff = target_gs - angle; + double gs_diff = target_gs - _gsDirect; // convert desired vertical path angle into a climb rate - double des_angle = angle - 10 * gs_diff; + double des_angle = _gsDirect - 10 * gs_diff; /* printf("target_gs=%.1f angle=%.1f gs_diff=%.1f des_angle=%.1f\n", - target_gs, angle, gs_diff, des_angle); */ + target_gs, _gsDirect, gs_diff, des_angle); */ // estimate horizontal speed towards ILS in meters per minute double elapsedDistance = last_x - gsDist; @@ -798,7 +796,7 @@ void FGNavRadio::updateCDI(double dt) ////////////////////////////////////////////////////////// // compute the time to intercept selected radial (based on - // current and last cross track errors and dt + // current and last cross track errors and dt) ////////////////////////////////////////////////////////// double t = 0.0; if ( inrange && cdi_serviceable ) { @@ -819,6 +817,7 @@ void FGNavRadio::updateCDI(double dt) gs_deflection_node->setDoubleValue(_gsNeedleDeflection); gs_deflection_deg_node->setDoubleValue(_gsNeedleDeflectionNorm * 0.7); gs_deflection_norm_node->setDoubleValue(_gsNeedleDeflectionNorm); + gs_direct_node->setDoubleValue(_gsDirect); last_xtrack_error = _cdiCrossTrackErrorM; } diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index 5aa1c7229..5f81a8a08 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -102,6 +102,7 @@ class FGNavRadio : public SGSubsystem, public SGPropertyChangeListener SGPropertyNode_ptr gs_deflection_node; SGPropertyNode_ptr gs_deflection_deg_node; SGPropertyNode_ptr gs_deflection_norm_node; + SGPropertyNode_ptr gs_direct_node; SGPropertyNode_ptr gs_rate_of_climb_node; SGPropertyNode_ptr gs_rate_of_climb_fpm_node; SGPropertyNode_ptr gs_dist_node; @@ -163,6 +164,7 @@ class FGNavRadio : public SGSubsystem, public SGPropertyChangeListener double _cdiCrossTrackErrorM; double _gsNeedleDeflection; double _gsNeedleDeflectionNorm; + double _gsDirect; SGSharedPtr _sgr; std::vector _tiedNodes;