Fixed a typo preventing the nav2 heading needle from moving.
DG heading bug initializes to a random setting. Activating heading hold doesn't touch the DG heading bug any more. Max autopilot decent rate is now -1000.
This commit is contained in:
parent
bd9ce60174
commit
74cb68daae
3 changed files with 25 additions and 16 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
#include <simgear/math/sg_random.h>
|
||||
|
||||
#include <Cockpit/steam.hxx>
|
||||
#include <Cockpit/radiostack.hxx>
|
||||
|
@ -51,6 +52,7 @@ FGAutopilot *current_autopilot;
|
|||
const double min_climb = 70.0; // kts
|
||||
const double best_climb = 75.0; // kts
|
||||
const double ideal_climb_rate = 500.0 * FEET_TO_METER; // fpm -> mpm
|
||||
const double ideal_decent_rate = 1000.0 * FEET_TO_METER; // fpm -> mpm
|
||||
|
||||
/// These statics will eventually go into the class
|
||||
/// they are just here while I am experimenting -- NHV :-)
|
||||
|
@ -208,6 +210,9 @@ void FGAutopilot::init() {
|
|||
altitude_hold = false ; // turn the altitude hold off
|
||||
auto_throttle = false ; // turn the auto throttle off
|
||||
|
||||
sg_srandom_time();
|
||||
DGTargetHeading = sg_random() * 360.0;
|
||||
|
||||
// Initialize target location to startup location
|
||||
old_lat = FGBFI::getLatitude();
|
||||
old_lon = FGBFI::getLongitude();
|
||||
|
@ -638,13 +643,15 @@ int FGAutopilot::run() {
|
|||
TargetClimbRate = max_climb;
|
||||
}
|
||||
|
||||
if ( TargetClimbRate < -ideal_climb_rate ) {
|
||||
TargetClimbRate = -ideal_climb_rate;
|
||||
if ( TargetClimbRate < -ideal_decent_rate ) {
|
||||
TargetClimbRate = -ideal_decent_rate;
|
||||
}
|
||||
// cout << "Target climb = " << TargetClimbRate * METER_TO_FEET
|
||||
// << " fpm" << endl;
|
||||
|
||||
error = FGBFI::getVerticalSpeed() * FEET_TO_METER - TargetClimbRate;
|
||||
// cout << "climb rate = " << fgAPget_climb()
|
||||
// << " error = " << error << endl;
|
||||
cout << "climb rate = " << FGBFI::getVerticalSpeed()
|
||||
<< " vsi rate = " << FGSteam::get_VSI_fps() << endl;
|
||||
|
||||
// accumulate the error under the curve ... this really should
|
||||
// be *= delta t
|
||||
|
@ -761,7 +768,9 @@ void FGAutopilot::set_HeadingMode( fgAutoHeadingMode mode ) {
|
|||
|
||||
if ( heading_mode == FG_DG_HEADING_LOCK ) {
|
||||
// set heading hold to current heading (as read from DG)
|
||||
DGTargetHeading = FGSteam::get_DG_deg();
|
||||
// ... no, leave target heading along ... just use the current
|
||||
// heading bug value
|
||||
// DGTargetHeading = FGSteam::get_DG_deg();
|
||||
} else if ( heading_mode == FG_HEADING_LOCK ) {
|
||||
// set heading hold to current heading
|
||||
TargetHeading = FGBFI::getHeading();
|
||||
|
|
|
@ -135,9 +135,9 @@ FGRadioStack::bind ()
|
|||
fgTie("/radios/nav2/dme/distance", this, &FGRadioStack::get_nav2_dme_dist);
|
||||
fgTie("/radios/nav2/dme/in-range", this,
|
||||
&FGRadioStack::get_nav2_dme_inrange);
|
||||
fgTie("/radios/nav1/heading-needle-deflection", this,
|
||||
fgTie("/radios/nav2/heading-needle-deflection", this,
|
||||
&FGRadioStack::get_nav2_heading_needle_deflection);
|
||||
fgTie("/radios/nav1/gs-needle-deflection", this,
|
||||
fgTie("/radios/nav2/gs-needle-deflection", this,
|
||||
&FGRadioStack::get_nav2_gs_needle_deflection);
|
||||
|
||||
// User inputs
|
||||
|
@ -477,15 +477,15 @@ double FGRadioStack::get_nav2_heading_needle_deflection() const {
|
|||
|
||||
if ( nav2_inrange ) {
|
||||
r = nav2_heading - nav2_radial;
|
||||
// cout << "Radial = " << nav1_radial
|
||||
// << " Bearing = " << nav1_heading << endl;
|
||||
// cout << "Radial = " << nav2_radial
|
||||
// << " Bearing = " << nav2_heading << endl;
|
||||
|
||||
while (r> 180.0) r-=360.0;
|
||||
while (r<-180.0) r+=360.0;
|
||||
if ( fabs(r) > 90.0 )
|
||||
r = ( r<0.0 ? -r-180.0 : -r+180.0 );
|
||||
// According to Robin Peel, the ILS is 4x more sensitive than a vor
|
||||
if ( nav1_loc ) r *= 4.0;
|
||||
if ( nav2_loc ) r *= 4.0;
|
||||
if ( r < -10.0 ) r = -10.0;
|
||||
if ( r > 10.0 ) r = 10.0;
|
||||
} else {
|
||||
|
@ -532,7 +532,7 @@ FGRadioStack::get_nav1_to_flag () const
|
|||
if (nav1_inrange) {
|
||||
double offset = fabs(nav1_heading - nav1_radial);
|
||||
if (nav1_loc)
|
||||
return (offset <= 8.0 || offset >= 352.0);
|
||||
return true;
|
||||
else
|
||||
return (offset <= 90.0 || offset >= 270.0);
|
||||
} else {
|
||||
|
@ -550,7 +550,7 @@ FGRadioStack::get_nav1_from_flag () const
|
|||
if (nav1_inrange) {
|
||||
double offset = fabs(nav1_heading - nav1_radial);
|
||||
if (nav1_loc)
|
||||
return (offset >= 172.0 && offset <= 188.0);
|
||||
return false;
|
||||
else
|
||||
return (offset > 90.0 && offset < 270.0);
|
||||
} else {
|
||||
|
@ -568,7 +568,7 @@ FGRadioStack::get_nav2_to_flag () const
|
|||
if (nav2_inrange) {
|
||||
double offset = fabs(nav2_heading - nav2_radial);
|
||||
if (nav2_loc)
|
||||
return (offset <= 8.0 || offset >= 352.0);
|
||||
return true;
|
||||
else
|
||||
return (offset <= 90.0 || offset >= 270.0);
|
||||
} else {
|
||||
|
@ -586,7 +586,7 @@ FGRadioStack::get_nav2_from_flag () const
|
|||
if (nav2_inrange) {
|
||||
double offset = fabs(nav2_heading - nav2_radial);
|
||||
if (nav2_loc)
|
||||
return (offset >= 172.0 && offset <= 188.0);
|
||||
return false;
|
||||
else
|
||||
return (offset > 90.0 && offset < 270.0);
|
||||
} else {
|
||||
|
@ -594,4 +594,3 @@ FGRadioStack::get_nav2_from_flag () const
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ _set_view_from_axes ()
|
|||
// Local functions
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the BFI by binding its functions to properties.
|
||||
*
|
||||
|
@ -197,7 +198,7 @@ FGBFI::init ()
|
|||
fgTie("/autopilot/settings/altitude", getAPAltitude, setAPAltitude);
|
||||
fgTie("/autopilot/locks/heading", getAPHeadingLock, setAPHeadingLock);
|
||||
fgTie("/autopilot/settings/heading", getAPHeading, setAPHeading);
|
||||
fgTie("/autopilot/settings/heading-dg", getAPHeadingDG, setAPHeadingDG);
|
||||
fgTie("/autopilot/settings/heading-dg", getAPHeadingDG, setAPHeadingDG, false);
|
||||
fgTie("/autopilot/settings/heading-magnetic",
|
||||
getAPHeadingMag, setAPHeadingMag);
|
||||
fgTie("/autopilot/locks/nav1", getAPNAV1Lock, setAPNAV1Lock);
|
||||
|
|
Loading…
Reference in a new issue