1
0
Fork 0

Rename some existing variables/methods in the navcomm module for

clarity:

  nav_radial => nav_target_radial (same as selected, except for a LOC)
  nav_heading => nav_reciprocal_radial
  nav_magvar => nav_twist (it's not always the same as magvar)
  nav_heading_needle_deflection => nav_cdi_deflection
  nav_gs_needle_deflection => nav_gs_deflection

Added nav_radial back in, but now it shows the current radial from the
VOR, as one would expect.  This value also appears in the
/radios/nav[*]/radials/actual-deg property.
This commit is contained in:
david 2003-07-04 19:13:03 +00:00
parent fa4d245555
commit ba8b2bfca3
4 changed files with 53 additions and 53 deletions

View file

@ -519,12 +519,12 @@ FGAutopilot::update (double dt)
// determine our current radial position relative to the // determine our current radial position relative to the
// navaid in "true" heading. // navaid in "true" heading.
double cur_radial = current_radiostack->get_navcom1()->get_nav_heading(); double cur_radial = current_radiostack->get_navcom1()->get_nav_reciprocal_radial();
if ( current_radiostack->get_navcom1()->get_nav_loc() ) { if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
// ILS localizers radials are already "true" in our // ILS localizers radials are already "true" in our
// database // database
} else { } else {
cur_radial += current_radiostack->get_navcom1()->get_nav_magvar(); cur_radial += current_radiostack->get_navcom1()->get_nav_twist();
} }
if ( current_radiostack->get_navcom1()->get_nav_from_flag() ) { if ( current_radiostack->get_navcom1()->get_nav_from_flag() ) {
cur_radial += 180.0; cur_radial += 180.0;
@ -538,18 +538,18 @@ FGAutopilot::update (double dt)
// database // database
} else { } else {
// VOR radials need to have that vor's offset added in // VOR radials need to have that vor's offset added in
tgt_radial += current_radiostack->get_navcom1()->get_nav_magvar(); tgt_radial += current_radiostack->get_navcom1()->get_nav_twist();
} }
// determine the heading adjustment needed. // determine the heading adjustment needed.
double adjustment = double adjustment =
current_radiostack->get_navcom1()->get_nav_heading_needle_deflection() current_radiostack->get_navcom1()->get_nav_cdi_deflection()
* (current_radiostack->get_navcom1()->get_nav_loc_dist() * SG_METER_TO_NM); * (current_radiostack->get_navcom1()->get_nav_loc_dist() * SG_METER_TO_NM);
SG_CLAMP_RANGE( adjustment, -30.0, 30.0 ); SG_CLAMP_RANGE( adjustment, -30.0, 30.0 );
// clamp closer when inside cone when beyond 5km... // clamp closer when inside cone when beyond 5km...
if (current_radiostack->get_navcom1()->get_nav_loc_dist() > 5000) { if (current_radiostack->get_navcom1()->get_nav_loc_dist() > 5000) {
double clamp_angle = fabs(current_radiostack->get_navcom1()->get_nav_heading_needle_deflection()) * 3; double clamp_angle = fabs(current_radiostack->get_navcom1()->get_nav_cdi_deflection()) * 3;
if (clamp_angle < 30) if (clamp_angle < 30)
SG_CLAMP_RANGE( adjustment, -clamp_angle, clamp_angle); SG_CLAMP_RANGE( adjustment, -clamp_angle, clamp_angle);
} }

View file

@ -59,7 +59,7 @@ FGNavCom::FGNavCom() :
comm_vol_btn(0.0), comm_vol_btn(0.0),
nav_freq(0.0), nav_freq(0.0),
nav_alt_freq(0.0), nav_alt_freq(0.0),
nav_radial(0.0), nav_target_radial(0.0),
nav_vol_btn(0.0), nav_vol_btn(0.0),
nav_ident_btn(true) nav_ident_btn(true)
{ {
@ -193,13 +193,13 @@ FGNavCom::bind ()
fgTie( propname, this, &FGNavCom::get_nav_inrange ); fgTie( propname, this, &FGNavCom::get_nav_inrange );
snprintf(propname, 256, "/radios/nav[%d]/heading-needle-deflection", index); snprintf(propname, 256, "/radios/nav[%d]/heading-needle-deflection", index);
fgTie( propname, this, &FGNavCom::get_nav_heading_needle_deflection ); fgTie( propname, this, &FGNavCom::get_nav_cdi_deflection );
snprintf(propname, 256, "/radios/nav[%d]/has-gs", index); snprintf(propname, 256, "/radios/nav[%d]/has-gs", index);
fgTie( propname, this, &FGNavCom::get_nav_has_gs ); fgTie( propname, this, &FGNavCom::get_nav_has_gs );
snprintf(propname, 256, "/radios/nav[%d]/gs-needle-deflection", index); snprintf(propname, 256, "/radios/nav[%d]/gs-needle-deflection", index);
fgTie( propname, this, &FGNavCom::get_nav_gs_needle_deflection ); fgTie( propname, this, &FGNavCom::get_nav_gs_deflection );
snprintf(propname, 256, "/radios/nav[%d]/nav-id", index); snprintf(propname, 256, "/radios/nav[%d]/nav-id", index);
fgTie( propname, this, &FGNavCom::get_nav_id ); fgTie( propname, this, &FGNavCom::get_nav_id );
@ -364,7 +364,7 @@ FGNavCom::update(double dt)
lon * SGD_RADIANS_TO_DEGREES, lon * SGD_RADIANS_TO_DEGREES,
nav_gslat, nav_gslon, nav_gslat, nav_gslon,
&az1, &az2, &s ); &az1, &az2, &s );
double r = az1 - nav_radial; double r = az1 - nav_target_radial;
while ( r > 180.0 ) { r -= 360.0;} while ( r > 180.0 ) { r -= 360.0;}
while ( r < -180.0 ) { r += 360.0;} while ( r < -180.0 ) { r += 360.0;}
if ( r >= -90.0 && r <= 90.0 ) { if ( r >= -90.0 && r <= 90.0 ) {
@ -372,7 +372,7 @@ FGNavCom::update(double dt)
} else { } else {
nav_gs_dist_signed = -nav_gs_dist; nav_gs_dist_signed = -nav_gs_dist;
} }
/* cout << "Target Radial = " << nav_radial /* cout << "Target Radial = " << nav_target_radial
<< " Bearing = " << az1 << " Bearing = " << az1
<< " dist (signed) = " << nav_gs_dist_signed << " dist (signed) = " << nav_gs_dist_signed
<< endl; */ << endl; */
@ -388,12 +388,12 @@ FGNavCom::update(double dt)
nav_loclat, nav_loclon, nav_loclat, nav_loclon,
&az1, &az2, &s ); &az1, &az2, &s );
// cout << "az1 = " << az1 << " magvar = " << nav_magvar << endl; // cout << "az1 = " << az1 << " magvar = " << nav_magvar << endl;
nav_heading = az1 - nav_magvar; nav_radial = az2 - nav_twist;
// cout << " heading = " << nav_heading // cout << " heading = " << nav_heading
// << " dist = " << nav_dist << endl; // << " dist = " << nav_dist << endl;
if ( nav_loc ) { if ( nav_loc ) {
double offset = nav_heading - nav_radial; double offset = nav_radial - nav_target_radial;
while ( offset < -180.0 ) { offset += 360.0; } while ( offset < -180.0 ) { offset += 360.0; }
while ( offset > 180.0 ) { offset -= 360.0; } while ( offset > 180.0 ) { offset -= 360.0; }
// cout << "ils offset = " << offset << endl; // cout << "ils offset = " << offset << endl;
@ -416,7 +416,7 @@ FGNavCom::update(double dt)
} }
if ( !nav_loc ) { if ( !nav_loc ) {
nav_radial = nav_sel_radial; nav_target_radial = nav_sel_radial;
} }
} else { } else {
nav_inrange = false; nav_inrange = false;
@ -508,13 +508,13 @@ void FGNavCom::search()
nav_gslon = ils->get_gslon(); nav_gslon = ils->get_gslon();
nav_gslat = ils->get_gslat(); nav_gslat = ils->get_gslat();
nav_elev = ils->get_gselev(); nav_elev = ils->get_gselev();
nav_magvar = 0; nav_twist = 0;
nav_range = FG_ILS_DEFAULT_RANGE; nav_range = FG_ILS_DEFAULT_RANGE;
nav_effective_range = nav_range; nav_effective_range = nav_range;
nav_target_gs = ils->get_gsangle(); nav_target_gs = ils->get_gsangle();
nav_radial = ils->get_locheading(); nav_target_radial = ils->get_locheading();
while ( nav_radial < 0.0 ) { nav_radial += 360.0; } while ( nav_target_radial < 0.0 ) { nav_target_radial += 360.0; }
while ( nav_radial > 360.0 ) { nav_radial -= 360.0; } while ( nav_target_radial > 360.0 ) { nav_target_radial -= 360.0; }
nav_x = ils->get_x(); nav_x = ils->get_x();
nav_y = ils->get_y(); nav_y = ils->get_y();
nav_z = ils->get_z(); nav_z = ils->get_z();
@ -524,7 +524,7 @@ void FGNavCom::search()
// derive GS baseline // derive GS baseline
double tlon, tlat, taz; double tlon, tlat, taz;
geo_direct_wgs_84 ( 0.0, nav_gslat, nav_gslon, nav_radial + 90, geo_direct_wgs_84 ( 0.0, nav_gslat, nav_gslon, nav_target_radial + 90,
100.0, &tlat, &tlon, &taz ); 100.0, &tlat, &tlon, &taz );
// cout << nav_gslon << "," << nav_gslat << " " // cout << nav_gslon << "," << nav_gslat << " "
// << tlon << "," << tlat << " (" << nav_elev << ")" << endl; // << tlon << "," << tlat << " (" << nav_elev << ")" << endl;
@ -579,11 +579,11 @@ void FGNavCom::search()
nav_loclon = nav->get_lon(); nav_loclon = nav->get_lon();
nav_loclat = nav->get_lat(); nav_loclat = nav->get_lat();
nav_elev = nav->get_elev(); nav_elev = nav->get_elev();
nav_magvar = nav->get_magvar(); nav_twist = nav->get_magvar();
nav_range = nav->get_range(); nav_range = nav->get_range();
nav_effective_range = adjustNavRange(nav_elev, elev, nav_range); nav_effective_range = adjustNavRange(nav_elev, elev, nav_range);
nav_target_gs = 0.0; nav_target_gs = 0.0;
nav_radial = nav_sel_radial; nav_target_radial = nav_sel_radial;
nav_x = nav->get_x(); nav_x = nav->get_x();
nav_y = nav->get_y(); nav_y = nav->get_y();
nav_z = nav->get_z(); nav_z = nav->get_z();
@ -622,7 +622,7 @@ void FGNavCom::search()
} else { } else {
nav_valid = false; nav_valid = false;
nav_id = ""; nav_id = "";
nav_radial = 0; nav_target_radial = 0;
nav_trans_ident = ""; nav_trans_ident = "";
last_nav_id = ""; last_nav_id = "";
if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) { if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) {
@ -636,15 +636,15 @@ void FGNavCom::search()
// return the amount of heading needle deflection, returns a value // return the amount of heading needle deflection, returns a value
// clamped to the range of ( -10 , 10 ) // clamped to the range of ( -10 , 10 )
double FGNavCom::get_nav_heading_needle_deflection() const { double FGNavCom::get_nav_cdi_deflection() const {
double r; double r;
if ( nav_inrange if ( nav_inrange
&& nav_servicable->getBoolValue() && cdi_servicable->getBoolValue() ) && nav_servicable->getBoolValue() && cdi_servicable->getBoolValue() )
{ {
r = nav_heading - nav_radial; r = nav_radial - nav_target_radial;
// cout << "Radial = " << nav_radial // cout << "Target radial = " << nav_target_radial
// << " Bearing = " << nav_heading << endl; // << " Actual radial = " << nav_radial << endl;
while ( r > 180.0 ) { r -= 360.0;} while ( r > 180.0 ) { r -= 360.0;}
while ( r < -180.0 ) { r += 360.0;} while ( r < -180.0 ) { r += 360.0;}
@ -652,6 +652,7 @@ double FGNavCom::get_nav_heading_needle_deflection() const {
r = ( r<0.0 ? -r-180.0 : -r+180.0 ); r = ( r<0.0 ? -r-180.0 : -r+180.0 );
// According to Robin Peel, the ILS is 4x more sensitive than a vor // According to Robin Peel, the ILS is 4x more sensitive than a vor
r = -r; // reverse, since radial is outbound
if ( nav_loc ) { r *= 4.0; } if ( nav_loc ) { r *= 4.0; }
if ( r < -10.0 ) { r = -10.0; } if ( r < -10.0 ) { r = -10.0; }
if ( r > 10.0 ) { r = 10.0; } if ( r > 10.0 ) { r = 10.0; }
@ -665,7 +666,7 @@ double FGNavCom::get_nav_heading_needle_deflection() const {
// return the amount of glide slope needle deflection (.i.e. the // return the amount of glide slope needle deflection (.i.e. the
// number of degrees we are off the glide slope * 5.0 // number of degrees we are off the glide slope * 5.0
double FGNavCom::get_nav_gs_needle_deflection() const { double FGNavCom::get_nav_gs_deflection() const {
if ( nav_inrange && nav_has_gs if ( nav_inrange && nav_has_gs
&& nav_servicable->getBoolValue() && gs_servicable->getBoolValue() ) && nav_servicable->getBoolValue() && gs_servicable->getBoolValue() )
{ {
@ -691,11 +692,11 @@ FGNavCom::get_nav_to_flag () const
&& nav_servicable->getBoolValue() && nav_servicable->getBoolValue()
&& tofrom_servicable->getBoolValue() ) && tofrom_servicable->getBoolValue() )
{ {
double offset = fabs(nav_heading - nav_radial); double offset = fabs(nav_radial - nav_target_radial);
if (nav_loc) { if (nav_loc) {
return true; return true;
} else { } else {
return (offset <= 90.0 || offset >= 270.0); return !(offset <= 90.0 || offset >= 270.0);
} }
} else { } else {
return false; return false;
@ -712,11 +713,11 @@ FGNavCom::get_nav_from_flag () const
if ( nav_inrange if ( nav_inrange
&& nav_servicable->getBoolValue() && nav_servicable->getBoolValue()
&& tofrom_servicable->getBoolValue() ) { && tofrom_servicable->getBoolValue() ) {
double offset = fabs(nav_heading - nav_radial); double offset = fabs(nav_radial - nav_target_radial);
if (nav_loc) { if (nav_loc) {
return false; return false;
} else { } else {
return (offset > 90.0 && offset < 270.0); return !(offset > 90.0 && offset < 270.0);
} }
} else { } else {
return false; return false;
@ -726,20 +727,18 @@ FGNavCom::get_nav_from_flag () const
/** /**
* Return the current radial. * Return the current radial.
*
* FIXME: the variable 'nav_radial' does not contain the current
* radial, while the variable 'nav_heading' contains the reciprocal of
* the current radial.
*/ */
double double
FGNavCom::get_nav_radial () const FGNavCom::get_nav_radial () const
{ {
if (nav_inrange && nav_servicable->getBoolValue()) { return nav_radial;
double radial = nav_heading + 180; }
if (radial >= 360)
radial -= 360; double
return radial; FGNavCom::get_nav_reciprocal_radial () const
} else { {
return 0.0; double recip = nav_radial + 180;
} if (recip >= 360)
recip = 360;
return recip;
} }

View file

@ -91,6 +91,7 @@ class FGNavCom : public FGSubsystem
double nav_alt_freq; double nav_alt_freq;
double nav_radial; double nav_radial;
double nav_sel_radial; double nav_sel_radial;
double nav_target_radial;
double nav_loclon; double nav_loclon;
double nav_loclat; double nav_loclat;
double nav_x; double nav_x;
@ -110,9 +111,8 @@ class FGNavCom : public FGSubsystem
double nav_elev; double nav_elev;
double nav_range; double nav_range;
double nav_effective_range; double nav_effective_range;
double nav_heading;
double nav_target_gs; double nav_target_gs;
double nav_magvar; double nav_twist;
double nav_vol_btn; double nav_vol_btn;
bool nav_ident_btn; bool nav_ident_btn;
@ -189,6 +189,7 @@ public:
inline double get_nav_freq () const { return nav_freq; } inline double get_nav_freq () const { return nav_freq; }
inline double get_nav_alt_freq () const { return nav_alt_freq; } inline double get_nav_alt_freq () const { return nav_alt_freq; }
inline double get_nav_sel_radial() const { return nav_sel_radial; } inline double get_nav_sel_radial() const { return nav_sel_radial; }
inline double get_nav_target_radial() const { return nav_target_radial; }
// Calculated values. // Calculated values.
inline bool get_comm_inrange() const { return comm_inrange; } inline bool get_comm_inrange() const { return comm_inrange; }
@ -212,12 +213,12 @@ public:
inline double get_nav_gs_dist() const { return nav_gs_dist; } inline double get_nav_gs_dist() const { return nav_gs_dist; }
inline double get_nav_gs_dist_signed() const { return nav_gs_dist_signed; } inline double get_nav_gs_dist_signed() const { return nav_gs_dist_signed; }
inline double get_nav_elev() const { return nav_elev; } inline double get_nav_elev() const { return nav_elev; }
inline double get_nav_heading() const { return nav_heading; } double get_nav_radial() const;
inline double get_nav_radial() const; double get_nav_reciprocal_radial() const;
inline double get_nav_target_gs() const { return nav_target_gs; } inline double get_nav_target_gs() const { return nav_target_gs; }
inline double get_nav_magvar() const { return nav_magvar; } inline double get_nav_twist() const { return nav_twist; }
double get_nav_heading_needle_deflection() const; double get_nav_cdi_deflection() const;
double get_nav_gs_needle_deflection() const; double get_nav_gs_deflection() const;
inline double get_nav_vol_btn() const { return nav_vol_btn; } inline double get_nav_vol_btn() const { return nav_vol_btn; }
inline bool get_nav_ident_btn() const { return nav_ident_btn; } inline bool get_nav_ident_btn() const { return nav_ident_btn; }
inline const char * get_nav_id() const { return nav_id.c_str(); } inline const char * get_nav_id() const { return nav_id.c_str(); }

View file

@ -152,7 +152,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
// Approach // Approach
net->tuned_freq = current_radiostack->get_navcom1()->get_nav_freq(); net->tuned_freq = current_radiostack->get_navcom1()->get_nav_freq();
net->nav_radial = current_radiostack->get_navcom1()->get_nav_radial(); net->nav_radial = current_radiostack->get_navcom1()->get_nav_target_radial();
net->in_range = current_radiostack->get_navcom1()->get_nav_inrange(); net->in_range = current_radiostack->get_navcom1()->get_nav_inrange();
if ( current_radiostack->get_navcom1()->get_nav_loc() ) { if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
@ -167,8 +167,8 @@ void FGProps2NetGUI( FGNetGUI *net ) {
} }
net->course_deviation_deg net->course_deviation_deg
= current_radiostack->get_navcom1()->get_nav_heading() = current_radiostack->get_navcom1()->get_nav_reciprocal_radial()
- current_radiostack->get_navcom1()->get_nav_radial(); - current_radiostack->get_navcom1()->get_nav_target_radial();
while ( net->course_deviation_deg > 180.0 ) { while ( net->course_deviation_deg > 180.0 ) {
net->course_deviation_deg -= 360.0; net->course_deviation_deg -= 360.0;
} }
@ -184,7 +184,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
if ( current_radiostack->get_navcom1()->get_nav_loc() ) { if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
// is an ILS // is an ILS
net->gs_deviation_deg net->gs_deviation_deg
= current_radiostack->get_navcom1()->get_nav_gs_needle_deflection() = current_radiostack->get_navcom1()->get_nav_gs_deflection()
/ 5.0; / 5.0;
} else { } else {
// is an ILS // is an ILS