From 11be846515046931953119ea17d78dbc066ea860 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 29 Aug 2024 14:28:50 +1200 Subject: [PATCH] camera: change API to support multiple cameras This changes the API to support more than one camera within one camera plugin instance. This will enable multiple cameras in language wrappers instead of just C++ as it is now. --- protos/camera/camera.proto | 381 ++++++++++++++++++++++++------------- protos/gimbal/gimbal.proto | 2 +- 2 files changed, 246 insertions(+), 137 deletions(-) diff --git a/protos/camera/camera.proto b/protos/camera/camera.proto index dcadaf88..cde20cba 100644 --- a/protos/camera/camera.proto +++ b/protos/camera/camera.proto @@ -17,10 +17,6 @@ option java_outer_classname = "CameraProto"; * `select_camera`. */ service CameraService { - /* - * Prepare the camera plugin (e.g. download the camera definition, etc). - */ - rpc Prepare(PrepareRequest) returns(PrepareResponse) {} /* * Take one photo. */ @@ -54,21 +50,32 @@ service CameraService { */ rpc SetMode(SetModeRequest) returns(SetModeResponse) {} /* - * List photos available on the camera. + * List photos available on the camera (currently not implemented). */ rpc ListPhotos(ListPhotosRequest) returns(ListPhotosResponse) {} + /* + * Subscribe to list of cameras. + * + * This allows to find out what cameras are connected to the system. + * Based on the camera ID, we can then address a specific camera. + */ + rpc SubscribeCameraList(SubscribeCameraListRequest) returns(stream CameraListResponse) {} /* * Subscribe to camera mode updates. */ - rpc SubscribeMode(SubscribeModeRequest) returns(stream ModeResponse) {} + rpc SubscribeMode(SubscribeModeRequest) returns(stream ModeResponse) { option (mavsdk.options.async_type) = ASYNC; } /* - * Subscribe to camera information updates. + * Get camera mode. */ - rpc SubscribeInformation(SubscribeInformationRequest) returns(stream InformationResponse) {} + rpc GetMode(GetModeRequest) returns(GetModeResponse) { option (mavsdk.options.async_type) = SYNC; } /* * Subscribe to video stream info updates. */ - rpc SubscribeVideoStreamInfo(SubscribeVideoStreamInfoRequest) returns(stream VideoStreamInfoResponse) {} + rpc SubscribeVideoStreamInfo(SubscribeVideoStreamInfoRequest) returns(stream VideoStreamInfoResponse) { option (mavsdk.options.async_type) = ASYNC; } + /* + * Get video stream info. + */ + rpc GetVideoStreamInfo(GetVideoStreamInfoRequest) returns(GetVideoStreamInfoResponse) { option (mavsdk.options.async_type) = SYNC; } /* * Subscribe to capture info updates. */ @@ -76,15 +83,27 @@ service CameraService { /* * Subscribe to camera status updates. */ - rpc SubscribeStatus(SubscribeStatusRequest) returns(stream StatusResponse) {} + rpc SubscribeStatus(SubscribeStatusRequest) returns(stream StatusResponse) { option (mavsdk.options.async_type) = ASYNC; } + /* + * Get camera status. + */ + rpc GetStatus(GetStatusRequest) returns(GetStatusResponse) { option (mavsdk.options.async_type) = SYNC; } /* * Get the list of current camera settings. */ rpc SubscribeCurrentSettings(SubscribeCurrentSettingsRequest) returns(stream CurrentSettingsResponse) { option (mavsdk.options.async_type) = ASYNC; } + /* + * Get current settings. + */ + rpc GetCurrentSettings(GetCurrentSettingsRequest) returns(GetCurrentSettingsResponse) { option (mavsdk.options.async_type) = SYNC; } /* * Get the list of settings that can be changed. */ - rpc SubscribePossibleSettingOptions(SubscribePossibleSettingOptionsRequest) returns(stream PossibleSettingOptionsResponse) {} + rpc SubscribePossibleSettingOptions(SubscribePossibleSettingOptionsRequest) returns(stream PossibleSettingOptionsResponse) { option (mavsdk.options.async_type) = ASYNC; } + /* + * Get possible setting options. + */ + rpc GetPossibleSettingOptions(GetPossibleSettingOptionsRequest) returns(GetPossibleSettingOptionsResponse) { option (mavsdk.options.async_type) = SYNC; } /* * Set a setting to some value. * @@ -103,12 +122,6 @@ service CameraService { * This will delete all content of the camera storage! */ rpc FormatStorage(FormatStorageRequest) returns(FormatStorageResponse) {} - /* - * Select current camera . - * - * Bind the plugin instance to a specific camera_id - */ - rpc SelectCamera(SelectCameraRequest) returns(SelectCameraResponse) { option (mavsdk.options.async_type) = SYNC; } /* * Reset all settings in camera. * @@ -161,80 +174,153 @@ service CameraService { rpc FocusRange(FocusRangeRequest) returns(FocusRangeResponse) {} } -message PrepareRequest {} -message PrepareResponse { - CameraResult camera_result = 1; +// Type to represent a setting option. +message Option { + string option_id = 1; // Name of the option (machine readable) + string option_description = 2; // Description of the option (human readable) } -message TakePhotoRequest {} +// Type to represent a setting with a selected option. +message Setting { + string setting_id = 1; // Name of a setting (machine readable) + string setting_description = 2; // Description of the setting (human readable). This field is meant to be read from the drone, ignore it when setting. + Option option = 3; // Selected option + bool is_range = 4; // If option is given as a range. This field is meant to be read from the drone, ignore it when setting. +} + +// Type to represent a setting with a list of options to choose from. +message SettingOptions { + int32 camera_id = 1; // Camera ID + string setting_id = 2; // Name of the setting (machine readable) + string setting_description = 3; // Description of the setting (human readable) + repeated Option options = 4; // List of options or if range [min, max] or [min, max, interval] + bool is_range = 5; // If option is given as a range +} + +// Type for video stream settings. +message VideoStreamSettings { + float frame_rate_hz = 1; // Frames per second + uint32 horizontal_resolution_pix = 2; // Horizontal resolution (in pixels) + uint32 vertical_resolution_pix = 3; // Vertical resolution (in pixels) + uint32 bit_rate_b_s = 4; // Bit rate (in bits per second) + uint32 rotation_deg = 5; // Video image rotation (clockwise, 0-359 degrees) + string uri = 6; // Video stream URI + float horizontal_fov_deg = 7; // Horizontal fov in degrees +} + +// Information about the video stream. +message VideoStreamInfo { + // Video stream status type. + enum VideoStreamStatus { + VIDEO_STREAM_STATUS_NOT_RUNNING = 0; // Video stream is not running + VIDEO_STREAM_STATUS_IN_PROGRESS = 1; // Video stream is running + } + + // Video stream light spectrum type + enum VideoStreamSpectrum { + VIDEO_STREAM_SPECTRUM_UNKNOWN = 0; // Unknown + VIDEO_STREAM_SPECTRUM_VISIBLE_LIGHT = 1; // Visible light + VIDEO_STREAM_SPECTRUM_INFRARED = 2; // Infrared + } + + int32 camera_id = 1; // Camera ID + VideoStreamSettings settings = 2; // Video stream settings + VideoStreamStatus status = 3; // Current status of video streaming + VideoStreamSpectrum spectrum = 4; // Light-spectrum of the video stream +} + +message TakePhotoRequest { + int32 camera_id = 1; // Camera ID +} message TakePhotoResponse { CameraResult camera_result = 1; } message StartPhotoIntervalRequest { - float interval_s = 1; // Interval between photos (in seconds) + int32 camera_id = 1; // Camera ID + float interval_s = 2; // Interval between photos (in seconds) } message StartPhotoIntervalResponse { CameraResult camera_result = 1; } -message StopPhotoIntervalRequest {} +message StopPhotoIntervalRequest { + int32 camera_id = 1; // Camera ID +} message StopPhotoIntervalResponse { CameraResult camera_result = 1; } -message StartVideoRequest {} +message StartVideoRequest { + int32 camera_id = 1; // Camera ID +} message StartVideoResponse { CameraResult camera_result = 1; } -message StopVideoRequest {} +message StopVideoRequest { + int32 camera_id = 1; // Camera ID +} message StopVideoResponse { CameraResult camera_result = 1; } message StartVideoStreamingRequest { - int32 stream_id = 1; // video stream id + int32 camera_id = 1; // Camera ID + int32 stream_id = 2; // video stream id } message StartVideoStreamingResponse { CameraResult camera_result = 1; } message StopVideoStreamingRequest { - int32 stream_id = 1; // video stream id + int32 camera_id = 1; // Camera ID + int32 stream_id = 2; // video stream id } message StopVideoStreamingResponse { CameraResult camera_result = 1; } message SetModeRequest { - Mode mode = 1; // Camera mode to set + int32 camera_id = 1; // Camera ID + Mode mode = 2; // Camera mode to set } message SetModeResponse { CameraResult camera_result = 1; } message ListPhotosRequest { - PhotosRange photos_range = 1; // Which photos should be listed (all or since connection) + int32 camera_id = 1; // Camera ID + PhotosRange photos_range = 2; // Which photos should be listed (all or since connection) } message ListPhotosResponse { CameraResult camera_result = 1; repeated CaptureInfo capture_infos = 2; // List of capture infos (representing the photos) } -message SubscribeInformationRequest {} -message InformationResponse { - Information information = 1; // Camera information +message SubscribeCameraListRequest {} +message CameraListResponse { + CameraList camera_list = 1; // Camera list +} + +message ModeUpdate { + int32 camera_id = 1; // Camera ID + Mode mode = 2; // Camera mode } message SubscribeModeRequest {} message ModeResponse { - Mode mode = 1; // Camera mode + ModeUpdate update = 1; // Mode update for camera +} + +message VideoStreamUpdate { + int32 camera_id = 1; // Camera ID + VideoStreamInfo video_stream_info = 2; // Video stream info } message SubscribeVideoStreamInfoRequest {} message VideoStreamInfoResponse { - VideoStreamInfo video_stream_info = 1; // Video stream info + VideoStreamUpdate update = 1; // Video stream update for camera } message SubscribeCaptureInfoRequest {} @@ -247,25 +333,77 @@ message StatusResponse { Status camera_status = 1; // Camera status } +message CurrentSettingsUpdate { + int32 camera_id = 1; // Camera ID + repeated Setting current_settings = 2; // List of current settings +} + message SubscribeCurrentSettingsRequest {} message CurrentSettingsResponse { - repeated Setting current_settings = 1; // List of current settings + CurrentSettingsUpdate update = 1; // Current setting update per camera +} + +message PossibleSettingOptionsUpdate { + int32 camera_id = 1; // Camera ID + repeated SettingOptions setting_options = 2; // List of settings that can be changed } message SubscribePossibleSettingOptionsRequest {} message PossibleSettingOptionsResponse { - repeated SettingOptions setting_options = 1; // List of settings that can be changed + PossibleSettingOptionsUpdate update = 1; // Possible setting update per camera } message SetSettingRequest { - Setting setting = 1; // Desired setting + int32 camera_id = 1; // Camera ID + Setting setting = 2; // Desired setting } message SetSettingResponse { CameraResult camera_result = 1; } +message GetModeRequest { + int32 camera_id = 1; // Camera ID +} +message GetModeResponse { + CameraResult camera_result = 1; + Mode mode = 2; // Mode +} + +message GetVideoStreamInfoRequest { + int32 camera_id = 1; // Camera ID +} +message GetVideoStreamInfoResponse { + CameraResult camera_reuslt = 1; + VideoStreamInfo video_stream_info = 2; // Video stream info +} + +message GetStatusRequest { + int32 camera_id = 1; // Camera ID +} +message GetStatusResponse { + CameraResult camera_result = 1; + Status status = 2; // Camera status +} + +message GetCurrentSettingsRequest { + int32 camera_id = 1; // Camera ID +} +message GetCurrentSettingsResponse { + CameraResult camera_result = 1; + repeated Setting current_settings = 2; // List of current settings +} + +message GetPossibleSettingOptionsRequest { + int32 camera_id = 1; // Camera ID +} +message GetPossibleSettingOptionsResponse { + CameraResult camera_result = 1; + repeated SettingOptions setting_options = 2; // List of settings that can be changed +} + message GetSettingRequest { - Setting setting = 1; // Requested setting + int32 camera_id = 1; // Camera ID (0/all not available) + Setting setting = 2; // Requested setting } message GetSettingResponse { CameraResult camera_result = 1; @@ -273,91 +411,105 @@ message GetSettingResponse { } message FormatStorageRequest { - int32 storage_id = 1; //Storage identify to be format + int32 camera_id = 1; // Camera ID + int32 storage_id = 2; //Storage identify to be format } message FormatStorageResponse { CameraResult camera_result = 1; } -message SelectCameraResponse { - CameraResult camera_result = 1; -} -message SelectCameraRequest { - int32 camera_id = 1; // Id of camera to be selected +message ResetSettingsRequest { + int32 camera_id = 1; // Camera ID } - -message ResetSettingsRequest {} message ResetSettingsResponse { CameraResult camera_result = 1; } -message ZoomInStartRequest {} +message ZoomInStartRequest { + int32 camera_id = 1; // Camera ID +} message ZoomInStartResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } -message ZoomOutStartRequest {} +message ZoomOutStartRequest { + int32 camera_id = 1; // Camera ID +} message ZoomOutStartResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } -message ZoomStopRequest {} +message ZoomStopRequest { + int32 camera_id = 1; // Camera ID +} message ZoomStopResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } message ZoomRangeRequest { - float range = 1; // Range must be between 0.0 and 100.0 + int32 camera_id = 1; // Camera ID + float range = 2; // Range must be between 0.0 and 100.0 } message ZoomRangeResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } message TrackPointRequest { - float point_x = 1; // Point in X axis (0..1, 0 is left, 1 is right) - float point_y = 2; // Point in Y axis (0..1, 0 is top, 1 is bottom) - float radius = 3; // Radius (0 is one pixel, 1 is full image width) + int32 camera_id = 1; // Camera ID + float point_x = 2; // Point in X axis (0..1, 0 is left, 1 is right) + float point_y = 3; // Point in Y axis (0..1, 0 is top, 1 is bottom) + float radius = 4; // Radius (0 is one pixel, 1 is full image width) } message TrackPointResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } message TrackRectangleRequest { - float top_left_x = 1; // Top left corner of rectangle x value (normalized 0..1, 0 is left, 1 is right) - float top_left_y = 2; // Top left corner of rectangle y value (normalized 0..1, 0 is top, 1 is bottom) - float bottom_right_x = 3; // Bottom right corner of rectangle x value (normalized 0..1, 0 is left, 1 is right) - float bottom_right_y = 4; // Bottom right corner of rectangle y value (normalized 0..1, 0 is top, 1 is bottom) + int32 camera_id = 1; // Camera ID + float top_left_x = 2; // Top left corner of rectangle x value (normalized 0..1, 0 is left, 1 is right) + float top_left_y = 3; // Top left corner of rectangle y value (normalized 0..1, 0 is top, 1 is bottom) + float bottom_right_x = 4; // Bottom right corner of rectangle x value (normalized 0..1, 0 is left, 1 is right) + float bottom_right_y = 5; // Bottom right corner of rectangle y value (normalized 0..1, 0 is top, 1 is bottom) } message TrackRectangleResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } -message TrackStopRequest {} +message TrackStopRequest { + int32 camera_id = 1; // Camera ID +} message TrackStopResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } -message FocusInStartRequest {} +message FocusInStartRequest { + int32 camera_id = 1; // Camera ID +} message FocusInStartResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } -message FocusOutStartRequest {} +message FocusOutStartRequest { + int32 camera_id = 1; // Camera ID +} message FocusOutStartResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } -message FocusStopRequest {} +message FocusStopRequest { + int32 camera_id = 1; // Camera ID +} message FocusStopResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } message FocusRangeRequest { - float range = 1; // Range must be between 0.0 - 100.0 + int32 camera_id = 1; // Camera ID + float range = 2; // Range must be between 0.0 - 100.0 } message FocusRangeResponse { - CameraResult camera_result = 1; + CameraResult camera_result = 1; } @@ -375,6 +527,10 @@ message CameraResult { RESULT_WRONG_ARGUMENT = 7; // Command has wrong argument(s) RESULT_NO_SYSTEM = 8; // No system connected RESULT_PROTOCOL_UNSUPPORTED = 9; // Definition file protocol not supported + RESULT_SETTINGS_UNAVAILABLE = 10; // Settings not available + RESULT_SETTINGS_LOADING = 11; // Settings not available yet + RESULT_CAMERA_ID_INVALID = 12; // Camera with camera ID not found + RESULT_ACTION_UNSUPPORTED = 13; // Camera action not supported } Result result = 1; // Result enum value @@ -444,37 +600,6 @@ message CaptureInfo { string file_url = 7; // Download URL of this image } -// Type for video stream settings. -message VideoStreamSettings { - float frame_rate_hz = 1; // Frames per second - uint32 horizontal_resolution_pix = 2; // Horizontal resolution (in pixels) - uint32 vertical_resolution_pix = 3; // Vertical resolution (in pixels) - uint32 bit_rate_b_s = 4; // Bit rate (in bits per second) - uint32 rotation_deg = 5; // Video image rotation (clockwise, 0-359 degrees) - string uri = 6; // Video stream URI - float horizontal_fov_deg = 7; // Horizontal fov in degrees -} - -// Information about the video stream. -message VideoStreamInfo { - // Video stream status type. - enum VideoStreamStatus { - VIDEO_STREAM_STATUS_NOT_RUNNING = 0; // Video stream is not running - VIDEO_STREAM_STATUS_IN_PROGRESS = 1; // Video stream is running - } - - // Video stream light spectrum type - enum VideoStreamSpectrum { - VIDEO_STREAM_SPECTRUM_UNKNOWN = 0; // Unknown - VIDEO_STREAM_SPECTRUM_VISIBLE_LIGHT = 1; // Visible light - VIDEO_STREAM_SPECTRUM_INFRARED = 2; // Infrared - } - - VideoStreamSettings settings = 1; // Video stream settings - VideoStreamStatus status = 2; // Current status of video streaming - VideoStreamSpectrum spectrum = 3; // Light-spectrum of the video stream -} - // Information about the camera status. message Status { // Storage status type. @@ -495,42 +620,21 @@ message Status { STORAGE_TYPE_OTHER = 254; // Storage type other, not listed } - bool video_on = 1; // Whether video recording is currently in process - bool photo_interval_on = 2; // Whether a photo interval is currently in process + int32 camera_id = 1; // Camera ID + bool video_on = 2; // Whether video recording is currently in process + bool photo_interval_on = 3; // Whether a photo interval is currently in process - float used_storage_mib = 3; // Used storage (in MiB) - float available_storage_mib = 4; // Available storage (in MiB) - float total_storage_mib = 5; // Total storage (in MiB) - float recording_time_s = 6; // Elapsed time since starting the video recording (in seconds) - string media_folder_name = 7; // Current folder name where media are saved + float used_storage_mib = 4; // Used storage (in MiB) + float available_storage_mib = 5; // Available storage (in MiB) + float total_storage_mib = 6; // Total storage (in MiB) + float recording_time_s = 7; // Elapsed time since starting the video recording (in seconds) + string media_folder_name = 8; // Current folder name where media are saved - StorageStatus storage_status = 8; // Storage status + StorageStatus storage_status = 9; // Storage status - uint32 storage_id = 9; // Storage ID starting at 1 + uint32 storage_id = 10; // Storage ID starting at 1 - StorageType storage_type = 10; // Storage type -} - -// Type to represent a setting option. -message Option { - string option_id = 1; // Name of the option (machine readable) - string option_description = 2; // Description of the option (human readable) -} - -// Type to represent a setting with a selected option. -message Setting { - string setting_id = 1; // Name of a setting (machine readable) - string setting_description = 2; // Description of the setting (human readable). This field is meant to be read from the drone, ignore it when setting. - Option option = 3; // Selected option - bool is_range = 4; // If option is given as a range. This field is meant to be read from the drone, ignore it when setting. -} - -// Type to represent a setting with a list of options to choose from. -message SettingOptions { - string setting_id = 1; // Name of the setting (machine readable) - string setting_description = 2; // Description of the setting (human readable) - repeated Option options = 3; // List of options or if range [min, max] or [min, max, interval] - bool is_range = 4; // If option is given as a range + StorageType storage_type = 11; // Storage type } // Type to represent a camera information. @@ -543,3 +647,8 @@ message Information { uint32 horizontal_resolution_px = 6; // Horizontal image resolution in pixels uint32 vertical_resolution_px = 7; // Vertical image resolution in pixels } + +// Camera list +message CameraList { + repeated Information cameras = 1; // Camera items. +} diff --git a/protos/gimbal/gimbal.proto b/protos/gimbal/gimbal.proto index 727e0ce9..59593e03 100644 --- a/protos/gimbal/gimbal.proto +++ b/protos/gimbal/gimbal.proto @@ -258,7 +258,7 @@ message GimbalItem { // Gimbal list message GimbalList { - repeated GimbalItem gimbals = 1; // Gimbal item. + repeated GimbalItem gimbals = 1; // Gimbal items. }