]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/newauto.cxx
Make sure that all elapsed time gets passed to update when a subsystem
[flightgear.git] / src / Autopilot / newauto.cxx
index a8699bf5769dff24efd87b27f733782154a59136..668811a6c9712e195c7d2c1cbdc8edd3605a74db 100644 (file)
@@ -37,7 +37,6 @@
 #include <simgear/math/sg_random.h>
 #include <simgear/route/route.hxx>
 
-#include <Cockpit/steam.hxx>
 #include <Cockpit/radiostack.hxx>
 #include <Controls/controls.hxx>
 #include <FDM/flight.hxx>
@@ -213,6 +212,9 @@ void FGAutopilot::init ()
     altitude_agl_node = fgGetNode("/position/altitude-agl-ft", true);
     vertical_speed_node = fgGetNode("/velocities/vertical-speed-fps", true);
     heading_node = fgGetNode("/orientation/heading-deg", true);
+    dg_heading_node
+        = fgGetNode("/instrumentation/heading-indicator/indicated-heading-deg",
+                    true);
     roll_node = fgGetNode("/orientation/roll-deg", true);
     pitch_node = fgGetNode("/orientation/pitch-deg", true);
 
@@ -393,7 +395,7 @@ void FGAutopilot::reset() {
        
     update_old_control_values();
 
-    sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
+    sprintf( NewTgtAirportId, "%s", fgGetString("/sim/presets/airport-id") );
        
     MakeTargetLatLonStr( get_TargetLatitude(), get_TargetLongitude() );
 }
@@ -484,8 +486,10 @@ FGAutopilot::update (double dt)
     // heading hold
     if ( heading_hold == true ) {
        if ( heading_mode == FG_DG_HEADING_LOCK ) {
-           TargetHeading = DGTargetHeading +
-             globals->get_steam()->get_DG_err();
+            double dg_error = heading_node->getDoubleValue()
+                - dg_heading_node->getDoubleValue();
+           TargetHeading = DGTargetHeading + dg_error;
+            // cout << "dg_error = " << dg_error << endl;
            while ( TargetHeading <   0.0 ) { TargetHeading += 360.0; }
            while ( TargetHeading > 360.0 ) { TargetHeading -= 360.0; }
            MakeTargetHeadingStr( TargetHeading );
@@ -607,7 +611,8 @@ FGAutopilot::update (double dt)
 
        if ( heading_mode == FG_TC_HEADING_LOCK ) {
            // drive the turn coordinator to zero
-           double turn = globals->get_steam()->get_TC_std();
+           double turn =
+                fgGetDouble("/instrumentation/turn-indicator/indicated-turn-rate");
            double AileronSet = -turn / 2.0;
             SG_CLAMP_RANGE( AileronSet, -1.0, 1.0 );
            globals->get_controls()->set_aileron( AileronSet );
@@ -694,7 +699,7 @@ FGAutopilot::update (double dt)
        if ( altitude_mode == FG_ALTITUDE_LOCK ) {
            climb_rate =
                ( TargetAltitude -
-                 globals->get_steam()->get_ALT_ft() * SG_FEET_TO_METER ) * 8.0;
+                 fgGetDouble("/instrumentation/altimeter/indicated-altitude-ft") * SG_FEET_TO_METER ) * 8.0;
         } else if ( altitude_mode == FG_TRUE_ALTITUDE_LOCK ) {
             climb_rate = ( TargetAltitude - alt ) * 8.0;
        } else if ( altitude_mode == FG_ALTITUDE_GS1 ) {
@@ -887,10 +892,7 @@ void FGAutopilot::set_HeadingMode( fgAutoHeadingMode mode ) {
     heading_mode = mode;
 
     if ( heading_mode == FG_DG_HEADING_LOCK ) {
-       // set heading hold to current heading (as read from DG)
-       // ... no, leave target heading along ... just use the current
-       // heading bug value
-        //  DGTargetHeading = FGSteam::get_DG_deg();
+       // use current heading bug value
     } else if ( heading_mode == FG_TC_HEADING_LOCK ) {
        // set autopilot to hold a zero turn (as reported by the TC)
     } else if ( heading_mode == FG_TRUE_HEADING_LOCK ) {