Skip to content

Commit

Permalink
7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegournay committed Mar 23, 2022
1 parent 13d4fb1 commit 3e44d9d
Show file tree
Hide file tree
Showing 21 changed files with 386 additions and 239 deletions.
6 changes: 3 additions & 3 deletions GroundSdk.podspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

Pod::Spec.new do |s|
s.name = "GroundSdk"
s.version = "7.1.0"
s.version = "7.2.0"
s.summary = "Parrot Drone SDK"
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_groundsdk.git', :tag => "7.1.0" }
s.source = { :git => 'https://github.com/Parrot-Developers/pod_groundsdk.git', :tag => "7.2.0" }
s.platform = :ios
s.ios.deployment_target = '12.0'
s.source_files = 'GroundSdk/**/*.{swift,h,m}'
s.resources = 'GroundSdk/**/*.{vsh,fsh,txt,png}'
s.dependency 'SdkCore', '7.1.0'
s.dependency 'SdkCore', '7.2.0'
s.public_header_files = ["GroundSdk/GroundSdk.h"]
s.swift_version = '5'
s.pod_target_xcconfig = {'SWIFT_VERSION' => '5'}
Expand Down
22 changes: 21 additions & 1 deletion GroundSdk/Device/Instrument/Alarms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ public class Alarm: NSObject {
/// direction.
case obstacleAvoidanceBlindMotionDirection

/// Obstacle avoidance is frozen.
/// The drone does not respond to PCMD.
/// Obstacle avoidance mode needs to be set to disabled for the drone to move again.
case obstacleAvoidanceFreeze

/// Drone inclination is to high to fly safely.
case inclinationTooHigh

Expand All @@ -171,6 +176,12 @@ public class Alarm: NSObject {
/// Vertical geofence reached.
case verticalGeofenceReached

/// Free fall detected.
case freeFallDetected

/// Stereo camera is decalibrated.
case stereoCameraDecalibrated

/// Debug description.
public var description: String {
switch self {
Expand Down Expand Up @@ -208,6 +219,9 @@ public class Alarm: NSObject {
case .inclinationTooHigh: return "inclinationTooHigh"
case .horizontalGeofenceReached: return "horizontalGeofenceReached"
case .verticalGeofenceReached: return "verticalGeofenceReached"
case .obstacleAvoidanceFreeze: return "obstacleAvoidanceFreeze"
case .freeFallDetected: return "freeFallDetected"
case .stereoCameraDecalibrated: return "stereoCameraDecalibrated"
}
}

Expand All @@ -222,7 +236,8 @@ public class Alarm: NSObject {
.obstacleAvoidanceDisabledTooDark, .obstacleAvoidanceDisabledEstimationUnreliable,
.obstacleAvoidanceDisabledCalibrationFailure, .obstacleAvoidanceStrongWind, .obstacleAvoidancePoorGps,
.obstacleAvoidanceComputationalError, .obstacleAvoidanceBlindMotionDirection,
.inclinationTooHigh, .horizontalGeofenceReached, .verticalGeofenceReached]
.inclinationTooHigh, .horizontalGeofenceReached, .verticalGeofenceReached,
.obstacleAvoidanceFreeze, .freeFallDetected, .stereoCameraDecalibrated]
}

/// Alarm level.
Expand Down Expand Up @@ -258,6 +273,11 @@ public class Alarm: NSObject {
/// Level of the alarm.
public internal(set) var level: Level

/// Delay related to this alarm.
/// Used only by Obstacle avoidance.
/// This delay indicates the time after which the obstacle avoidance is deactivated.
public internal(set) var timer: TimeInterval?

/// Constructor.
///
/// - Parameters:
Expand Down
168 changes: 114 additions & 54 deletions GroundSdk/Device/PilotingItf/FlightPlanPilotingItf.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion GroundSdk/GroundSdkConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public class GroundSdkConfig: NSObject {
}
}

/// Maximum memroy size used by cellular log messages, in kilobytes.
/// Maximum memory size used by cellular log messages, in kilobytes.
public var cellularCellularLogsKb: UInt? {
willSet(newValue) {
checkLocked()
Expand Down
20 changes: 20 additions & 0 deletions GroundSdk/Internal/Device/Instrument/AlarmsCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ extension AlarmsCore {
let alarm = getAlarm(kind: kind)
if alarm.level != level {
alarm.level = level
if alarm.level == .off {
alarm.timer = nil
}
markChanged()
}

return self
}

/// Changes the timer of a given alarm.
///
/// - Parameters:
/// - timer: the timer of the alarm
/// - forAlarm: kind of the alarm
/// - Returns: self to allow call chaining
/// - Note: Changes are not notified until notifyUpdated() is called.
@discardableResult public func update(timer: TimeInterval, forAlarm kind: Alarm.Kind) -> AlarmsCore {
let alarm = getAlarm(kind: kind)
if alarm.timer != timer {
alarm.timer = timer
markChanged()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,57 +29,13 @@

import Foundation

/// Flight camera recording setting.
public protocol FlightCameraRecorderSetting: AnyObject {
/// Setting to change the flight camera recording pipelines configuration.
public protocol FlightCameraRecorderPipelinesSetting: AnyObject {
/// Tells if setting value has been changed and is waiting for change confirmation.
var updating: Bool { get }

/// Supported modes.
var supportedValues: Set<FlightCameraRecorderPipeline> { get }

/// Flight camera recorder pipelines.
var value: Set<FlightCameraRecorderPipeline> { get set }
}

/// Type of pipeline.
public enum FlightCameraRecorderPipeline: Int, RawRepresentable, Hashable, CaseIterable, CustomStringConvertible {
/// Drone left stereo camera pipeline.
case fstcamLeftTimelapse
/// Drone right stereo camera pipeline.
case fstcamRightTimelapse
/// Drone front camera pipeline.
case fcamTimelapse
/// Drone left stereo camera last frames pipeline.
case fstcamLeftEmergency
/// Drone right stereo camera last frames pipeline.
case fstcamRightEmergency
/// Drone front camera last frames pipeline.
case fcamEmergency
/// Drone front camera follow me pipeline.
case fcamFollowme
/// Drone vertical camera precise home pipeline.
case vcamPrecisehome
/// Drone left stereo camera obstacle avoidance pipeline.
case fstcamLeftObstacleavoidance
/// Drone right stereo camera obstacle avoidance pipeline.
case fstcamRightObstacleavoidance
/// Drone vertical camera precise hovering pipeline.
case vcamPrecisehovering
/// Drone left stereo camera love calibration pipeline.
case fstcamLeftCalibration
/// Drone right stereo camera love calibration pipeline.
case fstcamRightCalibration
/// Drone right stereo camera precise hovering pipeline.
case fstcamRightPrecisehovering
/// Drone left stereo camera specific events pipeline.
case fstcamLeftEvent
/// Drone right stereo camera specific events pipeline.
case fstcamRightEvent
/// Drone front camera specific events pipeline.
case fcamEvent

/// Debug description.
public var description: String { "(\rawValue)" }
/// Flight camera recorder pipelines configuration identifier.
var id: UInt64 { get set }
}

/// Flight camera recorder peripheral interface for anafi2 drones.
Expand All @@ -92,10 +48,10 @@ public enum FlightCameraRecorderPipeline: Int, RawRepresentable, Hashable, CaseI
/// device.getPeripheral(Peripherals.flightCameraRecorder)
/// ```
public protocol FlightCameraRecorder: Peripheral {
/// Gives access to the active pipelines setting.
/// This setting allows to select which recording pipelines are active for flight camera recording.
/// Gives access to the flight camera recording pipelines configuration setting.
/// This setting allows to select current flight camera recording pipelines configuration.
/// - Note: This setting remains available when the drone is not connected.
var activePipelines: FlightCameraRecorderSetting { get }
var pipelines: FlightCameraRecorderPipelinesSetting { get }
}

/// :nodoc:
Expand Down
94 changes: 32 additions & 62 deletions GroundSdk/Internal/Device/Peripheral/FlightCameraRecorderCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ import Foundation

/// Flight camera recorder backend part.
public protocol FlightCameraRecorderBackend: AnyObject {
/// Sets active pipelines.
/// Sets flight camera recorder pipeline configuration identifier.
///
/// - Parameter activePipelines: the new set of active pipelines
/// - Parameter pipelineConfigId: the new flight camera recorder pipeline configuration identifier.
/// - Returns: true if the command has been sent, false if not connected and the value has been changed immediately
func set(activePipelines: Set<FlightCameraRecorderPipeline>) -> Bool
func set(pipelineConfigId: UInt64) -> Bool
}

/// Core implementation of FlightCameraRecorderSetting.
class FlightCameraRecorderSettingCore: FlightCameraRecorderSetting, CustomDebugStringConvertible {
/// Core implementation of FlightCameraRecorderPipelinesSetting.
class FlightCameraRecorderPipelinesSettingCore: FlightCameraRecorderPipelinesSetting, CustomDebugStringConvertible {
/// Delegate called when the setting value is changed by setting properties
private unowned let didChangeDelegate: SettingChangeDelegate

Expand All @@ -51,24 +51,20 @@ class FlightCameraRecorderSettingCore: FlightCameraRecorderSetting, CustomDebugS
/// Tells if the setting value has been changed and is waiting for change confirmation
var updating: Bool { return timeout.isScheduled }

/// Supported pipeline values
private(set) var supportedValues: Set<FlightCameraRecorderPipeline> = []

/// Flight camera recorder value.
var value: Set<FlightCameraRecorderPipeline> {
/// Flight camera recorder pipeline configuration identifier.
var id: UInt64 {
get {
return _value
return _id
}

set {
if _value != newValue {
let newSupportedValue = supportedValues.intersection(newValue)
if backend(newSupportedValue) {
let oldValue = _value
if _id != newValue {
if backend(newValue) {
let oldValue = _id
// value sent to the backend, update setting value and mark it updating
_value = newSupportedValue
_id = newValue
timeout.schedule { [weak self] in
if let `self` = self, self.update(activePipelines: oldValue) {
if let `self` = self, self.update(newId: oldValue) {
self.didChangeDelegate.userDidChangeSetting()
}
}
Expand All @@ -78,41 +74,29 @@ class FlightCameraRecorderSettingCore: FlightCameraRecorderSetting, CustomDebugS
}
}

/// Flight camera recorder set of pipelines.
private var _value: Set<FlightCameraRecorderPipeline> = []
/// Flight camera recorder pipeline configuration identifier.
private var _id = UInt64(0)

/// Closure to call to change the value
private let backend: ((Set<FlightCameraRecorderPipeline>) -> Bool)
private let backend: ((UInt64) -> Bool)

/// Constructor
///
/// - Parameters:
/// - didChangeDelegate: delegate called when the setting value is changed by setting properties
/// - backend: closure to call to change the setting value
init(didChangeDelegate: SettingChangeDelegate, backend: @escaping (Set<FlightCameraRecorderPipeline>) -> Bool) {
init(didChangeDelegate: SettingChangeDelegate, backend: @escaping (UInt64) -> Bool) {
self.didChangeDelegate = didChangeDelegate
self.backend = backend
}

/// Changes flight camera recorder supported pipeline values.
///
/// - Parameter supportedValues: new set of supported pipelines
/// - Returns: true if the setting has been changed, false otherwise
func update(supportedValues newSupportedValues: Set<FlightCameraRecorderPipeline>) -> Bool {
if supportedValues != newSupportedValues {
supportedValues = newSupportedValues
return true
}
return false
}

/// Changes flight camera recorder pipelines.
/// Changes flight camera recorder pipelines configuration identifier.
///
/// - Parameter activePipelines: new set of active pipelines
/// - Returns: true if the setting has been changed, false otherwise
func update(activePipelines newActivePipelines: Set<FlightCameraRecorderPipeline>) -> Bool {
if updating || _value != newActivePipelines {
_value = newActivePipelines
func update(newId: UInt64) -> Bool {
if updating || _id != newId {
_id = newId
timeout.cancel()
return true
}
Expand All @@ -131,7 +115,7 @@ class FlightCameraRecorderSettingCore: FlightCameraRecorderSetting, CustomDebugS

/// Debug description.
var debugDescription: String {
return "\(value.description) [updating: \(updating)]"
return "\(id) [updating: \(updating)]"
}

}
Expand All @@ -146,12 +130,12 @@ public class FlightCameraRecorderCore: PeripheralCore, FlightCameraRecorder {
/// Tells if the setting value has been changed and is waiting for change confirmation
var updating: Bool { return timeout.isScheduled }

public var activePipelines: FlightCameraRecorderSetting {
return _activePipelines
public var pipelines: FlightCameraRecorderPipelinesSetting {
return _pipelines
}

/// Internal storage for active pipelines setting.
private var _activePipelines: FlightCameraRecorderSettingCore!
private var _pipelines: FlightCameraRecorderPipelinesSettingCore!

/// Implementation backend
private unowned let backend: FlightCameraRecorderBackend
Expand All @@ -164,35 +148,21 @@ public class FlightCameraRecorderCore: PeripheralCore, FlightCameraRecorder {
public init(store: ComponentStoreCore, backend: FlightCameraRecorderBackend) {
self.backend = backend
super.init(desc: Peripherals.flightCameraRecorder, store: store)
_activePipelines = FlightCameraRecorderSettingCore(
didChangeDelegate: self) { [unowned self] newActivePipelines in
return self.backend.set(activePipelines: newActivePipelines)
_pipelines = FlightCameraRecorderPipelinesSettingCore(
didChangeDelegate: self) { [unowned self] id in
return self.backend.set(pipelineConfigId: id)
}
}
}

extension FlightCameraRecorderCore {

/// Called by the backend, set the supported pipeline values
///
/// - Parameter supportedValues: new supported pipeline values
/// - Returns: self to allow call chaining
/// - Note: Changes are not notified until notifyUpdated() is called.
@discardableResult public func update(supportedValues
newSupportedValues: Set<FlightCameraRecorderPipeline>) -> FlightCameraRecorderCore {
if _activePipelines.update(supportedValues: newSupportedValues) {
markChanged()
}
return self
}

/// Called by the backend, change the setting data
///
/// - Parameter activePipelines: new set of active pipelines
/// - Parameter pipelineConfigId: new pipeline configuration identifier
/// - Returns: self to allow call chaining
@discardableResult public func update(activePipelines
newActivePipelines: Set<FlightCameraRecorderPipeline>) -> FlightCameraRecorderCore {
if _activePipelines.update(activePipelines: newActivePipelines) {
@discardableResult public func update(pipelineConfigId: UInt64) -> FlightCameraRecorderCore {
if _pipelines.update(newId: pipelineConfigId) {
markChanged()
}
return self
Expand All @@ -203,7 +173,7 @@ extension FlightCameraRecorderCore {
/// - Returns: self to allow call chaining
/// - note: changes are not notified until notifyUpdated() is called
@discardableResult public func cancelSettingsRollback() -> FlightCameraRecorderCore {
_activePipelines.cancelRollback { markChanged() }
_pipelines.cancelRollback { markChanged() }
return self
}
}
Loading

0 comments on commit 3e44d9d

Please sign in to comment.