Skip to content

Commit

Permalink
Bump mavsdk_server to v0.40.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVautherin committed May 13, 2021
1 parent 4220216 commit 0dac524
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
41 changes: 41 additions & 0 deletions Sources/Mavsdk/Generated/Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 16 additions & 3 deletions Sources/Mavsdk/Generated/Info.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,25 @@ public class Info {
*/
public struct Identification: Equatable {
public let hardwareUid: String
public let legacyUid: UInt64



/**
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 {
Expand All @@ -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
}
}

Expand Down
44 changes: 44 additions & 0 deletions Sources/Mavsdk/Generated/action.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ internal protocol Mavsdk_Rpc_Action_ActionServiceClientProtocol: GRPCClient {
callOptions: CallOptions?
) -> UnaryCall<Mavsdk_Rpc_Action_HoldRequest, Mavsdk_Rpc_Action_HoldResponse>

func setActuator(
_ request: Mavsdk_Rpc_Action_SetActuatorRequest,
callOptions: CallOptions?
) -> UnaryCall<Mavsdk_Rpc_Action_SetActuatorRequest, Mavsdk_Rpc_Action_SetActuatorResponse>

func transitionToFixedwing(
_ request: Mavsdk_Rpc_Action_TransitionToFixedwingRequest,
callOptions: CallOptions?
Expand Down Expand Up @@ -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<Mavsdk_Rpc_Action_SetActuatorRequest, Mavsdk_Rpc_Action_SetActuatorResponse> {
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.
///
Expand Down Expand Up @@ -606,6 +630,9 @@ internal protocol Mavsdk_Rpc_Action_ActionServiceClientInterceptorFactoryProtoco
/// - Returns: Interceptors to use when invoking 'hold'.
func makeHoldInterceptors() -> [ClientInterceptor<Mavsdk_Rpc_Action_HoldRequest, Mavsdk_Rpc_Action_HoldResponse>]

/// - Returns: Interceptors to use when invoking 'setActuator'.
func makeSetActuatorInterceptors() -> [ClientInterceptor<Mavsdk_Rpc_Action_SetActuatorRequest, Mavsdk_Rpc_Action_SetActuatorResponse>]

/// - Returns: Interceptors to use when invoking 'transitionToFixedwing'.
func makeTransitionToFixedwingInterceptors() -> [ClientInterceptor<Mavsdk_Rpc_Action_TransitionToFixedwingRequest, Mavsdk_Rpc_Action_TransitionToFixedwingResponse>]

Expand Down Expand Up @@ -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<Mavsdk_Rpc_Action_HoldResponse>

///
/// Send command to set the value of an actuator.
func setActuator(request: Mavsdk_Rpc_Action_SetActuatorRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Mavsdk_Rpc_Action_SetActuatorResponse>

///
/// Send command to transition the drone to fixedwing.
///
Expand Down Expand Up @@ -907,6 +938,15 @@ extension Mavsdk_Rpc_Action_ActionServiceProvider {
userFunction: self.hold(request:context:)
)

case "SetActuator":
return UnaryServerHandler(
context: context,
requestDeserializer: ProtobufDeserializer<Mavsdk_Rpc_Action_SetActuatorRequest>(),
responseSerializer: ProtobufSerializer<Mavsdk_Rpc_Action_SetActuatorResponse>(),
interceptors: self.interceptors?.makeSetActuatorInterceptors() ?? [],
userFunction: self.setActuator(request:context:)
)

case "TransitionToFixedwing":
return UnaryServerHandler(
context: context,
Expand Down Expand Up @@ -1035,6 +1075,10 @@ internal protocol Mavsdk_Rpc_Action_ActionServiceServerInterceptorFactoryProtoco
/// Defaults to calling `self.makeInterceptors()`.
func makeHoldInterceptors() -> [ServerInterceptor<Mavsdk_Rpc_Action_HoldRequest, Mavsdk_Rpc_Action_HoldResponse>]

/// - Returns: Interceptors to use when handling 'setActuator'.
/// Defaults to calling `self.makeInterceptors()`.
func makeSetActuatorInterceptors() -> [ServerInterceptor<Mavsdk_Rpc_Action_SetActuatorRequest, Mavsdk_Rpc_Action_SetActuatorResponse>]

/// - Returns: Interceptors to use when handling 'transitionToFixedwing'.
/// Defaults to calling `self.makeInterceptors()`.
func makeTransitionToFixedwingInterceptors() -> [ServerInterceptor<Mavsdk_Rpc_Action_TransitionToFixedwingRequest, Mavsdk_Rpc_Action_TransitionToFixedwingResponse>]
Expand Down
107 changes: 107 additions & 0 deletions Sources/Mavsdk/Generated/action.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<D: SwiftProtobuf.Decoder>(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<V: SwiftProtobuf.Visitor>(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<D: SwiftProtobuf.Decoder>(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<V: SwiftProtobuf.Visitor>(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()
Expand Down
9 changes: 9 additions & 0 deletions Sources/Mavsdk/Generated/info.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
Expand All @@ -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
}
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Mavsdk/proto

0 comments on commit 0dac524

Please sign in to comment.