Skip to content

Commit 3239936

Browse files
authored
Merge pull request #325 from mavlink/update-protos
Update proto submodule
2 parents 163f47c + 79367b6 commit 3239936

19 files changed

+2796
-649
lines changed

mavsdk/calibration.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,18 @@ async def cancel(self):
533533
"""
534534
Cancel ongoing calibration process.
535535
536-
536+
Raises
537+
------
538+
CalibrationError
539+
If the request fails. The error contains the reason for the failure.
537540
"""
538541

539542
request = calibration_pb2.CancelRequest()
540543
response = await self._stub.Cancel(request)
541544

545+
546+
result = self._extract_result(response)
547+
548+
if result.result is not CalibrationResult.Result.SUCCESS:
549+
raise CalibrationError(result, "cancel()")
542550

mavsdk/calibration_pb2.py

+18-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mavsdk/camera.py

+102-18
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,9 @@ class VideoStreamSettings:
736736
uri : std::string
737737
Video stream URI
738738
739+
horizontal_fov_deg : float
740+
Horizontal fov in degrees
741+
739742
"""
740743

741744

@@ -747,14 +750,16 @@ def __init__(
747750
vertical_resolution_pix,
748751
bit_rate_b_s,
749752
rotation_deg,
750-
uri):
753+
uri,
754+
horizontal_fov_deg):
751755
""" Initializes the VideoStreamSettings object """
752756
self.frame_rate_hz = frame_rate_hz
753757
self.horizontal_resolution_pix = horizontal_resolution_pix
754758
self.vertical_resolution_pix = vertical_resolution_pix
755759
self.bit_rate_b_s = bit_rate_b_s
756760
self.rotation_deg = rotation_deg
757761
self.uri = uri
762+
self.horizontal_fov_deg = horizontal_fov_deg
758763

759764
def __equals__(self, to_compare):
760765
""" Checks if two VideoStreamSettings are the same """
@@ -767,7 +772,8 @@ def __equals__(self, to_compare):
767772
(self.vertical_resolution_pix == to_compare.vertical_resolution_pix) and \
768773
(self.bit_rate_b_s == to_compare.bit_rate_b_s) and \
769774
(self.rotation_deg == to_compare.rotation_deg) and \
770-
(self.uri == to_compare.uri)
775+
(self.uri == to_compare.uri) and \
776+
(self.horizontal_fov_deg == to_compare.horizontal_fov_deg)
771777

772778
except AttributeError:
773779
return False
@@ -780,7 +786,8 @@ def __str__(self):
780786
"vertical_resolution_pix: " + str(self.vertical_resolution_pix),
781787
"bit_rate_b_s: " + str(self.bit_rate_b_s),
782788
"rotation_deg: " + str(self.rotation_deg),
783-
"uri: " + str(self.uri)
789+
"uri: " + str(self.uri),
790+
"horizontal_fov_deg: " + str(self.horizontal_fov_deg)
784791
])
785792

786793
return f"VideoStreamSettings: [{struct_repr}]"
@@ -805,7 +812,10 @@ def translate_from_rpc(rpcVideoStreamSettings):
805812
rpcVideoStreamSettings.rotation_deg,
806813

807814

808-
rpcVideoStreamSettings.uri
815+
rpcVideoStreamSettings.uri,
816+
817+
818+
rpcVideoStreamSettings.horizontal_fov_deg
809819
)
810820

811821
def translate_to_rpc(self, rpcVideoStreamSettings):
@@ -848,6 +858,12 @@ def translate_to_rpc(self, rpcVideoStreamSettings):
848858

849859

850860

861+
862+
863+
rpcVideoStreamSettings.horizontal_fov_deg = self.horizontal_fov_deg
864+
865+
866+
851867

852868

853869
class VideoStreamInfo:
@@ -859,14 +875,17 @@ class VideoStreamInfo:
859875
settings : VideoStreamSettings
860876
Video stream settings
861877
862-
status : Status
878+
status : VideoStreamStatus
863879
Current status of video streaming
864880
881+
spectrum : VideoStreamSpectrum
882+
Light-spectrum of the video stream
883+
865884
"""
866885

867886

868887

869-
class Status(Enum):
888+
class VideoStreamStatus(Enum):
870889
"""
871890
Video stream status type.
872891
@@ -885,18 +904,62 @@ class Status(Enum):
885904
IN_PROGRESS = 1
886905

887906
def translate_to_rpc(self):
888-
if self == VideoStreamInfo.Status.NOT_RUNNING:
889-
return camera_pb2.VideoStreamInfo.STATUS_NOT_RUNNING
890-
if self == VideoStreamInfo.Status.IN_PROGRESS:
891-
return camera_pb2.VideoStreamInfo.STATUS_IN_PROGRESS
907+
if self == VideoStreamInfo.VideoStreamStatus.NOT_RUNNING:
908+
return camera_pb2.VideoStreamInfo.VIDEO_STREAM_STATUS_NOT_RUNNING
909+
if self == VideoStreamInfo.VideoStreamStatus.IN_PROGRESS:
910+
return camera_pb2.VideoStreamInfo.VIDEO_STREAM_STATUS_IN_PROGRESS
911+
912+
@staticmethod
913+
def translate_from_rpc(rpc_enum_value):
914+
""" Parses a gRPC response """
915+
if rpc_enum_value == camera_pb2.VideoStreamInfo.VIDEO_STREAM_STATUS_NOT_RUNNING:
916+
return VideoStreamInfo.VideoStreamStatus.NOT_RUNNING
917+
if rpc_enum_value == camera_pb2.VideoStreamInfo.VIDEO_STREAM_STATUS_IN_PROGRESS:
918+
return VideoStreamInfo.VideoStreamStatus.IN_PROGRESS
919+
920+
def __str__(self):
921+
return self.name
922+
923+
924+
class VideoStreamSpectrum(Enum):
925+
"""
926+
Video stream light spectrum type
927+
928+
Values
929+
------
930+
UNKNOWN
931+
Unknown
932+
933+
VISIBLE_LIGHT
934+
Visible light
935+
936+
INFRARED
937+
Infrared
938+
939+
"""
940+
941+
942+
UNKNOWN = 0
943+
VISIBLE_LIGHT = 1
944+
INFRARED = 2
945+
946+
def translate_to_rpc(self):
947+
if self == VideoStreamInfo.VideoStreamSpectrum.UNKNOWN:
948+
return camera_pb2.VideoStreamInfo.VIDEO_STREAM_SPECTRUM_UNKNOWN
949+
if self == VideoStreamInfo.VideoStreamSpectrum.VISIBLE_LIGHT:
950+
return camera_pb2.VideoStreamInfo.VIDEO_STREAM_SPECTRUM_VISIBLE_LIGHT
951+
if self == VideoStreamInfo.VideoStreamSpectrum.INFRARED:
952+
return camera_pb2.VideoStreamInfo.VIDEO_STREAM_SPECTRUM_INFRARED
892953

893954
@staticmethod
894955
def translate_from_rpc(rpc_enum_value):
895956
""" Parses a gRPC response """
896-
if rpc_enum_value == camera_pb2.VideoStreamInfo.STATUS_NOT_RUNNING:
897-
return VideoStreamInfo.Status.NOT_RUNNING
898-
if rpc_enum_value == camera_pb2.VideoStreamInfo.STATUS_IN_PROGRESS:
899-
return VideoStreamInfo.Status.IN_PROGRESS
957+
if rpc_enum_value == camera_pb2.VideoStreamInfo.VIDEO_STREAM_SPECTRUM_UNKNOWN:
958+
return VideoStreamInfo.VideoStreamSpectrum.UNKNOWN
959+
if rpc_enum_value == camera_pb2.VideoStreamInfo.VIDEO_STREAM_SPECTRUM_VISIBLE_LIGHT:
960+
return VideoStreamInfo.VideoStreamSpectrum.VISIBLE_LIGHT
961+
if rpc_enum_value == camera_pb2.VideoStreamInfo.VIDEO_STREAM_SPECTRUM_INFRARED:
962+
return VideoStreamInfo.VideoStreamSpectrum.INFRARED
900963

901964
def __str__(self):
902965
return self.name
@@ -905,10 +968,12 @@ def __str__(self):
905968
def __init__(
906969
self,
907970
settings,
908-
status):
971+
status,
972+
spectrum):
909973
""" Initializes the VideoStreamInfo object """
910974
self.settings = settings
911975
self.status = status
976+
self.spectrum = spectrum
912977

913978
def __equals__(self, to_compare):
914979
""" Checks if two VideoStreamInfo are the same """
@@ -917,7 +982,8 @@ def __equals__(self, to_compare):
917982
# VideoStreamInfo object
918983
return \
919984
(self.settings == to_compare.settings) and \
920-
(self.status == to_compare.status)
985+
(self.status == to_compare.status) and \
986+
(self.spectrum == to_compare.spectrum)
921987

922988
except AttributeError:
923989
return False
@@ -926,7 +992,8 @@ def __str__(self):
926992
""" VideoStreamInfo in string representation """
927993
struct_repr = ", ".join([
928994
"settings: " + str(self.settings),
929-
"status: " + str(self.status)
995+
"status: " + str(self.status),
996+
"spectrum: " + str(self.spectrum)
930997
])
931998

932999
return f"VideoStreamInfo: [{struct_repr}]"
@@ -939,7 +1006,10 @@ def translate_from_rpc(rpcVideoStreamInfo):
9391006
VideoStreamSettings.translate_from_rpc(rpcVideoStreamInfo.settings),
9401007

9411008

942-
VideoStreamInfo.Status.translate_from_rpc(rpcVideoStreamInfo.status)
1009+
VideoStreamInfo.VideoStreamStatus.translate_from_rpc(rpcVideoStreamInfo.status),
1010+
1011+
1012+
VideoStreamInfo.VideoStreamSpectrum.translate_from_rpc(rpcVideoStreamInfo.spectrum)
9431013
)
9441014

9451015
def translate_to_rpc(self, rpcVideoStreamInfo):
@@ -958,6 +1028,12 @@ def translate_to_rpc(self, rpcVideoStreamInfo):
9581028

9591029

9601030

1031+
1032+
1033+
rpcVideoStreamInfo.spectrum = self.spectrum.translate_to_rpc()
1034+
1035+
1036+
9611037

9621038

9631039
class Status:
@@ -1009,12 +1085,16 @@ class StorageStatus(Enum):
10091085
FORMATTED
10101086
Storage is formatted (i.e. has recognized a file system)
10111087
1088+
NOT_SUPPORTED
1089+
Storage status is not supported
1090+
10121091
"""
10131092

10141093

10151094
NOT_AVAILABLE = 0
10161095
UNFORMATTED = 1
10171096
FORMATTED = 2
1097+
NOT_SUPPORTED = 3
10181098

10191099
def translate_to_rpc(self):
10201100
if self == Status.StorageStatus.NOT_AVAILABLE:
@@ -1023,6 +1103,8 @@ def translate_to_rpc(self):
10231103
return camera_pb2.Status.STORAGE_STATUS_UNFORMATTED
10241104
if self == Status.StorageStatus.FORMATTED:
10251105
return camera_pb2.Status.STORAGE_STATUS_FORMATTED
1106+
if self == Status.StorageStatus.NOT_SUPPORTED:
1107+
return camera_pb2.Status.STORAGE_STATUS_NOT_SUPPORTED
10261108

10271109
@staticmethod
10281110
def translate_from_rpc(rpc_enum_value):
@@ -1033,6 +1115,8 @@ def translate_from_rpc(rpc_enum_value):
10331115
return Status.StorageStatus.UNFORMATTED
10341116
if rpc_enum_value == camera_pb2.Status.STORAGE_STATUS_FORMATTED:
10351117
return Status.StorageStatus.FORMATTED
1118+
if rpc_enum_value == camera_pb2.Status.STORAGE_STATUS_NOT_SUPPORTED:
1119+
return Status.StorageStatus.NOT_SUPPORTED
10361120

10371121
def __str__(self):
10381122
return self.name

0 commit comments

Comments
 (0)