FGRouteMgr::FGRouteMgr() :
_route( new SGRoute ),
_autoSequence(true),
- lon( NULL ),
- lat( NULL ),
- alt( NULL ),
- target_altitude_ft( NULL ),
- altitude_lock( NULL ),
+ _driveAutopilot(true),
input(fgGetNode( RM "input", true )),
mirror(fgGetNode( RM "route", true )),
altitude_set( false )
alt = fgGetNode( "/position/altitude-ft", true );
magvar = fgGetNode("/environment/magnetic-variation-deg", true);
- target_altitude_ft = fgGetNode( "/autopilot/settings/target-altitude-ft", true );
- altitude_lock = fgGetNode( "/autopilot/locks/altitude", true );
-
+// autopilot drive properties
+ _apTargetAltitudeFt = fgGetNode( "/autopilot/settings/target-altitude-ft", true );
+ _apAltitudeLock = fgGetNode( "/autopilot/locks/altitude", true );
+ _apTrueHeading = fgGetNode( "/autopilot/settings/true-heading-deg", true );
+ rm->tie("drive-autopilot", SGRawValuePointer<bool>(&_driveAutopilot));
+
departure = fgGetNode(RM "departure", true);
// init departure information from current location
SGGeod pos = SGGeod::fromDegFt(lon->getDoubleValue(), lat->getDoubleValue(), alt->getDoubleValue());
}
altitude_set = true;
- target_altitude_ft->setDoubleValue(wp.get_target().getElevationFt());
+
+ if (!_driveAutopilot) {
+ return;
+ }
+
+ _apTargetAltitudeFt->setDoubleValue(wp.get_target().getElevationFt());
if ( !near_ground() ) {
- // James Turner [zakalawe]: there's no explanation for this logic,
- // it feels like the autopilot should pull the target altitude out of
- // wp0 instead of us pushing it through here. Hmmm.
- altitude_lock->setStringValue( "altitude-hold" );
+ _apAltitudeLock->setStringValue( "altitude-hold" );
}
}
}
}
+ if (_driveAutopilot) {
+ _apTrueHeading->setDoubleValue(wp_course);
+ }
+
// update wp0 / wp1 / wp-last for legacy users
wp0->setDoubleValue("dist", wp_distance * SG_METER_TO_NM);
wp_course -= magvar->getDoubleValue(); // expose magnetic bearing
}
currentWp->setIntValue(_route->current_index());
+ updateTargetAltitude();
SG_LOG(SG_AUTOPILOT, SG_INFO, "route manager, current-wp is now " << _route->current_index());
}
SGPropertyNode_ptr magvar;
// automatic outputs
- SGPropertyNode_ptr target_altitude_ft;
- SGPropertyNode_ptr altitude_lock;
-
+ bool _driveAutopilot;
+ SGPropertyNode_ptr _apTargetAltitudeFt;
+ SGPropertyNode_ptr _apAltitudeLock;
+ SGPropertyNode_ptr _apTrueHeading;
+
SGPropertyNode_ptr departure; ///< departure airport information
SGPropertyNode_ptr destination; ///< destination airport information
SGPropertyNode_ptr alternate; ///< alternate airport information