Fix unrealistic-but-convenient direct-drive from the route-manager to the autopilot code. A new boolean config prop, 'drive-autopilot' exists, to disable this behaviour.
This commit is contained in:
parent
bde366e0e3
commit
110dd605a0
2 changed files with 24 additions and 16 deletions
|
@ -65,11 +65,7 @@ static double get_ground_speed() {
|
|||
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 )
|
||||
|
@ -96,9 +92,12 @@ void FGRouteMgr::init() {
|
|||
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());
|
||||
|
@ -203,13 +202,15 @@ void FGRouteMgr::updateTargetAltitude() {
|
|||
}
|
||||
|
||||
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" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,6 +262,10 @@ void FGRouteMgr::update( double dt ) {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -639,6 +644,7 @@ void FGRouteMgr::currentWaypointChanged()
|
|||
}
|
||||
|
||||
currentWp->setIntValue(_route->current_index());
|
||||
updateTargetAltitude();
|
||||
SG_LOG(SG_AUTOPILOT, SG_INFO, "route manager, current-wp is now " << _route->current_index());
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,11 @@ private:
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue