Skip to content

Commit

Permalink
[DEV] Groundsdk - release 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegournay committed Nov 18, 2019
1 parent 8b0cc39 commit 284e8c8
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 14 deletions.
6 changes: 3 additions & 3 deletions ArsdkEngine.podspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

Pod::Spec.new do |s|
s.name = "ArsdkEngine"
s.version = "1.1.1"
s.version = "1.1.2"
s.summary = "Parrot Drone SDK, arsdk based engine"
s.homepage = "https://developer.parrot.com"
s.license = "{ :type => 'BSD 3-Clause License', :file => 'LICENSE' }"
s.author = 'Parrot Drone SAS'
s.source = { :git => 'https://github.com/Parrot-Developers/pod_arsdkengine.git', :tag => "1.1.1" }
s.source = { :git => 'https://github.com/Parrot-Developers/pod_arsdkengine.git', :tag => "1.1.2" }
s.platform = :ios
s.ios.deployment_target = '10.0'
s.source_files = 'ArsdkEngine/**/*'
s.dependency 'GroundSdk', '1.1.1'
s.dependency 'GroundSdk', '1.1.2'
s.swift_version = '4.2'
s.pod_target_xcconfig = {'SWIFT_VERSION' => '4.2'}
s.xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
Expand Down
89 changes: 78 additions & 11 deletions ArsdkEngine/PilotingItf/AnafiPoiPilotingItf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class AnafiPoiPilotingItf: ActivablePilotingItfController {
/// Whether POI command is available on the drone
private var dronePoiFeatureAvailable = false

/// Whether PilotedPOIV2 command is supported
private var poiV2Supported = false

/// Constructor
///
/// - Parameter activationController: activation controller that owns this piloting interface controller
Expand All @@ -76,8 +79,8 @@ class AnafiPoiPilotingItf: ActivablePilotingItfController {
// the unavailable state will be set in unpublish
pilotingItf.unpublish()
// be sure to reset the current status
pendingPointOfInterest = nil
currentPointOfInterest = nil
pendingPointOfInterest = nil
isFlying = false
dronePoiFeatureAvailable = false
}
Expand All @@ -102,7 +105,7 @@ class AnafiPoiPilotingItf: ActivablePilotingItfController {
if let pendingPointOfInterest = pendingPointOfInterest {
sendStartPoi(
latitude: pendingPointOfInterest.latitude, longitude: pendingPointOfInterest.longitude,
altitude: pendingPointOfInterest.altitude)
altitude: pendingPointOfInterest.altitude, mode: pendingPointOfInterest.mode)
self.pendingPointOfInterest = nil
}
}
Expand Down Expand Up @@ -140,8 +143,8 @@ class AnafiPoiPilotingItf: ActivablePilotingItfController {
notifyActive()
}
} else {
pendingPointOfInterest = nil
currentPointOfInterest = nil
pendingPointOfInterest = nil
notifyUnavailable()
}
}
Expand Down Expand Up @@ -171,13 +174,14 @@ extension AnafiPoiPilotingItf: PoiPilotingItfBackend {
setGaz(verticalSpeed)
}

func start(latitude: Double, longitude: Double, altitude: Double) {
func start(latitude: Double, longitude: Double, altitude: Double, mode: PointOfInterestMode) {
switch pilotingItf.state {
case .idle:
pendingPointOfInterest = PointOfInterestCore(latitude: latitude, longitude: longitude, altitude: altitude)
pendingPointOfInterest = PointOfInterestCore(latitude: latitude, longitude: longitude, altitude: altitude,
mode: mode)
_ = droneController.pilotingItfActivationController.activate(pilotingItf: self)
case .active:
sendStartPoi(latitude: latitude, longitude: longitude, altitude: altitude)
sendStartPoi(latitude: latitude, longitude: longitude, altitude: altitude, mode: mode)
case .unavailable:
break
}
Expand All @@ -192,10 +196,24 @@ extension AnafiPoiPilotingItf: PoiPilotingItfBackend {
/// - latitude: latitude of the location (in degrees) to look at
/// - longitude: longitude of the location (in degrees) to look at
/// - altitude: altitude above take off point (in meters) to look at
private func sendStartPoi(latitude: Double, longitude: Double, altitude: Double) {
sendCommand(
ArsdkFeatureArdrone3Piloting.startPilotedPOIEncoder(
latitude: latitude, longitude: longitude, altitude: altitude))
/// - mode: Point Of Interest mode
private func sendStartPoi(latitude: Double, longitude: Double, altitude: Double, mode: PointOfInterestMode) {
if poiV2Supported {
let arsdkMode: ArsdkFeatureArdrone3PilotingStartpilotedpoiv2Mode
switch mode {
case .lockedGimbal:
arsdkMode = .lockedGimbal
case .freeGimbal:
arsdkMode = .freeGimbal
}
sendCommand(
ArsdkFeatureArdrone3Piloting.startPilotedPOIV2Encoder(
latitude: latitude, longitude: longitude, altitude: altitude, mode: arsdkMode))
} else if mode == .lockedGimbal {
sendCommand(
ArsdkFeatureArdrone3Piloting.startPilotedPOIEncoder(
latitude: latitude, longitude: longitude, altitude: altitude))
}
}

/// Send the command to cancel a Point Of Interest
Expand Down Expand Up @@ -228,7 +246,8 @@ extension AnafiPoiPilotingItf: ArsdkFeatureArdrone3PilotingstateCallback {
if latitude != AnafiPoiPilotingItf.UnknownCoordinate &&
longitude != AnafiPoiPilotingItf.UnknownCoordinate &&
altitude != AnafiPoiPilotingItf.UnknownCoordinate {
newPointOfInterest = PointOfInterestCore(latitude: latitude, longitude: longitude, altitude: altitude)
newPointOfInterest = PointOfInterestCore(latitude: latitude, longitude: longitude, altitude: altitude,
mode: .lockedGimbal)
} else {
newPointOfInterest = nil
}
Expand All @@ -243,6 +262,54 @@ extension AnafiPoiPilotingItf: ArsdkFeatureArdrone3PilotingstateCallback {
}
}

func onPilotedPOIV2(latitude: Double, longitude: Double, altitude: Double,
mode: ArsdkFeatureArdrone3PilotingstatePilotedpoiv2Mode,
status: ArsdkFeatureArdrone3PilotingstatePilotedpoiv2Status) {
ULog.d(.ctrlTag, "PoiPiloting: onPilotedPoiV2 latitude=\(latitude) longitude=\(longitude)" +
" altitude=\(altitude) mode=\(mode) status=\(status)")

poiV2Supported = true

switch status {
case .unavailable:
currentPointOfInterest = nil
update(dronePoiFeatureAvailable: false, pointOfInterest: nil)

case .running:
let newPointOfInterest: PointOfInterestCore?
if latitude != AnafiPoiPilotingItf.UnknownCoordinate &&
longitude != AnafiPoiPilotingItf.UnknownCoordinate &&
altitude != AnafiPoiPilotingItf.UnknownCoordinate {
let newMode: PointOfInterestMode?
switch mode {
case .lockedGimbal:
newMode = .lockedGimbal
case .freeGimbal:
newMode = .freeGimbal
case .sdkCoreUnknown:
newMode = nil
}
if let newMode = newMode {
newPointOfInterest = PointOfInterestCore(latitude: latitude, longitude: longitude,
altitude: altitude, mode: newMode)
} else {
newPointOfInterest = nil
}
} else {
newPointOfInterest = nil
}

update(dronePoiFeatureAvailable: true, pointOfInterest: newPointOfInterest)

case .sdkCoreUnknown:
// don't change anything if value is unknown
ULog.w(.tag, "Unknown onPilotedPoiV2 status, skipping this event.")

default:
update(dronePoiFeatureAvailable: true, pointOfInterest: nil)
}
}

/// Piloting State decode callback implementation
func onFlyingStateChanged(state: ArsdkFeatureArdrone3PilotingstateFlyingstatechangedState) {
// If the drone is not flying, the interface state is set to .unavailable
Expand Down

0 comments on commit 284e8c8

Please sign in to comment.