Skip to content

Commit

Permalink
Merge pull request #455 from mavlink/pr-update
Browse files Browse the repository at this point in the history
Update to latest proto and server
  • Loading branch information
julianoes committed Mar 18, 2022
2 parents 3c2ad41 + 517901b commit 108ef86
Show file tree
Hide file tree
Showing 47 changed files with 4,808 additions and 29,723 deletions.
2 changes: 1 addition & 1 deletion MAVSDK_SERVER_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.50.0
v1.1.0
2 changes: 1 addition & 1 deletion examples/takeoff_and_land.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def run():
print("-- Taking off")
await drone.action.takeoff()

await asyncio.sleep(5)
await asyncio.sleep(10)

print("-- Landing")
await drone.action.land()
Expand Down
8 changes: 8 additions & 0 deletions mavsdk/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class Result(Enum):
PARAMETER_ERROR
Error getting or setting parameter
UNSUPPORTED
Action not supported
"""


Expand All @@ -139,6 +142,7 @@ class Result(Enum):
VTOL_TRANSITION_SUPPORT_UNKNOWN = 9
NO_VTOL_TRANSITION_SUPPORT = 10
PARAMETER_ERROR = 11
UNSUPPORTED = 12

def translate_to_rpc(self):
if self == ActionResult.Result.UNKNOWN:
Expand All @@ -165,6 +169,8 @@ def translate_to_rpc(self):
return action_pb2.ActionResult.RESULT_NO_VTOL_TRANSITION_SUPPORT
if self == ActionResult.Result.PARAMETER_ERROR:
return action_pb2.ActionResult.RESULT_PARAMETER_ERROR
if self == ActionResult.Result.UNSUPPORTED:
return action_pb2.ActionResult.RESULT_UNSUPPORTED

@staticmethod
def translate_from_rpc(rpc_enum_value):
Expand Down Expand Up @@ -193,6 +199,8 @@ def translate_from_rpc(rpc_enum_value):
return ActionResult.Result.NO_VTOL_TRANSITION_SUPPORT
if rpc_enum_value == action_pb2.ActionResult.RESULT_PARAMETER_ERROR:
return ActionResult.Result.PARAMETER_ERROR
if rpc_enum_value == action_pb2.ActionResult.RESULT_UNSUPPORTED:
return ActionResult.Result.UNSUPPORTED

def __str__(self):
return self.name
Expand Down
1,938 changes: 150 additions & 1,788 deletions mavsdk/action_pb2.py

Large diffs are not rendered by default.

1,379 changes: 120 additions & 1,259 deletions mavsdk/action_server_pb2.py

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions mavsdk/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class Result(Enum):
FAILED_ARMED
Calibration process failed since the vehicle is armed
UNSUPPORTED
Functionality not supported
"""


Expand All @@ -75,6 +78,7 @@ class Result(Enum):
TIMEOUT = 8
CANCELLED = 9
FAILED_ARMED = 10
UNSUPPORTED = 11

def translate_to_rpc(self):
if self == CalibrationResult.Result.UNKNOWN:
Expand All @@ -99,6 +103,8 @@ def translate_to_rpc(self):
return calibration_pb2.CalibrationResult.RESULT_CANCELLED
if self == CalibrationResult.Result.FAILED_ARMED:
return calibration_pb2.CalibrationResult.RESULT_FAILED_ARMED
if self == CalibrationResult.Result.UNSUPPORTED:
return calibration_pb2.CalibrationResult.RESULT_UNSUPPORTED

@staticmethod
def translate_from_rpc(rpc_enum_value):
Expand All @@ -125,6 +131,8 @@ def translate_from_rpc(rpc_enum_value):
return CalibrationResult.Result.CANCELLED
if rpc_enum_value == calibration_pb2.CalibrationResult.RESULT_FAILED_ARMED:
return CalibrationResult.Result.FAILED_ARMED
if rpc_enum_value == calibration_pb2.CalibrationResult.RESULT_UNSUPPORTED:
return CalibrationResult.Result.UNSUPPORTED

def __str__(self):
return self.name
Expand Down
731 changes: 72 additions & 659 deletions mavsdk/calibration_pb2.py

Large diffs are not rendered by default.

108 changes: 104 additions & 4 deletions mavsdk/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,12 @@ class Status:
storage_status : StorageStatus
Storage status
storage_id : uint32_t
Storage ID starting at 1
storage_type : StorageType
Storage type
"""


Expand Down Expand Up @@ -1129,6 +1135,74 @@ def translate_from_rpc(rpc_enum_value):
def __str__(self):
return self.name


class StorageType(Enum):
"""
Storage type.
Values
------
UNKNOWN
Storage type unknown
USB_STICK
Storage type USB stick
SD
Storage type SD card
MICROSD
Storage type MicroSD card
HD
Storage type HD mass storage
OTHER
Storage type other, not listed
"""


UNKNOWN = 0
USB_STICK = 1
SD = 2
MICROSD = 3
HD = 4
OTHER = 5

def translate_to_rpc(self):
if self == Status.StorageType.UNKNOWN:
return camera_pb2.Status.STORAGE_TYPE_UNKNOWN
if self == Status.StorageType.USB_STICK:
return camera_pb2.Status.STORAGE_TYPE_USB_STICK
if self == Status.StorageType.SD:
return camera_pb2.Status.STORAGE_TYPE_SD
if self == Status.StorageType.MICROSD:
return camera_pb2.Status.STORAGE_TYPE_MICROSD
if self == Status.StorageType.HD:
return camera_pb2.Status.STORAGE_TYPE_HD
if self == Status.StorageType.OTHER:
return camera_pb2.Status.STORAGE_TYPE_OTHER

@staticmethod
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
if rpc_enum_value == camera_pb2.Status.STORAGE_TYPE_UNKNOWN:
return Status.StorageType.UNKNOWN
if rpc_enum_value == camera_pb2.Status.STORAGE_TYPE_USB_STICK:
return Status.StorageType.USB_STICK
if rpc_enum_value == camera_pb2.Status.STORAGE_TYPE_SD:
return Status.StorageType.SD
if rpc_enum_value == camera_pb2.Status.STORAGE_TYPE_MICROSD:
return Status.StorageType.MICROSD
if rpc_enum_value == camera_pb2.Status.STORAGE_TYPE_HD:
return Status.StorageType.HD
if rpc_enum_value == camera_pb2.Status.STORAGE_TYPE_OTHER:
return Status.StorageType.OTHER

def __str__(self):
return self.name


def __init__(
self,
Expand All @@ -1139,7 +1213,9 @@ def __init__(
total_storage_mib,
recording_time_s,
media_folder_name,
storage_status):
storage_status,
storage_id,
storage_type):
""" Initializes the Status object """
self.video_on = video_on
self.photo_interval_on = photo_interval_on
Expand All @@ -1149,6 +1225,8 @@ def __init__(
self.recording_time_s = recording_time_s
self.media_folder_name = media_folder_name
self.storage_status = storage_status
self.storage_id = storage_id
self.storage_type = storage_type

def __eq__(self, to_compare):
""" Checks if two Status are the same """
Expand All @@ -1163,7 +1241,9 @@ def __eq__(self, to_compare):
(self.total_storage_mib == to_compare.total_storage_mib) and \
(self.recording_time_s == to_compare.recording_time_s) and \
(self.media_folder_name == to_compare.media_folder_name) and \
(self.storage_status == to_compare.storage_status)
(self.storage_status == to_compare.storage_status) and \
(self.storage_id == to_compare.storage_id) and \
(self.storage_type == to_compare.storage_type)

except AttributeError:
return False
Expand All @@ -1178,7 +1258,9 @@ def __str__(self):
"total_storage_mib: " + str(self.total_storage_mib),
"recording_time_s: " + str(self.recording_time_s),
"media_folder_name: " + str(self.media_folder_name),
"storage_status: " + str(self.storage_status)
"storage_status: " + str(self.storage_status),
"storage_id: " + str(self.storage_id),
"storage_type: " + str(self.storage_type)
])

return f"Status: [{struct_repr}]"
Expand Down Expand Up @@ -1209,7 +1291,13 @@ def translate_from_rpc(rpcStatus):
rpcStatus.media_folder_name,


Status.StorageStatus.translate_from_rpc(rpcStatus.storage_status)
Status.StorageStatus.translate_from_rpc(rpcStatus.storage_status),


rpcStatus.storage_id,


Status.StorageType.translate_from_rpc(rpcStatus.storage_type)
)

def translate_to_rpc(self, rpcStatus):
Expand Down Expand Up @@ -1264,6 +1352,18 @@ def translate_to_rpc(self, rpcStatus):





rpcStatus.storage_id = self.storage_id





rpcStatus.storage_type = self.storage_type.translate_to_rpc()





class Option:
Expand Down
Loading

0 comments on commit 108ef86

Please sign in to comment.