Skip to content

Commit

Permalink
7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegournay committed Oct 18, 2021
1 parent 175f0bd commit 1fc65c8
Show file tree
Hide file tree
Showing 168 changed files with 34,449 additions and 1,151 deletions.
13 changes: 7 additions & 6 deletions ArsdkEngine.podspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@

Pod::Spec.new do |s|
s.name = "ArsdkEngine"
s.version = "1.8.0"
s.version = "7.0.0"
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.8.0" }
s.source = { :git => 'https://github.com/Parrot-Developers/pod_arsdkengine.git', :tag => "7.0.0" }
s.platform = :ios
s.ios.deployment_target = '10.0'
s.ios.deployment_target = '12.0'
s.source_files = 'ArsdkEngine/**/*'
s.dependency 'GroundSdk', '1.8.0'
s.swift_version = '4.2'
s.pod_target_xcconfig = {'SWIFT_VERSION' => '4.2'}
s.dependency 'GroundSdk', '7.0.0'
s.dependency 'SwiftProtobuf', '1.13.0'
s.swift_version = '5'
s.pod_target_xcconfig = {'SWIFT_VERSION' => '5'}
s.xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
end
18 changes: 12 additions & 6 deletions ArsdkEngine/Arsdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ private class ArsdkDeviceProvider: DeviceProvider {
case .mux:
return ArsdkDeviceProvider.usb
case .unknown:
fallthrough
@unknown default:
return nil
}
}
Expand Down Expand Up @@ -262,14 +264,16 @@ class ArsdkDeviceCtrlBackend: NSObject, DeviceControllerBackend {
deviceHandle, deviceType: model.internalId, port: UInt16(port), completion: completion)
}

func destroyTcpProxy(block: @escaping () -> Void) {
arsdk.arsdkCore.dispatch_sync {
block()
}
func createVideoSourceLive(cameraType: ArsdkSourceLiveCameraType) -> ArsdkSourceLive {
return arsdk.arsdkCore.createVideoSourceLive(deviceHandle, cameraType: cameraType)
}

func createVideoSourceMedia(url: String, trackName: String?) -> ArsdkSourceMedia {
return arsdk.arsdkCore.createVideoSourceMedia(deviceHandle, url: url, trackName: trackName)
}

func createVideoStream(url: String, track: String, listener: SdkCoreStreamListener) -> ArsdkStream {
return arsdk.arsdkCore.createVideoStream(deviceHandle, url: url, track: track, listener: listener)
func createVideoStream(listener: ArsdkStreamListener) -> ArsdkStream {
return arsdk.arsdkCore.createVideoStream(listener)
}

func browseMedia(model: DeviceModel, completion: @escaping ArsdkMediaListCompletion) -> ArsdkRequest {
Expand Down Expand Up @@ -363,6 +367,8 @@ extension ArsdkDeviceCtrlBackend: ArsdkCoreDeviceListener {
cause = .failure
case .reject:
cause = .refused
@unknown default:
cause = .failure
}
deviceController.linkDidCancelConnect(cause: cause, removing: removing)
if removing {
Expand Down
12 changes: 5 additions & 7 deletions ArsdkEngine/ArsdkEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class ArsdkEngine: EngineBaseCore {
arsdk = Arsdk(engine: self)
persistentStore = createPersistentStore()
AppDefaults.importTo(persistentStore: persistentStore)

// Publish utilities by the engine initiative.
publishUtility(FileReplayBackendProviderCore())
}

public override func startEngine() {
Expand Down Expand Up @@ -125,11 +128,6 @@ public class ArsdkEngine: EngineBaseCore {
backendController.append(ArsdkMuxEaBackendController(
supportedDeviceTypes: Set<NSNumber>(usbModels.map { NSNumber(value: $0.internalId) })))
}
if GroundSdkConfig.sharedInstance.enableUsbDebug {
let usbModels = DeviceModel.supportingTechnology(models: supportedDevices, technology: .usb)
backendController.append(ArsdkMuxIpBackendController(
supportedDeviceTypes: Set<NSNumber>(usbModels.map { NSNumber(value: $0.internalId) })))
}
return backendController
}

Expand Down Expand Up @@ -170,12 +168,12 @@ public class ArsdkEngine: EngineBaseCore {
switch model {
case .drone(let droneModel):
switch droneModel {
case .anafi4k, .anafiThermal, .anafiUa, .anafiUsa:
case .anafi4k, .anafiThermal, .anafi2, .anafiUa, .anafiUsa:
return AnafiFamilyDroneController(engine: self, deviceUid: uid, name: name, model: droneModel)
}
case .rc(let rcModel):
switch rcModel {
case .skyCtrl3, .skyCtrlUA:
case .skyCtrl3, .skyCtrl4, .skyCtrlUA:
return SkyControllerFamilyController(engine: self, deviceUid: uid, model: rcModel, name: name)
}
}
Expand Down
10 changes: 8 additions & 2 deletions ArsdkEngine/BlackBox/BlackBoxContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ class BlackBoxContext {
/// Remote control session, nil if it has not been opened
private var rcSession: BlackBoxRcSession?

/// Black box buffer capacity in seconds
private var blackBoxBufferCapacity: Int

/// Constructor
///
/// - Parameters:
/// - blackBoxBufferCapacity: black box buffer capacity in seconds
/// - blackBoxReadyCb: block that will be called when the black box is ready to be archived
/// - blackBox: the black box data to archive
/// - closeCb: block that will be called when the context is about to be closed
init(blackBoxReadyCb: @escaping (_ blackBox: BlackBoxData) -> Void, closeCb: @escaping () -> Void) {
init(blackBoxBufferCapacity: Int,
blackBoxReadyCb: @escaping (_ blackBox: BlackBoxData) -> Void, closeCb: @escaping () -> Void) {
self.blackBoxReadyCb = blackBoxReadyCb
self.closeCb = closeCb
self.blackBoxBufferCapacity = blackBoxBufferCapacity
}

/// Creates a drone session
Expand All @@ -61,7 +67,7 @@ class BlackBoxContext {
func createDroneSession(drone: DroneCore) -> BlackBoxDroneSession {
precondition(droneSession == nil, "Drone session is already existing.")

droneSession = BlackBoxDroneSession(drone: drone) {
droneSession = BlackBoxDroneSession(blackBoxBufferCapacity: blackBoxBufferCapacity, drone: drone) {
if let rcSession = self.rcSession {
self.droneSession!.setRemoteControlData(rcSession.rcData)
}
Expand Down
12 changes: 8 additions & 4 deletions ArsdkEngine/BlackBox/BlackBoxData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@ struct BlackBoxData: Encodable {
private var events: [BlackBoxEvent] = []

/// Flight data sample buffer (limited to the last 1 minute datas)
private var flightDatas = BlackBoxCircularArray<BlackBoxFlightData>(size: 5 * 60)
private var flightDatas: BlackBoxCircularArray<BlackBoxFlightData>

/// Environment data sample buffer (limited to the last 1 minute datas)
private var environmentDatas = BlackBoxCircularArray<BlackBoxEnvironmentData>(size: 60)
private var environmentDatas: BlackBoxCircularArray<BlackBoxEnvironmentData>

/// Constructor
///
/// - Parameter drone: drone that this black box is recorded for
init(drone: DroneCore) {
/// - Parameters:
/// - blackBoxBufferCapacity: buffer capacity for blackbox in seconds
/// - drone: drone that this black box is recorded for
init(blackBoxBufferCapacity: Int, drone: DroneCore) {
header = BlackBoxHeaderData(drone: drone)
flightDatas = BlackBoxCircularArray<BlackBoxFlightData>(size: 5 * blackBoxBufferCapacity)
environmentDatas = BlackBoxCircularArray<BlackBoxEnvironmentData>(size: blackBoxBufferCapacity)
}

/// Records an event in the blackbox
Expand Down
13 changes: 11 additions & 2 deletions ArsdkEngine/BlackBox/BlackBoxDroneSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ class BlackBoxDroneSession: NSObject, BlackBoxSession {
/// Constructor
///
/// - Parameters:
/// - blackBoxBufferCapacity: buffer capacity for blackbox in seconds
/// - drone: drone to record a black box from
/// - didClose: block that will be called when the session is about to close
init(drone: DroneCore, didClose: @escaping () -> Void) {
blackBox = BlackBoxData(drone: drone)
init(blackBoxBufferCapacity: Int, drone: DroneCore, didClose: @escaping () -> Void) {
blackBox = BlackBoxData(blackBoxBufferCapacity: blackBoxBufferCapacity, drone: drone)
self.didClose = didClose

super.init()
Expand Down Expand Up @@ -151,6 +152,8 @@ class BlackBoxDroneSession: NSObject, BlackBoxSession {
ArsdkFeatureCommonSettingsstate.decode(command, callback: self)
case kArsdkFeatureFollowMeUid:
ArsdkFeatureFollowMe.decode(command, callback: self)
case kArsdkFeatureMotorsUid:
ArsdkFeatureMotors.decode(command, callback: self)
default:
break
}
Expand Down Expand Up @@ -322,3 +325,9 @@ extension BlackBoxDroneSession: ArsdkFeatureFollowMeCallback {
blackBox.add(event: BlackBoxEvent.followMeModeChange(mode: mode.rawValue))
}
}

extension BlackBoxDroneSession: ArsdkFeatureMotorsCallback {
func onThreeMotorsFlightStarted(id: ArsdkFeatureMotorsMotorId, reason: ArsdkFeatureMotorsThreeMotorsReason) {
blackBox.add(event: BlackBoxEvent.threeMotorsFlight(reason.rawValue))
}
}
2 changes: 1 addition & 1 deletion ArsdkEngine/BlackBox/BlackBoxRcSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Foundation
import GroundSdk

/// Remote control session delegate
protocol BlackBoxRcSessionDelegate: class {
protocol BlackBoxRcSessionDelegate: AnyObject {
/// Called when a button has been triggered
///
/// - Parameter action: the button action
Expand Down
6 changes: 5 additions & 1 deletion ArsdkEngine/BlackBox/BlackBoxRecorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ class BlackBoxRecorder {
/// Live black box contexts, by master uid
private var sessions: [String: BlackBoxContext] = [:]

/// Blackbox circular buffers capacity, in seconds.
private var blackBoxBufferCapacity: Int

/// Constructor
///
/// - Parameters:
/// - engine: arsdk engine
/// - blackBoxStorage: black box storage utility
init(engine: ArsdkEngine, blackBoxStorage: BlackBoxStorageCore) {
self.blackBoxStorage = blackBoxStorage
self.blackBoxBufferCapacity = GroundSdkConfig.sharedInstance.blackboxBufferCapacity ?? 60
}

/// Opens a session to record drone black box data
Expand Down Expand Up @@ -82,7 +86,7 @@ class BlackBoxRecorder {
private func obtainContext(masterUid: String) -> BlackBoxContext {
var session = sessions[masterUid]
if session == nil {
session = BlackBoxContext(blackBoxReadyCb: { blackBox in
session = BlackBoxContext(blackBoxBufferCapacity: blackBoxBufferCapacity, blackBoxReadyCb: { blackBox in
self.blackBoxStorage.notifyBlackBoxDataReady(blackBoxData: blackBox)
}, closeCb: {
self.sessions[masterUid] = session
Expand Down
8 changes: 8 additions & 0 deletions ArsdkEngine/BlackBox/Data/BlackBoxEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ struct BlackBoxEvent: Encodable {
return BlackBoxEvent(type: "product_motor_error", value: error)
}

/// Obtains a three motors flight event
///
/// - Parameter reason: three motors flight reason
/// - Returns: three motors flight event
static func threeMotorsFlight(_ reason: Int) -> BlackBoxEvent {
return BlackBoxEvent(type: "product_three_motors_flight", value: reason)
}

/// Obtains a battery alert event
///
/// - Parameters:
Expand Down
60 changes: 51 additions & 9 deletions ArsdkEngine/DeviceControllers/AnafiFamilyDroneController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import Foundation
import GroundSdk

/// Anafi 4k specific drone controller
/// Anafi specific drone controller
class AnafiFamilyDroneController: DroneController {

/// Shared last known state of the tracking function at the drone level
Expand Down Expand Up @@ -62,12 +62,18 @@ class AnafiFamilyDroneController: DroneController {
componentControllers.append(AnafiPoiPilotingItf(
activationController: pilotingItfActivationController))

componentControllers.append(AutoLookAtPilotingItf(
activationController: pilotingItfActivationController))
componentControllers.append(AutoFollowPilotingItf(
activationController: pilotingItfActivationController))
componentControllers.append(FollowFeatureLookAtPilotingItf(
activationController: pilotingItfActivationController, trackingSharing: trackingSharing))
componentControllers.append(FollowFeatureFollowMePilotingItf(
activationController: pilotingItfActivationController, trackingSharing: trackingSharing))

// Not activable piloting Itfs
componentControllers.append(AnimFeaturePilotingItfController(droneController: self))
componentControllers.append(AnimFeaturePilotingItfController(
activationController: pilotingItfActivationController))
// Instruments
componentControllers.append(AnafiFlyingIndicators(deviceController: self))
componentControllers.append(AnafiAlarms(deviceController: self))
Expand All @@ -80,13 +86,27 @@ class AnafiFamilyDroneController: DroneController {
componentControllers.append(CommonBatteryInfo(deviceController: self))
componentControllers.append(AnafiFlightMeter(deviceController: self))
componentControllers.append(CameraFeatureExposureValues(deviceController: self))
componentControllers.append(AnafiFlightInfo(deviceController: self))
if model == .anafi2 {
componentControllers.append(Anafi2CellularLogs(deviceController: self))
}
// Peripherals
componentControllers.append(AnafiMagnetometer(deviceController: self))
componentControllers.append(StreamServerController(deviceController: self))
let streamServer = (model == .anafi4k || model == .anafiThermal || model == .anafiUa || model == .anafiUsa) ?
StreamServerMonoController(deviceController: self) :
StreamServerMultiController(deviceController: self)
componentControllers.append(streamServer)
componentControllers.append(CameraFeatureCameraRouter(deviceController: self))
componentControllers.append(CameraFeatureAntiflicker(deviceController: self))
if model == .anafi2 {
componentControllers.append(Anafi2Antiflicker(deviceController: self))
} else {
componentControllers.append(CameraFeatureAntiflicker(deviceController: self))
}
componentControllers.append(Camera2Router(deviceController: self))
componentControllers.append(HttpMediaStore(deviceController: self))
componentControllers.append(AnafiSystemInfo(deviceController: self))

componentControllers.append(MissionUpdaterController(deviceController: self))
if let firmwareStore = engine.utilities.getUtility(Utilities.firmwareStore),
let firmwareDownloader = engine.utilities.getUtility(Utilities.firmwareDownloader) {
componentControllers.append(
Expand All @@ -103,29 +123,47 @@ class AnafiFamilyDroneController: DroneController {
componentControllers.append(
HttpFlightDataDownloader(deviceController: self, flightDataStorage: flightDataStorage))
}
if let flightLogStorage = engine.utilities.getUtility(Utilities.flightLogStorage) {
if let flightLogConverterStorage = engine.utilities.getUtility(Utilities.flightLogConverterStorage) {
componentControllers.append(
HttpFlightLogDownloader(deviceController: self, flightLogStorage: flightLogStorage,
converter: GutmaLogProducer.create(deviceController: self)))
HttpFlightLogDownloader(deviceController: self, flightLogConverterStorage: flightLogConverterStorage))
} else if let flightLogStorage = engine.utilities.getUtility(Utilities.flightLogStorage) {
componentControllers.append(
HttpFlightLogDownloader(deviceController: self, flightLogStorage: flightLogStorage))
}
if let flightCameraRecordStorage = engine.utilities.getUtility(Utilities.flightCameraRecordStorage) {
componentControllers.append(
HttpFlightCameraRecordDownloader(deviceController: self,
flightCameraRecordStorage: flightCameraRecordStorage))
}
componentControllers.append(WifiFeatureWifiAccessPoint(deviceController: self))
componentControllers.append(UserStorageRemovableUserStorage(deviceController: self))
componentControllers.append(RemovableUserStorageController(deviceController: self))
componentControllers.append(InternalUserStorageController(deviceController: self))
componentControllers.append(AnafiBeeper(deviceController: self))
componentControllers.append(GimbalFeatureGimbal(deviceController: self))
componentControllers.append(GimbalFeatureFrontStereoGimbal(deviceController: self))
componentControllers.append(TargetTrackerController(deviceController: self))
componentControllers.append(AnafiGeofence(deviceController: self))
componentControllers.append(PreciseHomeController(deviceController: self))
componentControllers.append(ThermalController(deviceController: self))
componentControllers.append(LedsController(deviceController: self))
componentControllers.append(PhotoProgressIndicatorController(deviceController: self))
componentControllers.append(AnafiPilotingControl(deviceController: self))
componentControllers.append(OnboardTrackerController(deviceController: self))
componentControllers.append(BatteryGaugeUpdaterController(deviceController: self))
componentControllers.append(DriController(deviceController: self))
componentControllers.append(AnafiStereoVisionSensor(deviceController: self))
componentControllers.append(LogControlController(deviceController: self))
componentControllers.append(CertificateUploaderController(deviceController: self))
componentControllers.append(CellularController(deviceController: self))
componentControllers.append(ObstacleAvoidanceController(deviceController: self))
if GroundSdkConfig.sharedInstance.enableDevToolbox {
componentControllers.append(AnafiDevToolbox(deviceController: self))
}
componentControllers.append(MissionManagerController(deviceController: self))
componentControllers.append(CertificateUploaderController(deviceController: self))
componentControllers.append(NetworkController(deviceController: self))
componentControllers.append(FlightCameraRecorderController(deviceController: self))
componentControllers.append(SecureElementController(deviceController: self))
componentControllers.append(AnafiTakeoffChecklist(deviceController: self))
sendDateAndTime = { [weak self] in
let dateFormatter = DateFormatter()
dateFormatter.timeZone = NSTimeZone.system
Expand All @@ -136,6 +174,10 @@ class AnafiFamilyDroneController: DroneController {
dateFormatter.dateFormat = "yyyyMMdd'T'HHmmssZZZ"
let currentDateStr = dateFormatter.string(from: currentDate)
self?.sendCommand(ArsdkFeatureCommonCommon.currentDateTimeEncoder(datetime: currentDateStr))

if let eventLogger = self?.engine.utilities.getUtility(Utilities.eventLogger) {
eventLogger.log("EVT:SEND_TIME;time='\(currentDateStr)'")
}
}
}

Expand Down
Loading

0 comments on commit 1fc65c8

Please sign in to comment.