Bug 974, GPS exceptions at end-of-route.
One of the two route termination conditions was improperly handled, leading to bad leg/wpt indices and exceptions from the GPS code. Detect passing the final waypoint in a more robust way now. Also fix the GPS code to avoid turn computation on the final leg.
This commit is contained in:
parent
e9ecf4eb52
commit
d311045018
3 changed files with 33 additions and 28 deletions
|
@ -453,7 +453,7 @@ void FGRouteMgr::update( double dt )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkFinished()) {
|
if (checkFinished()) {
|
||||||
// maybe we're done
|
endOfRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
// basic course/distance information
|
// basic course/distance information
|
||||||
|
@ -535,14 +535,11 @@ int FGRouteMgr::currentIndex() const
|
||||||
|
|
||||||
Waypt* FGRouteMgr::wayptAtIndex(int index) const
|
Waypt* FGRouteMgr::wayptAtIndex(int index) const
|
||||||
{
|
{
|
||||||
if (_plan) {
|
if (!_plan) {
|
||||||
FlightPlan::Leg* leg = _plan->legAtIndex(index);
|
throw sg_range_exception("wayptAtindex: no flightplan");
|
||||||
if (leg) {
|
|
||||||
return leg->waypoint();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return _plan->legAtIndex(index)->waypoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
int FGRouteMgr::numLegs() const
|
int FGRouteMgr::numLegs() const
|
||||||
|
@ -590,8 +587,12 @@ void FGRouteMgr::removeLegAtIndex(int aIndex)
|
||||||
void FGRouteMgr::waypointsChanged()
|
void FGRouteMgr::waypointsChanged()
|
||||||
{
|
{
|
||||||
update_mirror();
|
update_mirror();
|
||||||
_edited->fireValueChanged();
|
_edited->fireValueChanged();
|
||||||
checkFinished();
|
|
||||||
|
// removing waypoints, deactivate if we hit the end.
|
||||||
|
if (currentIndex() >= numLegs()) {
|
||||||
|
endOfRoute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mirror internal route to the property system for inspection by other subsystems
|
// mirror internal route to the property system for inspection by other subsystems
|
||||||
|
@ -802,11 +803,21 @@ void FGRouteMgr::sequence()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkFinished()) {
|
int nextIndex = _plan->currentIndex() + 1;
|
||||||
|
if (nextIndex >= _plan->numLegs()) {
|
||||||
|
SG_LOG(SG_AUTOPILOT, SG_INFO, "sequenced on final leg, deactivating route");
|
||||||
|
endOfRoute();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_plan->setCurrentIndex(_plan->currentIndex() + 1);
|
_plan->setCurrentIndex(nextIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FGRouteMgr::endOfRoute()
|
||||||
|
{
|
||||||
|
SG_LOG(SG_AUTOPILOT, SG_INFO, "reached end of active route");
|
||||||
|
_finished->fireValueChanged();
|
||||||
|
active->setBoolValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FGRouteMgr::checkFinished()
|
bool FGRouteMgr::checkFinished()
|
||||||
|
@ -824,15 +835,8 @@ bool FGRouteMgr::checkFinished()
|
||||||
done = weightOnWheels->getBoolValue() && (gs < 25);
|
done = weightOnWheels->getBoolValue() && (gs < 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
// also done if we hit the final waypoint
|
|
||||||
if (_plan->currentIndex() >= _plan->numLegs()) {
|
|
||||||
done = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
SG_LOG(SG_AUTOPILOT, SG_INFO, "reached end of active route");
|
SG_LOG(SG_AUTOPILOT, SG_INFO, "checkFinished: on the ground on destination runway, we're done");
|
||||||
_finished->fireValueChanged();
|
|
||||||
active->setBoolValue(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return done;
|
return done;
|
||||||
|
|
|
@ -194,6 +194,11 @@ private:
|
||||||
*/
|
*/
|
||||||
bool checkFinished();
|
bool checkFinished();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* update state when we pass the final waypoint
|
||||||
|
*/
|
||||||
|
void endOfRoute();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Predicate for helping the UI - test if at least one waypoint was
|
* Predicate for helping the UI - test if at least one waypoint was
|
||||||
* entered by the user (as opposed to being generated by the route-manager)
|
* entered by the user (as opposed to being generated by the route-manager)
|
||||||
|
|
|
@ -877,18 +877,14 @@ double GPS::computeTurnProgress(double aBearing) const
|
||||||
void GPS::computeTurnData()
|
void GPS::computeTurnData()
|
||||||
{
|
{
|
||||||
_computeTurnData = false;
|
_computeTurnData = false;
|
||||||
if (_mode != "leg") { // and approach modes in the future
|
int nextIndex = _routeMgr->currentIndex() + 1;
|
||||||
|
if ((_mode != "leg") || (nextIndex >= _routeMgr->numWaypts())) {
|
||||||
_anticipateTurn = false;
|
_anticipateTurn = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WayptRef next = _routeMgr->wayptAtIndex(_routeMgr->currentIndex() + 1);
|
WayptRef next = _routeMgr->wayptAtIndex(nextIndex);
|
||||||
if (!next || next->flag(WPT_DYNAMIC)) {
|
if (next->flag(WPT_DYNAMIC) || !_config.turnAnticipationEnabled()) {
|
||||||
_anticipateTurn = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_config.turnAnticipationEnabled()) {
|
|
||||||
_anticipateTurn = false;
|
_anticipateTurn = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue