PathPlanner does not engage correctly when FlightModeChangeRestartsPathPlan is set to False

Description

PathPlanner Flight Mode does not behave as desired when

FlightModeSettings | FlightModeChangeRestartsPathPlan is False

and any other autonomous mode, like PH, RTB, etc., that itself changes pathDesired is used before entering PP. In this situation attempt to enter PP uses the existing values in pathDesired instead of values from current waypoint in the path plan, typically resulting in attempt to PH at these not related to path plan coordinates.

To fix the issue, I suggest a minor correction in

\flight\modules\PathPlanner\pathplanner.c, in pathPlannerTask()
rows 231-234, currently:

1 2 3 4 if (restart == FLIGHTMODESETTINGS_FLIGHTMODECHANGERESTARTSPATHPLAN_TRUE) { setWaypoint(0); return; }

replace with:

1 2 3 4 5 6 7 if (restart == FLIGHTMODESETTINGS_FLIGHTMODECHANGERESTARTSPATHPLAN_TRUE) { setWaypoint(0); } else { setWaypoint(waypointActive.Index); } return;

Calling setWaypoint() ensures that pathDesired is updated according current waypoint (on the first engagement of PP mode, this is waypoint "0").
As a result of the initiated waypoint change, the updatePathDesired() is executed and pathDesired gets the valid values from current path plan waypoint.

I've compiled a r711 based Revo firmware with this suggested code change and tested it successfully with a multirotor. Hadn't yet a chance to test it on a fixed wing.

P.S. I'm getting acquainted with the Git Workflow (from the LibrePilot Developer Manual) and I'll try to post a commit with the suggested code change.

Environment

None

Status

Assignee

Julian Lilov

Reporter

Julian Lilov

Labels

Components

Fix versions

Affects versions

REL-16.09 - Black Rhino

Priority

Medium
Configure