Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/main/navigation/rth_trackback.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ bool rthTrackBackSetNewPosition(void)
rth_trackback.activePointIndex = NAV_RTH_TRACKBACK_POINTS - 1;
}

calculateAndSetActiveWaypointToLocalPosition(getRthTrackBackPosition());

if (rth_trackback.activePointIndex - rth_trackback.WrapAroundCounter == 0) {
rth_trackback.WrapAroundCounter = rth_trackback.activePointIndex = -1;
// Last trackback point reached when activePointIndex = WrapAroundCounter so only set position when not equal
if (rth_trackback.activePointIndex != rth_trackback.WrapAroundCounter) {
calculateAndSetActiveWaypointToLocalPosition(getRthTrackBackPosition());
} else {
rth_trackback.activePointIndex = -1; // if not already = -1 set to -1 to end trackback next iteration
}
} else {
setDesiredPosition(getRthTrackBackPosition(), 0, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_BEARING);
Expand Down