I thought this code would make the drone go up and down and up and down. In this case the downward components seemed to be summed causing the drone to only go up 2 meters in one motion.
I found this .currentDirective attribute which shows “Current guided flight directive if there’s a guided flight in progress, nil otherwise.” So I tried this:
GuidedPilotingItf doesn’t store guided flights.
If moveToLocation or moveToRelativePosition are called while a guided flight is still in progress, the current guided flight will be stopped immediately and the new guided flight is started.
If the main thread is blocked, GroundSdk can’t work and can’t update its states.
Thanks for the response! Ultimately, I converged on a similar solution. I was wondering if i could ask a follow-up question. Currently this is my setup.
Note: Waypoint is just a struct that has lat/long/alt/orientation, for my own convenience.
My question is: I would like to take a photo after I stop at each point. I have the “mainCamera.startPhotoCapture()” This doesn’t seem to work. Any suggestions on this?
public func executeWaypointMission(mission: [Waypoint]?) {
// Update local instance of mission. We need it stored locally as
// we pass a reference to self into the piloting closure
self.mission = mission
self.guidedPilotingItf = self.drone?.getPilotingItf(PilotingItfs.guided) { [weak self] pilotingItf in
// On each update of the piloting interface, determine whether the drone has completed previous mission
if let pilotingItf = pilotingItf {
if pilotingItf.currentDirective == nil && self?.mission != nil {
if self?.mission?.count ?? 0 > 0 {
let waypoint = (self!.mission?.removeFirst())!
self!.mainCamera?.startPhotoCapture()
pilotingItf.moveToLocation(latitude: waypoint.latitude,
longitude: waypoint.longitude,
altitude: waypoint.altitude,
orientation: waypoint.orientation)
}
}
}
}
}
I do set up my camera in the following way, previous to the mission execution