I’m adding new mission items to the end of a running mission with Lua, but the AP restarts the running mission item when I do so. This seems to happen due to a mission change check in
My reading of
AP_Mission_ChangeDetector::check_for_mission_change() suggests that so long as the three mission items after the current one are the same, this function should return
false, no change.
However, if I add a mission item (at the end of the mission — many mission items away) between when the current mission item is read by ArudPilot but before it has been reached,
check_for_mission_change() claims the mission has changed and
AP_Mission restarts the current item. This seems to happen because the
mis_change_detect structure saves the current command index, but that command index is advanced somewhere in this process, making the items “mismatch.”
Is this the desired behavior? If so, why?
(An alternative, to wait for
MISSION_COMPLETE and then load the new items prompts the Copter to slow down and pause before starting the next mission items, which is not ideal.)