1
0
Fork 0

More fixes to ils approaches and autopilot.

This commit is contained in:
curt 2000-05-12 22:17:09 +00:00
parent db89ecfae8
commit 5127740c72
7 changed files with 109 additions and 50 deletions

View file

@ -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_dme_dist() * METER_TO_NM);
diff *= (current_radiostack->get_nav1_loc_dist() * METER_TO_NM);
if ( diff < -30.0 ) { diff = -30.0; }
if ( diff > 30.0 ) { diff = 30.0; }

View file

@ -52,12 +52,22 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
double az1, az2, s;
if ( nav1_valid ) {
// staightline distance
station = Point3D( nav1_dme_x, nav1_dme_y, nav1_dme_z );
nav1_dme_dist = aircraft.distance3D( station );
if ( nav1_loc ) {
station = Point3D( nav1_x, nav1_y, nav1_z );
nav1_loc_dist = aircraft.distance3D( station );
if ( nav1_has_dme ) {
// staightline distance
station = Point3D( nav1_dme_x, nav1_dme_y, nav1_dme_z );
nav1_dme_dist = aircraft.distance3D( station );
} else {
nav1_dme_dist = 0.0;
}
if ( nav1_has_gs ) {
station = Point3D( nav1_gs_x, nav1_gs_y, nav1_gs_z );
nav1_gs_dist = aircraft.distance3D( station );
} else {
nav1_gs_dist = 0.0;
}
if ( nav1_dme_dist < nav1_effective_range * NM_TO_METER ) {
@ -85,12 +95,22 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
}
if ( nav2_valid ) {
// staightline distance
station = Point3D( nav2_dme_x, nav2_dme_y, nav2_dme_z );
nav2_dme_dist = aircraft.distance3D( station );
if ( nav2_loc ) {
station = Point3D( nav2_x, nav2_y, nav2_z );
nav2_loc_dist = aircraft.distance3D( station );
if ( nav2_has_dme ) {
// staightline distance
station = Point3D( nav2_dme_x, nav2_dme_y, nav2_dme_z );
nav2_dme_dist = aircraft.distance3D( station );
} else {
nav2_dme_dist = 0.0;
}
if ( nav2_has_gs ) {
station = Point3D( nav2_gs_x, nav2_gs_y, nav2_gs_z );
nav2_gs_dist = aircraft.distance3D( station );
} else {
nav2_gs_dist = 0.0;
}
if ( nav2_dme_dist < nav2_effective_range * NM_TO_METER ) {
@ -151,7 +171,8 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
if ( current_ilslist->query( lon, lat, elev, nav1_freq, &ils ) ) {
nav1_valid = true;
nav1_loc = true;
nav1_dme = true;
nav1_has_dme = ils.get_has_dme();
nav1_has_gs = ils.get_has_gs();
nav1_loclon = ils.get_loclon();
nav1_loclat = ils.get_loclat();
@ -165,6 +186,9 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
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();
@ -176,16 +200,17 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
} else if ( current_navlist->query( lon, lat, elev, nav1_freq, &nav ) ) {
nav1_valid = true;
nav1_loc = false;
nav1_dme = nav.get_dme();
nav1_has_dme = nav.get_has_dme();
nav1_has_gs = false;
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_dme_x = nav.get_x();
nav1_dme_y = nav.get_y();
nav1_dme_y = nav.get_z();
nav1_x = nav1_dme_x = nav.get_x();
nav1_y = nav1_dme_y = nav.get_y();
nav1_z = nav1_dme_y = nav.get_z();
// cout << "Found a vor station in range" << endl;
// cout << " id = " << nav.get_ident() << endl;
} else {
@ -196,7 +221,8 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
if ( current_ilslist->query( lon, lat, elev, nav2_freq, &ils ) ) {
nav2_valid = true;
nav2_loc = true;
nav2_dme = true;
nav2_has_dme = ils.get_has_dme();
nav2_has_gs = ils.get_has_gs();
nav2_loclon = ils.get_loclon();
nav2_loclat = ils.get_loclat();
@ -206,6 +232,9 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
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();
@ -217,17 +246,17 @@ void FGRadioStack::search( double lon, double lat, double elev ) {
} else if ( current_navlist->query( lon, lat, elev, nav2_freq, &nav ) ) {
nav2_valid = true;
nav2_loc = false;
nav2_dme = nav.get_dme();
nav2_has_dme = nav.get_has_dme();
nav2_has_dme = false;
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_dme_x = nav.get_x();
nav2_dme_y = nav.get_y();
nav2_dme_z = nav.get_z();
nav2_x = nav2_dme_x = nav.get_x();
nav2_y = nav2_dme_y = nav.get_y();
nav2_z = nav2_dme_z = nav.get_z();
// cout << "Found a vor station in range" << endl;
// cout << " id = " << nav.get_ident() << endl;
} else {

View file

@ -37,7 +37,8 @@ class FGRadioStack {
bool nav1_valid;
bool nav1_inrange;
bool nav1_dme;
bool nav1_has_dme;
bool nav1_has_gs;
bool nav1_loc;
double nav1_freq;
double nav1_alt_freq;
@ -45,6 +46,10 @@ class FGRadioStack {
double nav1_sel_radial;
double nav1_loclon;
double nav1_loclat;
double nav1_x;
double nav1_y;
double nav1_z;
double nav1_loc_dist;
double nav1_gslon;
double nav1_gslat;
double nav1_gs_x;
@ -64,7 +69,8 @@ class FGRadioStack {
bool nav2_valid;
bool nav2_inrange;
bool nav2_dme;
bool nav2_has_dme;
bool nav2_has_gs;
bool nav2_loc;
double nav2_freq;
double nav2_alt_freq;
@ -72,6 +78,10 @@ class FGRadioStack {
double nav2_sel_radial;
double nav2_loclon;
double nav2_loclat;
double nav2_x;
double nav2_y;
double nav2_z;
double nav2_loc_dist;
double nav2_gslon;
double nav2_gslat;
double nav2_gs_x;
@ -158,10 +168,12 @@ public:
// Calculated values.
inline bool get_nav1_inrange() const { return nav1_inrange; }
inline bool get_nav1_dme() const { return nav1_dme; }
inline bool get_nav1_has_dme() const { return nav1_has_dme; }
inline bool get_nav1_has_gs() const { return nav1_has_gs; }
inline bool get_nav1_loc() const { return nav1_loc; }
inline double get_nav1_loclon() const { return nav1_loclon; }
inline double get_nav1_loclat() const { return nav1_loclat; }
inline double get_nav1_loc_dist() const { return nav1_loc_dist; }
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; }
@ -174,10 +186,12 @@ public:
inline double get_nav1_target_gs() const { return nav1_target_gs; }
inline bool get_nav2_inrange() const { return nav2_inrange; }
inline bool get_nav2_dme() const { return nav2_dme; }
inline bool get_nav2_has_dme() const { return nav2_has_dme; }
inline bool get_nav2_has_gs() const { return nav2_has_gs; }
inline bool get_nav2_loc() const { return nav2_loc; }
inline double get_nav2_loclon() const { return nav2_loclon; }
inline double get_nav2_loclat() const { return nav2_loclat; }
inline double get_nav2_loc_dist() const { return nav2_loc_dist; }
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; }

View file

@ -332,7 +332,7 @@ void FGSteam::_CatchUp()
double FGSteam::get_HackGS_deg () {
if ( current_radiostack->get_nav1_inrange() &&
current_radiostack->get_nav1_loc() )
current_radiostack->get_nav1_has_gs() )
{
double x = current_radiostack->get_nav1_gs_dist();
double y = (FGBFI::getAltitude() - current_radiostack->get_nav1_elev())

View file

@ -57,11 +57,14 @@ class FGILS {
double locheading;
double loclat;
double loclon;
double x, y, z;
bool has_gs;
double gselev;
double gsangle;
double gslat;
double gslon;
double gs_x, gs_y, gs_z;
bool has_dme;
double dmelat;
double dmelon;
double dme_x, dme_y, dme_z;
@ -86,6 +89,10 @@ public:
inline double get_locheading() const { return locheading; }
inline double get_loclat() const { return loclat; }
inline double get_loclon() const { return loclon; }
inline double get_x() const { return x; }
inline double get_y() const { return y; }
inline double get_z() const { return z; }
inline bool get_has_gs() const { return has_gs; }
inline double get_gselev() const { return gselev; }
inline double get_gsangle() const { return gsangle; }
inline double get_gslat() const { return gslat; }
@ -93,6 +100,7 @@ public:
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 bool get_has_dme() const { return has_dme; }
inline double get_dmelat() const { return dmelat; }
inline double get_dmelon() const { return dmelon; }
inline double get_dme_x() const { return dme_x; }
@ -127,30 +135,38 @@ operator >> ( istream& in, FGILS& i )
// generate cartesian coordinates
Point3D geod, cart;
geod = Point3D( i.loclon * DEG_TO_RAD, i.loclat * DEG_TO_RAD, i.gselev );
cart = fgGeodToCart( geod );
i.x = cart.x();
i.y = cart.y();
i.z = cart.z();
if ( i.gslon < FG_EPSILON && i.gslat < FG_EPSILON ) {
i.gslon = i.loclon;
i.gslat = i.loclat;
i.has_gs = false;
} else {
i.has_gs = true;
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;
}
if ( i.dmelon < FG_EPSILON && i.dmelat < FG_EPSILON ) {
i.dmelon = i.gslon;
i.dmelat = i.gslat;
i.has_dme = false;
} else {
i.has_dme = true;
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;
}
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;
}

View file

@ -122,9 +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_dme_x(),
current->get_dme_y(),
current->get_dme_z());
station = Point3D(current->get_x(),
current->get_y(),
current->get_z());
// cout << " aircraft = " << aircraft << " station = " << station
// << endl;

View file

@ -52,7 +52,7 @@ class FGNav {
double x, y, z;
int freq;
int range;
bool dme;
bool has_dme;
char ident[5];
public:
@ -69,7 +69,7 @@ public:
inline double get_z() const { return z; }
inline int get_freq() const { return freq; }
inline int get_range() const { return range; }
inline bool get_dme() const { return dme; }
inline bool get_has_dme() const { return has_dme; }
inline char *get_ident() { return ident; }
/* inline void set_type( char t ) { type = t; }
@ -95,9 +95,9 @@ operator >> ( istream& in, FGNav& n )
n.freq = (int)(f*100.0 + 0.5);
if ( c == 'Y' ) {
n.dme = true;
n.has_dme = true;
} else {
n.dme = false;
n.has_dme = false;
}
// generate cartesian coordinates