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.
#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>
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 :-)
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();
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
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();
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
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 {
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 {
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 {
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 {
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 {
}
}
-
// Local functions
////////////////////////////////////////////////////////////////////////
+
/**
* Initialize the BFI by binding its functions to properties.
*
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);