Skip to content

Commit

Permalink
Merge pull request #222 from mavlink/update-mavsdk-server-1.4.17
Browse files Browse the repository at this point in the history
Update mavsdk-server to 1.4.17
  • Loading branch information
JonasVautherin authored Oct 11, 2023
2 parents 515e532 + aa1305c commit 7ddd47c
Show file tree
Hide file tree
Showing 34 changed files with 1,307 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ let package = Package(
]
),
.binaryTarget(name: "mavsdk_server",
url: "https://github.com/mavlink/MAVSDK/releases/download/v1.4.4/mavsdk_server.xcframework.zip",
checksum: "a8c116952919a415a4d8bf166831f0ba4e87c26f4ba33f07aacec9073bc45be6"),
url: "https://github.com/mavlink/MAVSDK/releases/download/v1.4.17/mavsdk_server.xcframework.zip",
checksum: "e5b1f13add15892aba1315412d9aa9a9eb4eb565512e87325819d7f23dde8aec"),
.testTarget(name: "MavsdkTests",
dependencies: [
"Mavsdk",
Expand Down
8 changes: 7 additions & 1 deletion Sources/Mavsdk/Drone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import MavsdkServer

public class Drone {
private let scheduler: SchedulerType
private var mavsdkServer: MavsdkServer?
public var mavsdkServer: MavsdkServer?

public var action: Action!
public var calibration: Calibration!
public var camera: Camera!
public var core: Core!
public var failure: Failure!
public var followMe: FollowMe!
public var ftp: Ftp!
public var geofence: Geofence!
Expand All @@ -22,8 +23,10 @@ public class Drone {
public var mocap: Mocap!
public var offboard: Offboard!
public var param: Param!
public var rtk: Rtk!
public var shell: Shell!
public var telemetry: Telemetry!
public var transponder: Transponder!
public var tune: Tune!

public init(scheduler: SchedulerType = ConcurrentDispatchQueueScheduler(qos: .background)) {
Expand Down Expand Up @@ -76,6 +79,7 @@ public class Drone {
self.calibration = Calibration(address: address, port: port, scheduler: scheduler)
self.camera = Camera(address: address, port: port, scheduler: scheduler)
self.core = Core(address: address, port: port, scheduler: scheduler)
self.failure = Failure(address: address, port: port, scheduler: scheduler)
self.followMe = FollowMe(address: address, port: port, scheduler: scheduler)
self.ftp = Ftp(address: address, port: port, scheduler: scheduler)
self.geofence = Geofence(address: address, port: port, scheduler: scheduler)
Expand All @@ -88,8 +92,10 @@ public class Drone {
self.mocap = Mocap(address: address, port: port, scheduler: scheduler)
self.offboard = Offboard(address: address, port: port, scheduler: scheduler)
self.param = Param(address: address, port: port, scheduler: scheduler)
self.rtk = Rtk(address: address, port: port, scheduler: scheduler)
self.shell = Shell(address: address, port: port, scheduler: scheduler)
self.telemetry = Telemetry(address: address, port: port, scheduler: scheduler)
self.transponder = Transponder(address: address, port: port, scheduler: scheduler)
self.tune = Tune(address: address, port: port, scheduler: scheduler)
}

Expand Down
158 changes: 155 additions & 3 deletions Sources/Mavsdk/Generated/Param.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,64 @@ public class Param {
}

/**
Type collecting all integer and float parameters.
Type for custom parameters
*/
public struct CustomParam: Equatable {
public let name: String
public let value: String



/**
Initializes a new `CustomParam`.
- Parameters:
- name: Name of the parameter
- value: Value of the parameter (max len 128 bytes)
*/
public init(name: String, value: String) {
self.name = name
self.value = value
}

internal var rpcCustomParam: Mavsdk_Rpc_Param_CustomParam {
var rpcCustomParam = Mavsdk_Rpc_Param_CustomParam()


rpcCustomParam.name = name




rpcCustomParam.value = value



return rpcCustomParam
}

internal static func translateFromRpc(_ rpcCustomParam: Mavsdk_Rpc_Param_CustomParam) -> CustomParam {
return CustomParam(name: rpcCustomParam.name, value: rpcCustomParam.value)
}

public static func == (lhs: CustomParam, rhs: CustomParam) -> Bool {
return lhs.name == rhs.name
&& lhs.value == rhs.value
}
}

/**
Type collecting all integer, float, and custom parameters.
*/
public struct AllParams: Equatable {
public let intParams: [IntParam]
public let floatParams: [FloatParam]
public let customParams: [CustomParam]



Expand All @@ -176,11 +229,14 @@ public class Param {
- floatParams: Collection of all parameter names and values of type float
- customParams: Collection of all parameter names and values of type custom
*/
public init(intParams: [IntParam], floatParams: [FloatParam]) {
public init(intParams: [IntParam], floatParams: [FloatParam], customParams: [CustomParam]) {
self.intParams = intParams
self.floatParams = floatParams
self.customParams = customParams
}

internal var rpcAllParams: Mavsdk_Rpc_Param_AllParams {
Expand All @@ -195,17 +251,23 @@ public class Param {
rpcAllParams.floatParams = floatParams.map{ $0.rpcFloatParam }




rpcAllParams.customParams = customParams.map{ $0.rpcCustomParam }



return rpcAllParams
}

internal static func translateFromRpc(_ rpcAllParams: Mavsdk_Rpc_Param_AllParams) -> AllParams {
return AllParams(intParams: rpcAllParams.intParams.map{ IntParam.translateFromRpc($0) }, floatParams: rpcAllParams.floatParams.map{ FloatParam.translateFromRpc($0) })
return AllParams(intParams: rpcAllParams.intParams.map{ IntParam.translateFromRpc($0) }, floatParams: rpcAllParams.floatParams.map{ FloatParam.translateFromRpc($0) }, customParams: rpcAllParams.customParams.map{ CustomParam.translateFromRpc($0) })
}

public static func == (lhs: AllParams, rhs: AllParams) -> Bool {
return lhs.intParams == rhs.intParams
&& lhs.floatParams == rhs.floatParams
&& lhs.customParams == rhs.customParams
}
}

Expand Down Expand Up @@ -237,6 +299,8 @@ public class Param {
case paramNameTooLong
/// No system connected.
case noSystem
/// Param value too long (> 128).
case paramValueTooLong
case UNRECOGNIZED(Int)

internal var rpcResult: Mavsdk_Rpc_Param_ParamResult.Result {
Expand All @@ -255,6 +319,8 @@ public class Param {
return .paramNameTooLong
case .noSystem:
return .noSystem
case .paramValueTooLong:
return .paramValueTooLong
case .UNRECOGNIZED(let i):
return .UNRECOGNIZED(i)
}
Expand All @@ -276,6 +342,8 @@ public class Param {
return .paramNameTooLong
case .noSystem:
return .noSystem
case .paramValueTooLong:
return .paramValueTooLong
case .UNRECOGNIZED(let i):
return .UNRECOGNIZED(i)
}
Expand Down Expand Up @@ -495,6 +563,90 @@ public class Param {
}
}

/**
Get a custom parameter.
If the type is wrong, the result will be `WRONG_TYPE`.
- Parameter name: Name of the parameter
*/
public func getParamCustom(name: String) -> Single<String> {
return Single<String>.create { single in
var request = Mavsdk_Rpc_Param_GetParamCustomRequest()



request.name = name



do {
let response = self.service.getParamCustom(request)


let result = try response.response.wait().paramResult
if (result.result != Mavsdk_Rpc_Param_ParamResult.Result.success) {
single(.failure(ParamError(code: ParamResult.Result.translateFromRpc(result.result), description: result.resultStr)))

return Disposables.create()
}


let value = try response.response.wait().value

single(.success(value))
} catch {
single(.failure(error))
}

return Disposables.create()
}
}

/**
Set a custom parameter.
If the type is wrong, the result will be `WRONG_TYPE`.
- Parameters:
- name: Name of the parameter to set
- value: Value the parameter should be set to
*/
public func setParamCustom(name: String, value: String) -> Completable {
return Completable.create { completable in
var request = Mavsdk_Rpc_Param_SetParamCustomRequest()



request.name = name



request.value = value



do {

let response = self.service.setParamCustom(request)

let result = try response.response.wait().paramResult
if (result.result == Mavsdk_Rpc_Param_ParamResult.Result.success) {
completable(.completed)
} else {
completable(.error(ParamError(code: ParamResult.Result.translateFromRpc(result.result), description: result.resultStr)))
}

} catch {
completable(.error(error))
}

return Disposables.create()
}
}

/**
Get all parameters.
Expand Down
Loading

0 comments on commit 7ddd47c

Please sign in to comment.