diff --git a/MAVSDK_SERVER_VERSION b/MAVSDK_SERVER_VERSION index 79127d85..75740798 100644 --- a/MAVSDK_SERVER_VERSION +++ b/MAVSDK_SERVER_VERSION @@ -1 +1 @@ -v1.2.0 +v1.3.1 diff --git a/mavsdk/camera_server.py b/mavsdk/camera_server.py new file mode 100644 index 00000000..a961c5eb --- /dev/null +++ b/mavsdk/camera_server.py @@ -0,0 +1,947 @@ +# -*- coding: utf-8 -*- +# DO NOT EDIT! This file is auto-generated from +# https://github.com/mavlink/MAVSDK-Python/tree/main/other/templates/py +from ._base import AsyncBase +from . import camera_server_pb2, camera_server_pb2_grpc +from enum import Enum + + +class TakePhotoFeedback(Enum): + """ + Possible results when taking a photo. + + Values + ------ + UNKNOWN + Unknown + + OK + Ok + + BUSY + Busy + + FAILED + Failed + + """ + + + UNKNOWN = 0 + OK = 1 + BUSY = 2 + FAILED = 3 + + def translate_to_rpc(self): + if self == TakePhotoFeedback.UNKNOWN: + return camera_server_pb2.TAKE_PHOTO_FEEDBACK_UNKNOWN + if self == TakePhotoFeedback.OK: + return camera_server_pb2.TAKE_PHOTO_FEEDBACK_OK + if self == TakePhotoFeedback.BUSY: + return camera_server_pb2.TAKE_PHOTO_FEEDBACK_BUSY + if self == TakePhotoFeedback.FAILED: + return camera_server_pb2.TAKE_PHOTO_FEEDBACK_FAILED + + @staticmethod + def translate_from_rpc(rpc_enum_value): + """ Parses a gRPC response """ + if rpc_enum_value == camera_server_pb2.TAKE_PHOTO_FEEDBACK_UNKNOWN: + return TakePhotoFeedback.UNKNOWN + if rpc_enum_value == camera_server_pb2.TAKE_PHOTO_FEEDBACK_OK: + return TakePhotoFeedback.OK + if rpc_enum_value == camera_server_pb2.TAKE_PHOTO_FEEDBACK_BUSY: + return TakePhotoFeedback.BUSY + if rpc_enum_value == camera_server_pb2.TAKE_PHOTO_FEEDBACK_FAILED: + return TakePhotoFeedback.FAILED + + def __str__(self): + return self.name + + +class Information: + """ + Type to represent a camera information. + + Parameters + ---------- + vendor_name : std::string + Name of the camera vendor + + model_name : std::string + Name of the camera model + + firmware_version : std::string + Camera firmware version in major[.minor[.patch[.dev]]] format + + focal_length_mm : float + Focal length + + horizontal_sensor_size_mm : float + Horizontal sensor size + + vertical_sensor_size_mm : float + Vertical sensor size + + horizontal_resolution_px : uint32_t + Horizontal image resolution in pixels + + vertical_resolution_px : uint32_t + Vertical image resolution in pixels + + lens_id : uint32_t + Lens ID + + definition_file_version : uint32_t + Camera definition file version (iteration) + + definition_file_uri : std::string + Camera definition URI (http or mavlink ftp) + + """ + + + + def __init__( + self, + vendor_name, + model_name, + firmware_version, + focal_length_mm, + horizontal_sensor_size_mm, + vertical_sensor_size_mm, + horizontal_resolution_px, + vertical_resolution_px, + lens_id, + definition_file_version, + definition_file_uri): + """ Initializes the Information object """ + self.vendor_name = vendor_name + self.model_name = model_name + self.firmware_version = firmware_version + self.focal_length_mm = focal_length_mm + self.horizontal_sensor_size_mm = horizontal_sensor_size_mm + self.vertical_sensor_size_mm = vertical_sensor_size_mm + self.horizontal_resolution_px = horizontal_resolution_px + self.vertical_resolution_px = vertical_resolution_px + self.lens_id = lens_id + self.definition_file_version = definition_file_version + self.definition_file_uri = definition_file_uri + + def __eq__(self, to_compare): + """ Checks if two Information are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # Information object + return \ + (self.vendor_name == to_compare.vendor_name) and \ + (self.model_name == to_compare.model_name) and \ + (self.firmware_version == to_compare.firmware_version) and \ + (self.focal_length_mm == to_compare.focal_length_mm) and \ + (self.horizontal_sensor_size_mm == to_compare.horizontal_sensor_size_mm) and \ + (self.vertical_sensor_size_mm == to_compare.vertical_sensor_size_mm) and \ + (self.horizontal_resolution_px == to_compare.horizontal_resolution_px) and \ + (self.vertical_resolution_px == to_compare.vertical_resolution_px) and \ + (self.lens_id == to_compare.lens_id) and \ + (self.definition_file_version == to_compare.definition_file_version) and \ + (self.definition_file_uri == to_compare.definition_file_uri) + + except AttributeError: + return False + + def __str__(self): + """ Information in string representation """ + struct_repr = ", ".join([ + "vendor_name: " + str(self.vendor_name), + "model_name: " + str(self.model_name), + "firmware_version: " + str(self.firmware_version), + "focal_length_mm: " + str(self.focal_length_mm), + "horizontal_sensor_size_mm: " + str(self.horizontal_sensor_size_mm), + "vertical_sensor_size_mm: " + str(self.vertical_sensor_size_mm), + "horizontal_resolution_px: " + str(self.horizontal_resolution_px), + "vertical_resolution_px: " + str(self.vertical_resolution_px), + "lens_id: " + str(self.lens_id), + "definition_file_version: " + str(self.definition_file_version), + "definition_file_uri: " + str(self.definition_file_uri) + ]) + + return f"Information: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcInformation): + """ Translates a gRPC struct to the SDK equivalent """ + return Information( + + rpcInformation.vendor_name, + + + rpcInformation.model_name, + + + rpcInformation.firmware_version, + + + rpcInformation.focal_length_mm, + + + rpcInformation.horizontal_sensor_size_mm, + + + rpcInformation.vertical_sensor_size_mm, + + + rpcInformation.horizontal_resolution_px, + + + rpcInformation.vertical_resolution_px, + + + rpcInformation.lens_id, + + + rpcInformation.definition_file_version, + + + rpcInformation.definition_file_uri + ) + + def translate_to_rpc(self, rpcInformation): + """ Translates this SDK object into its gRPC equivalent """ + + + + + rpcInformation.vendor_name = self.vendor_name + + + + + + rpcInformation.model_name = self.model_name + + + + + + rpcInformation.firmware_version = self.firmware_version + + + + + + rpcInformation.focal_length_mm = self.focal_length_mm + + + + + + rpcInformation.horizontal_sensor_size_mm = self.horizontal_sensor_size_mm + + + + + + rpcInformation.vertical_sensor_size_mm = self.vertical_sensor_size_mm + + + + + + rpcInformation.horizontal_resolution_px = self.horizontal_resolution_px + + + + + + rpcInformation.vertical_resolution_px = self.vertical_resolution_px + + + + + + rpcInformation.lens_id = self.lens_id + + + + + + rpcInformation.definition_file_version = self.definition_file_version + + + + + + rpcInformation.definition_file_uri = self.definition_file_uri + + + + + +class Position: + """ + Position type in global coordinates. + + Parameters + ---------- + latitude_deg : double + Latitude in degrees (range: -90 to +90) + + longitude_deg : double + Longitude in degrees (range: -180 to +180) + + absolute_altitude_m : float + Altitude AMSL (above mean sea level) in metres + + relative_altitude_m : float + Altitude relative to takeoff altitude in metres + + """ + + + + def __init__( + self, + latitude_deg, + longitude_deg, + absolute_altitude_m, + relative_altitude_m): + """ Initializes the Position object """ + self.latitude_deg = latitude_deg + self.longitude_deg = longitude_deg + self.absolute_altitude_m = absolute_altitude_m + self.relative_altitude_m = relative_altitude_m + + def __eq__(self, to_compare): + """ Checks if two Position are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # Position object + return \ + (self.latitude_deg == to_compare.latitude_deg) and \ + (self.longitude_deg == to_compare.longitude_deg) and \ + (self.absolute_altitude_m == to_compare.absolute_altitude_m) and \ + (self.relative_altitude_m == to_compare.relative_altitude_m) + + except AttributeError: + return False + + def __str__(self): + """ Position in string representation """ + struct_repr = ", ".join([ + "latitude_deg: " + str(self.latitude_deg), + "longitude_deg: " + str(self.longitude_deg), + "absolute_altitude_m: " + str(self.absolute_altitude_m), + "relative_altitude_m: " + str(self.relative_altitude_m) + ]) + + return f"Position: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcPosition): + """ Translates a gRPC struct to the SDK equivalent """ + return Position( + + rpcPosition.latitude_deg, + + + rpcPosition.longitude_deg, + + + rpcPosition.absolute_altitude_m, + + + rpcPosition.relative_altitude_m + ) + + def translate_to_rpc(self, rpcPosition): + """ Translates this SDK object into its gRPC equivalent """ + + + + + rpcPosition.latitude_deg = self.latitude_deg + + + + + + rpcPosition.longitude_deg = self.longitude_deg + + + + + + rpcPosition.absolute_altitude_m = self.absolute_altitude_m + + + + + + rpcPosition.relative_altitude_m = self.relative_altitude_m + + + + + +class Quaternion: + """ + Quaternion type. + + All rotations and axis systems follow the right-hand rule. + The Hamilton quaternion product definition is used. + A zero-rotation quaternion is represented by (1,0,0,0). + The quaternion could also be written as w + xi + yj + zk. + + For more info see: https://en.wikipedia.org/wiki/Quaternion + + Parameters + ---------- + w : float + Quaternion entry 0, also denoted as a + + x : float + Quaternion entry 1, also denoted as b + + y : float + Quaternion entry 2, also denoted as c + + z : float + Quaternion entry 3, also denoted as d + + """ + + + + def __init__( + self, + w, + x, + y, + z): + """ Initializes the Quaternion object """ + self.w = w + self.x = x + self.y = y + self.z = z + + def __eq__(self, to_compare): + """ Checks if two Quaternion are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # Quaternion object + return \ + (self.w == to_compare.w) and \ + (self.x == to_compare.x) and \ + (self.y == to_compare.y) and \ + (self.z == to_compare.z) + + except AttributeError: + return False + + def __str__(self): + """ Quaternion in string representation """ + struct_repr = ", ".join([ + "w: " + str(self.w), + "x: " + str(self.x), + "y: " + str(self.y), + "z: " + str(self.z) + ]) + + return f"Quaternion: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcQuaternion): + """ Translates a gRPC struct to the SDK equivalent """ + return Quaternion( + + rpcQuaternion.w, + + + rpcQuaternion.x, + + + rpcQuaternion.y, + + + rpcQuaternion.z + ) + + def translate_to_rpc(self, rpcQuaternion): + """ Translates this SDK object into its gRPC equivalent """ + + + + + rpcQuaternion.w = self.w + + + + + + rpcQuaternion.x = self.x + + + + + + rpcQuaternion.y = self.y + + + + + + rpcQuaternion.z = self.z + + + + + +class CaptureInfo: + """ + Information about a picture just captured. + + Parameters + ---------- + position : Position + Location where the picture was taken + + attitude_quaternion : Quaternion + Attitude of the camera when the picture was taken (quaternion) + + time_utc_us : uint64_t + Timestamp in UTC (since UNIX epoch) in microseconds + + is_success : bool + True if the capture was successful + + index : int32_t + Index from TakePhotoResponse + + file_url : std::string + Download URL of this image + + """ + + + + def __init__( + self, + position, + attitude_quaternion, + time_utc_us, + is_success, + index, + file_url): + """ Initializes the CaptureInfo object """ + self.position = position + self.attitude_quaternion = attitude_quaternion + self.time_utc_us = time_utc_us + self.is_success = is_success + self.index = index + self.file_url = file_url + + def __eq__(self, to_compare): + """ Checks if two CaptureInfo are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # CaptureInfo object + return \ + (self.position == to_compare.position) and \ + (self.attitude_quaternion == to_compare.attitude_quaternion) and \ + (self.time_utc_us == to_compare.time_utc_us) and \ + (self.is_success == to_compare.is_success) and \ + (self.index == to_compare.index) and \ + (self.file_url == to_compare.file_url) + + except AttributeError: + return False + + def __str__(self): + """ CaptureInfo in string representation """ + struct_repr = ", ".join([ + "position: " + str(self.position), + "attitude_quaternion: " + str(self.attitude_quaternion), + "time_utc_us: " + str(self.time_utc_us), + "is_success: " + str(self.is_success), + "index: " + str(self.index), + "file_url: " + str(self.file_url) + ]) + + return f"CaptureInfo: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcCaptureInfo): + """ Translates a gRPC struct to the SDK equivalent """ + return CaptureInfo( + + Position.translate_from_rpc(rpcCaptureInfo.position), + + + Quaternion.translate_from_rpc(rpcCaptureInfo.attitude_quaternion), + + + rpcCaptureInfo.time_utc_us, + + + rpcCaptureInfo.is_success, + + + rpcCaptureInfo.index, + + + rpcCaptureInfo.file_url + ) + + def translate_to_rpc(self, rpcCaptureInfo): + """ Translates this SDK object into its gRPC equivalent """ + + + + + self.position.translate_to_rpc(rpcCaptureInfo.position) + + + + + + self.attitude_quaternion.translate_to_rpc(rpcCaptureInfo.attitude_quaternion) + + + + + + rpcCaptureInfo.time_utc_us = self.time_utc_us + + + + + + rpcCaptureInfo.is_success = self.is_success + + + + + + rpcCaptureInfo.index = self.index + + + + + + rpcCaptureInfo.file_url = self.file_url + + + + + +class CameraServerResult: + """ + Result type. + + Parameters + ---------- + result : Result + Result enum value + + result_str : std::string + Human-readable English string describing the result + + """ + + + + class Result(Enum): + """ + Possible results returned for action requests. + + Values + ------ + UNKNOWN + Unknown result + + SUCCESS + Command executed successfully + + IN_PROGRESS + Command in progress + + BUSY + Camera is busy and rejected command + + DENIED + Camera denied the command + + ERROR + An error has occurred while executing the command + + TIMEOUT + Command timed out + + WRONG_ARGUMENT + Command has wrong argument(s) + + NO_SYSTEM + No system connected + + """ + + + UNKNOWN = 0 + SUCCESS = 1 + IN_PROGRESS = 2 + BUSY = 3 + DENIED = 4 + ERROR = 5 + TIMEOUT = 6 + WRONG_ARGUMENT = 7 + NO_SYSTEM = 8 + + def translate_to_rpc(self): + if self == CameraServerResult.Result.UNKNOWN: + return camera_server_pb2.CameraServerResult.RESULT_UNKNOWN + if self == CameraServerResult.Result.SUCCESS: + return camera_server_pb2.CameraServerResult.RESULT_SUCCESS + if self == CameraServerResult.Result.IN_PROGRESS: + return camera_server_pb2.CameraServerResult.RESULT_IN_PROGRESS + if self == CameraServerResult.Result.BUSY: + return camera_server_pb2.CameraServerResult.RESULT_BUSY + if self == CameraServerResult.Result.DENIED: + return camera_server_pb2.CameraServerResult.RESULT_DENIED + if self == CameraServerResult.Result.ERROR: + return camera_server_pb2.CameraServerResult.RESULT_ERROR + if self == CameraServerResult.Result.TIMEOUT: + return camera_server_pb2.CameraServerResult.RESULT_TIMEOUT + if self == CameraServerResult.Result.WRONG_ARGUMENT: + return camera_server_pb2.CameraServerResult.RESULT_WRONG_ARGUMENT + if self == CameraServerResult.Result.NO_SYSTEM: + return camera_server_pb2.CameraServerResult.RESULT_NO_SYSTEM + + @staticmethod + def translate_from_rpc(rpc_enum_value): + """ Parses a gRPC response """ + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_UNKNOWN: + return CameraServerResult.Result.UNKNOWN + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_SUCCESS: + return CameraServerResult.Result.SUCCESS + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_IN_PROGRESS: + return CameraServerResult.Result.IN_PROGRESS + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_BUSY: + return CameraServerResult.Result.BUSY + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_DENIED: + return CameraServerResult.Result.DENIED + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_ERROR: + return CameraServerResult.Result.ERROR + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_TIMEOUT: + return CameraServerResult.Result.TIMEOUT + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_WRONG_ARGUMENT: + return CameraServerResult.Result.WRONG_ARGUMENT + if rpc_enum_value == camera_server_pb2.CameraServerResult.RESULT_NO_SYSTEM: + return CameraServerResult.Result.NO_SYSTEM + + def __str__(self): + return self.name + + + def __init__( + self, + result, + result_str): + """ Initializes the CameraServerResult object """ + self.result = result + self.result_str = result_str + + def __eq__(self, to_compare): + """ Checks if two CameraServerResult are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # CameraServerResult object + return \ + (self.result == to_compare.result) and \ + (self.result_str == to_compare.result_str) + + except AttributeError: + return False + + def __str__(self): + """ CameraServerResult in string representation """ + struct_repr = ", ".join([ + "result: " + str(self.result), + "result_str: " + str(self.result_str) + ]) + + return f"CameraServerResult: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcCameraServerResult): + """ Translates a gRPC struct to the SDK equivalent """ + return CameraServerResult( + + CameraServerResult.Result.translate_from_rpc(rpcCameraServerResult.result), + + + rpcCameraServerResult.result_str + ) + + def translate_to_rpc(self, rpcCameraServerResult): + """ Translates this SDK object into its gRPC equivalent """ + + + + + rpcCameraServerResult.result = self.result.translate_to_rpc() + + + + + + rpcCameraServerResult.result_str = self.result_str + + + + + + +class CameraServerError(Exception): + """ Raised when a CameraServerResult is a fail code """ + + def __init__(self, result, origin, *params): + self._result = result + self._origin = origin + self._params = params + + def __str__(self): + return f"{self._result.result}: '{self._result.result_str}'; origin: {self._origin}; params: {self._params}" + + +class CameraServer(AsyncBase): + """ + Provides handling of camera trigger commands. + + Generated by dcsdkgen - MAVSDK CameraServer API + """ + + # Plugin name + name = "CameraServer" + + def _setup_stub(self, channel): + """ Setups the api stub """ + self._stub = camera_server_pb2_grpc.CameraServerServiceStub(channel) + + + def _extract_result(self, response): + """ Returns the response status and description """ + return CameraServerResult.translate_from_rpc(response.camera_server_result) + + + async def set_information(self, information): + """ + Sets the camera information. This must be called as soon as the camera server is created. + + Parameters + ---------- + information : Information + information about the camera + + Raises + ------ + CameraServerError + If the request fails. The error contains the reason for the failure. + """ + + request = camera_server_pb2.SetInformationRequest() + + information.translate_to_rpc(request.information) + + + response = await self._stub.SetInformation(request) + + + result = self._extract_result(response) + + if result.result != CameraServerResult.Result.SUCCESS: + raise CameraServerError(result, "set_information()", information) + + + async def set_in_progress(self, in_progress): + """ + Sets image capture in progress status flags. This should be set to true when the camera is busy taking a photo and false when it is done. + + Parameters + ---------- + in_progress : bool + true if capture is in progress or false for idle. + + Raises + ------ + CameraServerError + If the request fails. The error contains the reason for the failure. + """ + + request = camera_server_pb2.SetInProgressRequest() + request.in_progress = in_progress + response = await self._stub.SetInProgress(request) + + + result = self._extract_result(response) + + if result.result != CameraServerResult.Result.SUCCESS: + raise CameraServerError(result, "set_in_progress()", in_progress) + + + async def take_photo(self): + """ + Subscribe to image capture requests. Each request received should respond to using RespondTakePhoto. + + Yields + ------- + index : int32_t + + + """ + + request = camera_server_pb2.SubscribeTakePhotoRequest() + take_photo_stream = self._stub.SubscribeTakePhoto(request) + + try: + async for response in take_photo_stream: + + + + yield response.index + finally: + take_photo_stream.cancel() + + async def respond_take_photo(self, take_photo_feedback, capture_info): + """ + Respond to an image capture request from SubscribeTakePhoto. + + Parameters + ---------- + take_photo_feedback : TakePhotoFeedback + The feedback + + capture_info : CaptureInfo + The capture information + + Raises + ------ + CameraServerError + If the request fails. The error contains the reason for the failure. + """ + + request = camera_server_pb2.RespondTakePhotoRequest() + + request.take_photo_feedback = take_photo_feedback.translate_to_rpc() + + + + capture_info.translate_to_rpc(request.capture_info) + + + response = await self._stub.RespondTakePhoto(request) + + + result = self._extract_result(response) + + if result.result != CameraServerResult.Result.SUCCESS: + raise CameraServerError(result, "respond_take_photo()", take_photo_feedback, capture_info) + \ No newline at end of file diff --git a/mavsdk/camera_server_pb2.py b/mavsdk/camera_server_pb2.py new file mode 100644 index 00000000..fe50c48e --- /dev/null +++ b/mavsdk/camera_server_pb2.py @@ -0,0 +1,179 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: camera_server/camera_server.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from . import mavsdk_options_pb2 as mavsdk__options__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!camera_server/camera_server.proto\x12\x18mavsdk.rpc.camera_server\x1a\x14mavsdk_options.proto\"S\n\x15SetInformationRequest\x12:\n\x0binformation\x18\x01 \x01(\x0b\x32%.mavsdk.rpc.camera_server.Information\"d\n\x16SetInformationResponse\x12J\n\x14\x63\x61mera_server_result\x18\x01 \x01(\x0b\x32,.mavsdk.rpc.camera_server.CameraServerResult\"+\n\x14SetInProgressRequest\x12\x13\n\x0bin_progress\x18\x01 \x01(\x08\"c\n\x15SetInProgressResponse\x12J\n\x14\x63\x61mera_server_result\x18\x01 \x01(\x0b\x32,.mavsdk.rpc.camera_server.CameraServerResult\"\x1b\n\x19SubscribeTakePhotoRequest\"\"\n\x11TakePhotoResponse\x12\r\n\x05index\x18\x01 \x01(\x05\"\xa0\x01\n\x17RespondTakePhotoRequest\x12H\n\x13take_photo_feedback\x18\x01 \x01(\x0e\x32+.mavsdk.rpc.camera_server.TakePhotoFeedback\x12;\n\x0c\x63\x61pture_info\x18\x02 \x01(\x0b\x32%.mavsdk.rpc.camera_server.CaptureInfo\"f\n\x18RespondTakePhotoResponse\x12J\n\x14\x63\x61mera_server_result\x18\x01 \x01(\x0b\x32,.mavsdk.rpc.camera_server.CameraServerResult\"\xbe\x02\n\x0bInformation\x12\x13\n\x0bvendor_name\x18\x01 \x01(\t\x12\x12\n\nmodel_name\x18\x02 \x01(\t\x12\x18\n\x10\x66irmware_version\x18\x03 \x01(\t\x12\x17\n\x0f\x66ocal_length_mm\x18\x04 \x01(\x02\x12!\n\x19horizontal_sensor_size_mm\x18\x05 \x01(\x02\x12\x1f\n\x17vertical_sensor_size_mm\x18\x06 \x01(\x02\x12 \n\x18horizontal_resolution_px\x18\x07 \x01(\r\x12\x1e\n\x16vertical_resolution_px\x18\x08 \x01(\r\x12\x0f\n\x07lens_id\x18\t \x01(\r\x12\x1f\n\x17\x64\x65\x66inition_file_version\x18\n \x01(\r\x12\x1b\n\x13\x64\x65\x66inition_file_uri\x18\x0b \x01(\t\"q\n\x08Position\x12\x14\n\x0clatitude_deg\x18\x01 \x01(\x01\x12\x15\n\rlongitude_deg\x18\x02 \x01(\x01\x12\x1b\n\x13\x61\x62solute_altitude_m\x18\x03 \x01(\x02\x12\x1b\n\x13relative_altitude_m\x18\x04 \x01(\x02\"8\n\nQuaternion\x12\t\n\x01w\x18\x01 \x01(\x02\x12\t\n\x01x\x18\x02 \x01(\x02\x12\t\n\x01y\x18\x03 \x01(\x02\x12\t\n\x01z\x18\x04 \x01(\x02\"\xd0\x01\n\x0b\x43\x61ptureInfo\x12\x34\n\x08position\x18\x01 \x01(\x0b\x32\".mavsdk.rpc.camera_server.Position\x12\x41\n\x13\x61ttitude_quaternion\x18\x02 \x01(\x0b\x32$.mavsdk.rpc.camera_server.Quaternion\x12\x13\n\x0btime_utc_us\x18\x03 \x01(\x04\x12\x12\n\nis_success\x18\x04 \x01(\x08\x12\r\n\x05index\x18\x05 \x01(\x05\x12\x10\n\x08\x66ile_url\x18\x06 \x01(\t\"\xb3\x02\n\x12\x43\x61meraServerResult\x12\x43\n\x06result\x18\x01 \x01(\x0e\x32\x33.mavsdk.rpc.camera_server.CameraServerResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\xc3\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x16\n\x12RESULT_IN_PROGRESS\x10\x02\x12\x0f\n\x0bRESULT_BUSY\x10\x03\x12\x11\n\rRESULT_DENIED\x10\x04\x12\x10\n\x0cRESULT_ERROR\x10\x05\x12\x12\n\x0eRESULT_TIMEOUT\x10\x06\x12\x19\n\x15RESULT_WRONG_ARGUMENT\x10\x07\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x08*\x8e\x01\n\x11TakePhotoFeedback\x12\x1f\n\x1bTAKE_PHOTO_FEEDBACK_UNKNOWN\x10\x00\x12\x1a\n\x16TAKE_PHOTO_FEEDBACK_OK\x10\x01\x12\x1c\n\x18TAKE_PHOTO_FEEDBACK_BUSY\x10\x02\x12\x1e\n\x1aTAKE_PHOTO_FEEDBACK_FAILED\x10\x03\x32\x89\x04\n\x13\x43\x61meraServerService\x12y\n\x0eSetInformation\x12/.mavsdk.rpc.camera_server.SetInformationRequest\x1a\x30.mavsdk.rpc.camera_server.SetInformationResponse\"\x04\x80\xb5\x18\x01\x12v\n\rSetInProgress\x12..mavsdk.rpc.camera_server.SetInProgressRequest\x1a/.mavsdk.rpc.camera_server.SetInProgressResponse\"\x04\x80\xb5\x18\x01\x12~\n\x12SubscribeTakePhoto\x12\x33.mavsdk.rpc.camera_server.SubscribeTakePhotoRequest\x1a+.mavsdk.rpc.camera_server.TakePhotoResponse\"\x04\x80\xb5\x18\x00\x30\x01\x12\x7f\n\x10RespondTakePhoto\x12\x31.mavsdk.rpc.camera_server.RespondTakePhotoRequest\x1a\x32.mavsdk.rpc.camera_server.RespondTakePhotoResponse\"\x04\x80\xb5\x18\x01\x42,\n\x17io.mavsdk.camera_serverB\x11\x43\x61meraServerProtob\x06proto3') + +_TAKEPHOTOFEEDBACK = DESCRIPTOR.enum_types_by_name['TakePhotoFeedback'] +TakePhotoFeedback = enum_type_wrapper.EnumTypeWrapper(_TAKEPHOTOFEEDBACK) +TAKE_PHOTO_FEEDBACK_UNKNOWN = 0 +TAKE_PHOTO_FEEDBACK_OK = 1 +TAKE_PHOTO_FEEDBACK_BUSY = 2 +TAKE_PHOTO_FEEDBACK_FAILED = 3 + + +_SETINFORMATIONREQUEST = DESCRIPTOR.message_types_by_name['SetInformationRequest'] +_SETINFORMATIONRESPONSE = DESCRIPTOR.message_types_by_name['SetInformationResponse'] +_SETINPROGRESSREQUEST = DESCRIPTOR.message_types_by_name['SetInProgressRequest'] +_SETINPROGRESSRESPONSE = DESCRIPTOR.message_types_by_name['SetInProgressResponse'] +_SUBSCRIBETAKEPHOTOREQUEST = DESCRIPTOR.message_types_by_name['SubscribeTakePhotoRequest'] +_TAKEPHOTORESPONSE = DESCRIPTOR.message_types_by_name['TakePhotoResponse'] +_RESPONDTAKEPHOTOREQUEST = DESCRIPTOR.message_types_by_name['RespondTakePhotoRequest'] +_RESPONDTAKEPHOTORESPONSE = DESCRIPTOR.message_types_by_name['RespondTakePhotoResponse'] +_INFORMATION = DESCRIPTOR.message_types_by_name['Information'] +_POSITION = DESCRIPTOR.message_types_by_name['Position'] +_QUATERNION = DESCRIPTOR.message_types_by_name['Quaternion'] +_CAPTUREINFO = DESCRIPTOR.message_types_by_name['CaptureInfo'] +_CAMERASERVERRESULT = DESCRIPTOR.message_types_by_name['CameraServerResult'] +_CAMERASERVERRESULT_RESULT = _CAMERASERVERRESULT.enum_types_by_name['Result'] +SetInformationRequest = _reflection.GeneratedProtocolMessageType('SetInformationRequest', (_message.Message,), { + 'DESCRIPTOR' : _SETINFORMATIONREQUEST, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.SetInformationRequest) + }) +_sym_db.RegisterMessage(SetInformationRequest) + +SetInformationResponse = _reflection.GeneratedProtocolMessageType('SetInformationResponse', (_message.Message,), { + 'DESCRIPTOR' : _SETINFORMATIONRESPONSE, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.SetInformationResponse) + }) +_sym_db.RegisterMessage(SetInformationResponse) + +SetInProgressRequest = _reflection.GeneratedProtocolMessageType('SetInProgressRequest', (_message.Message,), { + 'DESCRIPTOR' : _SETINPROGRESSREQUEST, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.SetInProgressRequest) + }) +_sym_db.RegisterMessage(SetInProgressRequest) + +SetInProgressResponse = _reflection.GeneratedProtocolMessageType('SetInProgressResponse', (_message.Message,), { + 'DESCRIPTOR' : _SETINPROGRESSRESPONSE, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.SetInProgressResponse) + }) +_sym_db.RegisterMessage(SetInProgressResponse) + +SubscribeTakePhotoRequest = _reflection.GeneratedProtocolMessageType('SubscribeTakePhotoRequest', (_message.Message,), { + 'DESCRIPTOR' : _SUBSCRIBETAKEPHOTOREQUEST, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.SubscribeTakePhotoRequest) + }) +_sym_db.RegisterMessage(SubscribeTakePhotoRequest) + +TakePhotoResponse = _reflection.GeneratedProtocolMessageType('TakePhotoResponse', (_message.Message,), { + 'DESCRIPTOR' : _TAKEPHOTORESPONSE, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.TakePhotoResponse) + }) +_sym_db.RegisterMessage(TakePhotoResponse) + +RespondTakePhotoRequest = _reflection.GeneratedProtocolMessageType('RespondTakePhotoRequest', (_message.Message,), { + 'DESCRIPTOR' : _RESPONDTAKEPHOTOREQUEST, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.RespondTakePhotoRequest) + }) +_sym_db.RegisterMessage(RespondTakePhotoRequest) + +RespondTakePhotoResponse = _reflection.GeneratedProtocolMessageType('RespondTakePhotoResponse', (_message.Message,), { + 'DESCRIPTOR' : _RESPONDTAKEPHOTORESPONSE, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.RespondTakePhotoResponse) + }) +_sym_db.RegisterMessage(RespondTakePhotoResponse) + +Information = _reflection.GeneratedProtocolMessageType('Information', (_message.Message,), { + 'DESCRIPTOR' : _INFORMATION, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.Information) + }) +_sym_db.RegisterMessage(Information) + +Position = _reflection.GeneratedProtocolMessageType('Position', (_message.Message,), { + 'DESCRIPTOR' : _POSITION, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.Position) + }) +_sym_db.RegisterMessage(Position) + +Quaternion = _reflection.GeneratedProtocolMessageType('Quaternion', (_message.Message,), { + 'DESCRIPTOR' : _QUATERNION, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.Quaternion) + }) +_sym_db.RegisterMessage(Quaternion) + +CaptureInfo = _reflection.GeneratedProtocolMessageType('CaptureInfo', (_message.Message,), { + 'DESCRIPTOR' : _CAPTUREINFO, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.CaptureInfo) + }) +_sym_db.RegisterMessage(CaptureInfo) + +CameraServerResult = _reflection.GeneratedProtocolMessageType('CameraServerResult', (_message.Message,), { + 'DESCRIPTOR' : _CAMERASERVERRESULT, + '__module__' : 'camera_server.camera_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.camera_server.CameraServerResult) + }) +_sym_db.RegisterMessage(CameraServerResult) + +_CAMERASERVERSERVICE = DESCRIPTOR.services_by_name['CameraServerService'] +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'\n\027io.mavsdk.camera_serverB\021CameraServerProto' + _CAMERASERVERSERVICE.methods_by_name['SetInformation']._options = None + _CAMERASERVERSERVICE.methods_by_name['SetInformation']._serialized_options = b'\200\265\030\001' + _CAMERASERVERSERVICE.methods_by_name['SetInProgress']._options = None + _CAMERASERVERSERVICE.methods_by_name['SetInProgress']._serialized_options = b'\200\265\030\001' + _CAMERASERVERSERVICE.methods_by_name['SubscribeTakePhoto']._options = None + _CAMERASERVERSERVICE.methods_by_name['SubscribeTakePhoto']._serialized_options = b'\200\265\030\000' + _CAMERASERVERSERVICE.methods_by_name['RespondTakePhoto']._options = None + _CAMERASERVERSERVICE.methods_by_name['RespondTakePhoto']._serialized_options = b'\200\265\030\001' + _TAKEPHOTOFEEDBACK._serialized_start=1766 + _TAKEPHOTOFEEDBACK._serialized_end=1908 + _SETINFORMATIONREQUEST._serialized_start=85 + _SETINFORMATIONREQUEST._serialized_end=168 + _SETINFORMATIONRESPONSE._serialized_start=170 + _SETINFORMATIONRESPONSE._serialized_end=270 + _SETINPROGRESSREQUEST._serialized_start=272 + _SETINPROGRESSREQUEST._serialized_end=315 + _SETINPROGRESSRESPONSE._serialized_start=317 + _SETINPROGRESSRESPONSE._serialized_end=416 + _SUBSCRIBETAKEPHOTOREQUEST._serialized_start=418 + _SUBSCRIBETAKEPHOTOREQUEST._serialized_end=445 + _TAKEPHOTORESPONSE._serialized_start=447 + _TAKEPHOTORESPONSE._serialized_end=481 + _RESPONDTAKEPHOTOREQUEST._serialized_start=484 + _RESPONDTAKEPHOTOREQUEST._serialized_end=644 + _RESPONDTAKEPHOTORESPONSE._serialized_start=646 + _RESPONDTAKEPHOTORESPONSE._serialized_end=748 + _INFORMATION._serialized_start=751 + _INFORMATION._serialized_end=1069 + _POSITION._serialized_start=1071 + _POSITION._serialized_end=1184 + _QUATERNION._serialized_start=1186 + _QUATERNION._serialized_end=1242 + _CAPTUREINFO._serialized_start=1245 + _CAPTUREINFO._serialized_end=1453 + _CAMERASERVERRESULT._serialized_start=1456 + _CAMERASERVERRESULT._serialized_end=1763 + _CAMERASERVERRESULT_RESULT._serialized_start=1568 + _CAMERASERVERRESULT_RESULT._serialized_end=1763 + _CAMERASERVERSERVICE._serialized_start=1911 + _CAMERASERVERSERVICE._serialized_end=2432 +# @@protoc_insertion_point(module_scope) diff --git a/mavsdk/camera_server_pb2_grpc.py b/mavsdk/camera_server_pb2_grpc.py new file mode 100644 index 00000000..cf0a8464 --- /dev/null +++ b/mavsdk/camera_server_pb2_grpc.py @@ -0,0 +1,172 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + +from . import camera_server_pb2 as camera__server_dot_camera__server__pb2 + + +class CameraServerServiceStub(object): + """Provides handling of camera trigger commands. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.SetInformation = channel.unary_unary( + '/mavsdk.rpc.camera_server.CameraServerService/SetInformation', + request_serializer=camera__server_dot_camera__server__pb2.SetInformationRequest.SerializeToString, + response_deserializer=camera__server_dot_camera__server__pb2.SetInformationResponse.FromString, + ) + self.SetInProgress = channel.unary_unary( + '/mavsdk.rpc.camera_server.CameraServerService/SetInProgress', + request_serializer=camera__server_dot_camera__server__pb2.SetInProgressRequest.SerializeToString, + response_deserializer=camera__server_dot_camera__server__pb2.SetInProgressResponse.FromString, + ) + self.SubscribeTakePhoto = channel.unary_stream( + '/mavsdk.rpc.camera_server.CameraServerService/SubscribeTakePhoto', + request_serializer=camera__server_dot_camera__server__pb2.SubscribeTakePhotoRequest.SerializeToString, + response_deserializer=camera__server_dot_camera__server__pb2.TakePhotoResponse.FromString, + ) + self.RespondTakePhoto = channel.unary_unary( + '/mavsdk.rpc.camera_server.CameraServerService/RespondTakePhoto', + request_serializer=camera__server_dot_camera__server__pb2.RespondTakePhotoRequest.SerializeToString, + response_deserializer=camera__server_dot_camera__server__pb2.RespondTakePhotoResponse.FromString, + ) + + +class CameraServerServiceServicer(object): + """Provides handling of camera trigger commands. + """ + + def SetInformation(self, request, context): + """Sets the camera information. This must be called as soon as the camera server is created. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def SetInProgress(self, request, context): + """Sets image capture in progress status flags. This should be set to true when the camera is busy taking a photo and false when it is done. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def SubscribeTakePhoto(self, request, context): + """Subscribe to image capture requests. Each request received should respond to using RespondTakePhoto. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def RespondTakePhoto(self, request, context): + """Respond to an image capture request from SubscribeTakePhoto. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_CameraServerServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'SetInformation': grpc.unary_unary_rpc_method_handler( + servicer.SetInformation, + request_deserializer=camera__server_dot_camera__server__pb2.SetInformationRequest.FromString, + response_serializer=camera__server_dot_camera__server__pb2.SetInformationResponse.SerializeToString, + ), + 'SetInProgress': grpc.unary_unary_rpc_method_handler( + servicer.SetInProgress, + request_deserializer=camera__server_dot_camera__server__pb2.SetInProgressRequest.FromString, + response_serializer=camera__server_dot_camera__server__pb2.SetInProgressResponse.SerializeToString, + ), + 'SubscribeTakePhoto': grpc.unary_stream_rpc_method_handler( + servicer.SubscribeTakePhoto, + request_deserializer=camera__server_dot_camera__server__pb2.SubscribeTakePhotoRequest.FromString, + response_serializer=camera__server_dot_camera__server__pb2.TakePhotoResponse.SerializeToString, + ), + 'RespondTakePhoto': grpc.unary_unary_rpc_method_handler( + servicer.RespondTakePhoto, + request_deserializer=camera__server_dot_camera__server__pb2.RespondTakePhotoRequest.FromString, + response_serializer=camera__server_dot_camera__server__pb2.RespondTakePhotoResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'mavsdk.rpc.camera_server.CameraServerService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + # This class is part of an EXPERIMENTAL API. +class CameraServerService(object): + """Provides handling of camera trigger commands. + """ + + @staticmethod + def SetInformation(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.camera_server.CameraServerService/SetInformation', + camera__server_dot_camera__server__pb2.SetInformationRequest.SerializeToString, + camera__server_dot_camera__server__pb2.SetInformationResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def SetInProgress(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.camera_server.CameraServerService/SetInProgress', + camera__server_dot_camera__server__pb2.SetInProgressRequest.SerializeToString, + camera__server_dot_camera__server__pb2.SetInProgressResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def SubscribeTakePhoto(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_stream(request, target, '/mavsdk.rpc.camera_server.CameraServerService/SubscribeTakePhoto', + camera__server_dot_camera__server__pb2.SubscribeTakePhotoRequest.SerializeToString, + camera__server_dot_camera__server__pb2.TakePhotoResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def RespondTakePhoto(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.camera_server.CameraServerService/RespondTakePhoto', + camera__server_dot_camera__server__pb2.RespondTakePhotoRequest.SerializeToString, + camera__server_dot_camera__server__pb2.RespondTakePhotoResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/mavsdk/log_files.py b/mavsdk/log_files.py index 8ef3117a..65dc3d72 100644 --- a/mavsdk/log_files.py +++ b/mavsdk/log_files.py @@ -429,4 +429,70 @@ async def download_log_file(self, entry, path): yield ProgressData.translate_from_rpc(response.progress) finally: - download_log_file_stream.cancel() \ No newline at end of file + download_log_file_stream.cancel() + + async def download_log_file(self, entry, path): + """ + Download log file synchronously. + + Parameters + ---------- + entry : Entry + Entry of the log file to download. + + path : std::string + Path of where to download log file to. + + Returns + ------- + progress : ProgressData + Progress if result is progress + + Raises + ------ + LogFilesError + If the request fails. The error contains the reason for the failure. + """ + + request = log_files_pb2.DownloadLogFileRequest() + + + + entry.translate_to_rpc(request.entry) + + + + + request.path = path + + response = await self._stub.DownloadLogFile(request) + + + result = self._extract_result(response) + + if result.result != LogFilesResult.Result.SUCCESS: + raise LogFilesError(result, "download_log_file()", entry, path) + + + return ProgressData.translate_from_rpc(response.progress) + + + async def erase_all_log_files(self): + """ + Erase all log files. + + Raises + ------ + LogFilesError + If the request fails. The error contains the reason for the failure. + """ + + request = log_files_pb2.EraseAllLogFilesRequest() + response = await self._stub.EraseAllLogFiles(request) + + + result = self._extract_result(response) + + if result.result != LogFilesResult.Result.SUCCESS: + raise LogFilesError(result, "erase_all_log_files()") + \ No newline at end of file diff --git a/mavsdk/log_files_pb2.py b/mavsdk/log_files_pb2.py index 1b0a4f56..0de55057 100644 --- a/mavsdk/log_files_pb2.py +++ b/mavsdk/log_files_pb2.py @@ -15,7 +15,7 @@ from . import mavsdk_options_pb2 as mavsdk__options__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19log_files/log_files.proto\x12\x14mavsdk.rpc.log_files\x1a\x14mavsdk_options.proto\"\x13\n\x11GetEntriesRequest\"\x82\x01\n\x12GetEntriesResponse\x12>\n\x10log_files_result\x18\x01 \x01(\x0b\x32$.mavsdk.rpc.log_files.LogFilesResult\x12,\n\x07\x65ntries\x18\x02 \x03(\x0b\x32\x1b.mavsdk.rpc.log_files.Entry\"[\n\x1fSubscribeDownloadLogFileRequest\x12*\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x1b.mavsdk.rpc.log_files.Entry\x12\x0c\n\x04path\x18\x02 \x01(\t\"\x8f\x01\n\x17\x44ownloadLogFileResponse\x12>\n\x10log_files_result\x18\x01 \x01(\x0b\x32$.mavsdk.rpc.log_files.LogFilesResult\x12\x34\n\x08progress\x18\x02 \x01(\x0b\x32\".mavsdk.rpc.log_files.ProgressData\")\n\x0cProgressData\x12\x19\n\x08progress\x18\x01 \x01(\x02\x42\x07\x82\xb5\x18\x03NaN\"5\n\x05\x45ntry\x12\n\n\x02id\x18\x01 \x01(\r\x12\x0c\n\x04\x64\x61te\x18\x02 \x01(\t\x12\x12\n\nsize_bytes\x18\x03 \x01(\r\"\xa1\x02\n\x0eLogFilesResult\x12;\n\x06result\x18\x01 \x01(\x0e\x32+.mavsdk.rpc.log_files.LogFilesResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\xbd\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x0f\n\x0bRESULT_NEXT\x10\x02\x12\x16\n\x12RESULT_NO_LOGFILES\x10\x03\x12\x12\n\x0eRESULT_TIMEOUT\x10\x04\x12\x1b\n\x17RESULT_INVALID_ARGUMENT\x10\x05\x12\x1b\n\x17RESULT_FILE_OPEN_FAILED\x10\x06\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x07\x32\x83\x02\n\x0fLogFilesService\x12\x61\n\nGetEntries\x12\'.mavsdk.rpc.log_files.GetEntriesRequest\x1a(.mavsdk.rpc.log_files.GetEntriesResponse\"\x00\x12\x8c\x01\n\x18SubscribeDownloadLogFile\x12\x35.mavsdk.rpc.log_files.SubscribeDownloadLogFileRequest\x1a-.mavsdk.rpc.log_files.DownloadLogFileResponse\"\x08\x80\xb5\x18\x00\x88\xb5\x18\x01\x30\x01\x42$\n\x13io.mavsdk.log_filesB\rLogFilesProtob\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19log_files/log_files.proto\x12\x14mavsdk.rpc.log_files\x1a\x14mavsdk_options.proto\"\x13\n\x11GetEntriesRequest\"\x82\x01\n\x12GetEntriesResponse\x12>\n\x10log_files_result\x18\x01 \x01(\x0b\x32$.mavsdk.rpc.log_files.LogFilesResult\x12,\n\x07\x65ntries\x18\x02 \x03(\x0b\x32\x1b.mavsdk.rpc.log_files.Entry\"[\n\x1fSubscribeDownloadLogFileRequest\x12*\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x1b.mavsdk.rpc.log_files.Entry\x12\x0c\n\x04path\x18\x02 \x01(\t\"\x8f\x01\n\x17\x44ownloadLogFileResponse\x12>\n\x10log_files_result\x18\x01 \x01(\x0b\x32$.mavsdk.rpc.log_files.LogFilesResult\x12\x34\n\x08progress\x18\x02 \x01(\x0b\x32\".mavsdk.rpc.log_files.ProgressData\"R\n\x16\x44ownloadLogFileRequest\x12*\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x1b.mavsdk.rpc.log_files.Entry\x12\x0c\n\x04path\x18\x02 \x01(\t\"\x19\n\x17\x45raseAllLogFilesRequest\"Z\n\x18\x45raseAllLogFilesResponse\x12>\n\x10log_files_result\x18\x01 \x01(\x0b\x32$.mavsdk.rpc.log_files.LogFilesResult\")\n\x0cProgressData\x12\x19\n\x08progress\x18\x01 \x01(\x02\x42\x07\x82\xb5\x18\x03NaN\"5\n\x05\x45ntry\x12\n\n\x02id\x18\x01 \x01(\r\x12\x0c\n\x04\x64\x61te\x18\x02 \x01(\t\x12\x12\n\nsize_bytes\x18\x03 \x01(\r\"\xa1\x02\n\x0eLogFilesResult\x12;\n\x06result\x18\x01 \x01(\x0e\x32+.mavsdk.rpc.log_files.LogFilesResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\xbd\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x0f\n\x0bRESULT_NEXT\x10\x02\x12\x16\n\x12RESULT_NO_LOGFILES\x10\x03\x12\x12\n\x0eRESULT_TIMEOUT\x10\x04\x12\x1b\n\x17RESULT_INVALID_ARGUMENT\x10\x05\x12\x1b\n\x17RESULT_FILE_OPEN_FAILED\x10\x06\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x07\x32\xf2\x03\n\x0fLogFilesService\x12\x61\n\nGetEntries\x12\'.mavsdk.rpc.log_files.GetEntriesRequest\x1a(.mavsdk.rpc.log_files.GetEntriesResponse\"\x00\x12\x8c\x01\n\x18SubscribeDownloadLogFile\x12\x35.mavsdk.rpc.log_files.SubscribeDownloadLogFileRequest\x1a-.mavsdk.rpc.log_files.DownloadLogFileResponse\"\x08\x80\xb5\x18\x00\x88\xb5\x18\x01\x30\x01\x12t\n\x0f\x44ownloadLogFile\x12,.mavsdk.rpc.log_files.DownloadLogFileRequest\x1a-.mavsdk.rpc.log_files.DownloadLogFileResponse\"\x04\x80\xb5\x18\x01\x12w\n\x10\x45raseAllLogFiles\x12-.mavsdk.rpc.log_files.EraseAllLogFilesRequest\x1a..mavsdk.rpc.log_files.EraseAllLogFilesResponse\"\x04\x80\xb5\x18\x01\x42$\n\x13io.mavsdk.log_filesB\rLogFilesProtob\x06proto3') @@ -23,6 +23,9 @@ _GETENTRIESRESPONSE = DESCRIPTOR.message_types_by_name['GetEntriesResponse'] _SUBSCRIBEDOWNLOADLOGFILEREQUEST = DESCRIPTOR.message_types_by_name['SubscribeDownloadLogFileRequest'] _DOWNLOADLOGFILERESPONSE = DESCRIPTOR.message_types_by_name['DownloadLogFileResponse'] +_DOWNLOADLOGFILEREQUEST = DESCRIPTOR.message_types_by_name['DownloadLogFileRequest'] +_ERASEALLLOGFILESREQUEST = DESCRIPTOR.message_types_by_name['EraseAllLogFilesRequest'] +_ERASEALLLOGFILESRESPONSE = DESCRIPTOR.message_types_by_name['EraseAllLogFilesResponse'] _PROGRESSDATA = DESCRIPTOR.message_types_by_name['ProgressData'] _ENTRY = DESCRIPTOR.message_types_by_name['Entry'] _LOGFILESRESULT = DESCRIPTOR.message_types_by_name['LogFilesResult'] @@ -55,6 +58,27 @@ }) _sym_db.RegisterMessage(DownloadLogFileResponse) +DownloadLogFileRequest = _reflection.GeneratedProtocolMessageType('DownloadLogFileRequest', (_message.Message,), { + 'DESCRIPTOR' : _DOWNLOADLOGFILEREQUEST, + '__module__' : 'log_files.log_files_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.log_files.DownloadLogFileRequest) + }) +_sym_db.RegisterMessage(DownloadLogFileRequest) + +EraseAllLogFilesRequest = _reflection.GeneratedProtocolMessageType('EraseAllLogFilesRequest', (_message.Message,), { + 'DESCRIPTOR' : _ERASEALLLOGFILESREQUEST, + '__module__' : 'log_files.log_files_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.log_files.EraseAllLogFilesRequest) + }) +_sym_db.RegisterMessage(EraseAllLogFilesRequest) + +EraseAllLogFilesResponse = _reflection.GeneratedProtocolMessageType('EraseAllLogFilesResponse', (_message.Message,), { + 'DESCRIPTOR' : _ERASEALLLOGFILESRESPONSE, + '__module__' : 'log_files.log_files_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.log_files.EraseAllLogFilesResponse) + }) +_sym_db.RegisterMessage(EraseAllLogFilesResponse) + ProgressData = _reflection.GeneratedProtocolMessageType('ProgressData', (_message.Message,), { 'DESCRIPTOR' : _PROGRESSDATA, '__module__' : 'log_files.log_files_pb2' @@ -85,6 +109,10 @@ _PROGRESSDATA.fields_by_name['progress']._serialized_options = b'\202\265\030\003NaN' _LOGFILESSERVICE.methods_by_name['SubscribeDownloadLogFile']._options = None _LOGFILESSERVICE.methods_by_name['SubscribeDownloadLogFile']._serialized_options = b'\200\265\030\000\210\265\030\001' + _LOGFILESSERVICE.methods_by_name['DownloadLogFile']._options = None + _LOGFILESSERVICE.methods_by_name['DownloadLogFile']._serialized_options = b'\200\265\030\001' + _LOGFILESSERVICE.methods_by_name['EraseAllLogFiles']._options = None + _LOGFILESSERVICE.methods_by_name['EraseAllLogFiles']._serialized_options = b'\200\265\030\001' _GETENTRIESREQUEST._serialized_start=73 _GETENTRIESREQUEST._serialized_end=92 _GETENTRIESRESPONSE._serialized_start=95 @@ -93,14 +121,20 @@ _SUBSCRIBEDOWNLOADLOGFILEREQUEST._serialized_end=318 _DOWNLOADLOGFILERESPONSE._serialized_start=321 _DOWNLOADLOGFILERESPONSE._serialized_end=464 - _PROGRESSDATA._serialized_start=466 - _PROGRESSDATA._serialized_end=507 - _ENTRY._serialized_start=509 - _ENTRY._serialized_end=562 - _LOGFILESRESULT._serialized_start=565 - _LOGFILESRESULT._serialized_end=854 - _LOGFILESRESULT_RESULT._serialized_start=665 - _LOGFILESRESULT_RESULT._serialized_end=854 - _LOGFILESSERVICE._serialized_start=857 - _LOGFILESSERVICE._serialized_end=1116 + _DOWNLOADLOGFILEREQUEST._serialized_start=466 + _DOWNLOADLOGFILEREQUEST._serialized_end=548 + _ERASEALLLOGFILESREQUEST._serialized_start=550 + _ERASEALLLOGFILESREQUEST._serialized_end=575 + _ERASEALLLOGFILESRESPONSE._serialized_start=577 + _ERASEALLLOGFILESRESPONSE._serialized_end=667 + _PROGRESSDATA._serialized_start=669 + _PROGRESSDATA._serialized_end=710 + _ENTRY._serialized_start=712 + _ENTRY._serialized_end=765 + _LOGFILESRESULT._serialized_start=768 + _LOGFILESRESULT._serialized_end=1057 + _LOGFILESRESULT_RESULT._serialized_start=868 + _LOGFILESRESULT_RESULT._serialized_end=1057 + _LOGFILESSERVICE._serialized_start=1060 + _LOGFILESSERVICE._serialized_end=1558 # @@protoc_insertion_point(module_scope) diff --git a/mavsdk/log_files_pb2_grpc.py b/mavsdk/log_files_pb2_grpc.py index 784fc007..938aed6c 100644 --- a/mavsdk/log_files_pb2_grpc.py +++ b/mavsdk/log_files_pb2_grpc.py @@ -26,6 +26,16 @@ def __init__(self, channel): request_serializer=log__files_dot_log__files__pb2.SubscribeDownloadLogFileRequest.SerializeToString, response_deserializer=log__files_dot_log__files__pb2.DownloadLogFileResponse.FromString, ) + self.DownloadLogFile = channel.unary_unary( + '/mavsdk.rpc.log_files.LogFilesService/DownloadLogFile', + request_serializer=log__files_dot_log__files__pb2.DownloadLogFileRequest.SerializeToString, + response_deserializer=log__files_dot_log__files__pb2.DownloadLogFileResponse.FromString, + ) + self.EraseAllLogFiles = channel.unary_unary( + '/mavsdk.rpc.log_files.LogFilesService/EraseAllLogFiles', + request_serializer=log__files_dot_log__files__pb2.EraseAllLogFilesRequest.SerializeToString, + response_deserializer=log__files_dot_log__files__pb2.EraseAllLogFilesResponse.FromString, + ) class LogFilesServiceServicer(object): @@ -47,6 +57,20 @@ def SubscribeDownloadLogFile(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def DownloadLogFile(self, request, context): + """Download log file synchronously. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def EraseAllLogFiles(self, request, context): + """Erase all log files. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def add_LogFilesServiceServicer_to_server(servicer, server): rpc_method_handlers = { @@ -60,6 +84,16 @@ def add_LogFilesServiceServicer_to_server(servicer, server): request_deserializer=log__files_dot_log__files__pb2.SubscribeDownloadLogFileRequest.FromString, response_serializer=log__files_dot_log__files__pb2.DownloadLogFileResponse.SerializeToString, ), + 'DownloadLogFile': grpc.unary_unary_rpc_method_handler( + servicer.DownloadLogFile, + request_deserializer=log__files_dot_log__files__pb2.DownloadLogFileRequest.FromString, + response_serializer=log__files_dot_log__files__pb2.DownloadLogFileResponse.SerializeToString, + ), + 'EraseAllLogFiles': grpc.unary_unary_rpc_method_handler( + servicer.EraseAllLogFiles, + request_deserializer=log__files_dot_log__files__pb2.EraseAllLogFilesRequest.FromString, + response_serializer=log__files_dot_log__files__pb2.EraseAllLogFilesResponse.SerializeToString, + ), } generic_handler = grpc.method_handlers_generic_handler( 'mavsdk.rpc.log_files.LogFilesService', rpc_method_handlers) @@ -105,3 +139,37 @@ def SubscribeDownloadLogFile(request, log__files_dot_log__files__pb2.DownloadLogFileResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def DownloadLogFile(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.log_files.LogFilesService/DownloadLogFile', + log__files_dot_log__files__pb2.DownloadLogFileRequest.SerializeToString, + log__files_dot_log__files__pb2.DownloadLogFileResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def EraseAllLogFiles(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.log_files.LogFilesService/EraseAllLogFiles', + log__files_dot_log__files__pb2.EraseAllLogFilesRequest.SerializeToString, + log__files_dot_log__files__pb2.EraseAllLogFilesResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/mavsdk/param.py b/mavsdk/param.py index 8730b0d8..945af501 100644 --- a/mavsdk/param.py +++ b/mavsdk/param.py @@ -154,9 +154,83 @@ def translate_to_rpc(self, rpcFloatParam): +class CustomParam: + """ + Type for custom parameters + + Parameters + ---------- + name : std::string + Name of the parameter + + value : std::string + Value of the parameter (max len 128 bytes) + + """ + + + + def __init__( + self, + name, + value): + """ Initializes the CustomParam object """ + self.name = name + self.value = value + + def __eq__(self, to_compare): + """ Checks if two CustomParam are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # CustomParam object + return \ + (self.name == to_compare.name) and \ + (self.value == to_compare.value) + + except AttributeError: + return False + + def __str__(self): + """ CustomParam in string representation """ + struct_repr = ", ".join([ + "name: " + str(self.name), + "value: " + str(self.value) + ]) + + return f"CustomParam: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcCustomParam): + """ Translates a gRPC struct to the SDK equivalent """ + return CustomParam( + + rpcCustomParam.name, + + + rpcCustomParam.value + ) + + def translate_to_rpc(self, rpcCustomParam): + """ Translates this SDK object into its gRPC equivalent """ + + + + + rpcCustomParam.name = self.name + + + + + + rpcCustomParam.value = self.value + + + + + class AllParams: """ - Type collecting all integer and float parameters. + Type collecting all integer, float, and custom parameters. Parameters ---------- @@ -166,6 +240,9 @@ class AllParams: float_params : [FloatParam] Collection of all parameter names and values of type float + custom_params : [CustomParam] + Collection of all parameter names and values of type custom + """ @@ -173,10 +250,12 @@ class AllParams: def __init__( self, int_params, - float_params): + float_params, + custom_params): """ Initializes the AllParams object """ self.int_params = int_params self.float_params = float_params + self.custom_params = custom_params def __eq__(self, to_compare): """ Checks if two AllParams are the same """ @@ -185,7 +264,8 @@ def __eq__(self, to_compare): # AllParams object return \ (self.int_params == to_compare.int_params) and \ - (self.float_params == to_compare.float_params) + (self.float_params == to_compare.float_params) and \ + (self.custom_params == to_compare.custom_params) except AttributeError: return False @@ -194,7 +274,8 @@ def __str__(self): """ AllParams in string representation """ struct_repr = ", ".join([ "int_params: " + str(self.int_params), - "float_params: " + str(self.float_params) + "float_params: " + str(self.float_params), + "custom_params: " + str(self.custom_params) ]) return f"AllParams: [{struct_repr}]" @@ -207,7 +288,10 @@ def translate_from_rpc(rpcAllParams): list(map(lambda elem: IntParam.translate_from_rpc(elem), rpcAllParams.int_params)), - list(map(lambda elem: FloatParam.translate_from_rpc(elem), rpcAllParams.float_params)) + list(map(lambda elem: FloatParam.translate_from_rpc(elem), rpcAllParams.float_params)), + + + list(map(lambda elem: CustomParam.translate_from_rpc(elem), rpcAllParams.custom_params)) ) def translate_to_rpc(self, rpcAllParams): @@ -240,6 +324,19 @@ def translate_to_rpc(self, rpcAllParams): + + + rpc_elems_list = [] + for elem in self.custom_params: + + rpc_elem = param_pb2.CustomParam() + elem.translate_to_rpc(rpc_elem) + rpc_elems_list.append(rpc_elem) + + rpcAllParams.custom_params.extend(rpc_elems_list) + + + class ParamResult: @@ -285,6 +382,9 @@ class Result(Enum): NO_SYSTEM No system connected + PARAM_VALUE_TOO_LONG + Param value too long (> 128) + """ @@ -295,6 +395,7 @@ class Result(Enum): WRONG_TYPE = 4 PARAM_NAME_TOO_LONG = 5 NO_SYSTEM = 6 + PARAM_VALUE_TOO_LONG = 7 def translate_to_rpc(self): if self == ParamResult.Result.UNKNOWN: @@ -311,6 +412,8 @@ def translate_to_rpc(self): return param_pb2.ParamResult.RESULT_PARAM_NAME_TOO_LONG if self == ParamResult.Result.NO_SYSTEM: return param_pb2.ParamResult.RESULT_NO_SYSTEM + if self == ParamResult.Result.PARAM_VALUE_TOO_LONG: + return param_pb2.ParamResult.RESULT_PARAM_VALUE_TOO_LONG @staticmethod def translate_from_rpc(rpc_enum_value): @@ -329,6 +432,8 @@ def translate_from_rpc(rpc_enum_value): return ParamResult.Result.PARAM_NAME_TOO_LONG if rpc_enum_value == param_pb2.ParamResult.RESULT_NO_SYSTEM: return ParamResult.Result.NO_SYSTEM + if rpc_enum_value == param_pb2.ParamResult.RESULT_PARAM_VALUE_TOO_LONG: + return ParamResult.Result.PARAM_VALUE_TOO_LONG def __str__(self): return self.name @@ -567,6 +672,77 @@ async def set_param_float(self, name, value): raise ParamError(result, "set_param_float()", name, value) + async def get_param_custom(self, name): + """ + Get a custom parameter. + + If the type is wrong, the result will be `WRONG_TYPE`. + + Parameters + ---------- + name : std::string + Name of the parameter + + Returns + ------- + value : std::string + Value of the requested parameter + + Raises + ------ + ParamError + If the request fails. The error contains the reason for the failure. + """ + + request = param_pb2.GetParamCustomRequest() + + + request.name = name + + response = await self._stub.GetParamCustom(request) + + + result = self._extract_result(response) + + if result.result != ParamResult.Result.SUCCESS: + raise ParamError(result, "get_param_custom()", name) + + + return response.value + + + async def set_param_custom(self, name, value): + """ + Set a custom parameter. + + If the type is wrong, the result will be `WRONG_TYPE`. + + Parameters + ---------- + name : std::string + Name of the parameter to set + + value : std::string + Value the parameter should be set to + + Raises + ------ + ParamError + If the request fails. The error contains the reason for the failure. + """ + + request = param_pb2.SetParamCustomRequest() + request.name = name + request.value = value + response = await self._stub.SetParamCustom(request) + + + result = self._extract_result(response) + + if result.result != ParamResult.Result.SUCCESS: + raise ParamError(result, "set_param_custom()", name, value) + + async def get_all_params(self): """ Get all parameters. diff --git a/mavsdk/param_pb2.py b/mavsdk/param_pb2.py index 487318ed..56096215 100644 --- a/mavsdk/param_pb2.py +++ b/mavsdk/param_pb2.py @@ -15,7 +15,7 @@ from . import mavsdk_options_pb2 as mavsdk__options__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11param/param.proto\x12\x10mavsdk.rpc.param\x1a\x14mavsdk_options.proto\"\"\n\x12GetParamIntRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"Y\n\x13GetParamIntResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\x12\r\n\x05value\x18\x02 \x01(\x05\"1\n\x12SetParamIntRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\"J\n\x13SetParamIntResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\"$\n\x14GetParamFloatRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"[\n\x15GetParamFloatResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\x12\r\n\x05value\x18\x02 \x01(\x02\"3\n\x14SetParamFloatRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x02\"L\n\x15SetParamFloatResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\"\x15\n\x13GetAllParamsRequest\"C\n\x14GetAllParamsResponse\x12+\n\x06params\x18\x01 \x01(\x0b\x32\x1b.mavsdk.rpc.param.AllParams\"\'\n\x08IntParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\")\n\nFloatParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x02\"o\n\tAllParams\x12.\n\nint_params\x18\x01 \x03(\x0b\x32\x1a.mavsdk.rpc.param.IntParam\x12\x32\n\x0c\x66loat_params\x18\x02 \x03(\x0b\x32\x1c.mavsdk.rpc.param.FloatParam\"\x88\x02\n\x0bParamResult\x12\x34\n\x06result\x18\x01 \x01(\x0e\x32$.mavsdk.rpc.param.ParamResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\xae\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x12\n\x0eRESULT_TIMEOUT\x10\x02\x12\x1b\n\x17RESULT_CONNECTION_ERROR\x10\x03\x12\x15\n\x11RESULT_WRONG_TYPE\x10\x04\x12\x1e\n\x1aRESULT_PARAM_NAME_TOO_LONG\x10\x05\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x06\x32\x87\x04\n\x0cParamService\x12`\n\x0bGetParamInt\x12$.mavsdk.rpc.param.GetParamIntRequest\x1a%.mavsdk.rpc.param.GetParamIntResponse\"\x04\x80\xb5\x18\x01\x12`\n\x0bSetParamInt\x12$.mavsdk.rpc.param.SetParamIntRequest\x1a%.mavsdk.rpc.param.SetParamIntResponse\"\x04\x80\xb5\x18\x01\x12\x66\n\rGetParamFloat\x12&.mavsdk.rpc.param.GetParamFloatRequest\x1a\'.mavsdk.rpc.param.GetParamFloatResponse\"\x04\x80\xb5\x18\x01\x12\x66\n\rSetParamFloat\x12&.mavsdk.rpc.param.SetParamFloatRequest\x1a\'.mavsdk.rpc.param.SetParamFloatResponse\"\x04\x80\xb5\x18\x01\x12\x63\n\x0cGetAllParams\x12%.mavsdk.rpc.param.GetAllParamsRequest\x1a&.mavsdk.rpc.param.GetAllParamsResponse\"\x04\x80\xb5\x18\x01\x42\x1d\n\x0fio.mavsdk.paramB\nParamProtob\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11param/param.proto\x12\x10mavsdk.rpc.param\x1a\x14mavsdk_options.proto\"\"\n\x12GetParamIntRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"Y\n\x13GetParamIntResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\x12\r\n\x05value\x18\x02 \x01(\x05\"1\n\x12SetParamIntRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\"J\n\x13SetParamIntResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\"$\n\x14GetParamFloatRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"[\n\x15GetParamFloatResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\x12\r\n\x05value\x18\x02 \x01(\x02\"3\n\x14SetParamFloatRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x02\"L\n\x15SetParamFloatResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\"%\n\x15GetParamCustomRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\\\n\x16GetParamCustomResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\x12\r\n\x05value\x18\x02 \x01(\t\"4\n\x15SetParamCustomRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\"M\n\x16SetParamCustomResponse\x12\x33\n\x0cparam_result\x18\x01 \x01(\x0b\x32\x1d.mavsdk.rpc.param.ParamResult\"\x15\n\x13GetAllParamsRequest\"C\n\x14GetAllParamsResponse\x12+\n\x06params\x18\x01 \x01(\x0b\x32\x1b.mavsdk.rpc.param.AllParams\"\'\n\x08IntParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\")\n\nFloatParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x02\"*\n\x0b\x43ustomParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\"\xa5\x01\n\tAllParams\x12.\n\nint_params\x18\x01 \x03(\x0b\x32\x1a.mavsdk.rpc.param.IntParam\x12\x32\n\x0c\x66loat_params\x18\x02 \x03(\x0b\x32\x1c.mavsdk.rpc.param.FloatParam\x12\x34\n\rcustom_params\x18\x03 \x03(\x0b\x32\x1d.mavsdk.rpc.param.CustomParam\"\xa9\x02\n\x0bParamResult\x12\x34\n\x06result\x18\x01 \x01(\x0e\x32$.mavsdk.rpc.param.ParamResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\xcf\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x12\n\x0eRESULT_TIMEOUT\x10\x02\x12\x1b\n\x17RESULT_CONNECTION_ERROR\x10\x03\x12\x15\n\x11RESULT_WRONG_TYPE\x10\x04\x12\x1e\n\x1aRESULT_PARAM_NAME_TOO_LONG\x10\x05\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x06\x12\x1f\n\x1bRESULT_PARAM_VALUE_TOO_LONG\x10\x07\x32\xdd\x05\n\x0cParamService\x12`\n\x0bGetParamInt\x12$.mavsdk.rpc.param.GetParamIntRequest\x1a%.mavsdk.rpc.param.GetParamIntResponse\"\x04\x80\xb5\x18\x01\x12`\n\x0bSetParamInt\x12$.mavsdk.rpc.param.SetParamIntRequest\x1a%.mavsdk.rpc.param.SetParamIntResponse\"\x04\x80\xb5\x18\x01\x12\x66\n\rGetParamFloat\x12&.mavsdk.rpc.param.GetParamFloatRequest\x1a\'.mavsdk.rpc.param.GetParamFloatResponse\"\x04\x80\xb5\x18\x01\x12\x66\n\rSetParamFloat\x12&.mavsdk.rpc.param.SetParamFloatRequest\x1a\'.mavsdk.rpc.param.SetParamFloatResponse\"\x04\x80\xb5\x18\x01\x12i\n\x0eGetParamCustom\x12\'.mavsdk.rpc.param.GetParamCustomRequest\x1a(.mavsdk.rpc.param.GetParamCustomResponse\"\x04\x80\xb5\x18\x01\x12i\n\x0eSetParamCustom\x12\'.mavsdk.rpc.param.SetParamCustomRequest\x1a(.mavsdk.rpc.param.SetParamCustomResponse\"\x04\x80\xb5\x18\x01\x12\x63\n\x0cGetAllParams\x12%.mavsdk.rpc.param.GetAllParamsRequest\x1a&.mavsdk.rpc.param.GetAllParamsResponse\"\x04\x80\xb5\x18\x01\x42\x1d\n\x0fio.mavsdk.paramB\nParamProtob\x06proto3') @@ -27,10 +27,15 @@ _GETPARAMFLOATRESPONSE = DESCRIPTOR.message_types_by_name['GetParamFloatResponse'] _SETPARAMFLOATREQUEST = DESCRIPTOR.message_types_by_name['SetParamFloatRequest'] _SETPARAMFLOATRESPONSE = DESCRIPTOR.message_types_by_name['SetParamFloatResponse'] +_GETPARAMCUSTOMREQUEST = DESCRIPTOR.message_types_by_name['GetParamCustomRequest'] +_GETPARAMCUSTOMRESPONSE = DESCRIPTOR.message_types_by_name['GetParamCustomResponse'] +_SETPARAMCUSTOMREQUEST = DESCRIPTOR.message_types_by_name['SetParamCustomRequest'] +_SETPARAMCUSTOMRESPONSE = DESCRIPTOR.message_types_by_name['SetParamCustomResponse'] _GETALLPARAMSREQUEST = DESCRIPTOR.message_types_by_name['GetAllParamsRequest'] _GETALLPARAMSRESPONSE = DESCRIPTOR.message_types_by_name['GetAllParamsResponse'] _INTPARAM = DESCRIPTOR.message_types_by_name['IntParam'] _FLOATPARAM = DESCRIPTOR.message_types_by_name['FloatParam'] +_CUSTOMPARAM = DESCRIPTOR.message_types_by_name['CustomParam'] _ALLPARAMS = DESCRIPTOR.message_types_by_name['AllParams'] _PARAMRESULT = DESCRIPTOR.message_types_by_name['ParamResult'] _PARAMRESULT_RESULT = _PARAMRESULT.enum_types_by_name['Result'] @@ -90,6 +95,34 @@ }) _sym_db.RegisterMessage(SetParamFloatResponse) +GetParamCustomRequest = _reflection.GeneratedProtocolMessageType('GetParamCustomRequest', (_message.Message,), { + 'DESCRIPTOR' : _GETPARAMCUSTOMREQUEST, + '__module__' : 'param.param_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param.GetParamCustomRequest) + }) +_sym_db.RegisterMessage(GetParamCustomRequest) + +GetParamCustomResponse = _reflection.GeneratedProtocolMessageType('GetParamCustomResponse', (_message.Message,), { + 'DESCRIPTOR' : _GETPARAMCUSTOMRESPONSE, + '__module__' : 'param.param_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param.GetParamCustomResponse) + }) +_sym_db.RegisterMessage(GetParamCustomResponse) + +SetParamCustomRequest = _reflection.GeneratedProtocolMessageType('SetParamCustomRequest', (_message.Message,), { + 'DESCRIPTOR' : _SETPARAMCUSTOMREQUEST, + '__module__' : 'param.param_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param.SetParamCustomRequest) + }) +_sym_db.RegisterMessage(SetParamCustomRequest) + +SetParamCustomResponse = _reflection.GeneratedProtocolMessageType('SetParamCustomResponse', (_message.Message,), { + 'DESCRIPTOR' : _SETPARAMCUSTOMRESPONSE, + '__module__' : 'param.param_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param.SetParamCustomResponse) + }) +_sym_db.RegisterMessage(SetParamCustomResponse) + GetAllParamsRequest = _reflection.GeneratedProtocolMessageType('GetAllParamsRequest', (_message.Message,), { 'DESCRIPTOR' : _GETALLPARAMSREQUEST, '__module__' : 'param.param_pb2' @@ -118,6 +151,13 @@ }) _sym_db.RegisterMessage(FloatParam) +CustomParam = _reflection.GeneratedProtocolMessageType('CustomParam', (_message.Message,), { + 'DESCRIPTOR' : _CUSTOMPARAM, + '__module__' : 'param.param_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param.CustomParam) + }) +_sym_db.RegisterMessage(CustomParam) + AllParams = _reflection.GeneratedProtocolMessageType('AllParams', (_message.Message,), { 'DESCRIPTOR' : _ALLPARAMS, '__module__' : 'param.param_pb2' @@ -145,6 +185,10 @@ _PARAMSERVICE.methods_by_name['GetParamFloat']._serialized_options = b'\200\265\030\001' _PARAMSERVICE.methods_by_name['SetParamFloat']._options = None _PARAMSERVICE.methods_by_name['SetParamFloat']._serialized_options = b'\200\265\030\001' + _PARAMSERVICE.methods_by_name['GetParamCustom']._options = None + _PARAMSERVICE.methods_by_name['GetParamCustom']._serialized_options = b'\200\265\030\001' + _PARAMSERVICE.methods_by_name['SetParamCustom']._options = None + _PARAMSERVICE.methods_by_name['SetParamCustom']._serialized_options = b'\200\265\030\001' _PARAMSERVICE.methods_by_name['GetAllParams']._options = None _PARAMSERVICE.methods_by_name['GetAllParams']._serialized_options = b'\200\265\030\001' _GETPARAMINTREQUEST._serialized_start=61 @@ -163,20 +207,30 @@ _SETPARAMFLOATREQUEST._serialized_end=497 _SETPARAMFLOATRESPONSE._serialized_start=499 _SETPARAMFLOATRESPONSE._serialized_end=575 - _GETALLPARAMSREQUEST._serialized_start=577 - _GETALLPARAMSREQUEST._serialized_end=598 - _GETALLPARAMSRESPONSE._serialized_start=600 - _GETALLPARAMSRESPONSE._serialized_end=667 - _INTPARAM._serialized_start=669 - _INTPARAM._serialized_end=708 - _FLOATPARAM._serialized_start=710 - _FLOATPARAM._serialized_end=751 - _ALLPARAMS._serialized_start=753 - _ALLPARAMS._serialized_end=864 - _PARAMRESULT._serialized_start=867 - _PARAMRESULT._serialized_end=1131 - _PARAMRESULT_RESULT._serialized_start=957 - _PARAMRESULT_RESULT._serialized_end=1131 - _PARAMSERVICE._serialized_start=1134 - _PARAMSERVICE._serialized_end=1653 + _GETPARAMCUSTOMREQUEST._serialized_start=577 + _GETPARAMCUSTOMREQUEST._serialized_end=614 + _GETPARAMCUSTOMRESPONSE._serialized_start=616 + _GETPARAMCUSTOMRESPONSE._serialized_end=708 + _SETPARAMCUSTOMREQUEST._serialized_start=710 + _SETPARAMCUSTOMREQUEST._serialized_end=762 + _SETPARAMCUSTOMRESPONSE._serialized_start=764 + _SETPARAMCUSTOMRESPONSE._serialized_end=841 + _GETALLPARAMSREQUEST._serialized_start=843 + _GETALLPARAMSREQUEST._serialized_end=864 + _GETALLPARAMSRESPONSE._serialized_start=866 + _GETALLPARAMSRESPONSE._serialized_end=933 + _INTPARAM._serialized_start=935 + _INTPARAM._serialized_end=974 + _FLOATPARAM._serialized_start=976 + _FLOATPARAM._serialized_end=1017 + _CUSTOMPARAM._serialized_start=1019 + _CUSTOMPARAM._serialized_end=1061 + _ALLPARAMS._serialized_start=1064 + _ALLPARAMS._serialized_end=1229 + _PARAMRESULT._serialized_start=1232 + _PARAMRESULT._serialized_end=1529 + _PARAMRESULT_RESULT._serialized_start=1322 + _PARAMRESULT_RESULT._serialized_end=1529 + _PARAMSERVICE._serialized_start=1532 + _PARAMSERVICE._serialized_end=2265 # @@protoc_insertion_point(module_scope) diff --git a/mavsdk/param_pb2_grpc.py b/mavsdk/param_pb2_grpc.py index b392bd28..2fef8c95 100644 --- a/mavsdk/param_pb2_grpc.py +++ b/mavsdk/param_pb2_grpc.py @@ -35,6 +35,16 @@ def __init__(self, channel): request_serializer=param_dot_param__pb2.SetParamFloatRequest.SerializeToString, response_deserializer=param_dot_param__pb2.SetParamFloatResponse.FromString, ) + self.GetParamCustom = channel.unary_unary( + '/mavsdk.rpc.param.ParamService/GetParamCustom', + request_serializer=param_dot_param__pb2.GetParamCustomRequest.SerializeToString, + response_deserializer=param_dot_param__pb2.GetParamCustomResponse.FromString, + ) + self.SetParamCustom = channel.unary_unary( + '/mavsdk.rpc.param.ParamService/SetParamCustom', + request_serializer=param_dot_param__pb2.SetParamCustomRequest.SerializeToString, + response_deserializer=param_dot_param__pb2.SetParamCustomResponse.FromString, + ) self.GetAllParams = channel.unary_unary( '/mavsdk.rpc.param.ParamService/GetAllParams', request_serializer=param_dot_param__pb2.GetAllParamsRequest.SerializeToString, @@ -86,6 +96,26 @@ def SetParamFloat(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def GetParamCustom(self, request, context): + """ + Get a custom parameter. + + If the type is wrong, the result will be `WRONG_TYPE`. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def SetParamCustom(self, request, context): + """ + Set a custom parameter. + + If the type is wrong, the result will be `WRONG_TYPE`. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def GetAllParams(self, request, context): """ Get all parameters. @@ -117,6 +147,16 @@ def add_ParamServiceServicer_to_server(servicer, server): request_deserializer=param_dot_param__pb2.SetParamFloatRequest.FromString, response_serializer=param_dot_param__pb2.SetParamFloatResponse.SerializeToString, ), + 'GetParamCustom': grpc.unary_unary_rpc_method_handler( + servicer.GetParamCustom, + request_deserializer=param_dot_param__pb2.GetParamCustomRequest.FromString, + response_serializer=param_dot_param__pb2.GetParamCustomResponse.SerializeToString, + ), + 'SetParamCustom': grpc.unary_unary_rpc_method_handler( + servicer.SetParamCustom, + request_deserializer=param_dot_param__pb2.SetParamCustomRequest.FromString, + response_serializer=param_dot_param__pb2.SetParamCustomResponse.SerializeToString, + ), 'GetAllParams': grpc.unary_unary_rpc_method_handler( servicer.GetAllParams, request_deserializer=param_dot_param__pb2.GetAllParamsRequest.FromString, @@ -201,6 +241,40 @@ def SetParamFloat(request, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod + def GetParamCustom(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.param.ParamService/GetParamCustom', + param_dot_param__pb2.GetParamCustomRequest.SerializeToString, + param_dot_param__pb2.GetParamCustomResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def SetParamCustom(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.param.ParamService/SetParamCustom', + param_dot_param__pb2.SetParamCustomRequest.SerializeToString, + param_dot_param__pb2.SetParamCustomResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod def GetAllParams(request, target, diff --git a/mavsdk/param_server.py b/mavsdk/param_server.py index 1b712899..5dac9e4c 100644 --- a/mavsdk/param_server.py +++ b/mavsdk/param_server.py @@ -154,9 +154,83 @@ def translate_to_rpc(self, rpcFloatParam): +class CustomParam: + """ + Type for float parameters. + + Parameters + ---------- + name : std::string + Name of the parameter + + value : std::string + Value of the parameter + + """ + + + + def __init__( + self, + name, + value): + """ Initializes the CustomParam object """ + self.name = name + self.value = value + + def __eq__(self, to_compare): + """ Checks if two CustomParam are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # CustomParam object + return \ + (self.name == to_compare.name) and \ + (self.value == to_compare.value) + + except AttributeError: + return False + + def __str__(self): + """ CustomParam in string representation """ + struct_repr = ", ".join([ + "name: " + str(self.name), + "value: " + str(self.value) + ]) + + return f"CustomParam: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcCustomParam): + """ Translates a gRPC struct to the SDK equivalent """ + return CustomParam( + + rpcCustomParam.name, + + + rpcCustomParam.value + ) + + def translate_to_rpc(self, rpcCustomParam): + """ Translates this SDK object into its gRPC equivalent """ + + + + + rpcCustomParam.name = self.name + + + + + + rpcCustomParam.value = self.value + + + + + class AllParams: """ - Type collecting all integer and float parameters. + Type collecting all integer, float, and custom parameters. Parameters ---------- @@ -166,6 +240,9 @@ class AllParams: float_params : [FloatParam] Collection of all parameter names and values of type float + custom_params : [CustomParam] + Collection of all parameter names and values of type custom + """ @@ -173,10 +250,12 @@ class AllParams: def __init__( self, int_params, - float_params): + float_params, + custom_params): """ Initializes the AllParams object """ self.int_params = int_params self.float_params = float_params + self.custom_params = custom_params def __eq__(self, to_compare): """ Checks if two AllParams are the same """ @@ -185,7 +264,8 @@ def __eq__(self, to_compare): # AllParams object return \ (self.int_params == to_compare.int_params) and \ - (self.float_params == to_compare.float_params) + (self.float_params == to_compare.float_params) and \ + (self.custom_params == to_compare.custom_params) except AttributeError: return False @@ -194,7 +274,8 @@ def __str__(self): """ AllParams in string representation """ struct_repr = ", ".join([ "int_params: " + str(self.int_params), - "float_params: " + str(self.float_params) + "float_params: " + str(self.float_params), + "custom_params: " + str(self.custom_params) ]) return f"AllParams: [{struct_repr}]" @@ -207,7 +288,10 @@ def translate_from_rpc(rpcAllParams): list(map(lambda elem: IntParam.translate_from_rpc(elem), rpcAllParams.int_params)), - list(map(lambda elem: FloatParam.translate_from_rpc(elem), rpcAllParams.float_params)) + list(map(lambda elem: FloatParam.translate_from_rpc(elem), rpcAllParams.float_params)), + + + list(map(lambda elem: CustomParam.translate_from_rpc(elem), rpcAllParams.custom_params)) ) def translate_to_rpc(self, rpcAllParams): @@ -240,6 +324,19 @@ def translate_to_rpc(self, rpcAllParams): + + + rpc_elems_list = [] + for elem in self.custom_params: + + rpc_elem = param_server_pb2.CustomParam() + elem.translate_to_rpc(rpc_elem) + rpc_elems_list.append(rpc_elem) + + rpcAllParams.custom_params.extend(rpc_elems_list) + + + class ParamServerResult: @@ -282,6 +379,9 @@ class Result(Enum): NO_SYSTEM No system available + PARAM_VALUE_TOO_LONG + Parameter name too long (> 128) + """ @@ -291,6 +391,7 @@ class Result(Enum): WRONG_TYPE = 3 PARAM_NAME_TOO_LONG = 4 NO_SYSTEM = 5 + PARAM_VALUE_TOO_LONG = 6 def translate_to_rpc(self): if self == ParamServerResult.Result.UNKNOWN: @@ -305,6 +406,8 @@ def translate_to_rpc(self): return param_server_pb2.ParamServerResult.RESULT_PARAM_NAME_TOO_LONG if self == ParamServerResult.Result.NO_SYSTEM: return param_server_pb2.ParamServerResult.RESULT_NO_SYSTEM + if self == ParamServerResult.Result.PARAM_VALUE_TOO_LONG: + return param_server_pb2.ParamServerResult.RESULT_PARAM_VALUE_TOO_LONG @staticmethod def translate_from_rpc(rpc_enum_value): @@ -321,6 +424,8 @@ def translate_from_rpc(rpc_enum_value): return ParamServerResult.Result.PARAM_NAME_TOO_LONG if rpc_enum_value == param_server_pb2.ParamServerResult.RESULT_NO_SYSTEM: return ParamServerResult.Result.NO_SYSTEM + if rpc_enum_value == param_server_pb2.ParamServerResult.RESULT_PARAM_VALUE_TOO_LONG: + return ParamServerResult.Result.PARAM_VALUE_TOO_LONG def __str__(self): return self.name @@ -559,6 +664,77 @@ async def provide_param_float(self, name, value): raise ParamServerError(result, "provide_param_float()", name, value) + async def retrieve_param_custom(self, name): + """ + Retrieve a custom parameter. + + If the type is wrong, the result will be `WRONG_TYPE`. + + Parameters + ---------- + name : std::string + Name of the parameter + + Returns + ------- + value : std::string + Value of the requested parameter + + Raises + ------ + ParamServerError + If the request fails. The error contains the reason for the failure. + """ + + request = param_server_pb2.RetrieveParamCustomRequest() + + + request.name = name + + response = await self._stub.RetrieveParamCustom(request) + + + result = self._extract_result(response) + + if result.result != ParamServerResult.Result.SUCCESS: + raise ParamServerError(result, "retrieve_param_custom()", name) + + + return response.value + + + async def provide_param_custom(self, name, value): + """ + Provide a custom parameter. + + If the type is wrong, the result will be `WRONG_TYPE`. + + Parameters + ---------- + name : std::string + Name of the parameter to provide + + value : std::string + Value the parameter should be set to + + Raises + ------ + ParamServerError + If the request fails. The error contains the reason for the failure. + """ + + request = param_server_pb2.ProvideParamCustomRequest() + request.name = name + request.value = value + response = await self._stub.ProvideParamCustom(request) + + + result = self._extract_result(response) + + if result.result != ParamServerResult.Result.SUCCESS: + raise ParamServerError(result, "provide_param_custom()", name, value) + + async def retrieve_all_params(self): """ Retrieve all parameters. diff --git a/mavsdk/param_server_pb2.py b/mavsdk/param_server_pb2.py index c2c7378c..9edd3c6b 100644 --- a/mavsdk/param_server_pb2.py +++ b/mavsdk/param_server_pb2.py @@ -15,7 +15,7 @@ from . import mavsdk_options_pb2 as mavsdk__options__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1fparam_server/param_server.proto\x12\x17mavsdk.rpc.param_server\x1a\x14mavsdk_options.proto\"\'\n\x17RetrieveParamIntRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"r\n\x18RetrieveParamIntResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\x12\r\n\x05value\x18\x02 \x01(\x05\"5\n\x16ProvideParamIntRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\"b\n\x17ProvideParamIntResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\")\n\x19RetrieveParamFloatRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"t\n\x1aRetrieveParamFloatResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\x12\r\n\x05value\x18\x02 \x01(\x02\"7\n\x18ProvideParamFloatRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x02\"d\n\x19ProvideParamFloatResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\"\x1a\n\x18RetrieveAllParamsRequest\"O\n\x19RetrieveAllParamsResponse\x12\x32\n\x06params\x18\x01 \x01(\x0b\x32\".mavsdk.rpc.param_server.AllParams\"\'\n\x08IntParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\")\n\nFloatParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x02\"}\n\tAllParams\x12\x35\n\nint_params\x18\x01 \x03(\x0b\x32!.mavsdk.rpc.param_server.IntParam\x12\x39\n\x0c\x66loat_params\x18\x02 \x03(\x0b\x32#.mavsdk.rpc.param_server.FloatParam\"\x80\x02\n\x11ParamServerResult\x12\x41\n\x06result\x18\x01 \x01(\x0e\x32\x31.mavsdk.rpc.param_server.ParamServerResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\x93\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x14\n\x10RESULT_NOT_FOUND\x10\x02\x12\x15\n\x11RESULT_WRONG_TYPE\x10\x03\x12\x1e\n\x1aRESULT_PARAM_NAME_TOO_LONG\x10\x04\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x05\x32\x9b\x05\n\x12ParamServerService\x12}\n\x10RetrieveParamInt\x12\x30.mavsdk.rpc.param_server.RetrieveParamIntRequest\x1a\x31.mavsdk.rpc.param_server.RetrieveParamIntResponse\"\x04\x80\xb5\x18\x01\x12z\n\x0fProvideParamInt\x12/.mavsdk.rpc.param_server.ProvideParamIntRequest\x1a\x30.mavsdk.rpc.param_server.ProvideParamIntResponse\"\x04\x80\xb5\x18\x01\x12\x83\x01\n\x12RetrieveParamFloat\x12\x32.mavsdk.rpc.param_server.RetrieveParamFloatRequest\x1a\x33.mavsdk.rpc.param_server.RetrieveParamFloatResponse\"\x04\x80\xb5\x18\x01\x12\x80\x01\n\x11ProvideParamFloat\x12\x31.mavsdk.rpc.param_server.ProvideParamFloatRequest\x1a\x32.mavsdk.rpc.param_server.ProvideParamFloatResponse\"\x04\x80\xb5\x18\x01\x12\x80\x01\n\x11RetrieveAllParams\x12\x31.mavsdk.rpc.param_server.RetrieveAllParamsRequest\x1a\x32.mavsdk.rpc.param_server.RetrieveAllParamsResponse\"\x04\x80\xb5\x18\x01\x42*\n\x16io.mavsdk.param_serverB\x10ParamServerProtob\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1fparam_server/param_server.proto\x12\x17mavsdk.rpc.param_server\x1a\x14mavsdk_options.proto\"\'\n\x17RetrieveParamIntRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"r\n\x18RetrieveParamIntResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\x12\r\n\x05value\x18\x02 \x01(\x05\"5\n\x16ProvideParamIntRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\"b\n\x17ProvideParamIntResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\")\n\x19RetrieveParamFloatRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"t\n\x1aRetrieveParamFloatResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\x12\r\n\x05value\x18\x02 \x01(\x02\"7\n\x18ProvideParamFloatRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x02\"d\n\x19ProvideParamFloatResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\"*\n\x1aRetrieveParamCustomRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"u\n\x1bRetrieveParamCustomResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\x12\r\n\x05value\x18\x02 \x01(\t\"8\n\x19ProvideParamCustomRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\"e\n\x1aProvideParamCustomResponse\x12G\n\x13param_server_result\x18\x01 \x01(\x0b\x32*.mavsdk.rpc.param_server.ParamServerResult\"\x1a\n\x18RetrieveAllParamsRequest\"O\n\x19RetrieveAllParamsResponse\x12\x32\n\x06params\x18\x01 \x01(\x0b\x32\".mavsdk.rpc.param_server.AllParams\"\'\n\x08IntParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\")\n\nFloatParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x02\"*\n\x0b\x43ustomParam\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\"\xba\x01\n\tAllParams\x12\x35\n\nint_params\x18\x01 \x03(\x0b\x32!.mavsdk.rpc.param_server.IntParam\x12\x39\n\x0c\x66loat_params\x18\x02 \x03(\x0b\x32#.mavsdk.rpc.param_server.FloatParam\x12;\n\rcustom_params\x18\x03 \x03(\x0b\x32$.mavsdk.rpc.param_server.CustomParam\"\xa1\x02\n\x11ParamServerResult\x12\x41\n\x06result\x18\x01 \x01(\x0e\x32\x31.mavsdk.rpc.param_server.ParamServerResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\xb4\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x14\n\x10RESULT_NOT_FOUND\x10\x02\x12\x15\n\x11RESULT_WRONG_TYPE\x10\x03\x12\x1e\n\x1aRESULT_PARAM_NAME_TOO_LONG\x10\x04\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x05\x12\x1f\n\x1bRESULT_PARAM_VALUE_TOO_LONG\x10\x06\x32\xaa\x07\n\x12ParamServerService\x12}\n\x10RetrieveParamInt\x12\x30.mavsdk.rpc.param_server.RetrieveParamIntRequest\x1a\x31.mavsdk.rpc.param_server.RetrieveParamIntResponse\"\x04\x80\xb5\x18\x01\x12z\n\x0fProvideParamInt\x12/.mavsdk.rpc.param_server.ProvideParamIntRequest\x1a\x30.mavsdk.rpc.param_server.ProvideParamIntResponse\"\x04\x80\xb5\x18\x01\x12\x83\x01\n\x12RetrieveParamFloat\x12\x32.mavsdk.rpc.param_server.RetrieveParamFloatRequest\x1a\x33.mavsdk.rpc.param_server.RetrieveParamFloatResponse\"\x04\x80\xb5\x18\x01\x12\x80\x01\n\x11ProvideParamFloat\x12\x31.mavsdk.rpc.param_server.ProvideParamFloatRequest\x1a\x32.mavsdk.rpc.param_server.ProvideParamFloatResponse\"\x04\x80\xb5\x18\x01\x12\x86\x01\n\x13RetrieveParamCustom\x12\x33.mavsdk.rpc.param_server.RetrieveParamCustomRequest\x1a\x34.mavsdk.rpc.param_server.RetrieveParamCustomResponse\"\x04\x80\xb5\x18\x01\x12\x83\x01\n\x12ProvideParamCustom\x12\x32.mavsdk.rpc.param_server.ProvideParamCustomRequest\x1a\x33.mavsdk.rpc.param_server.ProvideParamCustomResponse\"\x04\x80\xb5\x18\x01\x12\x80\x01\n\x11RetrieveAllParams\x12\x31.mavsdk.rpc.param_server.RetrieveAllParamsRequest\x1a\x32.mavsdk.rpc.param_server.RetrieveAllParamsResponse\"\x04\x80\xb5\x18\x01\x42*\n\x16io.mavsdk.param_serverB\x10ParamServerProtob\x06proto3') @@ -27,10 +27,15 @@ _RETRIEVEPARAMFLOATRESPONSE = DESCRIPTOR.message_types_by_name['RetrieveParamFloatResponse'] _PROVIDEPARAMFLOATREQUEST = DESCRIPTOR.message_types_by_name['ProvideParamFloatRequest'] _PROVIDEPARAMFLOATRESPONSE = DESCRIPTOR.message_types_by_name['ProvideParamFloatResponse'] +_RETRIEVEPARAMCUSTOMREQUEST = DESCRIPTOR.message_types_by_name['RetrieveParamCustomRequest'] +_RETRIEVEPARAMCUSTOMRESPONSE = DESCRIPTOR.message_types_by_name['RetrieveParamCustomResponse'] +_PROVIDEPARAMCUSTOMREQUEST = DESCRIPTOR.message_types_by_name['ProvideParamCustomRequest'] +_PROVIDEPARAMCUSTOMRESPONSE = DESCRIPTOR.message_types_by_name['ProvideParamCustomResponse'] _RETRIEVEALLPARAMSREQUEST = DESCRIPTOR.message_types_by_name['RetrieveAllParamsRequest'] _RETRIEVEALLPARAMSRESPONSE = DESCRIPTOR.message_types_by_name['RetrieveAllParamsResponse'] _INTPARAM = DESCRIPTOR.message_types_by_name['IntParam'] _FLOATPARAM = DESCRIPTOR.message_types_by_name['FloatParam'] +_CUSTOMPARAM = DESCRIPTOR.message_types_by_name['CustomParam'] _ALLPARAMS = DESCRIPTOR.message_types_by_name['AllParams'] _PARAMSERVERRESULT = DESCRIPTOR.message_types_by_name['ParamServerResult'] _PARAMSERVERRESULT_RESULT = _PARAMSERVERRESULT.enum_types_by_name['Result'] @@ -90,6 +95,34 @@ }) _sym_db.RegisterMessage(ProvideParamFloatResponse) +RetrieveParamCustomRequest = _reflection.GeneratedProtocolMessageType('RetrieveParamCustomRequest', (_message.Message,), { + 'DESCRIPTOR' : _RETRIEVEPARAMCUSTOMREQUEST, + '__module__' : 'param_server.param_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param_server.RetrieveParamCustomRequest) + }) +_sym_db.RegisterMessage(RetrieveParamCustomRequest) + +RetrieveParamCustomResponse = _reflection.GeneratedProtocolMessageType('RetrieveParamCustomResponse', (_message.Message,), { + 'DESCRIPTOR' : _RETRIEVEPARAMCUSTOMRESPONSE, + '__module__' : 'param_server.param_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param_server.RetrieveParamCustomResponse) + }) +_sym_db.RegisterMessage(RetrieveParamCustomResponse) + +ProvideParamCustomRequest = _reflection.GeneratedProtocolMessageType('ProvideParamCustomRequest', (_message.Message,), { + 'DESCRIPTOR' : _PROVIDEPARAMCUSTOMREQUEST, + '__module__' : 'param_server.param_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param_server.ProvideParamCustomRequest) + }) +_sym_db.RegisterMessage(ProvideParamCustomRequest) + +ProvideParamCustomResponse = _reflection.GeneratedProtocolMessageType('ProvideParamCustomResponse', (_message.Message,), { + 'DESCRIPTOR' : _PROVIDEPARAMCUSTOMRESPONSE, + '__module__' : 'param_server.param_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param_server.ProvideParamCustomResponse) + }) +_sym_db.RegisterMessage(ProvideParamCustomResponse) + RetrieveAllParamsRequest = _reflection.GeneratedProtocolMessageType('RetrieveAllParamsRequest', (_message.Message,), { 'DESCRIPTOR' : _RETRIEVEALLPARAMSREQUEST, '__module__' : 'param_server.param_server_pb2' @@ -118,6 +151,13 @@ }) _sym_db.RegisterMessage(FloatParam) +CustomParam = _reflection.GeneratedProtocolMessageType('CustomParam', (_message.Message,), { + 'DESCRIPTOR' : _CUSTOMPARAM, + '__module__' : 'param_server.param_server_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.param_server.CustomParam) + }) +_sym_db.RegisterMessage(CustomParam) + AllParams = _reflection.GeneratedProtocolMessageType('AllParams', (_message.Message,), { 'DESCRIPTOR' : _ALLPARAMS, '__module__' : 'param_server.param_server_pb2' @@ -145,6 +185,10 @@ _PARAMSERVERSERVICE.methods_by_name['RetrieveParamFloat']._serialized_options = b'\200\265\030\001' _PARAMSERVERSERVICE.methods_by_name['ProvideParamFloat']._options = None _PARAMSERVERSERVICE.methods_by_name['ProvideParamFloat']._serialized_options = b'\200\265\030\001' + _PARAMSERVERSERVICE.methods_by_name['RetrieveParamCustom']._options = None + _PARAMSERVERSERVICE.methods_by_name['RetrieveParamCustom']._serialized_options = b'\200\265\030\001' + _PARAMSERVERSERVICE.methods_by_name['ProvideParamCustom']._options = None + _PARAMSERVERSERVICE.methods_by_name['ProvideParamCustom']._serialized_options = b'\200\265\030\001' _PARAMSERVERSERVICE.methods_by_name['RetrieveAllParams']._options = None _PARAMSERVERSERVICE.methods_by_name['RetrieveAllParams']._serialized_options = b'\200\265\030\001' _RETRIEVEPARAMINTREQUEST._serialized_start=82 @@ -163,20 +207,30 @@ _PROVIDEPARAMFLOATREQUEST._serialized_end=610 _PROVIDEPARAMFLOATRESPONSE._serialized_start=612 _PROVIDEPARAMFLOATRESPONSE._serialized_end=712 - _RETRIEVEALLPARAMSREQUEST._serialized_start=714 - _RETRIEVEALLPARAMSREQUEST._serialized_end=740 - _RETRIEVEALLPARAMSRESPONSE._serialized_start=742 - _RETRIEVEALLPARAMSRESPONSE._serialized_end=821 - _INTPARAM._serialized_start=823 - _INTPARAM._serialized_end=862 - _FLOATPARAM._serialized_start=864 - _FLOATPARAM._serialized_end=905 - _ALLPARAMS._serialized_start=907 - _ALLPARAMS._serialized_end=1032 - _PARAMSERVERRESULT._serialized_start=1035 - _PARAMSERVERRESULT._serialized_end=1291 - _PARAMSERVERRESULT_RESULT._serialized_start=1144 - _PARAMSERVERRESULT_RESULT._serialized_end=1291 - _PARAMSERVERSERVICE._serialized_start=1294 - _PARAMSERVERSERVICE._serialized_end=1961 + _RETRIEVEPARAMCUSTOMREQUEST._serialized_start=714 + _RETRIEVEPARAMCUSTOMREQUEST._serialized_end=756 + _RETRIEVEPARAMCUSTOMRESPONSE._serialized_start=758 + _RETRIEVEPARAMCUSTOMRESPONSE._serialized_end=875 + _PROVIDEPARAMCUSTOMREQUEST._serialized_start=877 + _PROVIDEPARAMCUSTOMREQUEST._serialized_end=933 + _PROVIDEPARAMCUSTOMRESPONSE._serialized_start=935 + _PROVIDEPARAMCUSTOMRESPONSE._serialized_end=1036 + _RETRIEVEALLPARAMSREQUEST._serialized_start=1038 + _RETRIEVEALLPARAMSREQUEST._serialized_end=1064 + _RETRIEVEALLPARAMSRESPONSE._serialized_start=1066 + _RETRIEVEALLPARAMSRESPONSE._serialized_end=1145 + _INTPARAM._serialized_start=1147 + _INTPARAM._serialized_end=1186 + _FLOATPARAM._serialized_start=1188 + _FLOATPARAM._serialized_end=1229 + _CUSTOMPARAM._serialized_start=1231 + _CUSTOMPARAM._serialized_end=1273 + _ALLPARAMS._serialized_start=1276 + _ALLPARAMS._serialized_end=1462 + _PARAMSERVERRESULT._serialized_start=1465 + _PARAMSERVERRESULT._serialized_end=1754 + _PARAMSERVERRESULT_RESULT._serialized_start=1574 + _PARAMSERVERRESULT_RESULT._serialized_end=1754 + _PARAMSERVERSERVICE._serialized_start=1757 + _PARAMSERVERSERVICE._serialized_end=2695 # @@protoc_insertion_point(module_scope) diff --git a/mavsdk/param_server_pb2_grpc.py b/mavsdk/param_server_pb2_grpc.py index 2bd8127e..d7721b0d 100644 --- a/mavsdk/param_server_pb2_grpc.py +++ b/mavsdk/param_server_pb2_grpc.py @@ -35,6 +35,16 @@ def __init__(self, channel): request_serializer=param__server_dot_param__server__pb2.ProvideParamFloatRequest.SerializeToString, response_deserializer=param__server_dot_param__server__pb2.ProvideParamFloatResponse.FromString, ) + self.RetrieveParamCustom = channel.unary_unary( + '/mavsdk.rpc.param_server.ParamServerService/RetrieveParamCustom', + request_serializer=param__server_dot_param__server__pb2.RetrieveParamCustomRequest.SerializeToString, + response_deserializer=param__server_dot_param__server__pb2.RetrieveParamCustomResponse.FromString, + ) + self.ProvideParamCustom = channel.unary_unary( + '/mavsdk.rpc.param_server.ParamServerService/ProvideParamCustom', + request_serializer=param__server_dot_param__server__pb2.ProvideParamCustomRequest.SerializeToString, + response_deserializer=param__server_dot_param__server__pb2.ProvideParamCustomResponse.FromString, + ) self.RetrieveAllParams = channel.unary_unary( '/mavsdk.rpc.param_server.ParamServerService/RetrieveAllParams', request_serializer=param__server_dot_param__server__pb2.RetrieveAllParamsRequest.SerializeToString, @@ -86,6 +96,26 @@ def ProvideParamFloat(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def RetrieveParamCustom(self, request, context): + """ + Retrieve a custom parameter. + + If the type is wrong, the result will be `WRONG_TYPE`. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def ProvideParamCustom(self, request, context): + """ + Provide a custom parameter. + + If the type is wrong, the result will be `WRONG_TYPE`. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def RetrieveAllParams(self, request, context): """ Retrieve all parameters. @@ -117,6 +147,16 @@ def add_ParamServerServiceServicer_to_server(servicer, server): request_deserializer=param__server_dot_param__server__pb2.ProvideParamFloatRequest.FromString, response_serializer=param__server_dot_param__server__pb2.ProvideParamFloatResponse.SerializeToString, ), + 'RetrieveParamCustom': grpc.unary_unary_rpc_method_handler( + servicer.RetrieveParamCustom, + request_deserializer=param__server_dot_param__server__pb2.RetrieveParamCustomRequest.FromString, + response_serializer=param__server_dot_param__server__pb2.RetrieveParamCustomResponse.SerializeToString, + ), + 'ProvideParamCustom': grpc.unary_unary_rpc_method_handler( + servicer.ProvideParamCustom, + request_deserializer=param__server_dot_param__server__pb2.ProvideParamCustomRequest.FromString, + response_serializer=param__server_dot_param__server__pb2.ProvideParamCustomResponse.SerializeToString, + ), 'RetrieveAllParams': grpc.unary_unary_rpc_method_handler( servicer.RetrieveAllParams, request_deserializer=param__server_dot_param__server__pb2.RetrieveAllParamsRequest.FromString, @@ -201,6 +241,40 @@ def ProvideParamFloat(request, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod + def RetrieveParamCustom(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.param_server.ParamServerService/RetrieveParamCustom', + param__server_dot_param__server__pb2.RetrieveParamCustomRequest.SerializeToString, + param__server_dot_param__server__pb2.RetrieveParamCustomResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def ProvideParamCustom(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.param_server.ParamServerService/ProvideParamCustom', + param__server_dot_param__server__pb2.ProvideParamCustomRequest.SerializeToString, + param__server_dot_param__server__pb2.ProvideParamCustomResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod def RetrieveAllParams(request, target, diff --git a/mavsdk/rtk.py b/mavsdk/rtk.py new file mode 100644 index 00000000..3321458c --- /dev/null +++ b/mavsdk/rtk.py @@ -0,0 +1,261 @@ +# -*- coding: utf-8 -*- +# DO NOT EDIT! This file is auto-generated from +# https://github.com/mavlink/MAVSDK-Python/tree/main/other/templates/py +from ._base import AsyncBase +from . import rtk_pb2, rtk_pb2_grpc +from enum import Enum + + +class RtcmData: + """ + RTCM data type + + Parameters + ---------- + data : std::string + The data encoded as a string + + """ + + + + def __init__( + self, + data): + """ Initializes the RtcmData object """ + self.data = data + + def __eq__(self, to_compare): + """ Checks if two RtcmData are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # RtcmData object + return \ + (self.data == to_compare.data) + + except AttributeError: + return False + + def __str__(self): + """ RtcmData in string representation """ + struct_repr = ", ".join([ + "data: " + str(self.data) + ]) + + return f"RtcmData: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcRtcmData): + """ Translates a gRPC struct to the SDK equivalent """ + return RtcmData( + + rpcRtcmData.data + ) + + def translate_to_rpc(self, rpcRtcmData): + """ Translates this SDK object into its gRPC equivalent """ + + + + + rpcRtcmData.data = self.data + + + + + +class RtkResult: + """ + + + Parameters + ---------- + result : Result + Result enum value + + result_str : std::string + Human-readable English string describing the result + + """ + + + + class Result(Enum): + """ + Possible results returned for rtk requests. + + Values + ------ + UNKNOWN + Unknown result + + SUCCESS + Request succeeded + + TOO_LONG + Passed data is too long + + NO_SYSTEM + No system connected + + CONNECTION_ERROR + Connection error + + """ + + + UNKNOWN = 0 + SUCCESS = 1 + TOO_LONG = 2 + NO_SYSTEM = 3 + CONNECTION_ERROR = 4 + + def translate_to_rpc(self): + if self == RtkResult.Result.UNKNOWN: + return rtk_pb2.RtkResult.RESULT_UNKNOWN + if self == RtkResult.Result.SUCCESS: + return rtk_pb2.RtkResult.RESULT_SUCCESS + if self == RtkResult.Result.TOO_LONG: + return rtk_pb2.RtkResult.RESULT_TOO_LONG + if self == RtkResult.Result.NO_SYSTEM: + return rtk_pb2.RtkResult.RESULT_NO_SYSTEM + if self == RtkResult.Result.CONNECTION_ERROR: + return rtk_pb2.RtkResult.RESULT_CONNECTION_ERROR + + @staticmethod + def translate_from_rpc(rpc_enum_value): + """ Parses a gRPC response """ + if rpc_enum_value == rtk_pb2.RtkResult.RESULT_UNKNOWN: + return RtkResult.Result.UNKNOWN + if rpc_enum_value == rtk_pb2.RtkResult.RESULT_SUCCESS: + return RtkResult.Result.SUCCESS + if rpc_enum_value == rtk_pb2.RtkResult.RESULT_TOO_LONG: + return RtkResult.Result.TOO_LONG + if rpc_enum_value == rtk_pb2.RtkResult.RESULT_NO_SYSTEM: + return RtkResult.Result.NO_SYSTEM + if rpc_enum_value == rtk_pb2.RtkResult.RESULT_CONNECTION_ERROR: + return RtkResult.Result.CONNECTION_ERROR + + def __str__(self): + return self.name + + + def __init__( + self, + result, + result_str): + """ Initializes the RtkResult object """ + self.result = result + self.result_str = result_str + + def __eq__(self, to_compare): + """ Checks if two RtkResult are the same """ + try: + # Try to compare - this likely fails when it is compared to a non + # RtkResult object + return \ + (self.result == to_compare.result) and \ + (self.result_str == to_compare.result_str) + + except AttributeError: + return False + + def __str__(self): + """ RtkResult in string representation """ + struct_repr = ", ".join([ + "result: " + str(self.result), + "result_str: " + str(self.result_str) + ]) + + return f"RtkResult: [{struct_repr}]" + + @staticmethod + def translate_from_rpc(rpcRtkResult): + """ Translates a gRPC struct to the SDK equivalent """ + return RtkResult( + + RtkResult.Result.translate_from_rpc(rpcRtkResult.result), + + + rpcRtkResult.result_str + ) + + def translate_to_rpc(self, rpcRtkResult): + """ Translates this SDK object into its gRPC equivalent """ + + + + + rpcRtkResult.result = self.result.translate_to_rpc() + + + + + + rpcRtkResult.result_str = self.result_str + + + + + + +class RtkError(Exception): + """ Raised when a RtkResult is a fail code """ + + def __init__(self, result, origin, *params): + self._result = result + self._origin = origin + self._params = params + + def __str__(self): + return f"{self._result.result}: '{self._result.result_str}'; origin: {self._origin}; params: {self._params}" + + +class Rtk(AsyncBase): + """ + Service to send RTK corrections to the vehicle. + + Generated by dcsdkgen - MAVSDK Rtk API + """ + + # Plugin name + name = "Rtk" + + def _setup_stub(self, channel): + """ Setups the api stub """ + self._stub = rtk_pb2_grpc.RtkServiceStub(channel) + + + def _extract_result(self, response): + """ Returns the response status and description """ + return RtkResult.translate_from_rpc(response.rtk_result) + + + async def send_rtcm_data(self, rtcm_data): + """ + Send RTCM data. + + Parameters + ---------- + rtcm_data : RtcmData + The data + + Raises + ------ + RtkError + If the request fails. The error contains the reason for the failure. + """ + + request = rtk_pb2.SendRtcmDataRequest() + + rtcm_data.translate_to_rpc(request.rtcm_data) + + + response = await self._stub.SendRtcmData(request) + + + result = self._extract_result(response) + + if result.result != RtkResult.Result.SUCCESS: + raise RtkError(result, "send_rtcm_data()", rtcm_data) + \ No newline at end of file diff --git a/mavsdk/rtk_pb2.py b/mavsdk/rtk_pb2.py new file mode 100644 index 00000000..8ec0b962 --- /dev/null +++ b/mavsdk/rtk_pb2.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: rtk/rtk.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from . import mavsdk_options_pb2 as mavsdk__options__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rrtk/rtk.proto\x12\x0emavsdk.rpc.rtk\x1a\x14mavsdk_options.proto\"\x18\n\x08RtcmData\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\t\"B\n\x13SendRtcmDataRequest\x12+\n\trtcm_data\x18\x01 \x01(\x0b\x32\x18.mavsdk.rpc.rtk.RtcmData\"E\n\x14SendRtcmDataResponse\x12-\n\nrtk_result\x18\x01 \x01(\x0b\x32\x19.mavsdk.rpc.rtk.RtkResult\"\xcb\x01\n\tRtkResult\x12\x30\n\x06result\x18\x01 \x01(\x0e\x32 .mavsdk.rpc.rtk.RtkResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"x\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x13\n\x0fRESULT_TOO_LONG\x10\x02\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x05\x12\x1b\n\x17RESULT_CONNECTION_ERROR\x10\x06\x32m\n\nRtkService\x12_\n\x0cSendRtcmData\x12#.mavsdk.rpc.rtk.SendRtcmDataRequest\x1a$.mavsdk.rpc.rtk.SendRtcmDataResponse\"\x04\x80\xb5\x18\x01\x42\x19\n\rio.mavsdk.rtkB\x08RtkProtob\x06proto3') + + + +_RTCMDATA = DESCRIPTOR.message_types_by_name['RtcmData'] +_SENDRTCMDATAREQUEST = DESCRIPTOR.message_types_by_name['SendRtcmDataRequest'] +_SENDRTCMDATARESPONSE = DESCRIPTOR.message_types_by_name['SendRtcmDataResponse'] +_RTKRESULT = DESCRIPTOR.message_types_by_name['RtkResult'] +_RTKRESULT_RESULT = _RTKRESULT.enum_types_by_name['Result'] +RtcmData = _reflection.GeneratedProtocolMessageType('RtcmData', (_message.Message,), { + 'DESCRIPTOR' : _RTCMDATA, + '__module__' : 'rtk.rtk_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.rtk.RtcmData) + }) +_sym_db.RegisterMessage(RtcmData) + +SendRtcmDataRequest = _reflection.GeneratedProtocolMessageType('SendRtcmDataRequest', (_message.Message,), { + 'DESCRIPTOR' : _SENDRTCMDATAREQUEST, + '__module__' : 'rtk.rtk_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.rtk.SendRtcmDataRequest) + }) +_sym_db.RegisterMessage(SendRtcmDataRequest) + +SendRtcmDataResponse = _reflection.GeneratedProtocolMessageType('SendRtcmDataResponse', (_message.Message,), { + 'DESCRIPTOR' : _SENDRTCMDATARESPONSE, + '__module__' : 'rtk.rtk_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.rtk.SendRtcmDataResponse) + }) +_sym_db.RegisterMessage(SendRtcmDataResponse) + +RtkResult = _reflection.GeneratedProtocolMessageType('RtkResult', (_message.Message,), { + 'DESCRIPTOR' : _RTKRESULT, + '__module__' : 'rtk.rtk_pb2' + # @@protoc_insertion_point(class_scope:mavsdk.rpc.rtk.RtkResult) + }) +_sym_db.RegisterMessage(RtkResult) + +_RTKSERVICE = DESCRIPTOR.services_by_name['RtkService'] +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'\n\rio.mavsdk.rtkB\010RtkProto' + _RTKSERVICE.methods_by_name['SendRtcmData']._options = None + _RTKSERVICE.methods_by_name['SendRtcmData']._serialized_options = b'\200\265\030\001' + _RTCMDATA._serialized_start=55 + _RTCMDATA._serialized_end=79 + _SENDRTCMDATAREQUEST._serialized_start=81 + _SENDRTCMDATAREQUEST._serialized_end=147 + _SENDRTCMDATARESPONSE._serialized_start=149 + _SENDRTCMDATARESPONSE._serialized_end=218 + _RTKRESULT._serialized_start=221 + _RTKRESULT._serialized_end=424 + _RTKRESULT_RESULT._serialized_start=304 + _RTKRESULT_RESULT._serialized_end=424 + _RTKSERVICE._serialized_start=426 + _RTKSERVICE._serialized_end=535 +# @@protoc_insertion_point(module_scope) diff --git a/mavsdk/rtk_pb2_grpc.py b/mavsdk/rtk_pb2_grpc.py new file mode 100644 index 00000000..0eafc465 --- /dev/null +++ b/mavsdk/rtk_pb2_grpc.py @@ -0,0 +1,70 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + +from . import rtk_pb2 as rtk_dot_rtk__pb2 + + +class RtkServiceStub(object): + """Service to send RTK corrections to the vehicle. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.SendRtcmData = channel.unary_unary( + '/mavsdk.rpc.rtk.RtkService/SendRtcmData', + request_serializer=rtk_dot_rtk__pb2.SendRtcmDataRequest.SerializeToString, + response_deserializer=rtk_dot_rtk__pb2.SendRtcmDataResponse.FromString, + ) + + +class RtkServiceServicer(object): + """Service to send RTK corrections to the vehicle. + """ + + def SendRtcmData(self, request, context): + """Send RTCM data. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_RtkServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'SendRtcmData': grpc.unary_unary_rpc_method_handler( + servicer.SendRtcmData, + request_deserializer=rtk_dot_rtk__pb2.SendRtcmDataRequest.FromString, + response_serializer=rtk_dot_rtk__pb2.SendRtcmDataResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'mavsdk.rpc.rtk.RtkService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + # This class is part of an EXPERIMENTAL API. +class RtkService(object): + """Service to send RTK corrections to the vehicle. + """ + + @staticmethod + def SendRtcmData(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.rtk.RtkService/SendRtcmData', + rtk_dot_rtk__pb2.SendRtcmDataRequest.SerializeToString, + rtk_dot_rtk__pb2.SendRtcmDataResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/mavsdk/source/plugins/camera_server.rst b/mavsdk/source/plugins/camera_server.rst new file mode 100644 index 00000000..f65c96e6 --- /dev/null +++ b/mavsdk/source/plugins/camera_server.rst @@ -0,0 +1,8 @@ +CameraServer +==== + +.. automodule:: mavsdk.camera_server + :members: + :undoc-members: + :show-inheritance: + :exclude-members: translate_from_rpc, translate_to_rpc \ No newline at end of file diff --git a/mavsdk/source/plugins/index.rst b/mavsdk/source/plugins/index.rst index 6c8771ac..811b4e34 100644 --- a/mavsdk/source/plugins/index.rst +++ b/mavsdk/source/plugins/index.rst @@ -33,3 +33,5 @@ Plugins tracking_server transponder tune + camera_server + rtk diff --git a/mavsdk/source/plugins/rtk.rst b/mavsdk/source/plugins/rtk.rst new file mode 100644 index 00000000..ca0a94de --- /dev/null +++ b/mavsdk/source/plugins/rtk.rst @@ -0,0 +1,8 @@ +Rtk +==== + +.. automodule:: mavsdk.rtk + :members: + :undoc-members: + :show-inheritance: + :exclude-members: translate_from_rpc, translate_to_rpc \ No newline at end of file diff --git a/mavsdk/transponder.py b/mavsdk/transponder.py index 5dd92d15..a1d487e9 100644 --- a/mavsdk/transponder.py +++ b/mavsdk/transponder.py @@ -222,6 +222,9 @@ class AdsbVehicle: squawk : uint32_t Squawk code. + tslc_s : uint32_t + Time Since Last Communication in seconds. + """ @@ -237,7 +240,8 @@ def __init__( vertical_velocity_m_s, callsign, emitter_type, - squawk): + squawk, + tslc_s): """ Initializes the AdsbVehicle object """ self.icao_address = icao_address self.latitude_deg = latitude_deg @@ -249,6 +253,7 @@ def __init__( self.callsign = callsign self.emitter_type = emitter_type self.squawk = squawk + self.tslc_s = tslc_s def __eq__(self, to_compare): """ Checks if two AdsbVehicle are the same """ @@ -265,7 +270,8 @@ def __eq__(self, to_compare): (self.vertical_velocity_m_s == to_compare.vertical_velocity_m_s) and \ (self.callsign == to_compare.callsign) and \ (self.emitter_type == to_compare.emitter_type) and \ - (self.squawk == to_compare.squawk) + (self.squawk == to_compare.squawk) and \ + (self.tslc_s == to_compare.tslc_s) except AttributeError: return False @@ -282,7 +288,8 @@ def __str__(self): "vertical_velocity_m_s: " + str(self.vertical_velocity_m_s), "callsign: " + str(self.callsign), "emitter_type: " + str(self.emitter_type), - "squawk: " + str(self.squawk) + "squawk: " + str(self.squawk), + "tslc_s: " + str(self.tslc_s) ]) return f"AdsbVehicle: [{struct_repr}]" @@ -319,7 +326,10 @@ def translate_from_rpc(rpcAdsbVehicle): AdsbEmitterType.translate_from_rpc(rpcAdsbVehicle.emitter_type), - rpcAdsbVehicle.squawk + rpcAdsbVehicle.squawk, + + + rpcAdsbVehicle.tslc_s ) def translate_to_rpc(self, rpcAdsbVehicle): @@ -386,6 +396,12 @@ def translate_to_rpc(self, rpcAdsbVehicle): + + + rpcAdsbVehicle.tslc_s = self.tslc_s + + + class TransponderResult: diff --git a/mavsdk/transponder_pb2.py b/mavsdk/transponder_pb2.py index 6b98f826..705bd61b 100644 --- a/mavsdk/transponder_pb2.py +++ b/mavsdk/transponder_pb2.py @@ -15,7 +15,7 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1dtransponder/transponder.proto\x12\x16mavsdk.rpc.transponder\"\x1d\n\x1bSubscribeTransponderRequest\"O\n\x13TransponderResponse\x12\x38\n\x0btransponder\x18\x01 \x01(\x0b\x32#.mavsdk.rpc.transponder.AdsbVehicle\",\n\x19SetRateTransponderRequest\x12\x0f\n\x07rate_hz\x18\x01 \x01(\x01\"c\n\x1aSetRateTransponderResponse\x12\x45\n\x12transponder_result\x18\x01 \x01(\x0b\x32).mavsdk.rpc.transponder.TransponderResult\"\xa3\x02\n\x0b\x41\x64sbVehicle\x12\x14\n\x0cicao_address\x18\x01 \x01(\r\x12\x14\n\x0clatitude_deg\x18\x02 \x01(\x01\x12\x15\n\rlongitude_deg\x18\x03 \x01(\x01\x12\x1b\n\x13\x61\x62solute_altitude_m\x18\x05 \x01(\x02\x12\x13\n\x0bheading_deg\x18\x06 \x01(\x02\x12\x1f\n\x17horizontal_velocity_m_s\x18\x07 \x01(\x02\x12\x1d\n\x15vertical_velocity_m_s\x18\x08 \x01(\x02\x12\x10\n\x08\x63\x61llsign\x18\t \x01(\t\x12=\n\x0c\x65mitter_type\x18\n \x01(\x0e\x32\'.mavsdk.rpc.transponder.AdsbEmitterType\x12\x0e\n\x06squawk\x18\r \x01(\r\"\x8f\x02\n\x11TransponderResult\x12@\n\x06result\x18\x01 \x01(\x0e\x32\x30.mavsdk.rpc.transponder.TransponderResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\xa3\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x02\x12\x1b\n\x17RESULT_CONNECTION_ERROR\x10\x03\x12\x0f\n\x0bRESULT_BUSY\x10\x04\x12\x19\n\x15RESULT_COMMAND_DENIED\x10\x05\x12\x12\n\x0eRESULT_TIMEOUT\x10\x06*\xad\x05\n\x0f\x41\x64sbEmitterType\x12\x1d\n\x19\x41\x44SB_EMITTER_TYPE_NO_INFO\x10\x00\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_LIGHT\x10\x01\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_SMALL\x10\x02\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_LARGE\x10\x03\x12\'\n#ADSB_EMITTER_TYPE_HIGH_VORTEX_LARGE\x10\x04\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_HEAVY\x10\x05\x12\"\n\x1e\x41\x44SB_EMITTER_TYPE_HIGHLY_MANUV\x10\x06\x12\x1f\n\x1b\x41\x44SB_EMITTER_TYPE_ROTOCRAFT\x10\x07\x12 \n\x1c\x41\x44SB_EMITTER_TYPE_UNASSIGNED\x10\x08\x12\x1c\n\x18\x41\x44SB_EMITTER_TYPE_GLIDER\x10\t\x12!\n\x1d\x41\x44SB_EMITTER_TYPE_LIGHTER_AIR\x10\n\x12\x1f\n\x1b\x41\x44SB_EMITTER_TYPE_PARACHUTE\x10\x0b\x12!\n\x1d\x41\x44SB_EMITTER_TYPE_ULTRA_LIGHT\x10\x0c\x12!\n\x1d\x41\x44SB_EMITTER_TYPE_UNASSIGNED2\x10\r\x12\x19\n\x15\x41\x44SB_EMITTER_TYPE_UAV\x10\x0e\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_SPACE\x10\x0f\x12!\n\x1d\x41\x44SB_EMITTER_TYPE_UNASSGINED3\x10\x10\x12\'\n#ADSB_EMITTER_TYPE_EMERGENCY_SURFACE\x10\x11\x12%\n!ADSB_EMITTER_TYPE_SERVICE_SURFACE\x10\x12\x12$\n ADSB_EMITTER_TYPE_POINT_OBSTACLE\x10\x13\x32\x91\x02\n\x12TransponderService\x12|\n\x14SubscribeTransponder\x12\x33.mavsdk.rpc.transponder.SubscribeTransponderRequest\x1a+.mavsdk.rpc.transponder.TransponderResponse\"\x00\x30\x01\x12}\n\x12SetRateTransponder\x12\x31.mavsdk.rpc.transponder.SetRateTransponderRequest\x1a\x32.mavsdk.rpc.transponder.SetRateTransponderResponse\"\x00\x42)\n\x15io.mavsdk.transponderB\x10TransponderProtob\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1dtransponder/transponder.proto\x12\x16mavsdk.rpc.transponder\"\x1d\n\x1bSubscribeTransponderRequest\"O\n\x13TransponderResponse\x12\x38\n\x0btransponder\x18\x01 \x01(\x0b\x32#.mavsdk.rpc.transponder.AdsbVehicle\",\n\x19SetRateTransponderRequest\x12\x0f\n\x07rate_hz\x18\x01 \x01(\x01\"c\n\x1aSetRateTransponderResponse\x12\x45\n\x12transponder_result\x18\x01 \x01(\x0b\x32).mavsdk.rpc.transponder.TransponderResult\"\xb3\x02\n\x0b\x41\x64sbVehicle\x12\x14\n\x0cicao_address\x18\x01 \x01(\r\x12\x14\n\x0clatitude_deg\x18\x02 \x01(\x01\x12\x15\n\rlongitude_deg\x18\x03 \x01(\x01\x12\x1b\n\x13\x61\x62solute_altitude_m\x18\x05 \x01(\x02\x12\x13\n\x0bheading_deg\x18\x06 \x01(\x02\x12\x1f\n\x17horizontal_velocity_m_s\x18\x07 \x01(\x02\x12\x1d\n\x15vertical_velocity_m_s\x18\x08 \x01(\x02\x12\x10\n\x08\x63\x61llsign\x18\t \x01(\t\x12=\n\x0c\x65mitter_type\x18\n \x01(\x0e\x32\'.mavsdk.rpc.transponder.AdsbEmitterType\x12\x0e\n\x06squawk\x18\r \x01(\r\x12\x0e\n\x06tslc_s\x18\x0e \x01(\r\"\x8f\x02\n\x11TransponderResult\x12@\n\x06result\x18\x01 \x01(\x0e\x32\x30.mavsdk.rpc.transponder.TransponderResult.Result\x12\x12\n\nresult_str\x18\x02 \x01(\t\"\xa3\x01\n\x06Result\x12\x12\n\x0eRESULT_UNKNOWN\x10\x00\x12\x12\n\x0eRESULT_SUCCESS\x10\x01\x12\x14\n\x10RESULT_NO_SYSTEM\x10\x02\x12\x1b\n\x17RESULT_CONNECTION_ERROR\x10\x03\x12\x0f\n\x0bRESULT_BUSY\x10\x04\x12\x19\n\x15RESULT_COMMAND_DENIED\x10\x05\x12\x12\n\x0eRESULT_TIMEOUT\x10\x06*\xad\x05\n\x0f\x41\x64sbEmitterType\x12\x1d\n\x19\x41\x44SB_EMITTER_TYPE_NO_INFO\x10\x00\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_LIGHT\x10\x01\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_SMALL\x10\x02\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_LARGE\x10\x03\x12\'\n#ADSB_EMITTER_TYPE_HIGH_VORTEX_LARGE\x10\x04\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_HEAVY\x10\x05\x12\"\n\x1e\x41\x44SB_EMITTER_TYPE_HIGHLY_MANUV\x10\x06\x12\x1f\n\x1b\x41\x44SB_EMITTER_TYPE_ROTOCRAFT\x10\x07\x12 \n\x1c\x41\x44SB_EMITTER_TYPE_UNASSIGNED\x10\x08\x12\x1c\n\x18\x41\x44SB_EMITTER_TYPE_GLIDER\x10\t\x12!\n\x1d\x41\x44SB_EMITTER_TYPE_LIGHTER_AIR\x10\n\x12\x1f\n\x1b\x41\x44SB_EMITTER_TYPE_PARACHUTE\x10\x0b\x12!\n\x1d\x41\x44SB_EMITTER_TYPE_ULTRA_LIGHT\x10\x0c\x12!\n\x1d\x41\x44SB_EMITTER_TYPE_UNASSIGNED2\x10\r\x12\x19\n\x15\x41\x44SB_EMITTER_TYPE_UAV\x10\x0e\x12\x1b\n\x17\x41\x44SB_EMITTER_TYPE_SPACE\x10\x0f\x12!\n\x1d\x41\x44SB_EMITTER_TYPE_UNASSGINED3\x10\x10\x12\'\n#ADSB_EMITTER_TYPE_EMERGENCY_SURFACE\x10\x11\x12%\n!ADSB_EMITTER_TYPE_SERVICE_SURFACE\x10\x12\x12$\n ADSB_EMITTER_TYPE_POINT_OBSTACLE\x10\x13\x32\x91\x02\n\x12TransponderService\x12|\n\x14SubscribeTransponder\x12\x33.mavsdk.rpc.transponder.SubscribeTransponderRequest\x1a+.mavsdk.rpc.transponder.TransponderResponse\"\x00\x30\x01\x12}\n\x12SetRateTransponder\x12\x31.mavsdk.rpc.transponder.SetRateTransponderRequest\x1a\x32.mavsdk.rpc.transponder.SetRateTransponderResponse\"\x00\x42)\n\x15io.mavsdk.transponderB\x10TransponderProtob\x06proto3') _ADSBEMITTERTYPE = DESCRIPTOR.enum_types_by_name['AdsbEmitterType'] AdsbEmitterType = enum_type_wrapper.EnumTypeWrapper(_ADSBEMITTERTYPE) @@ -95,8 +95,8 @@ DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n\025io.mavsdk.transponderB\020TransponderProto' - _ADSBEMITTERTYPE._serialized_start=885 - _ADSBEMITTERTYPE._serialized_end=1570 + _ADSBEMITTERTYPE._serialized_start=901 + _ADSBEMITTERTYPE._serialized_end=1586 _SUBSCRIBETRANSPONDERREQUEST._serialized_start=57 _SUBSCRIBETRANSPONDERREQUEST._serialized_end=86 _TRANSPONDERRESPONSE._serialized_start=88 @@ -106,11 +106,11 @@ _SETRATETRANSPONDERRESPONSE._serialized_start=215 _SETRATETRANSPONDERRESPONSE._serialized_end=314 _ADSBVEHICLE._serialized_start=317 - _ADSBVEHICLE._serialized_end=608 - _TRANSPONDERRESULT._serialized_start=611 - _TRANSPONDERRESULT._serialized_end=882 - _TRANSPONDERRESULT_RESULT._serialized_start=719 - _TRANSPONDERRESULT_RESULT._serialized_end=882 - _TRANSPONDERSERVICE._serialized_start=1573 - _TRANSPONDERSERVICE._serialized_end=1846 + _ADSBVEHICLE._serialized_end=624 + _TRANSPONDERRESULT._serialized_start=627 + _TRANSPONDERRESULT._serialized_end=898 + _TRANSPONDERRESULT_RESULT._serialized_start=735 + _TRANSPONDERRESULT_RESULT._serialized_end=898 + _TRANSPONDERSERVICE._serialized_start=1589 + _TRANSPONDERSERVICE._serialized_end=1862 # @@protoc_insertion_point(module_scope) diff --git a/proto b/proto index 6a705980..b9a1c1a5 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 6a70598087fa8fccda6ef7d89cc498550685659d +Subproject commit b9a1c1a51fc3344ee914d0d625f1eafc4189660f