Working on ironing out issues with VOR navigation. It think we are "as
good as we can get" until we find a data source with actual VOR magnetic offsets. We can use VOR offsets from some fixed date, but not all VOR's were installed on the same day so no matter what date we pick we will be off on most of them.
This commit is contained in:
parent
cbaf015481
commit
2827cf1387
7 changed files with 49 additions and 27 deletions
|
@ -375,10 +375,11 @@ int FGAutopilot::run() {
|
||||||
// localizers radials are "true"
|
// localizers radials are "true"
|
||||||
tgt_radial = current_radiostack->get_nav1_radial();
|
tgt_radial = current_radiostack->get_nav1_radial();
|
||||||
} else {
|
} else {
|
||||||
tgt_radial = current_radiostack->get_nav1_radial()
|
tgt_radial = current_radiostack->get_nav1_radial() +
|
||||||
+ FGBFI::getMagVar();
|
current_radiostack->get_nav1_magvar();
|
||||||
}
|
}
|
||||||
cur_radial = current_radiostack->get_nav1_heading();
|
cur_radial = current_radiostack->get_nav1_heading() +
|
||||||
|
current_radiostack->get_nav1_magvar();
|
||||||
// cout << "target rad (true) = " << tgt_radial
|
// cout << "target rad (true) = " << tgt_radial
|
||||||
// << " current rad (true) = " << cur_radial
|
// << " current rad (true) = " << cur_radial
|
||||||
// << endl;
|
// << endl;
|
||||||
|
@ -394,6 +395,7 @@ int FGAutopilot::run() {
|
||||||
TargetHeading = cur_radial - diff;
|
TargetHeading = cur_radial - diff;
|
||||||
while ( TargetHeading < 0.0 ) { TargetHeading += 360.0; }
|
while ( TargetHeading < 0.0 ) { TargetHeading += 360.0; }
|
||||||
while ( TargetHeading > 360.0 ) { TargetHeading -= 360.0; }
|
while ( TargetHeading > 360.0 ) { TargetHeading -= 360.0; }
|
||||||
|
MakeTargetHeadingStr( TargetHeading );
|
||||||
// cout << "target course (true) = " << TargetHeading << endl;
|
// cout << "target course (true) = " << TargetHeading << endl;
|
||||||
} else if ( heading_mode == FG_HEADING_WAYPOINT ) {
|
} else if ( heading_mode == FG_HEADING_WAYPOINT ) {
|
||||||
// update target heading to waypoint
|
// update target heading to waypoint
|
||||||
|
|
|
@ -209,7 +209,7 @@ FGRadioStack::update()
|
||||||
geo_inverse_wgs_84( elev, lat * RAD_TO_DEG, lon * RAD_TO_DEG,
|
geo_inverse_wgs_84( elev, lat * RAD_TO_DEG, lon * RAD_TO_DEG,
|
||||||
nav1_loclat, nav1_loclon,
|
nav1_loclat, nav1_loclon,
|
||||||
&az1, &az2, &s );
|
&az1, &az2, &s );
|
||||||
cout << "az1 = " << az1 << " magvar = " << nav1_magvar << endl;
|
// cout << "az1 = " << az1 << " magvar = " << nav1_magvar << endl;
|
||||||
nav1_heading = az1 - nav1_magvar;
|
nav1_heading = az1 - nav1_magvar;
|
||||||
// Alex: nav1_heading = - (az1 - FGBFI::getMagVar() / RAD_TO_DEG);
|
// Alex: nav1_heading = - (az1 - FGBFI::getMagVar() / RAD_TO_DEG);
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,7 @@ public:
|
||||||
inline double get_nav1_heading() const { return nav1_heading; }
|
inline double get_nav1_heading() const { return nav1_heading; }
|
||||||
inline double get_nav1_radial() const { return nav1_radial; }
|
inline double get_nav1_radial() const { return nav1_radial; }
|
||||||
inline double get_nav1_target_gs() const { return nav1_target_gs; }
|
inline double get_nav1_target_gs() const { return nav1_target_gs; }
|
||||||
|
inline double get_nav1_magvar() const { return nav1_magvar; }
|
||||||
|
|
||||||
inline bool get_nav2_inrange() const { return nav2_inrange; }
|
inline bool get_nav2_inrange() const { return nav2_inrange; }
|
||||||
bool get_nav2_to_flag () const;
|
bool get_nav2_to_flag () const;
|
||||||
|
@ -225,6 +226,7 @@ public:
|
||||||
inline double get_nav2_heading() const { return nav2_heading; }
|
inline double get_nav2_heading() const { return nav2_heading; }
|
||||||
inline double get_nav2_radial() const { return nav2_radial; }
|
inline double get_nav2_radial() const { return nav2_radial; }
|
||||||
inline double get_nav2_target_gs() const { return nav2_target_gs; }
|
inline double get_nav2_target_gs() const { return nav2_target_gs; }
|
||||||
|
inline double get_nav2_magvar() const { return nav2_magvar; }
|
||||||
|
|
||||||
inline bool get_adf_inrange() const { return adf_inrange; }
|
inline bool get_adf_inrange() const { return adf_inrange; }
|
||||||
inline double get_adf_lon() const { return adf_lon; }
|
inline double get_adf_lon() const { return adf_lon; }
|
||||||
|
|
|
@ -130,9 +130,6 @@ void FGSteam::update ( int timesteps )
|
||||||
_UpdatesPending += timesteps;
|
_UpdatesPending += timesteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DF1
|
|
||||||
#undef DF2
|
|
||||||
|
|
||||||
|
|
||||||
/* tc should be (elapsed_time_between_updates / desired_smoothing_time) */
|
/* tc should be (elapsed_time_between_updates / desired_smoothing_time) */
|
||||||
void FGSteam::set_lowpass ( double *outthe, double inthe, double tc )
|
void FGSteam::set_lowpass ( double *outthe, double inthe, double tc )
|
||||||
|
@ -169,11 +166,10 @@ void FGSteam::set_lowpass ( double *outthe, double inthe, double tc )
|
||||||
double pressInHgToAltFt(double p_inhg)
|
double pressInHgToAltFt(double p_inhg)
|
||||||
{
|
{
|
||||||
// Ref. Aviation Formulary, Ed Williams, www.best.com/~williams/avform.htm
|
// Ref. Aviation Formulary, Ed Williams, www.best.com/~williams/avform.htm
|
||||||
const double P_0 = 29.92126; // Std. MSL pressure, inHg. (=10135.25 mb)
|
const double P_0 = 29.92126; // Std. MSL pressure, inHg. (=1013.25 mb)
|
||||||
const double p_Tr = 0.2233609 * P_0; // Pressure at tropopause, same units.
|
const double p_Tr = 0.2233609 * P_0; // Pressure at tropopause, same units.
|
||||||
const double h_Tr = 36089.24; // Alt of tropopause, ft. (=11.0 km)
|
const double h_Tr = 36089.24; // Alt of tropopause, ft. (=11.0 km)
|
||||||
|
|
||||||
// return (P_0 - p_inhg) * 1000.0; // ### crude approx. for low alt's
|
|
||||||
if (p_inhg > p_Tr) // 0.0 to 11.0 km
|
if (p_inhg > p_Tr) // 0.0 to 11.0 km
|
||||||
return (1.0 - pow((p_inhg / P_0), 1.0 / 5.2558797)) / 6.8755856e-6;
|
return (1.0 - pow((p_inhg / P_0), 1.0 / 5.2558797)) / 6.8755856e-6;
|
||||||
return h_Tr + log10(p_inhg / p_Tr) / -4.806346e-5; // 11.0 to 20.0 km
|
return h_Tr + log10(p_inhg / p_Tr) / -4.806346e-5; // 11.0 to 20.0 km
|
||||||
|
@ -181,6 +177,21 @@ double pressInHgToAltFt(double p_inhg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert altitude to air pressure by ICAO Standard Atmosphere
|
||||||
|
double altFtToPressInHg(double alt_ft)
|
||||||
|
{
|
||||||
|
// Ref. Aviation Formulary, Ed Williams, www.best.com/~williams/avform.htm
|
||||||
|
const double P_0 = 29.92126; // Std. MSL pressure, inHg. (=1013.25 mb)
|
||||||
|
const double p_Tr = 0.2233609 * P_0; // Pressure at tropopause, same units.
|
||||||
|
const double h_Tr = 36089.24; // Alt of tropopause, ft. (=11.0 km)
|
||||||
|
|
||||||
|
if (alt_ft < h_Tr) // 0.0 to 11.0 km
|
||||||
|
return P_0 * pow(1.0 - 6.8755856e-6 * alt_ft, 5.2558797);
|
||||||
|
return p_Tr * exp(-4.806346e-5 * (alt_ft - h_Tr)); // 11.0 to 20.0 km
|
||||||
|
// We could put more code for higher altitudes here.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Here the fun really begins
|
// Here the fun really begins
|
||||||
|
@ -322,13 +333,7 @@ void FGSteam::_CatchUp()
|
||||||
We filter the actual value by one second to
|
We filter the actual value by one second to
|
||||||
account for the line impedance of the plumbing.
|
account for the line impedance of the plumbing.
|
||||||
*/
|
*/
|
||||||
double static_inhg = 29.92;
|
double static_inhg = altFtToPressInHg(FGBFI::getAltitude());
|
||||||
i = (int) FGBFI::getAltitude();
|
|
||||||
while ( i > 9000 )
|
|
||||||
{ static_inhg *= 0.707;
|
|
||||||
i -= 9000;
|
|
||||||
}
|
|
||||||
static_inhg *= ( 1.0 - 0.293 * i / 9000.0 );
|
|
||||||
set_lowpass ( & the_STATIC_inhg, static_inhg, dt );
|
set_lowpass ( & the_STATIC_inhg, static_inhg, dt );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -429,9 +434,9 @@ double FGSteam::get_HackVOR1_deg () {
|
||||||
if ( current_radiostack->get_nav1_inrange() ) {
|
if ( current_radiostack->get_nav1_inrange() ) {
|
||||||
r = current_radiostack->get_nav1_heading()
|
r = current_radiostack->get_nav1_heading()
|
||||||
- current_radiostack->get_nav1_radial();
|
- current_radiostack->get_nav1_radial();
|
||||||
cout << "Radial = " << current_radiostack->get_nav1_radial()
|
// cout << "Radial = " << current_radiostack->get_nav1_radial()
|
||||||
<< " Bearing = " << current_radiostack->get_nav1_heading()
|
// << " Bearing = " << current_radiostack->get_nav1_heading()
|
||||||
<< endl;
|
// << endl;
|
||||||
|
|
||||||
if (r> 180.0) r-=360.0; else
|
if (r> 180.0) r-=360.0; else
|
||||||
if (r<-180.0) r+=360.0;
|
if (r<-180.0) r+=360.0;
|
||||||
|
|
|
@ -8,6 +8,9 @@ libNavaids_a_SOURCES = \
|
||||||
nav.hxx navlist.hxx navlist.cxx
|
nav.hxx navlist.hxx navlist.cxx
|
||||||
|
|
||||||
testnavs_SOURCES = testnavs.cxx
|
testnavs_SOURCES = testnavs.cxx
|
||||||
testnavs_LDADD = libNavaids.a -lsgmath -lsgmisc -lsgdebug -lsgmagvar -lz
|
testnavs_LDADD = \
|
||||||
|
libNavaids.a \
|
||||||
|
-lsgtiming -lsgmath -lsgmisc -lsgdebug -lsgmagvar \
|
||||||
|
-lz
|
||||||
|
|
||||||
INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src
|
INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
#include <simgear/math/sg_geodesy.hxx>
|
||||||
#include <simgear/misc/fgstream.hxx>
|
#include <simgear/misc/fgstream.hxx>
|
||||||
#include <simgear/magvar/magvar.hxx>
|
#include <simgear/magvar/magvar.hxx>
|
||||||
|
#include <simgear/timing/sg_time.hxx>
|
||||||
|
|
||||||
#ifdef FG_HAVE_STD_INCLUDES
|
#ifdef FG_HAVE_STD_INCLUDES
|
||||||
# include <istream>
|
# include <istream>
|
||||||
|
@ -95,7 +96,16 @@ operator >> ( istream& in, FGNav& n )
|
||||||
double f;
|
double f;
|
||||||
char c /* , magvar_dir */ ;
|
char c /* , magvar_dir */ ;
|
||||||
string magvar_s;
|
string magvar_s;
|
||||||
|
|
||||||
|
static SGTime time_params;
|
||||||
|
static bool first_time = true;
|
||||||
|
static double julian_date = 0;
|
||||||
|
if ( first_time ) {
|
||||||
|
time_params.update( 0.0, 0.0, 0 );
|
||||||
|
julian_date = time_params.getJD();
|
||||||
|
first_time = false;
|
||||||
|
}
|
||||||
|
|
||||||
in >> n.type >> n.lat >> n.lon >> n.elev >> f >> n.range
|
in >> n.type >> n.lat >> n.lon >> n.elev >> f >> n.range
|
||||||
>> c >> n.ident >> magvar_s;
|
>> c >> n.ident >> magvar_s;
|
||||||
|
|
||||||
|
@ -110,9 +120,12 @@ operator >> ( istream& in, FGNav& n )
|
||||||
// cout << "Calculating magvar for navaid " << n.ident << endl;
|
// cout << "Calculating magvar for navaid " << n.ident << endl;
|
||||||
if (magvar_s == "XXX") {
|
if (magvar_s == "XXX") {
|
||||||
// default to mag var as of 1990-01-01 (Julian 2447892.5)
|
// default to mag var as of 1990-01-01 (Julian 2447892.5)
|
||||||
n.magvar = -sgGetMagVar(n.lon * DEG_TO_RAD, n.lat * DEG_TO_RAD,
|
// cout << "lat = " << n.lat << " lon = " << n.lon << " elev = "
|
||||||
|
// << n.elev << " JD = "
|
||||||
|
// << julian_date << endl;
|
||||||
|
n.magvar = sgGetMagVar(n.lon * DEG_TO_RAD, n.lat * DEG_TO_RAD,
|
||||||
n.elev * FEET_TO_METER,
|
n.elev * FEET_TO_METER,
|
||||||
2447892.5) * RAD_TO_DEG;
|
julian_date) * RAD_TO_DEG;
|
||||||
// cout << "Default variation at " << n.lon << ',' << n.lat
|
// cout << "Default variation at " << n.lon << ',' << n.lat
|
||||||
// << " is " << var << endl;
|
// << " is " << var << endl;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -134,7 +147,7 @@ operator >> ( istream& in, FGNav& n )
|
||||||
n.magvar = 0 - n.magvar;
|
n.magvar = 0 - n.magvar;
|
||||||
// cout << "Explicit magvar of " << n.magvar << endl;
|
// cout << "Explicit magvar of " << n.magvar << endl;
|
||||||
}
|
}
|
||||||
cout << n.ident << " " << n.magvar << endl;
|
// cout << n.ident << " " << n.magvar << endl;
|
||||||
|
|
||||||
// generate cartesian coordinates
|
// generate cartesian coordinates
|
||||||
Point3D geod( n.lon * DEG_TO_RAD, n.lat * DEG_TO_RAD, n.elev );
|
Point3D geod( n.lon * DEG_TO_RAD, n.lat * DEG_TO_RAD, n.elev );
|
||||||
|
|
|
@ -45,9 +45,6 @@ FGNavList::~FGNavList( void ) {
|
||||||
bool FGNavList::init( FGPath path ) {
|
bool FGNavList::init( FGPath path ) {
|
||||||
FGNav n;
|
FGNav n;
|
||||||
|
|
||||||
SGTime time_params;
|
|
||||||
time_params.update( 0.0, 0.0, 0 );
|
|
||||||
|
|
||||||
navaids.erase( navaids.begin(), navaids.end() );
|
navaids.erase( navaids.begin(), navaids.end() );
|
||||||
|
|
||||||
fg_gzifstream in( path.str() );
|
fg_gzifstream in( path.str() );
|
||||||
|
|
Loading…
Reference in a new issue