Fixes to ILS approaches ... now takes into consideration actual GS and DME
locations.
This commit is contained in:
parent
63df45998f
commit
db89ecfae8
9 changed files with 140 additions and 69 deletions
|
@ -319,7 +319,7 @@ int FGAutopilot::run() {
|
|||
while ( diff < -180.0 ) { diff += 360.0; }
|
||||
while ( diff > 180.0 ) { diff -= 360.0; }
|
||||
|
||||
diff *= (current_radiostack->get_nav1_dist() * METER_TO_NM);
|
||||
diff *= (current_radiostack->get_nav1_dme_dist() * METER_TO_NM);
|
||||
if ( diff < -30.0 ) { diff = -30.0; }
|
||||
if ( diff > 30.0 ) { diff = 30.0; }
|
||||
|
||||
|
@ -460,7 +460,7 @@ int FGAutopilot::run() {
|
|||
TargetClimbRate =
|
||||
( TargetAltitude - FGBFI::getAltitude() * FEET_TO_METER ) * 8.0;
|
||||
} else if ( altitude_mode == FG_ALTITUDE_GS1 ) {
|
||||
double x = current_radiostack->get_nav1_dist();
|
||||
double x = current_radiostack->get_nav1_gs_dist();
|
||||
double y = (FGBFI::getAltitude()
|
||||
- current_radiostack->get_nav1_elev()) * FEET_TO_METER;
|
||||
double angle = atan2( y, x ) * RAD_TO_DEG;
|
||||
|
|
|
@ -33,7 +33,7 @@ FGRadioStack *current_radiostack;
|
|||
|
||||
// Constructor
|
||||
FGRadioStack::FGRadioStack() {
|
||||
nav1_dist = 0.0;
|
||||
nav1_dme_dist = 0.0;
|
||||
need_update = true;
|
||||
}
|
||||
|
||||
|
@ -53,15 +53,19 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
|
|||
|
||||
if ( nav1_valid ) {
|
||||
// staightline distance
|
||||
station = Point3D( nav1_x, nav1_y, nav1_z );
|
||||
nav1_dist = aircraft.distance3D( station );
|
||||
station = Point3D( nav1_dme_x, nav1_dme_y, nav1_dme_z );
|
||||
nav1_dme_dist = aircraft.distance3D( station );
|
||||
if ( nav1_loc ) {
|
||||
station = Point3D( nav1_gs_x, nav1_gs_y, nav1_gs_z );
|
||||
nav1_gs_dist = aircraft.distance3D( station );
|
||||
}
|
||||
|
||||
if ( nav1_dist < nav1_effective_range * NM_TO_METER ) {
|
||||
if ( nav1_dme_dist < nav1_effective_range * NM_TO_METER ) {
|
||||
nav1_inrange = true;
|
||||
|
||||
// wgs84 heading
|
||||
geo_inverse_wgs_84( elev, lat * RAD_TO_DEG, lon * RAD_TO_DEG,
|
||||
nav1_lat, nav1_lon,
|
||||
nav1_loclat, nav1_loclon,
|
||||
&az1, &az2, &s );
|
||||
nav1_heading = az1;
|
||||
|
||||
|
@ -82,15 +86,19 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
|
|||
|
||||
if ( nav2_valid ) {
|
||||
// staightline distance
|
||||
station = Point3D( nav2_x, nav2_y, nav2_z );
|
||||
nav2_dist = aircraft.distance3D( station );
|
||||
station = Point3D( nav2_dme_x, nav2_dme_y, nav2_dme_z );
|
||||
nav2_dme_dist = aircraft.distance3D( station );
|
||||
if ( nav2_loc ) {
|
||||
station = Point3D( nav2_gs_x, nav2_gs_y, nav2_gs_z );
|
||||
nav2_gs_dist = aircraft.distance3D( station );
|
||||
}
|
||||
|
||||
if ( nav2_dist < nav2_effective_range * NM_TO_METER ) {
|
||||
if ( nav2_dme_dist < nav2_effective_range * NM_TO_METER ) {
|
||||
nav2_inrange = true;
|
||||
|
||||
// wgs84 heading
|
||||
geo_inverse_wgs_84( elev, lat * RAD_TO_DEG, lon * RAD_TO_DEG,
|
||||
nav2_lat, nav2_lon,
|
||||
nav2_loclat, nav2_loclon,
|
||||
&az1, &az2, &s );
|
||||
nav2_heading = az1;
|
||||
|
||||
|
@ -145,32 +153,39 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
|
|||
nav1_loc = true;
|
||||
nav1_dme = true;
|
||||
|
||||
nav1_lon = ils.get_loclon();
|
||||
nav1_lat = ils.get_loclat();
|
||||
nav1_loclon = ils.get_loclon();
|
||||
nav1_loclat = ils.get_loclat();
|
||||
nav1_gslon = ils.get_gslon();
|
||||
nav1_gslat = ils.get_gslat();
|
||||
nav1_dmelon = ils.get_dmelon();
|
||||
nav1_dmelat = ils.get_dmelat();
|
||||
nav1_elev = ils.get_gselev();
|
||||
nav1_effective_range = FG_ILS_DEFAULT_RANGE;
|
||||
nav1_target_gs = ils.get_gsangle();
|
||||
nav1_radial = ils.get_locheading();
|
||||
while ( nav1_radial < 0.0 ) { nav1_radial += 360.0; }
|
||||
while ( nav1_radial > 360.0 ) { nav1_radial -= 360.0; }
|
||||
nav1_x = ils.get_x();
|
||||
nav1_y = ils.get_y();
|
||||
nav1_z = ils.get_z();
|
||||
nav1_gs_x = ils.get_gs_x();
|
||||
nav1_gs_y = ils.get_gs_y();
|
||||
nav1_gs_z = ils.get_gs_z();
|
||||
nav1_dme_x = ils.get_dme_x();
|
||||
nav1_dme_y = ils.get_dme_y();
|
||||
nav1_dme_z = ils.get_dme_z();
|
||||
// cout << "Found an ils station in range" << endl;
|
||||
// cout << " id = " << ils.get_locident() << endl;
|
||||
} else if ( current_navlist->query( lon, lat, elev, nav1_freq, &nav ) ) {
|
||||
nav1_valid = true;
|
||||
nav1_loc = false;
|
||||
nav1_dme = nav.get_dme();
|
||||
nav1_lon = nav.get_lon();
|
||||
nav1_lat = nav.get_lat();
|
||||
nav1_loclon = nav.get_lon();
|
||||
nav1_loclat = nav.get_lat();
|
||||
nav1_elev = nav.get_elev();
|
||||
nav1_effective_range = nav.get_range();
|
||||
nav1_target_gs = 0.0;
|
||||
nav1_radial = nav1_sel_radial;
|
||||
nav1_x = nav.get_x();
|
||||
nav1_y = nav.get_y();
|
||||
nav1_z = nav.get_z();
|
||||
nav1_dme_x = nav.get_x();
|
||||
nav1_dme_y = nav.get_y();
|
||||
nav1_dme_y = nav.get_z();
|
||||
// cout << "Found a vor station in range" << endl;
|
||||
// cout << " id = " << nav.get_ident() << endl;
|
||||
} else {
|
||||
|
@ -183,17 +198,20 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
|
|||
nav2_loc = true;
|
||||
nav2_dme = true;
|
||||
|
||||
nav2_lon = ils.get_loclon();
|
||||
nav2_lat = ils.get_loclat();
|
||||
nav2_loclon = ils.get_loclon();
|
||||
nav2_loclat = ils.get_loclat();
|
||||
nav2_elev = ils.get_gselev();
|
||||
nav2_effective_range = FG_ILS_DEFAULT_RANGE;
|
||||
nav2_target_gs = ils.get_gsangle();
|
||||
nav2_radial = ils.get_locheading();
|
||||
while ( nav2_radial < 0.0 ) { nav2_radial += 360.0; }
|
||||
while ( nav2_radial > 360.0 ) { nav2_radial -= 360.0; }
|
||||
nav2_x = ils.get_x();
|
||||
nav2_y = ils.get_y();
|
||||
nav2_z = ils.get_z();
|
||||
nav2_gs_x = ils.get_gs_x();
|
||||
nav2_gs_y = ils.get_gs_y();
|
||||
nav2_gs_z = ils.get_gs_z();
|
||||
nav2_dme_x = ils.get_dme_x();
|
||||
nav2_dme_y = ils.get_dme_y();
|
||||
nav2_dme_z = ils.get_dme_z();
|
||||
// cout << "Found an ils station in range" << endl;
|
||||
// cout << " id = " << ils.get_locident() << endl;
|
||||
} else if ( current_navlist->query( lon, lat, elev, nav2_freq, &nav ) ) {
|
||||
|
@ -201,15 +219,15 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
|
|||
nav2_loc = false;
|
||||
nav2_dme = nav.get_dme();
|
||||
|
||||
nav2_lon = nav.get_lon();
|
||||
nav2_lat = nav.get_lat();
|
||||
nav2_loclon = nav.get_lon();
|
||||
nav2_loclat = nav.get_lat();
|
||||
nav2_elev = nav.get_elev();
|
||||
nav2_effective_range = nav.get_range();
|
||||
nav2_target_gs = 0.0;
|
||||
nav2_radial = nav2_sel_radial;
|
||||
nav2_x = nav.get_x();
|
||||
nav2_y = nav.get_y();
|
||||
nav2_z = nav.get_z();
|
||||
nav2_dme_x = nav.get_x();
|
||||
nav2_dme_y = nav.get_y();
|
||||
nav2_dme_z = nav.get_z();
|
||||
// cout << "Found a vor station in range" << endl;
|
||||
// cout << " id = " << nav.get_ident() << endl;
|
||||
} else {
|
||||
|
|
|
@ -43,16 +43,24 @@ class FGRadioStack {
|
|||
double nav1_alt_freq;
|
||||
double nav1_radial;
|
||||
double nav1_sel_radial;
|
||||
double nav1_lon;
|
||||
double nav1_lat;
|
||||
double nav1_loclon;
|
||||
double nav1_loclat;
|
||||
double nav1_gslon;
|
||||
double nav1_gslat;
|
||||
double nav1_gs_x;
|
||||
double nav1_gs_y;
|
||||
double nav1_gs_z;
|
||||
double nav1_gs_dist;
|
||||
double nav1_dmelon;
|
||||
double nav1_dmelat;
|
||||
double nav1_dme_x;
|
||||
double nav1_dme_y;
|
||||
double nav1_dme_z;
|
||||
double nav1_dme_dist;
|
||||
double nav1_elev;
|
||||
double nav1_effective_range;
|
||||
double nav1_dist;
|
||||
double nav1_heading;
|
||||
double nav1_target_gs;
|
||||
double nav1_x;
|
||||
double nav1_y;
|
||||
double nav1_z;
|
||||
|
||||
bool nav2_valid;
|
||||
bool nav2_inrange;
|
||||
|
@ -62,16 +70,24 @@ class FGRadioStack {
|
|||
double nav2_alt_freq;
|
||||
double nav2_radial;
|
||||
double nav2_sel_radial;
|
||||
double nav2_lon;
|
||||
double nav2_lat;
|
||||
double nav2_loclon;
|
||||
double nav2_loclat;
|
||||
double nav2_gslon;
|
||||
double nav2_gslat;
|
||||
double nav2_gs_x;
|
||||
double nav2_gs_y;
|
||||
double nav2_gs_z;
|
||||
double nav2_gs_dist;
|
||||
double nav2_dmelon;
|
||||
double nav2_dmelat;
|
||||
double nav2_dme_x;
|
||||
double nav2_dme_y;
|
||||
double nav2_dme_z;
|
||||
double nav2_dme_dist;
|
||||
double nav2_elev;
|
||||
double nav2_effective_range;
|
||||
double nav2_dist;
|
||||
double nav2_heading;
|
||||
double nav2_target_gs;
|
||||
double nav2_x;
|
||||
double nav2_y;
|
||||
double nav2_z;
|
||||
|
||||
bool adf_valid;
|
||||
bool adf_inrange;
|
||||
|
@ -144,10 +160,15 @@ public:
|
|||
inline bool get_nav1_inrange() const { return nav1_inrange; }
|
||||
inline bool get_nav1_dme() const { return nav1_dme; }
|
||||
inline bool get_nav1_loc() const { return nav1_loc; }
|
||||
inline double get_nav1_lon() const { return nav1_lon; }
|
||||
inline double get_nav1_lat() const { return nav1_lat; }
|
||||
inline double get_nav1_loclon() const { return nav1_loclon; }
|
||||
inline double get_nav1_loclat() const { return nav1_loclat; }
|
||||
inline double get_nav1_gslon() const { return nav1_gslon; }
|
||||
inline double get_nav1_gslat() const { return nav1_gslat; }
|
||||
inline double get_nav1_gs_dist() const { return nav1_gs_dist; }
|
||||
inline double get_nav1_dmelon() const { return nav1_dmelon; }
|
||||
inline double get_nav1_dmelat() const { return nav1_dmelat; }
|
||||
inline double get_nav1_dme_dist() const { return nav1_dme_dist; }
|
||||
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_radial() const { return nav1_radial; }
|
||||
inline double get_nav1_target_gs() const { return nav1_target_gs; }
|
||||
|
@ -155,10 +176,15 @@ public:
|
|||
inline bool get_nav2_inrange() const { return nav2_inrange; }
|
||||
inline bool get_nav2_dme() const { return nav2_dme; }
|
||||
inline bool get_nav2_loc() const { return nav2_loc; }
|
||||
inline double get_nav2_lon() const { return nav2_lon; }
|
||||
inline double get_nav2_lat() const { return nav2_lat; }
|
||||
inline double get_nav2_loclon() const { return nav2_loclon; }
|
||||
inline double get_nav2_loclat() const { return nav2_loclat; }
|
||||
inline double get_nav2_gslon() const { return nav2_gslon; }
|
||||
inline double get_nav2_gslat() const { return nav2_gslat; }
|
||||
inline double get_nav2_gs_dist() const { return nav2_gs_dist; }
|
||||
inline double get_nav2_dmelon() const { return nav2_dmelon; }
|
||||
inline double get_nav2_dmelat() const { return nav2_dmelat; }
|
||||
inline double get_nav2_dme_dist() const { return nav2_dme_dist; }
|
||||
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_radial() const { return nav2_radial; }
|
||||
inline double get_nav2_target_gs() const { return nav2_target_gs; }
|
||||
|
|
|
@ -812,7 +812,7 @@ createDME (int x, int y)
|
|||
|
||||
// Layer: current distance
|
||||
FGTextLayer * text = new FGTextLayer(SIX_W/2, SIX_W/4);
|
||||
text->addChunk(new FGTextLayer::Chunk(FGBFI::getNAV1Dist, "%05.1f",
|
||||
text->addChunk(new FGTextLayer::Chunk(FGBFI::getNAV1DistDME, "%05.1f",
|
||||
METER_TO_NM));
|
||||
text->setPointSize(14);
|
||||
text->setColor(1.0, 0.5, 0.0);
|
||||
|
|
|
@ -131,7 +131,7 @@ void FGSteam::_CatchUp()
|
|||
{ if ( _UpdatesPending != 0 )
|
||||
{ double dt = _UpdatesPending * 1.0 / current_options.get_model_hz();
|
||||
double AccN, AccE, AccU;
|
||||
int i,j;
|
||||
int i /*,j*/;
|
||||
double d, the_ENGINE_rpm;
|
||||
|
||||
#if 0
|
||||
|
@ -334,7 +334,7 @@ double FGSteam::get_HackGS_deg () {
|
|||
if ( current_radiostack->get_nav1_inrange() &&
|
||||
current_radiostack->get_nav1_loc() )
|
||||
{
|
||||
double x = current_radiostack->get_nav1_dist();
|
||||
double x = current_radiostack->get_nav1_gs_dist();
|
||||
double y = (FGBFI::getAltitude() - current_radiostack->get_nav1_elev())
|
||||
* FEET_TO_METER;
|
||||
double angle = atan2( y, x ) * RAD_TO_DEG;
|
||||
|
@ -365,7 +365,8 @@ double FGSteam::get_HackVOR1_deg () {
|
|||
if (r<-180.0) r+=360.0;
|
||||
if ( fabs(r) > 90.0 )
|
||||
r = ( r<0.0 ? -r-180.0 : -r+180.0 );
|
||||
if ( current_radiostack->get_nav1_loc() ) r *= 5.0;
|
||||
// According to Robin Peel, the ILS is 4x more sensitive than a vor
|
||||
if ( current_radiostack->get_nav1_loc() ) r *= 4.0;
|
||||
} else {
|
||||
r = 0.0;
|
||||
}
|
||||
|
|
|
@ -860,9 +860,9 @@ FGBFI::getNAV1SelRadial ()
|
|||
}
|
||||
|
||||
double
|
||||
FGBFI::getNAV1Dist ()
|
||||
FGBFI::getNAV1DistDME ()
|
||||
{
|
||||
return current_radiostack->get_nav1_dist();
|
||||
return current_radiostack->get_nav1_dme_dist();
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -890,9 +890,9 @@ FGBFI::getNAV2SelRadial ()
|
|||
}
|
||||
|
||||
double
|
||||
FGBFI::getNAV2Dist ()
|
||||
FGBFI::getNAV2DistDME ()
|
||||
{
|
||||
return current_radiostack->get_nav1_dist();
|
||||
return current_radiostack->get_nav2_dme_dist();
|
||||
}
|
||||
|
||||
double
|
||||
|
|
|
@ -136,13 +136,13 @@ public:
|
|||
static double getNAV1AltFreq ();
|
||||
static double getNAV1Radial ();
|
||||
static double getNAV1SelRadial ();
|
||||
static double getNAV1Dist ();
|
||||
static double getNAV1DistDME ();
|
||||
|
||||
static double getNAV2Freq ();
|
||||
static double getNAV2AltFreq ();
|
||||
static double getNAV2Radial ();
|
||||
static double getNAV2SelRadial ();
|
||||
static double getNAV2Dist ();
|
||||
static double getNAV2DistDME ();
|
||||
|
||||
static double getADFFreq ();
|
||||
static double getADFAltFreq ();
|
||||
|
|
|
@ -57,13 +57,14 @@ class FGILS {
|
|||
double locheading;
|
||||
double loclat;
|
||||
double loclon;
|
||||
double x, y, z;
|
||||
double gselev;
|
||||
double gsangle;
|
||||
double gslat;
|
||||
double gslon;
|
||||
double gs_x, gs_y, gs_z;
|
||||
double dmelat;
|
||||
double dmelon;
|
||||
double dme_x, dme_y, dme_z;
|
||||
double omlat;
|
||||
double omlon;
|
||||
double mmlat;
|
||||
|
@ -86,14 +87,17 @@ public:
|
|||
inline double get_loclat() const { return loclat; }
|
||||
inline double get_loclon() const { return loclon; }
|
||||
inline double get_gselev() const { return gselev; }
|
||||
inline double get_x() const { return x; }
|
||||
inline double get_y() const { return y; }
|
||||
inline double get_z() const { return z; }
|
||||
inline double get_gsangle() const { return gsangle; }
|
||||
inline double get_gslat() const { return gslat; }
|
||||
inline double get_gslon() const { return gslon; }
|
||||
inline double get_gs_x() const { return gs_x; }
|
||||
inline double get_gs_y() const { return gs_y; }
|
||||
inline double get_gs_z() const { return gs_z; }
|
||||
inline double get_dmelat() const { return dmelat; }
|
||||
inline double get_dmelon() const { return dmelon; }
|
||||
inline double get_dme_x() const { return dme_x; }
|
||||
inline double get_dme_y() const { return dme_y; }
|
||||
inline double get_dme_z() const { return dme_z; }
|
||||
inline double get_omlat() const { return omlat; }
|
||||
inline double get_omlon() const { return omlon; }
|
||||
inline double get_mmlat() const { return mmlat; }
|
||||
|
@ -121,11 +125,31 @@ operator >> ( istream& in, FGILS& i )
|
|||
i.locfreq = (int)(f*100.0 + 0.5);
|
||||
|
||||
// generate cartesian coordinates
|
||||
Point3D geod( i.loclon * DEG_TO_RAD, i.loclat * DEG_TO_RAD, i.gselev );
|
||||
Point3D cart = fgGeodToCart( geod );
|
||||
i.x = cart.x();
|
||||
i.y = cart.y();
|
||||
i.z = cart.z();
|
||||
Point3D geod, cart;
|
||||
|
||||
if ( i.gslon < FG_EPSILON && i.gslat < FG_EPSILON ) {
|
||||
i.gslon = i.loclon;
|
||||
i.gslat = i.loclat;
|
||||
}
|
||||
|
||||
if ( i.dmelon < FG_EPSILON && i.dmelat < FG_EPSILON ) {
|
||||
i.dmelon = i.gslon;
|
||||
i.dmelat = i.gslat;
|
||||
}
|
||||
|
||||
geod = Point3D( i.gslon * DEG_TO_RAD, i.gslat * DEG_TO_RAD, i.gselev );
|
||||
cart = fgGeodToCart( geod );
|
||||
i.gs_x = cart.x();
|
||||
i.gs_y = cart.y();
|
||||
i.gs_z = cart.z();
|
||||
// cout << "gs = " << cart << endl;
|
||||
|
||||
geod = Point3D( i.dmelon * DEG_TO_RAD, i.dmelat * DEG_TO_RAD, i.gselev );
|
||||
cart = fgGeodToCart( geod );
|
||||
i.dme_x = cart.x();
|
||||
i.dme_y = cart.y();
|
||||
i.dme_z = cart.z();
|
||||
// cout << "dme = " << cart << endl;
|
||||
|
||||
// return in >> skipeol;
|
||||
return in;
|
||||
|
|
|
@ -122,7 +122,9 @@ bool FGILSList::query( double lon, double lat, double elev, double freq,
|
|||
double d;
|
||||
for ( ; current != last ; ++current ) {
|
||||
// cout << " testing " << current->get_locident() << endl;
|
||||
station = Point3D(current->get_x(), current->get_y(), current->get_z());
|
||||
station = Point3D(current->get_dme_x(),
|
||||
current->get_dme_y(),
|
||||
current->get_dme_z());
|
||||
// cout << " aircraft = " << aircraft << " station = " << station
|
||||
// << endl;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue