Skip to content

Commit

Permalink
Merge pull request #677 from mavlink/pr-mavsdk-2.8
Browse files Browse the repository at this point in the history
Update to MAVSDK v2.8.0
  • Loading branch information
julianoes authored Apr 15, 2024
2 parents 8320ad7 + a9e30ed commit 162b3dd
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 115 deletions.
2 changes: 1 addition & 1 deletion MAVSDK_SERVER_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.7.0
v2.8.0
25 changes: 25 additions & 0 deletions mavsdk/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,31 @@ async def arm(self):
raise ActionError(result, "arm()")


async def arm_force(self):
"""
Send command to force-arm the drone without any checks.
Attention: this is not to be used for normal flying but only bench tests!
Arming a drone normally causes motors to spin at idle.
Before arming take all safety precautions and stand clear of the drone!
Raises
------
ActionError
If the request fails. The error contains the reason for the failure.
"""

request = action_pb2.ArmForceRequest()
response = await self._stub.ArmForce(request)


result = self._extract_result(response)

if result.result != ActionResult.Result.SUCCESS:
raise ActionError(result, "arm_force()")


async def disarm(self):
"""
Send command to disarm the drone.
Expand Down
206 changes: 113 additions & 93 deletions mavsdk/action_pb2.py

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions mavsdk/action_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def __init__(self, channel):
request_serializer=action_dot_action__pb2.ArmRequest.SerializeToString,
response_deserializer=action_dot_action__pb2.ArmResponse.FromString,
)
self.ArmForce = channel.unary_unary(
'/mavsdk.rpc.action.ActionService/ArmForce',
request_serializer=action_dot_action__pb2.ArmForceRequest.SerializeToString,
response_deserializer=action_dot_action__pb2.ArmForceResponse.FromString,
)
self.Disarm = channel.unary_unary(
'/mavsdk.rpc.action.ActionService/Disarm',
request_serializer=action_dot_action__pb2.DisarmRequest.SerializeToString,
Expand Down Expand Up @@ -142,6 +147,19 @@ def Arm(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def ArmForce(self, request, context):
"""
Send command to force-arm the drone without any checks.
Attention: this is not to be used for normal flying but only bench tests!
Arming a drone normally causes motors to spin at idle.
Before arming take all safety precautions and stand clear of the drone!
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def Disarm(self, request, context):
"""
Send command to disarm the drone.
Expand Down Expand Up @@ -369,6 +387,11 @@ def add_ActionServiceServicer_to_server(servicer, server):
request_deserializer=action_dot_action__pb2.ArmRequest.FromString,
response_serializer=action_dot_action__pb2.ArmResponse.SerializeToString,
),
'ArmForce': grpc.unary_unary_rpc_method_handler(
servicer.ArmForce,
request_deserializer=action_dot_action__pb2.ArmForceRequest.FromString,
response_serializer=action_dot_action__pb2.ArmForceResponse.SerializeToString,
),
'Disarm': grpc.unary_unary_rpc_method_handler(
servicer.Disarm,
request_deserializer=action_dot_action__pb2.DisarmRequest.FromString,
Expand Down Expand Up @@ -502,6 +525,23 @@ def Arm(request,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def ArmForce(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/ArmForce',
action_dot_action__pb2.ArmForceRequest.SerializeToString,
action_dot_action__pb2.ArmForceResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def Disarm(request,
target,
Expand Down
40 changes: 36 additions & 4 deletions mavsdk/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,27 @@ class FlightInfo:
flight_uid : uint64_t
Flight counter. Starts from zero, is incremented at every disarm and is never reset (even after reboot)
duration_since_arming_ms : uint32_t
Duration since arming in milliseconds
duration_since_takeoff_ms : uint32_t
Duration since takeoff in milliseconds
"""



def __init__(
self,
time_boot_ms,
flight_uid):
flight_uid,
duration_since_arming_ms,
duration_since_takeoff_ms):
""" Initializes the FlightInfo object """
self.time_boot_ms = time_boot_ms
self.flight_uid = flight_uid
self.duration_since_arming_ms = duration_since_arming_ms
self.duration_since_takeoff_ms = duration_since_takeoff_ms

def __eq__(self, to_compare):
""" Checks if two FlightInfo are the same """
Expand All @@ -37,7 +47,9 @@ def __eq__(self, to_compare):
# FlightInfo object
return \
(self.time_boot_ms == to_compare.time_boot_ms) and \
(self.flight_uid == to_compare.flight_uid)
(self.flight_uid == to_compare.flight_uid) and \
(self.duration_since_arming_ms == to_compare.duration_since_arming_ms) and \
(self.duration_since_takeoff_ms == to_compare.duration_since_takeoff_ms)

except AttributeError:
return False
Expand All @@ -46,7 +58,9 @@ def __str__(self):
""" FlightInfo in string representation """
struct_repr = ", ".join([
"time_boot_ms: " + str(self.time_boot_ms),
"flight_uid: " + str(self.flight_uid)
"flight_uid: " + str(self.flight_uid),
"duration_since_arming_ms: " + str(self.duration_since_arming_ms),
"duration_since_takeoff_ms: " + str(self.duration_since_takeoff_ms)
])

return f"FlightInfo: [{struct_repr}]"
Expand All @@ -59,7 +73,13 @@ def translate_from_rpc(rpcFlightInfo):
rpcFlightInfo.time_boot_ms,


rpcFlightInfo.flight_uid
rpcFlightInfo.flight_uid,


rpcFlightInfo.duration_since_arming_ms,


rpcFlightInfo.duration_since_takeoff_ms
)

def translate_to_rpc(self, rpcFlightInfo):
Expand All @@ -78,6 +98,18 @@ def translate_to_rpc(self, rpcFlightInfo):





rpcFlightInfo.duration_since_arming_ms = self.duration_since_arming_ms





rpcFlightInfo.duration_since_takeoff_ms = self.duration_since_takeoff_ms





class Identification:
Expand Down
32 changes: 16 additions & 16 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 1acb78 to e3f50d

0 comments on commit 162b3dd

Please sign in to comment.