From 0dac52415d368b0bccb56c0a46f9635b32d05e15 Mon Sep 17 00:00:00 2001 From: Jonas Vautherin Date: Thu, 13 May 2021 19:48:48 +0200 Subject: [PATCH] Bump mavsdk_server to v0.40.0 --- Package.resolved | 4 +- Package.swift | 2 +- README.md | 2 +- Sources/Mavsdk/Generated/Action.swift | 41 ++++++++ Sources/Mavsdk/Generated/Info.swift | 19 +++- Sources/Mavsdk/Generated/action.grpc.swift | 44 +++++++++ Sources/Mavsdk/Generated/action.pb.swift | 107 +++++++++++++++++++++ Sources/Mavsdk/Generated/info.pb.swift | 9 ++ Sources/Mavsdk/proto | 2 +- 9 files changed, 222 insertions(+), 8 deletions(-) diff --git a/Package.resolved b/Package.resolved index 60f9041..f0c47ad 100644 --- a/Package.resolved +++ b/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/mavlink/MAVSDK-XCFramework", "state": { "branch": null, - "revision": "ef704436a0ea3ba3dd207146cda8ff65518cf55b", - "version": "0.39.0" + "revision": "8c5fb3a00cac10cb777c146f70cd827328c593fe", + "version": "0.40.0" } }, { diff --git a/Package.swift b/Package.swift index 87c6192..c2e4c3f 100644 --- a/Package.swift +++ b/Package.swift @@ -23,7 +23,7 @@ let package = Package( dependencies: [ .package(url: "https://github.com/grpc/grpc-swift", from: "1.0.0"), .package(url: "https://github.com/ReactiveX/RxSwift.git", from: "5.0.0"), - .package(url: "https://github.com/mavlink/MAVSDK-XCFramework", .exact("0.39.0")) + .package(url: "https://github.com/mavlink/MAVSDK-XCFramework", .exact("0.40.0")) ], targets: [ .target(name: "Mavsdk", diff --git a/README.md b/README.md index 42cc93f..05edb27 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The official MAVSDK client for Swift. This cross-platform gRPC library communica Add the following to your Package.swift dependencies: ``` dependencies: [ - .package(url: "https://github.com/mavlink/Mavsdk", from: "0.12.0"), + .package(url: "https://github.com/mavlink/Mavsdk", from: "0.13.0"), ], ``` And add each product within each target as needed (`MavsdkServer` may be optional): diff --git a/Sources/Mavsdk/Generated/Action.swift b/Sources/Mavsdk/Generated/Action.swift index a942036..0f00272 100644 --- a/Sources/Mavsdk/Generated/Action.swift +++ b/Sources/Mavsdk/Generated/Action.swift @@ -705,6 +705,47 @@ public class Action { } } + /** + Send command to set the value of an actuator. + + - Parameters: + - index: Index of actuator (starting with 1) + - value: Value to set the actuator to (normalized from [-1..1]) + + */ + public func setActuator(index: Int32, value: Float) -> Completable { + return Completable.create { completable in + var request = Mavsdk_Rpc_Action_SetActuatorRequest() + + + + request.index = index + + + + request.value = value + + + + do { + + let response = self.service.setActuator(request) + + let result = try response.response.wait().actionResult + if (result.result == Mavsdk_Rpc_Action_ActionResult.Result.success) { + completable(.completed) + } else { + completable(.error(ActionError(code: ActionResult.Result.translateFromRpc(result.result), description: result.resultStr))) + } + + } catch { + completable(.error(error)) + } + + return Disposables.create() + } + } + /** Send command to transition the drone to fixedwing. diff --git a/Sources/Mavsdk/Generated/Info.swift b/Sources/Mavsdk/Generated/Info.swift index 1c79782..b66937f 100644 --- a/Sources/Mavsdk/Generated/Info.swift +++ b/Sources/Mavsdk/Generated/Info.swift @@ -110,6 +110,7 @@ public class Info { */ public struct Identification: Equatable { public let hardwareUid: String + public let legacyUid: UInt64 @@ -117,11 +118,17 @@ public class Info { Initializes a new `Identification`. - - Parameter hardwareUid: UID of the hardware. This refers to uid2 of MAVLink. If the system does not support uid2 yet, this is all zeros. + - Parameters: + + - hardwareUid: UID of the hardware. This refers to uid2 of MAVLink. If the system does not support uid2 yet, this is all zeros. + + - legacyUid: Legacy UID of the hardware, referred to as uid in MAVLink (formerly exposed during system discovery as UUID). + */ - public init(hardwareUid: String) { + public init(hardwareUid: String, legacyUid: UInt64) { self.hardwareUid = hardwareUid + self.legacyUid = legacyUid } internal var rpcIdentification: Mavsdk_Rpc_Info_Identification { @@ -131,16 +138,22 @@ public class Info { rpcIdentification.hardwareUid = hardwareUid + + + rpcIdentification.legacyUid = legacyUid + + return rpcIdentification } internal static func translateFromRpc(_ rpcIdentification: Mavsdk_Rpc_Info_Identification) -> Identification { - return Identification(hardwareUid: rpcIdentification.hardwareUid) + return Identification(hardwareUid: rpcIdentification.hardwareUid, legacyUid: rpcIdentification.legacyUid) } public static func == (lhs: Identification, rhs: Identification) -> Bool { return lhs.hardwareUid == rhs.hardwareUid + && lhs.legacyUid == rhs.legacyUid } } diff --git a/Sources/Mavsdk/Generated/action.grpc.swift b/Sources/Mavsdk/Generated/action.grpc.swift index b600b9a..a0a3854 100644 --- a/Sources/Mavsdk/Generated/action.grpc.swift +++ b/Sources/Mavsdk/Generated/action.grpc.swift @@ -92,6 +92,11 @@ internal protocol Mavsdk_Rpc_Action_ActionServiceClientProtocol: GRPCClient { callOptions: CallOptions? ) -> UnaryCall + func setActuator( + _ request: Mavsdk_Rpc_Action_SetActuatorRequest, + callOptions: CallOptions? + ) -> UnaryCall + func transitionToFixedwing( _ request: Mavsdk_Rpc_Action_TransitionToFixedwingRequest, callOptions: CallOptions? @@ -407,6 +412,25 @@ extension Mavsdk_Rpc_Action_ActionServiceClientProtocol { ) } + /// + /// Send command to set the value of an actuator. + /// + /// - Parameters: + /// - request: Request to send to SetActuator. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + internal func setActuator( + _ request: Mavsdk_Rpc_Action_SetActuatorRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/mavsdk.rpc.action.ActionService/SetActuator", + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeSetActuatorInterceptors() ?? [] + ) + } + /// /// Send command to transition the drone to fixedwing. /// @@ -606,6 +630,9 @@ internal protocol Mavsdk_Rpc_Action_ActionServiceClientInterceptorFactoryProtoco /// - Returns: Interceptors to use when invoking 'hold'. func makeHoldInterceptors() -> [ClientInterceptor] + /// - Returns: Interceptors to use when invoking 'setActuator'. + func makeSetActuatorInterceptors() -> [ClientInterceptor] + /// - Returns: Interceptors to use when invoking 'transitionToFixedwing'. func makeTransitionToFixedwingInterceptors() -> [ClientInterceptor] @@ -748,6 +775,10 @@ internal protocol Mavsdk_Rpc_Action_ActionServiceProvider: CallHandlerProvider { /// it implies a change to a PX4-specific mode. func hold(request: Mavsdk_Rpc_Action_HoldRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// + /// Send command to set the value of an actuator. + func setActuator(request: Mavsdk_Rpc_Action_SetActuatorRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// /// Send command to transition the drone to fixedwing. /// @@ -907,6 +938,15 @@ extension Mavsdk_Rpc_Action_ActionServiceProvider { userFunction: self.hold(request:context:) ) + case "SetActuator": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeSetActuatorInterceptors() ?? [], + userFunction: self.setActuator(request:context:) + ) + case "TransitionToFixedwing": return UnaryServerHandler( context: context, @@ -1035,6 +1075,10 @@ internal protocol Mavsdk_Rpc_Action_ActionServiceServerInterceptorFactoryProtoco /// Defaults to calling `self.makeInterceptors()`. func makeHoldInterceptors() -> [ServerInterceptor] + /// - Returns: Interceptors to use when handling 'setActuator'. + /// Defaults to calling `self.makeInterceptors()`. + func makeSetActuatorInterceptors() -> [ServerInterceptor] + /// - Returns: Interceptors to use when handling 'transitionToFixedwing'. /// Defaults to calling `self.makeInterceptors()`. func makeTransitionToFixedwingInterceptors() -> [ServerInterceptor] diff --git a/Sources/Mavsdk/Generated/action.pb.swift b/Sources/Mavsdk/Generated/action.pb.swift index 494f16a..8edb575 100644 --- a/Sources/Mavsdk/Generated/action.pb.swift +++ b/Sources/Mavsdk/Generated/action.pb.swift @@ -485,6 +485,43 @@ struct Mavsdk_Rpc_Action_HoldResponse { fileprivate var _actionResult: Mavsdk_Rpc_Action_ActionResult? = nil } +struct Mavsdk_Rpc_Action_SetActuatorRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Index of actuator (starting with 1) + var index: Int32 = 0 + + /// Value to set the actuator to (normalized from [-1..1]) + var value: Float = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct Mavsdk_Rpc_Action_SetActuatorResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var actionResult: Mavsdk_Rpc_Action_ActionResult { + get {return _actionResult ?? Mavsdk_Rpc_Action_ActionResult()} + set {_actionResult = newValue} + } + /// Returns true if `actionResult` has been explicitly set. + var hasActionResult: Bool {return self._actionResult != nil} + /// Clears the value of `actionResult`. Subsequent reads from it will return its default value. + mutating func clearActionResult() {self._actionResult = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _actionResult: Mavsdk_Rpc_Action_ActionResult? = nil +} + struct Mavsdk_Rpc_Action_TransitionToFixedwingRequest { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -1573,6 +1610,76 @@ extension Mavsdk_Rpc_Action_HoldResponse: SwiftProtobuf.Message, SwiftProtobuf._ } } +extension Mavsdk_Rpc_Action_SetActuatorRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".SetActuatorRequest" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "index"), + 2: .same(proto: "value"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self.index) }() + case 2: try { try decoder.decodeSingularFloatField(value: &self.value) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.index != 0 { + try visitor.visitSingularInt32Field(value: self.index, fieldNumber: 1) + } + if self.value != 0 { + try visitor.visitSingularFloatField(value: self.value, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Mavsdk_Rpc_Action_SetActuatorRequest, rhs: Mavsdk_Rpc_Action_SetActuatorRequest) -> Bool { + if lhs.index != rhs.index {return false} + if lhs.value != rhs.value {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Mavsdk_Rpc_Action_SetActuatorResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".SetActuatorResponse" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "action_result"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._actionResult) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if let v = self._actionResult { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Mavsdk_Rpc_Action_SetActuatorResponse, rhs: Mavsdk_Rpc_Action_SetActuatorResponse) -> Bool { + if lhs._actionResult != rhs._actionResult {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Mavsdk_Rpc_Action_TransitionToFixedwingRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".TransitionToFixedwingRequest" static let _protobuf_nameMap = SwiftProtobuf._NameMap() diff --git a/Sources/Mavsdk/Generated/info.pb.swift b/Sources/Mavsdk/Generated/info.pb.swift index b99a70a..3ba6aa8 100644 --- a/Sources/Mavsdk/Generated/info.pb.swift +++ b/Sources/Mavsdk/Generated/info.pb.swift @@ -248,6 +248,9 @@ struct Mavsdk_Rpc_Info_Identification { /// UID of the hardware. This refers to uid2 of MAVLink. If the system does not support uid2 yet, this is all zeros. var hardwareUid: String = String() + /// Legacy UID of the hardware, referred to as uid in MAVLink (formerly exposed during system discovery as UUID). + var legacyUid: UInt64 = 0 + var unknownFields = SwiftProtobuf.UnknownStorage() init() {} @@ -719,6 +722,7 @@ extension Mavsdk_Rpc_Info_Identification: SwiftProtobuf.Message, SwiftProtobuf._ static let protoMessageName: String = _protobuf_package + ".Identification" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "hardware_uid"), + 2: .standard(proto: "legacy_uid"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -728,6 +732,7 @@ extension Mavsdk_Rpc_Info_Identification: SwiftProtobuf.Message, SwiftProtobuf._ // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { case 1: try { try decoder.decodeSingularStringField(value: &self.hardwareUid) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.legacyUid) }() default: break } } @@ -737,11 +742,15 @@ extension Mavsdk_Rpc_Info_Identification: SwiftProtobuf.Message, SwiftProtobuf._ if !self.hardwareUid.isEmpty { try visitor.visitSingularStringField(value: self.hardwareUid, fieldNumber: 1) } + if self.legacyUid != 0 { + try visitor.visitSingularUInt64Field(value: self.legacyUid, fieldNumber: 2) + } try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: Mavsdk_Rpc_Info_Identification, rhs: Mavsdk_Rpc_Info_Identification) -> Bool { if lhs.hardwareUid != rhs.hardwareUid {return false} + if lhs.legacyUid != rhs.legacyUid {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Sources/Mavsdk/proto b/Sources/Mavsdk/proto index 8246091..a968c01 160000 --- a/Sources/Mavsdk/proto +++ b/Sources/Mavsdk/proto @@ -1 +1 @@ -Subproject commit 82460915fdc2f4a759b275789c40da060cfd7d7f +Subproject commit a968c018dd0216425d79307aa382192ed62e2362