Skip to content

Commit

Permalink
Merge pull request #353 from mavlink/update-to-v0.40.0
Browse files Browse the repository at this point in the history
Update mavsdk to v0.40.0
  • Loading branch information
JonasVautherin authored May 25, 2021
2 parents 225acdc + d6aa6ba commit fd6a162
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 100 deletions.
5 changes: 1 addition & 4 deletions MAVSDK_SERVER_VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
v0.39.0



v0.40.0
30 changes: 30 additions & 0 deletions mavsdk/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,36 @@ async def hold(self):
raise ActionError(result, "hold()")


async def set_actuator(self, index, value):
"""
Send command to set the value of an actuator.
Parameters
----------
index : int32_t
Index of actuator (starting with 1)
value : float
Value to set the actuator to (normalized from [-1..1])
Raises
------
ActionError
If the request fails. The error contains the reason for the failure.
"""

request = action_pb2.SetActuatorRequest()
request.index = index
request.value = value
response = await self._stub.SetActuator(request)


result = self._extract_result(response)

if result.result is not ActionResult.Result.SUCCESS:
raise ActionError(result, "set_actuator()", index, value)


async def transition_to_fixedwing(self):
"""
Send command to transition the drone to fixedwing.
Expand Down
196 changes: 147 additions & 49 deletions mavsdk/action_pb2.py

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions mavsdk/action_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def __init__(self, channel):
request_serializer=action_dot_action__pb2.HoldRequest.SerializeToString,
response_deserializer=action_dot_action__pb2.HoldResponse.FromString,
)
self.SetActuator = channel.unary_unary(
'/mavsdk.rpc.action.ActionService/SetActuator',
request_serializer=action_dot_action__pb2.SetActuatorRequest.SerializeToString,
response_deserializer=action_dot_action__pb2.SetActuatorResponse.FromString,
)
self.TransitionToFixedwing = channel.unary_unary(
'/mavsdk.rpc.action.ActionService/TransitionToFixedwing',
request_serializer=action_dot_action__pb2.TransitionToFixedwingRequest.SerializeToString,
Expand Down Expand Up @@ -258,6 +263,14 @@ def Hold(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def SetActuator(self, request, context):
"""
Send command to set the value of an actuator.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def TransitionToFixedwing(self, request, context):
"""
Send command to transition the drone to fixedwing.
Expand Down Expand Up @@ -393,6 +406,11 @@ def add_ActionServiceServicer_to_server(servicer, server):
request_deserializer=action_dot_action__pb2.HoldRequest.FromString,
response_serializer=action_dot_action__pb2.HoldResponse.SerializeToString,
),
'SetActuator': grpc.unary_unary_rpc_method_handler(
servicer.SetActuator,
request_deserializer=action_dot_action__pb2.SetActuatorRequest.FromString,
response_serializer=action_dot_action__pb2.SetActuatorResponse.SerializeToString,
),
'TransitionToFixedwing': grpc.unary_unary_rpc_method_handler(
servicer.TransitionToFixedwing,
request_deserializer=action_dot_action__pb2.TransitionToFixedwingRequest.FromString,
Expand Down Expand Up @@ -648,6 +666,23 @@ def Hold(request,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def SetActuator(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/mavsdk.rpc.action.ActionService/SetActuator',
action_dot_action__pb2.SetActuatorRequest.SerializeToString,
action_dot_action__pb2.SetActuatorResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def TransitionToFixedwing(request,
target,
Expand Down
16 changes: 0 additions & 16 deletions mavsdk/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class ConnectionState:
Parameters
----------
uuid : uint64_t
UUID of the vehicle
is_connected : bool
Whether the vehicle got connected or disconnected
Expand All @@ -24,10 +21,8 @@ class ConnectionState:

def __init__(
self,
uuid,
is_connected):
""" Initializes the ConnectionState object """
self.uuid = uuid
self.is_connected = is_connected

def __equals__(self, to_compare):
Expand All @@ -36,7 +31,6 @@ def __equals__(self, to_compare):
# Try to compare - this likely fails when it is compared to a non
# ConnectionState object
return \
(self.uuid == to_compare.uuid) and \
(self.is_connected == to_compare.is_connected)

except AttributeError:
Expand All @@ -45,7 +39,6 @@ def __equals__(self, to_compare):
def __str__(self):
""" ConnectionState in string representation """
struct_repr = ", ".join([
"uuid: " + str(self.uuid),
"is_connected: " + str(self.is_connected)
])

Expand All @@ -56,9 +49,6 @@ def translate_from_rpc(rpcConnectionState):
""" Translates a gRPC struct to the SDK equivalent """
return ConnectionState(

rpcConnectionState.uuid,


rpcConnectionState.is_connected
)

Expand All @@ -68,12 +58,6 @@ def translate_to_rpc(self, rpcConnectionState):



rpcConnectionState.uuid = self.uuid





rpcConnectionState.is_connected = self.is_connected


Expand Down
21 changes: 7 additions & 14 deletions mavsdk/core_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions mavsdk/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,38 @@ class Identification:
hardware_uid : std::string
UID of the hardware. This refers to uid2 of MAVLink. If the system does not support uid2 yet, this is all zeros.
legacy_uid : uint64_t
Legacy UID of the hardware, referred to as uid in MAVLink (formerly exposed during system discovery as UUID).
"""



def __init__(
self,
hardware_uid):
hardware_uid,
legacy_uid):
""" Initializes the Identification object """
self.hardware_uid = hardware_uid
self.legacy_uid = legacy_uid

def __equals__(self, to_compare):
""" Checks if two Identification are the same """
try:
# Try to compare - this likely fails when it is compared to a non
# Identification object
return \
(self.hardware_uid == to_compare.hardware_uid)
(self.hardware_uid == to_compare.hardware_uid) and \
(self.legacy_uid == to_compare.legacy_uid)

except AttributeError:
return False

def __str__(self):
""" Identification in string representation """
struct_repr = ", ".join([
"hardware_uid: " + str(self.hardware_uid)
"hardware_uid: " + str(self.hardware_uid),
"legacy_uid: " + str(self.legacy_uid)
])

return f"Identification: [{struct_repr}]"
Expand All @@ -123,7 +130,10 @@ def translate_from_rpc(rpcIdentification):
""" Translates a gRPC struct to the SDK equivalent """
return Identification(

rpcIdentification.hardware_uid
rpcIdentification.hardware_uid,


rpcIdentification.legacy_uid
)

def translate_to_rpc(self, rpcIdentification):
Expand All @@ -136,6 +146,12 @@ def translate_to_rpc(self, rpcIdentification):





rpcIdentification.legacy_uid = self.legacy_uid





class Product:
Expand Down
31 changes: 19 additions & 12 deletions mavsdk/info_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto
Submodule proto updated from 65d112 to a968c0

0 comments on commit fd6a162

Please sign in to comment.