FlightPlanPilotingItf

public protocol FlightPlanPilotingItf : ActivablePilotingItf, PilotingItf

Flight Plan piloting interface for drones.

Allows to make the drone execute predefined flight plans. A flight plan is defined using a file in Mavlink format. For further information, please refer to Parrot FlightPlan Mavlink documentation.

This piloting interface remains .unavailable until all FlightPlanUnavailabilityReason have been cleared:

  • A Flight Plan file (i.e. a mavlink file) has been uploaded to the drone (see uploadFlightPlan(filepath:))
  • The drone GPS location has been acquired
  • The drone is properly calibrated
  • The drone is in a state that allows it to take off

Then, when all those conditions hold, the interface becomes .idle and can be activated to begin or resume Flight Plan execution, which can be paused by deactivating this piloting interface.

This piloting interface can be retrieved by:

drone.getPilotingItf(flightPlan)
  • Latest flight plan file upload state.

    Declaration

    Swift

    var latestUploadState: FlightPlanFileUploadState { get }
  • Index of the latest mission item completed.

    Declaration

    Swift

    var latestMissionItemExecuted: UInt? { get }
  • Index of the latest mission item skipped.

    Declaration

    Swift

    var latestMissionItemSkipped: UInt? { get }
  • Set of reasons why this piloting interface is unavailable.

    Empty when state is .idle or .active.

    Declaration

    Swift

    var unavailabilityReasons: Set<FlightPlanUnavailabilityReason> { get }
  • Error raised during the latest activation.

    It is put back to .none as soon as activate(restart:) is called.

    Declaration

    Swift

    var latestActivationError: FlightPlanActivationError { get }
  • Whether the current flight plan on the drone is the latest one that has been uploaded from the application.

    Declaration

    Swift

    var flightPlanFileIsKnown: Bool { get }
  • Identifier of the flight plan currently loaded on the drone, nil if unknown.

    Declaration

    Swift

    var flightPlanId: String? { get }
  • Information about the latest flight plan started by the drone, nil if unavailable.

    This information is provided by the drone at connection and when a flight plan stops. It is turned to nil when the drone is disconnected or when clearRecoveryInfo() is called.

    If the application lose connection to the drone during a flight plan and then flight plan stops, this information will help the application to manage flight plan resume at reconnection.

    Declaration

    Swift

    var recoveryInfo: RecoveryInfo? { get }
  • Whether the flight plan is currently paused.

    If true, the restart parameter of activate(restart:) can be set to false to resume the flight plan instead of playing it from the beginning. If isPaused is false, this parameter will be ignored and the flight plan will be played from its beginning.

    When this piloting interface is deactivated, any currently playing flight plan will be paused.

    Declaration

    Swift

    var isPaused: Bool { get }
  • Whether start of a flight plan at a given mission item is supported.

    When true, method activate(restart:interpreter:missionItem:) can be used.

    Declaration

    Swift

    var activateAtMissionItemSupported: Bool { get }
  • Whether start of a flight plan at a given mission item with a disconnection policy is supported.

    When true, method activate(restart:interpreter:missionItem:disconnectionPolicy:) can be used.

    Declaration

    Swift

    var activateAtMissionItemV2Supported: Bool { get }
  • Tells whether uploading a flight plan with an associated custom identifier is supported.

    When true, method uploadFlightPlan(filepath:customFlightPlanId:) can be used.

    Declaration

    Swift

    var isUploadWithCustomIdSupported: Bool { get }
  • Uploads a Flight Plan file to the drone.

    When the upload ends, if all other necessary conditions hold (GPS location acquired, drone properly calibrated), then the interface becomes idle and the Flight Plan is ready to be executed.

    If any upload is on-going it is cancelled.

    Declaration

    Swift

    func uploadFlightPlan(filepath: String)

    Parameters

    filepath

    local path of the file to upload

  • Uploads a Flight Plan file to the drone.

    This method associates the provided identifier only if isUploadWithCustomIdSupported returns true, otherwise it behaves strictly as uploadFlightPlan(filepath:) function.

    When the upload ends, if all other necessary conditions hold (GPS location acquired, drone properly calibrated), then the interface becomes idle and the Flight Plan is ready to be executed.

    If any upload is on-going it is cancelled.

    Note

    customFlightPlanId will be ignored if activateAtMissionItemSupported is false.

    Declaration

    Swift

    func uploadFlightPlan(filepath: String, customFlightPlanId: String)

    Parameters

    filepath

    local path of the file to upload

    customFlightPlanId

    custom flight plan id

  • Cancels any on-going upload.

    If no upload is on-going there is no effect.

    Declaration

    Swift

    func cancelPendingUpload()
  • Activates this piloting interface and starts executing the uploaded flight plan.

    The interface should be .idle for this method to have effect. The flight plan is resumed if the restart parameter is false and isPaused is true. Otherwise, the flight plan is restarted from its beginning.

    If successful, it deactivates the current piloting interface and activates this one.

    Note

    activate(restart:) will call activate(restart: interpreter:) with interpreter legacy.

    Declaration

    Swift

    func activate(restart: Bool) -> Bool

    Parameters

    restart

    true to force restarting the flight plan. If isPaused is false, this parameter will be ignored.

    Return Value

    true on success, false if the piloting interface can’t be activated

  • Activates this piloting interface and starts executing the uploaded flight plan.

    The interface should be .idle for this method to have effect. The flight plan is resumed if the restart parameter is false and isPaused is true. Otherwise, the flight plan is restarted from its beginning.

    If successful, it deactivates the current piloting interface and activates this one.

    Declaration

    Swift

    func activate(restart: Bool, interpreter: FlightPlanInterpreter) -> Bool

    Parameters

    restart

    true to force restarting the flight plan. If isPaused is false, this parameter will be ignored.

    interpreter

    instructs how the flight plan must be interpreted by the drone.

    Return Value

    true on success, false if the piloting interface can’t be activated

  • Activates this piloting interface and starts executing the uploaded flight plan at given mission item.

    The interface should be .idle for this method to have effect. The flight plan is resumed if the restart parameter is false and isPaused is true. Otherwise, the flight plan is restarted from the mission item. This method can be used only when activateAtMissionItemSupported is true.

    If successful, it deactivates the current piloting interface and activates this one.

    Declaration

    Swift

    func activate(restart: Bool, interpreter: FlightPlanInterpreter, missionItem: UInt) -> Bool

    Parameters

    restart

    true to force restarting the flight plan. If isPaused is false, this parameter will be ignored.

    interpreter

    instructs how the flight plan must be interpreted by the drone

    missionItem

    index of mission item where the flight plan should start

    Return Value

    true on success, false if the piloting interface can’t be activated

  • Activates this piloting interface and starts executing the uploaded flight plan at given mission item.

    The interface should be .idle for this method to have effect. The flight plan is resumed if the restart parameter is false and isPaused is true. Otherwise, the flight plan is restarted from the mission item. This method can be used only when activateAtMissionItemSupported is true.

    If successful, it deactivates the current piloting interface and activates this one.

    Note

    This activation method is compatible with drones running on firmware at least 7.2.

    Declaration

    Swift

    func activate(restart: Bool, interpreter: FlightPlanInterpreter, missionItem: UInt,
                  disconnectionPolicy: FlightPlanDisconnectionPolicy) -> Bool

    Parameters

    restart

    true to force restarting the flight plan. If isPaused is false, this parameter will be ignored.

    interpreter

    instructs how the flight plan must be interpreted by the drone

    missionItem

    index of mission item where the flight plan should start

    disconnectionPolicy

    the behavior of the drone when a disconnection occurs

    Return Value

    true on success, false if the piloting interface can’t be activated

  • Stops execution of current flight plan, if any.

    This method has effect only if the piloting interface is active or if isPaused is true. Once the execution is stopped, the piloting interface is deactivated and isPaused is set to false.

    Declaration

    Swift

    func stop() -> Bool

    Return Value

    true if the stop command was sent to the drone, false otherwise

  • Clears information about the latest flight plan started by the drone prior to current connection.

    This sends a command to the drone to clear this information, and sets recoveryInfo to nil.

    Declaration

    Swift

    func clearRecoveryInfo()
  • Cleans media resources before recovery of a flight plan execution.

    When a flight plan execution is interrupted, it can be restarted later from the latest reached waypoint. This function can be called before the flight plan restart to delete media resources captured during the interrupted execution and after the latest reached waypoint. The aim is to not have duplicate media resources captured after the latest reached waypoint.

    Declaration

    Swift

    func cleanBeforeRecovery(customId: String, resourceId: String,
                             completion: @escaping (_ result: CleanBeforeRecoveryResult) -> Void) -> CancelableCore?

    Parameters

    customId

    custom identifier, as provided by recoveryInfo

    resourceId

    first resource identifier of media captured after the latest reached waypoint, as provided by recoveryInfo

    completion

    completion callback (called on the main thread)

    result

    media resources clean result

    Return Value

    a clean media resources cancelable request

  • Important

    DO NOT USE THIS METHOD, IT IS UNSTABLE, EXPERIMENTAL AND WILL DISAPPEAR ON THE NEXT VERSION

    TODO: remove

    Prepares the drone for the upcoming flight plan activation.

    The drone will prepare the execution of a flight plan. This includes storing the current camera settings that will be restored at the end of the flight plan.

    This method should be called:

    Declaration

    Swift

    func prepareForFlightPlanActivation()