Commit cacad2b2 authored by Don Gagne's avatar Don Gagne

Merge pull request #2774 from DonLakeFlyer/HomeLine

Fix line to home logic
parents 79959dcb 35118d54
......@@ -455,6 +455,7 @@ void MissionController::_recalcWaypointLines(void)
_waypointLines.clear();
bool linkBackToHome = false;
for (int i=1; i<_missionItems->count(); i++) {
MissionItem* item = qobject_cast<MissionItem*>(_missionItems->get(i));
......@@ -462,6 +463,10 @@ void MissionController::_recalcWaypointLines(void)
item->setAzimuth(0.0);
item->setDistance(-1.0);
if (firstCoordinateItem && item->command() == MavlinkQmlSingleton::MAV_CMD_NAV_TAKEOFF) {
linkBackToHome = true;
}
if (item->specifiesCoordinate()) {
double absoluteAltitude = item->coordinate().altitude();
if (item->relativeAltitude()) {
......@@ -471,23 +476,8 @@ void MissionController::_recalcWaypointLines(void)
maxAltSeen = std::max(maxAltSeen, absoluteAltitude);
if (!item->standaloneCoordinate()) {
if (firstCoordinateItem) {
if (item->command() == MavlinkQmlSingleton::MAV_CMD_NAV_TAKEOFF) {
// The first coordinate we hit is a takeoff command so link back to home position
if (showHomePosition) {
double azimuth, distance, altDifference;
_waypointLines.append(new CoordinateVector(homeItem->coordinate(), item->coordinate()));
_calcPrevWaypointValues(homeAlt, item, homeItem, &azimuth, &distance, &altDifference);
item->setAltDifference(altDifference);
item->setAzimuth(azimuth);
item->setDistance(distance);
}
} else {
// First coordiante is not a takeoff command, it does not link backwards to anything
}
firstCoordinateItem = false;
} else if (!lastCoordinateItem->homePosition() || showHomePosition) {
firstCoordinateItem = false;
if (!lastCoordinateItem->homePosition() || (showHomePosition && linkBackToHome)) {
double azimuth, distance, altDifference;
// Subsequent coordinate items link to last coordinate item. If the last coordinate item
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment