1
0
Fork 0

Updates to nav radio stack model ... starting to get to first usable pass.

This commit is contained in:
curt 2000-04-25 04:58:25 +00:00
parent b23f930aa6
commit b5420977d7
5 changed files with 85 additions and 51 deletions

View file

@ -53,10 +53,12 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
nav1_lon = ils.get_loclon();
nav1_lat = ils.get_loclat();
nav1_elev = ils.get_gselev();
cout << "Found a vor station in range" << endl;
cout << " id = " << ils.get_locident() << endl;
cout << " heading = " << nav1_heading
<< " dist = " << nav1_dist << endl;
nav1_target_gs = ils.get_gsangle();
nav1_radial = ils.get_locheading();
// cout << "Found a vor station in range" << endl;
// cout << " id = " << ils.get_locident() << endl;
// cout << " heading = " << nav1_heading
// << " dist = " << nav1_dist << endl;
} else {
nav1_inrange = false;
cout << "not picking up vor. :-(" << endl;
@ -70,10 +72,10 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
nav2_lon = nav.get_lon();
nav2_lat = nav.get_lat();
nav2_elev = nav.get_elev();
cout << "Found a vor station in range" << endl;
cout << " id = " << nav.get_ident() << endl;
cout << " heading = " << nav2_heading
<< " dist = " << nav2_dist << endl;
// cout << "Found a vor station in range" << endl;
// cout << " id = " << nav.get_ident() << endl;
// cout << " heading = " << nav2_heading
// << " dist = " << nav2_dist << endl;
} else {
nav2_inrange = false;
cout << "not picking up vor. :-(" << endl;
@ -87,10 +89,10 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
adf_lon = nav.get_lon();
adf_lat = nav.get_lat();
adf_elev = nav.get_elev();
cout << "Found an adf station in range" << endl;
cout << " id = " << nav.get_ident() << endl;
cout << " heading = " << adf_heading
<< " dist = " << junk << endl;
// cout << "Found an adf station in range" << endl;
// cout << " id = " << nav.get_ident() << endl;
// cout << " heading = " << adf_heading
// << " dist = " << junk << endl;
} else {
adf_inrange = false;
cout << "not picking up adf. :-(" << endl;

View file

@ -41,6 +41,7 @@ class FGRadioStack {
double nav1_elev;
double nav1_dist;
double nav1_heading;
double nav1_target_gs;
bool nav2_inrange;
double nav2_freq;
@ -50,6 +51,7 @@ class FGRadioStack {
double nav2_elev;
double nav2_dist;
double nav2_heading;
double nav2_target_gs;
bool adf_inrange;
double adf_freq;
@ -93,6 +95,7 @@ public:
inline double get_nav1_elev() const { return nav1_elev; }
inline double get_nav1_dist() const { return nav1_dist; }
inline double get_nav1_heading() const { return nav1_heading; }
inline double get_nav1_target_gs() const { return nav1_target_gs; }
inline bool get_nav2_inrange() const { return nav2_inrange; }
inline double get_nav2_radial() const { return nav2_radial; }
@ -101,6 +104,7 @@ public:
inline double get_nav2_elev() const { return nav2_elev; }
inline double get_nav2_dist() const { return nav2_dist; }
inline double get_nav2_heading() const { return nav2_heading; }
inline double get_nav2_target_gs() const { return nav2_target_gs; }
inline bool get_adf_inrange() const { return adf_inrange; }
inline double get_adf_lon() const { return adf_lon; }

View file

@ -232,47 +232,75 @@ void FGSteam::_CatchUp()
double FGSteam::get_HackGS_deg ()
{ double x,y,dme;
if (0==NAV1_LOC) return 0.0;
y = 60.0 * ( NAV1_Lat - FGBFI::getLatitude () );
x = 60.0 * ( NAV1_Lon - FGBFI::getLongitude() )
double FGSteam::get_HackGS_deg () {
double x = current_radiostack->get_nav1_dist();
double y = (FGBFI::getAltitude() - current_radiostack->get_nav1_elev())
* FEET_TO_METER;
double angle = atan2( y, x ) * RAD_TO_DEG;
return current_radiostack->get_nav1_target_gs() - angle;
#if 0
double x,y,dme;
if (0==NAV1_LOC) return 0.0;
y = 60.0 * ( NAV1_Lat - FGBFI::getLatitude () );
x = 60.0 * ( NAV1_Lon - FGBFI::getLongitude() )
* cos ( FGBFI::getLatitude () / RAD_TO_DEG );
dme = x*x + y*y;
if ( dme > 0.1 ) x = sqrt ( dme ); else x = 0.3;
y = FGBFI::getAltitude() - NAV1_Alt;
return 3.0 - (y/x) * 60.0 / 6000.0;
dme = x*x + y*y;
if ( dme > 0.1 ) x = sqrt ( dme ); else x = 0.3;
y = FGBFI::getAltitude() - NAV1_Alt;
return 3.0 - (y/x) * 60.0 / 6000.0;
#endif
}
double FGSteam::get_HackVOR1_deg ()
{ double r;
double x,y;
y = 60.0 * ( NAV1_Lat - FGBFI::getLatitude () );
x = 60.0 * ( NAV1_Lon - FGBFI::getLongitude() )
* cos ( FGBFI::getLatitude () / RAD_TO_DEG );
r = atan2 ( x, y ) * RAD_TO_DEG - NAV1_Rad - FGBFI::getMagVar();
if (r> 180.0) r-=360.0; else
double FGSteam::get_HackVOR1_deg () {
double r;
#if 0
double x,y;
y = 60.0 * ( NAV1_Lat - FGBFI::getLatitude () );
x = 60.0 * ( NAV1_Lon - FGBFI::getLongitude() )
* cos ( FGBFI::getLatitude () / RAD_TO_DEG );
r = atan2 ( x, y ) * RAD_TO_DEG - NAV1_Rad - FGBFI::getMagVar();
#endif
r = current_radiostack->get_nav1_radial() -
current_radiostack->get_nav1_heading() + 180.0;
// cout << "Radial = " << current_radiostack->get_nav1_radial()
// << " Bearing = " << current_radiostack->get_nav1_heading() << endl;
if (r> 180.0) r-=360.0; else
if (r<-180.0) r+=360.0;
if ( fabs(r) > 90.0 )
r = ( r<0.0 ? -r-180.0 : -r+180.0 );
if (NAV1_LOC) r*=5.0;
return r;
if ( fabs(r) > 90.0 )
r = ( r<0.0 ? -r-180.0 : -r+180.0 );
if (NAV1_LOC) r*=5.0;
return r;
}
double FGSteam::get_HackVOR2_deg ()
{ double r;
double x,y;
y = 60.0 * ( NAV2_Lat - FGBFI::getLatitude () );
x = 60.0 * ( NAV2_Lon - FGBFI::getLongitude() )
* cos ( FGBFI::getLatitude () / RAD_TO_DEG );
r = atan2 ( x, y ) * RAD_TO_DEG - NAV2_Rad - FGBFI::getMagVar();
if (r> 180.0) r-=360.0; else
double FGSteam::get_HackVOR2_deg () {
double r;
#if 0
double x,y;
y = 60.0 * ( NAV2_Lat - FGBFI::getLatitude () );
x = 60.0 * ( NAV2_Lon - FGBFI::getLongitude() )
* cos ( FGBFI::getLatitude () / RAD_TO_DEG );
r = atan2 ( x, y ) * RAD_TO_DEG - NAV2_Rad - FGBFI::getMagVar();
#endif
r = current_radiostack->get_nav2_radial() -
current_radiostack->get_nav2_heading() + 180.0;
// cout << "Radial = " << current_radiostack->get_nav1_radial()
// << " Bearing = " << current_radiostack->get_nav1_heading() << endl;
if (r> 180.0) r-=360.0; else
if (r<-180.0) r+=360.0;
if ( fabs(r) > 90.0 )
r = ( r<0.0 ? -r-180.0 : -r+180.0 );
return r;
if ( fabs(r) > 90.0 )
r = ( r<0.0 ? -r-180.0 : -r+180.0 );
return r;
}

View file

@ -473,13 +473,13 @@ bool fgInitSubsystems( void ) {
// Initialize the underlying radio stack model
current_radiostack = new FGRadioStack;
current_radiostack->set_nav1_freq( 111.70 );
current_radiostack->set_nav1_radial( 280.0 );
current_radiostack->set_nav1_freq( 110.30 );
current_radiostack->set_nav1_radial( 299.0 );
current_radiostack->set_nav2_freq( 117.80 );
current_radiostack->set_nav2_radial( 068.0 );
current_radiostack->set_nav2_freq( 115.70 );
current_radiostack->set_nav2_radial( 45.0 );
current_radiostack->set_adf_freq( 210.0 );
current_radiostack->set_adf_freq( 266.0 );
current_radiostack->update( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),

View file

@ -745,8 +745,8 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
ephem->update( t, cur_fdm_state->get_Latitude() );
// Update radio stack model
current_radiostack->update( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),
current_radiostack->update( cur_fdm_state->get_Longitude() * RAD_TO_DEG,
cur_fdm_state->get_Latitude() * RAD_TO_DEG,
cur_fdm_state->get_Altitude() * FEET_TO_METER );
}