Skip to content

Commit

Permalink
[DEV] Groundsdk - release 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime MAITRE committed Oct 11, 2019
1 parent 32a8458 commit 8b0cc39
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 4 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.0"
s.version = "1.1.1"
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.0" }
s.source = { :git => 'https://github.com/Parrot-Developers/pod_arsdkengine.git', :tag => "1.1.1" }
s.platform = :ios
s.ios.deployment_target = '10.0'
s.source_files = 'ArsdkEngine/**/*'
s.dependency 'GroundSdk', '1.1.0'
s.dependency 'GroundSdk', '1.1.1'
s.swift_version = '4.2'
s.pod_target_xcconfig = {'SWIFT_VERSION' => '4.2'}
s.xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
Expand Down
7 changes: 7 additions & 0 deletions ArsdkEngine/BlackBox/BlackBoxData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,11 @@ struct BlackBoxData: Encodable {
header.softwareVersion = software
header.hardwareVersion = hardware
}

/// Records the boot id
///
/// - Parameter bootId: the boot id to record
mutating func set(bootId: String) {
header.bootId = bootId
}
}
59 changes: 59 additions & 0 deletions ArsdkEngine/BlackBox/BlackBoxDroneSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class BlackBoxDroneSession: NSObject, BlackBoxSession {
ArsdkFeatureArdrone3Pilotingstate.decode(command, callback: self)
case kArsdkFeatureArdrone3SettingsstateUid:
ArsdkFeatureArdrone3Settingsstate.decode(command, callback: self)
case kArsdkFeatureBatteryUid:
ArsdkFeatureBattery.decode(command, callback: self)
case kArsdkFeatureCommonCommonstateUid:
ArsdkFeatureCommonCommonstate.decode(command, callback: self)
case kArsdkFeatureCommonMavlinkstateUid:
Expand Down Expand Up @@ -184,6 +186,28 @@ extension BlackBoxDroneSession: ArsdkFeatureArdrone3PilotingstateCallback {
blackBox.add(event: BlackBoxEvent.alertStateChange(state.rawValue))
}

func onHoveringWarning(noGpsTooDark: UInt, noGpsTooHigh: UInt) {
if noGpsTooDark != 0 {
blackBox.add(event: BlackBoxEvent.hoveringWarning(tooDark: true))
}
if noGpsTooHigh != 0 {
blackBox.add(event: BlackBoxEvent.hoveringWarning(tooDark: false))
}
}

func onForcedLandingAutoTrigger(reason: ArsdkFeatureArdrone3PilotingstateForcedlandingautotriggerReason,
delay: UInt) {
blackBox.add(event: BlackBoxEvent.forcedLanding(reason.rawValue))
}

func onWindStateChanged(state: ArsdkFeatureArdrone3PilotingstateWindstatechangedState) {
blackBox.add(event: BlackBoxEvent.windStateChange(state.rawValue))
}

func onVibrationLevelChanged(state: ArsdkFeatureArdrone3PilotingstateVibrationlevelchangedState) {
blackBox.add(event: BlackBoxEvent.vibrationLevelChange(state.rawValue))
}

func onFlyingStateChanged(state: ArsdkFeatureArdrone3PilotingstateFlyingstatechangedState) {
blackBox.add(event: BlackBoxEvent.flyingStateChange(state: state.rawValue))
if state == .takingoff {
Expand Down Expand Up @@ -213,6 +237,10 @@ extension BlackBoxDroneSession: ArsdkFeatureArdrone3PilotingstateCallback {
func onAltitudeChanged(altitude: Double) {
flightData.altitude = altitude
}

func onAltitudeAboveGroundChanged(altitude: Float) {
flightData.heightAboveGround = altitude
}
}

extension BlackBoxDroneSession: ArsdkFeatureArdrone3SettingsstateCallback {
Expand All @@ -223,16 +251,47 @@ extension BlackBoxDroneSession: ArsdkFeatureArdrone3SettingsstateCallback {
func onMotorSoftwareVersionChanged(version: String!) {
blackBox.set(motorSoftwareVersion: version)
}

func onMotorErrorStateChanged(motorids: UInt,
motorerror: ArsdkFeatureArdrone3SettingsstateMotorerrorstatechangedMotorerror) {
blackBox.add(event: BlackBoxEvent.motorError(motorerror.rawValue))
}
}

extension BlackBoxDroneSession: ArsdkFeatureBatteryCallback {
func onAlert(alert: ArsdkFeatureBatteryAlert, level: ArsdkFeatureBatteryAlertLevel, listFlagsBitField: UInt) {
if !ArsdkFeatureGenericListFlagsBitField.isSet(.empty, inBitField: listFlagsBitField) &&
!ArsdkFeatureGenericListFlagsBitField.isSet(.remove, inBitField: listFlagsBitField) &&
level != ArsdkFeatureBatteryAlertLevel.none {
blackBox.add(event: BlackBoxEvent.batteryAlert(critical: level == ArsdkFeatureBatteryAlertLevel.critical,
type: alert.rawValue))
}
}

func onVoltage(voltage: UInt) {
environmentData.batteryVoltage = Int(voltage)
}
}

extension BlackBoxDroneSession: ArsdkFeatureCommonCommonstateCallback {
func onSensorsStatesListChanged(sensorname: ArsdkFeatureCommonCommonstateSensorsstateslistchangedSensorname,
sensorstate: UInt) {
if sensorstate == 0 {
blackBox.add(event: BlackBoxEvent.sensorError(sensorname.rawValue))
}
}

func onBatteryStateChanged(percent: UInt) {
blackBox.add(event: BlackBoxEvent.batteryLevelChange(Int(percent)))
}

func onWifiSignalChanged(rssi: Int) {
environmentData.rssi = rssi
}

func onBootId(bootid: String!) {
blackBox.set(bootId: bootid)
}
}

extension BlackBoxDroneSession: ArsdkFeatureCommonMavlinkstateCallback {
Expand Down
10 changes: 10 additions & 0 deletions ArsdkEngine/BlackBox/Data/BlackBoxEnvironmentData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct BlackBoxEnvironmentData: Encodable {
case controllerLocation = "device_gps"
case rcPcmd = "mpp_pcmd"
case rssi = "wifi_rssi"
case batteryVoltage = "product_battery_voltage"
}

/// Whether the data has been modified since the last `useIfChanged` call
Expand Down Expand Up @@ -83,6 +84,15 @@ struct BlackBoxEnvironmentData: Encodable {
}
}

/// Battery voltage
var batteryVoltage = 0 {
didSet {
if oldValue != batteryVoltage {
hasChanged = true
}
}
}

/// Get a timestamped flight data if this object has changed since the last `useIfChanged` call.
///
/// - Returns: this object timestamped if it has changed, nil otherwise
Expand Down
58 changes: 58 additions & 0 deletions ArsdkEngine/BlackBox/Data/BlackBoxEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,64 @@ struct BlackBoxEvent: Encodable {
return BlackBoxEvent(type: "product_alert", value: state)
}

/// Obtains a hovering warning event
///
/// - Parameter tooDark: `true` if the reason is darkness, `false` if it's the drone height
/// - Returns: hovering warning event
static func hoveringWarning(tooDark: Bool) -> BlackBoxEvent {
return BlackBoxEvent(type: "product_hovering_warning", value: tooDark ? "no_gps_too_dark" : "no_gps_too_high")
}

/// Obtains a forced landing event
///
/// - Parameter reason: forced landing reason
/// - Returns: forced landing event
static func forcedLanding(_ reason: Int) -> BlackBoxEvent {
return BlackBoxEvent(type: "product_forced_landing", value: reason)
}

/// Obtains a wind state change event
///
/// - Parameter state: wind state
/// - Returns: wind state change event
static func windStateChange(_ state: Int) -> BlackBoxEvent {
return BlackBoxEvent(type: "product_wind", value: state)
}

/// Obtains a vibration level change event
///
/// - Parameter state: vibration level state
/// - Returns: vibration level change event
static func vibrationLevelChange(_ state: Int) -> BlackBoxEvent {
return BlackBoxEvent(type: "product_vibration_level", value: state)
}

/// Obtains a motor error event
///
/// - Parameter error: motor error
/// - Returns: motor error event
static func motorError(_ error: Int) -> BlackBoxEvent {
return BlackBoxEvent(type: "product_motor_error", value: error)
}

/// Obtains a battery alert event
///
/// - Parameters:
/// - critical: `true` if the alert is critical, `false` if it's a warning
/// - type: alert type
/// - Returns: battery alert event
static func batteryAlert(critical: Bool, type: Int) -> BlackBoxEvent {
return BlackBoxEvent(type: "product_battery_" + (critical ? "critical" : "warning"), value: type)
}

/// Obtains a sensor error event
///
/// - Parameter sensor: sensor
/// - Returns: sensor error event
static func sensorError(_ sensor: Int) -> BlackBoxEvent {
return BlackBoxEvent(type: "product_sensor_error", value: sensor)
}

/// Obtains a battery level change event
///
/// - Parameter level: battery level
Expand Down
10 changes: 10 additions & 0 deletions ArsdkEngine/BlackBox/Data/BlackBoxFlightData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct BlackBoxFlightData: Encodable {
private enum CodingKeys: String, CodingKey {
case timestamp
case altitude = "product_alt"
case heightAboveGround = "product_height_above_ground"
case speed = "product_speed"
case attitude = "product_angles"
case pcmd = "device_pcmd"
Expand All @@ -56,6 +57,15 @@ struct BlackBoxFlightData: Encodable {
}
}

/// Height of the drone in meters above ground level
var heightAboveGround = Float(0) {
didSet {
if oldValue != heightAboveGround {
hasChanged = true
}
}
}

/// Speed of the drone
var speed = BlackBoxSpeedData() {
didSet {
Expand Down
5 changes: 4 additions & 1 deletion ArsdkEngine/BlackBox/Data/BlackBoxHeaderData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ struct BlackBoxHeaderData: Encodable {
case motorVersion = "product_motor_version"
case gpsVersion = "product_gps_version"
case academyId = "academy_id"
case bootId = "boot_id"
case remoteControlData = "remote_controller"
}

/// Black box version
let blackBoxVersion = "1.0.3"
let blackBoxVersion = "1.0.5"
/// OS version
let osVersion = "iOS \(AppInfoCore.systemVersion)"
/// Device model
Expand All @@ -75,6 +76,8 @@ struct BlackBoxHeaderData: Encodable {
var gpsVersion: String?
/// User's academy id
var academyId: String? // TODO: defined here but needs academy integration.
/// Drone's boot id
var bootId: String?
/// Remote controller information
var remoteControlData: BlackBoxRemoteControlData?

Expand Down

0 comments on commit 8b0cc39

Please sign in to comment.