viam-sdk 0.25.2__py3-none-linux_armv7l.whl → 0.62.0__py3-none-linux_armv7l.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- viam/app/_logs.py +3 -6
- viam/app/app_client.py +606 -262
- viam/app/billing_client.py +60 -18
- viam/app/data_client.py +1086 -315
- viam/app/ml_training_client.py +51 -48
- viam/app/provisioning_client.py +3 -5
- viam/app/viam_client.py +105 -11
- viam/components/arm/__init__.py +1 -25
- viam/components/arm/arm.py +21 -22
- viam/components/arm/client.py +27 -30
- viam/components/arm/service.py +3 -3
- viam/components/audio_in/__init__.py +24 -0
- viam/components/audio_in/audio_in.py +74 -0
- viam/components/audio_in/client.py +76 -0
- viam/components/audio_in/service.py +83 -0
- viam/components/audio_input/__init__.py +1 -1
- viam/components/audio_input/audio_input.py +4 -3
- viam/components/audio_input/client.py +19 -8
- viam/components/audio_input/service.py +10 -0
- viam/components/audio_out/__init__.py +21 -0
- viam/components/audio_out/audio_out.py +72 -0
- viam/components/audio_out/client.py +67 -0
- viam/components/audio_out/service.py +63 -0
- viam/components/base/__init__.py +2 -10
- viam/components/base/base.py +20 -20
- viam/components/base/client.py +27 -30
- viam/components/board/__init__.py +2 -25
- viam/components/board/board.py +39 -77
- viam/components/board/client.py +39 -73
- viam/components/button/__init__.py +10 -0
- viam/components/button/button.py +41 -0
- viam/components/button/client.py +52 -0
- viam/components/button/service.py +46 -0
- viam/components/camera/__init__.py +1 -1
- viam/components/camera/camera.py +31 -22
- viam/components/camera/client.py +30 -20
- viam/components/camera/service.py +14 -12
- viam/components/component_base.py +10 -7
- viam/components/encoder/__init__.py +1 -1
- viam/components/encoder/client.py +15 -16
- viam/components/encoder/encoder.py +9 -9
- viam/components/gantry/__init__.py +1 -13
- viam/components/gantry/client.py +41 -28
- viam/components/gantry/gantry.py +48 -17
- viam/components/gantry/service.py +21 -5
- viam/components/generic/__init__.py +1 -1
- viam/components/generic/client.py +11 -7
- viam/components/generic/generic.py +3 -3
- viam/components/gripper/__init__.py +3 -12
- viam/components/gripper/client.py +43 -20
- viam/components/gripper/gripper.py +87 -12
- viam/components/gripper/service.py +32 -3
- viam/components/input/__init__.py +1 -14
- viam/components/input/client.py +22 -23
- viam/components/input/input.py +18 -12
- viam/components/motor/__init__.py +1 -21
- viam/components/motor/client.py +36 -42
- viam/components/motor/motor.py +24 -24
- viam/components/movement_sensor/__init__.py +1 -1
- viam/components/movement_sensor/client.py +33 -40
- viam/components/movement_sensor/movement_sensor.py +12 -12
- viam/components/pose_tracker/__init__.py +1 -1
- viam/components/pose_tracker/client.py +9 -8
- viam/components/pose_tracker/pose_tracker.py +2 -2
- viam/components/power_sensor/__init__.py +1 -1
- viam/components/power_sensor/client.py +15 -18
- viam/components/power_sensor/power_sensor.py +12 -12
- viam/components/sensor/__init__.py +1 -1
- viam/components/sensor/client.py +9 -8
- viam/components/sensor/sensor.py +5 -5
- viam/components/servo/__init__.py +1 -13
- viam/components/servo/client.py +18 -18
- viam/components/servo/servo.py +12 -12
- viam/components/switch/__init__.py +10 -0
- viam/components/switch/client.py +83 -0
- viam/components/switch/service.py +72 -0
- viam/components/switch/switch.py +95 -0
- viam/gen/app/agent/v1/agent_pb2.py +40 -29
- viam/gen/app/agent/v1/agent_pb2.pyi +73 -11
- viam/gen/app/cloudslam/v1/cloud_slam_pb2.py +45 -42
- viam/gen/app/data/v1/data_grpc.py +98 -2
- viam/gen/app/data/v1/data_pb2.py +238 -119
- viam/gen/app/data/v1/data_pb2.pyi +804 -34
- viam/gen/app/datapipelines/v1/data_pipelines_grpc.py +84 -0
- viam/gen/app/datapipelines/v1/data_pipelines_pb2.py +57 -0
- viam/gen/app/datapipelines/v1/data_pipelines_pb2.pyi +387 -0
- viam/gen/app/dataset/v1/dataset_grpc.py +10 -2
- viam/gen/app/dataset/v1/dataset_pb2.py +38 -31
- viam/gen/app/dataset/v1/dataset_pb2.pyi +36 -1
- viam/gen/app/datasync/v1/data_sync_grpc.py +1 -1
- viam/gen/app/datasync/v1/data_sync_pb2.py +61 -51
- viam/gen/app/datasync/v1/data_sync_pb2.pyi +52 -12
- viam/gen/app/mlinference/__init__.py +0 -0
- viam/gen/app/mlinference/v1/__init__.py +0 -0
- viam/gen/app/mlinference/v1/ml_inference_grpc.py +28 -0
- viam/gen/app/mlinference/v1/ml_inference_pb2.py +23 -0
- viam/gen/app/mlinference/v1/ml_inference_pb2.pyi +63 -0
- viam/gen/app/mltraining/v1/ml_training_grpc.py +18 -2
- viam/gen/app/mltraining/v1/ml_training_pb2.py +134 -101
- viam/gen/app/mltraining/v1/ml_training_pb2.pyi +193 -7
- viam/gen/app/packages/v1/packages_pb2.py +43 -40
- viam/gen/app/v1/app_grpc.py +290 -2
- viam/gen/app/v1/app_pb2.py +670 -453
- viam/gen/app/v1/app_pb2.pyi +3133 -947
- viam/gen/app/v1/billing_grpc.py +34 -2
- viam/gen/app/v1/billing_pb2.py +94 -35
- viam/gen/app/v1/billing_pb2.pyi +314 -61
- viam/gen/app/v1/end_user_pb2.py +50 -29
- viam/gen/app/v1/robot_pb2.py +120 -111
- viam/gen/app/v1/robot_pb2.pyi +137 -15
- viam/gen/common/v1/common_pb2.py +86 -66
- viam/gen/common/v1/common_pb2.pyi +184 -8
- viam/gen/component/arm/v1/arm_grpc.py +18 -2
- viam/gen/component/arm/v1/arm_pb2.py +68 -55
- viam/gen/component/arm/v1/arm_pb2.pyi +73 -3
- viam/gen/component/audioin/__init__.py +0 -0
- viam/gen/component/audioin/v1/__init__.py +0 -0
- viam/gen/component/audioin/v1/audioin_grpc.py +54 -0
- viam/gen/component/audioin/v1/audioin_pb2.py +34 -0
- viam/gen/component/audioin/v1/audioin_pb2.pyi +94 -0
- viam/gen/component/audioinput/v1/audioinput_pb2.py +35 -32
- viam/gen/component/audioout/__init__.py +0 -0
- viam/gen/component/audioout/v1/__init__.py +0 -0
- viam/gen/component/audioout/v1/audioout_grpc.py +54 -0
- viam/gen/component/audioout/v1/audioout_pb2.py +32 -0
- viam/gen/component/audioout/v1/audioout_pb2.pyi +47 -0
- viam/gen/component/base/v1/base_pb2.py +57 -54
- viam/gen/component/board/v1/board_pb2.py +93 -90
- viam/gen/component/button/__init__.py +0 -0
- viam/gen/component/button/v1/__init__.py +0 -0
- viam/gen/component/button/v1/button_grpc.py +38 -0
- viam/gen/component/button/v1/button_pb2.py +28 -0
- viam/gen/component/button/v1/button_pb2.pyi +39 -0
- viam/gen/component/camera/v1/camera_pb2.py +58 -55
- viam/gen/component/camera/v1/camera_pb2.pyi +31 -7
- viam/gen/component/encoder/v1/encoder_pb2.py +35 -32
- viam/gen/component/gantry/v1/gantry_grpc.py +9 -1
- viam/gen/component/gantry/v1/gantry_pb2.py +56 -51
- viam/gen/component/generic/v1/generic_pb2.py +15 -12
- viam/gen/component/gripper/v1/gripper_grpc.py +18 -2
- viam/gen/component/gripper/v1/gripper_pb2.py +48 -37
- viam/gen/component/gripper/v1/gripper_pb2.pyi +43 -1
- viam/gen/component/inputcontroller/v1/input_controller_pb2.py +45 -42
- viam/gen/component/motor/v1/motor_pb2.py +77 -74
- viam/gen/component/movementsensor/v1/movementsensor_pb2.py +69 -66
- viam/gen/component/posetracker/v1/pose_tracker_pb2.py +25 -22
- viam/gen/component/powersensor/v1/powersensor_pb2.py +33 -30
- viam/gen/component/sensor/v1/sensor_pb2.py +17 -14
- viam/gen/component/servo/v1/servo_pb2.py +41 -38
- viam/gen/component/switch/__init__.py +0 -0
- viam/gen/component/switch/v1/__init__.py +0 -0
- viam/gen/component/switch/v1/switch_grpc.py +54 -0
- viam/gen/component/switch/v1/switch_pb2.py +40 -0
- viam/gen/component/switch/v1/switch_pb2.pyi +116 -0
- viam/gen/component/testecho/v1/testecho_pb2.py +29 -26
- viam/gen/module/v1/module_pb2.py +36 -33
- viam/gen/module/v1/module_pb2.pyi +7 -2
- viam/gen/proto/rpc/examples/echo/v1/echo_pb2.py +26 -23
- viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.py +23 -20
- viam/gen/proto/rpc/v1/auth_pb2.py +27 -24
- viam/gen/proto/rpc/webrtc/v1/grpc_pb2.py +35 -32
- viam/gen/proto/rpc/webrtc/v1/signaling_pb2.py +62 -57
- viam/gen/proto/rpc/webrtc/v1/signaling_pb2.pyi +18 -4
- viam/gen/provisioning/v1/provisioning_grpc.py +10 -2
- viam/gen/provisioning/v1/provisioning_pb2.py +38 -31
- viam/gen/provisioning/v1/provisioning_pb2.pyi +20 -2
- viam/gen/robot/v1/robot_grpc.py +61 -29
- viam/gen/robot/v1/robot_pb2.py +186 -155
- viam/gen/robot/v1/robot_pb2.pyi +278 -59
- viam/gen/service/datamanager/v1/data_manager_grpc.py +11 -2
- viam/gen/service/datamanager/v1/data_manager_pb2.py +27 -17
- viam/gen/service/datamanager/v1/data_manager_pb2.pyi +47 -1
- viam/gen/service/discovery/__init__.py +0 -0
- viam/gen/service/discovery/v1/__init__.py +0 -0
- viam/gen/service/discovery/v1/discovery_grpc.py +39 -0
- viam/gen/service/discovery/v1/discovery_pb2.py +29 -0
- viam/gen/service/discovery/v1/discovery_pb2.pyi +51 -0
- viam/gen/service/generic/v1/generic_pb2.py +13 -10
- viam/gen/service/mlmodel/v1/mlmodel_pb2.py +75 -72
- viam/gen/service/motion/v1/motion_pb2.py +118 -85
- viam/gen/service/motion/v1/motion_pb2.pyi +130 -68
- viam/gen/service/navigation/v1/navigation_pb2.py +75 -72
- viam/gen/service/sensors/v1/sensors_pb2.py +59 -56
- viam/gen/service/shell/v1/shell_pb2.py +35 -32
- viam/gen/service/slam/v1/slam_pb2.py +43 -40
- viam/gen/service/slam/v1/slam_pb2.pyi +1 -1
- viam/gen/service/video/__init__.py +0 -0
- viam/gen/service/video/v1/__init__.py +0 -0
- viam/gen/service/video/v1/video_grpc.py +39 -0
- viam/gen/service/video/v1/video_pb2.py +29 -0
- viam/gen/service/video/v1/video_pb2.pyi +72 -0
- viam/gen/service/vision/v1/vision_pb2.py +60 -57
- viam/gen/service/vision/v1/vision_pb2.pyi +28 -3
- viam/gen/service/worldstatestore/__init__.py +0 -0
- viam/gen/service/worldstatestore/v1/__init__.py +0 -0
- viam/gen/service/worldstatestore/v1/world_state_store_grpc.py +55 -0
- viam/gen/service/worldstatestore/v1/world_state_store_pb2.py +39 -0
- viam/gen/service/worldstatestore/v1/world_state_store_pb2.pyi +171 -0
- viam/gen/stream/v1/stream_grpc.py +17 -1
- viam/gen/stream/v1/stream_pb2.py +34 -21
- viam/gen/stream/v1/stream_pb2.pyi +79 -1
- viam/gen/tagger/v1/tagger_pb2.py +9 -8
- viam/logging.py +77 -18
- viam/media/audio.py +28 -0
- viam/media/utils/pil/__init__.py +7 -3
- viam/media/video.py +80 -17
- viam/module/module.py +111 -38
- viam/module/resource_data_consumer.py +41 -0
- viam/module/service.py +9 -1
- viam/module/types.py +2 -4
- viam/proto/app/__init__.py +199 -0
- viam/proto/app/agent/__init__.py +5 -2
- viam/proto/app/billing.py +31 -4
- viam/proto/app/cloudslam/__init__.py +1 -0
- viam/proto/app/data/__init__.py +63 -0
- viam/proto/app/datapipelines/__init__.py +56 -0
- viam/proto/app/dataset/__init__.py +5 -0
- viam/proto/app/datasync/__init__.py +3 -0
- viam/proto/app/end_user.py +1 -0
- viam/proto/app/mlinference/__init__.py +15 -0
- viam/proto/app/mltraining/__init__.py +13 -0
- viam/proto/app/packages/__init__.py +1 -0
- viam/proto/app/robot.py +7 -0
- viam/proto/common/__init__.py +15 -0
- viam/proto/component/arm/__init__.py +7 -0
- viam/proto/component/audioin/__init__.py +16 -0
- viam/proto/component/audioinput/__init__.py +1 -0
- viam/proto/component/audioout/__init__.py +15 -0
- viam/proto/component/base/__init__.py +1 -0
- viam/proto/component/board/__init__.py +1 -0
- viam/proto/component/button/__init__.py +15 -0
- viam/proto/component/camera/__init__.py +1 -0
- viam/proto/component/encoder/__init__.py +1 -0
- viam/proto/component/gantry/__init__.py +1 -0
- viam/proto/component/generic/__init__.py +1 -0
- viam/proto/component/gripper/__init__.py +5 -0
- viam/proto/component/inputcontroller/__init__.py +1 -0
- viam/proto/component/motor/__init__.py +1 -0
- viam/proto/component/movementsensor/__init__.py +1 -0
- viam/proto/component/posetracker/__init__.py +1 -0
- viam/proto/component/powersensor/__init__.py +1 -0
- viam/proto/component/sensor/__init__.py +1 -0
- viam/proto/component/servo/__init__.py +1 -0
- viam/proto/component/switch/__init__.py +26 -0
- viam/proto/component/testecho/__init__.py +1 -0
- viam/proto/module/__init__.py +1 -0
- viam/proto/provisioning/__init__.py +5 -0
- viam/proto/robot/__init__.py +29 -8
- viam/proto/rpc/auth.py +1 -0
- viam/proto/rpc/examples/echo/__init__.py +1 -0
- viam/proto/rpc/examples/echoresource/__init__.py +1 -0
- viam/proto/rpc/webrtc/grpc.py +1 -0
- viam/proto/rpc/webrtc/signaling.py +3 -0
- viam/proto/service/datamanager/__init__.py +9 -1
- viam/proto/service/discovery/__init__.py +15 -0
- viam/proto/service/generic/__init__.py +1 -0
- viam/proto/service/mlmodel/__init__.py +1 -0
- viam/proto/service/motion/__init__.py +3 -0
- viam/proto/service/navigation/__init__.py +1 -0
- viam/proto/service/sensors/__init__.py +1 -0
- viam/proto/service/shell/__init__.py +1 -0
- viam/proto/service/slam/__init__.py +1 -0
- viam/proto/service/video/__init__.py +15 -0
- viam/proto/service/vision/__init__.py +1 -0
- viam/proto/service/worldstatestore/__init__.py +32 -0
- viam/proto/stream/__init__.py +11 -0
- viam/py.typed +0 -0
- viam/resource/base.py +12 -8
- viam/resource/easy_resource.py +24 -13
- viam/resource/manager.py +6 -5
- viam/resource/registry.py +39 -51
- viam/resource/rpc_client_base.py +33 -1
- viam/resource/types.py +13 -14
- viam/robot/client.py +190 -122
- viam/robot/service.py +2 -50
- viam/rpc/dial.py +54 -4
- viam/rpc/libviam_rust_utils.so +0 -0
- viam/rpc/server.py +25 -11
- viam/rpc/types.py +2 -4
- viam/services/discovery/__init__.py +12 -0
- viam/services/discovery/client.py +55 -0
- viam/services/discovery/discovery.py +52 -0
- viam/services/discovery/service.py +43 -0
- viam/services/generic/__init__.py +1 -1
- viam/services/generic/client.py +8 -5
- viam/services/generic/generic.py +2 -2
- viam/services/mlmodel/__init__.py +1 -1
- viam/services/mlmodel/client.py +17 -7
- viam/services/mlmodel/mlmodel.py +23 -12
- viam/services/mlmodel/service.py +5 -2
- viam/services/mlmodel/utils.py +11 -1
- viam/services/motion/__init__.py +2 -2
- viam/services/motion/client.py +32 -32
- viam/services/motion/motion.py +66 -62
- viam/services/navigation/__init__.py +1 -1
- viam/services/navigation/client.py +30 -20
- viam/services/navigation/navigation.py +23 -23
- viam/services/service_base.py +13 -9
- viam/services/service_client_base.py +3 -3
- viam/services/slam/__init__.py +1 -1
- viam/services/slam/client.py +15 -10
- viam/services/slam/slam.py +11 -11
- viam/services/vision/__init__.py +1 -1
- viam/services/vision/client.py +31 -24
- viam/services/vision/service.py +8 -8
- viam/services/vision/vision.py +36 -53
- viam/services/worldstatestore/__init__.py +18 -0
- viam/services/worldstatestore/client.py +94 -0
- viam/services/worldstatestore/service.py +55 -0
- viam/services/worldstatestore/worldstatestore.py +90 -0
- viam/sessions_client.py +115 -46
- viam/streams.py +3 -6
- viam/utils.py +44 -14
- viam/version_metadata.py +4 -0
- {viam_sdk-0.25.2.dist-info → viam_sdk-0.62.0.dist-info}/METADATA +27 -28
- viam_sdk-0.62.0.dist-info/RECORD +514 -0
- {viam_sdk-0.25.2.dist-info → viam_sdk-0.62.0.dist-info}/WHEEL +1 -1
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_grpc.py +0 -27
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.py +0 -18
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.pyi +0 -45
- viam/proto/rpc/examples/fileupload/__init__.py +0 -18
- viam/services/sensors/__init__.py +0 -5
- viam/services/sensors/client.py +0 -65
- viam_sdk-0.25.2.dist-info/LICENSE +0 -202
- viam_sdk-0.25.2.dist-info/RECORD +0 -442
- /viam/gen/{proto/rpc/examples/fileupload → app/datapipelines}/__init__.py +0 -0
- /viam/gen/{proto/rpc/examples/fileupload → app/datapipelines}/v1/__init__.py +0 -0
- /LICENSE → /viam_sdk-0.62.0.dist-info/licenses/LICENSE +0 -0
viam/services/vision/client.py
CHANGED
|
@@ -53,9 +53,9 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
53
53
|
*,
|
|
54
54
|
extra: Optional[Mapping[str, Any]] = None,
|
|
55
55
|
timeout: Optional[float] = None,
|
|
56
|
+
**kwargs,
|
|
56
57
|
) -> CaptureAllResult:
|
|
57
|
-
|
|
58
|
-
extra = {}
|
|
58
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
59
59
|
request = CaptureAllFromCameraRequest(
|
|
60
60
|
name=self.name,
|
|
61
61
|
camera_name=camera_name,
|
|
@@ -65,11 +65,15 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
65
65
|
return_object_point_clouds=return_object_point_clouds,
|
|
66
66
|
extra=dict_to_struct(extra),
|
|
67
67
|
)
|
|
68
|
-
response: CaptureAllFromCameraResponse = await self.client.CaptureAllFromCamera(request, timeout=timeout)
|
|
68
|
+
response: CaptureAllFromCameraResponse = await self.client.CaptureAllFromCamera(request, timeout=timeout, metadata=md)
|
|
69
69
|
result = CaptureAllResult()
|
|
70
70
|
result.extra = struct_to_dict(response.extra)
|
|
71
71
|
if return_image:
|
|
72
|
-
|
|
72
|
+
# TODO(RSDK-11728): remove this branching logic once we deleted the format field
|
|
73
|
+
if response.image.mime_type:
|
|
74
|
+
mime_type = CameraMimeType.from_string(response.image.mime_type)
|
|
75
|
+
else:
|
|
76
|
+
mime_type = CameraMimeType.from_proto(response.image.format)
|
|
73
77
|
img = ViamImage(response.image.image, mime_type)
|
|
74
78
|
result.image = img
|
|
75
79
|
if return_classifications:
|
|
@@ -86,11 +90,11 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
86
90
|
*,
|
|
87
91
|
extra: Optional[Mapping[str, Any]] = None,
|
|
88
92
|
timeout: Optional[float] = None,
|
|
93
|
+
**kwargs,
|
|
89
94
|
) -> List[Detection]:
|
|
90
|
-
|
|
91
|
-
extra = {}
|
|
95
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
92
96
|
request = GetDetectionsFromCameraRequest(name=self.name, camera_name=camera_name, extra=dict_to_struct(extra))
|
|
93
|
-
response: GetDetectionsFromCameraResponse = await self.client.GetDetectionsFromCamera(request, timeout=timeout)
|
|
97
|
+
response: GetDetectionsFromCameraResponse = await self.client.GetDetectionsFromCamera(request, timeout=timeout, metadata=md)
|
|
94
98
|
return list(response.detections)
|
|
95
99
|
|
|
96
100
|
async def get_detections(
|
|
@@ -99,9 +103,9 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
99
103
|
*,
|
|
100
104
|
extra: Optional[Mapping[str, Any]] = None,
|
|
101
105
|
timeout: Optional[float] = None,
|
|
106
|
+
**kwargs,
|
|
102
107
|
) -> List[Detection]:
|
|
103
|
-
|
|
104
|
-
extra = {}
|
|
108
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
105
109
|
mime_type = CameraMimeType.JPEG
|
|
106
110
|
|
|
107
111
|
if image.width is None or image.height is None:
|
|
@@ -115,7 +119,7 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
115
119
|
mime_type=mime_type,
|
|
116
120
|
extra=dict_to_struct(extra),
|
|
117
121
|
)
|
|
118
|
-
response: GetDetectionsResponse = await self.client.GetDetections(request, timeout=timeout)
|
|
122
|
+
response: GetDetectionsResponse = await self.client.GetDetections(request, timeout=timeout, metadata=md)
|
|
119
123
|
return list(response.detections)
|
|
120
124
|
|
|
121
125
|
async def get_classifications_from_camera(
|
|
@@ -125,11 +129,13 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
125
129
|
*,
|
|
126
130
|
extra: Optional[Mapping[str, Any]] = None,
|
|
127
131
|
timeout: Optional[float] = None,
|
|
132
|
+
**kwargs,
|
|
128
133
|
) -> List[Classification]:
|
|
129
|
-
|
|
130
|
-
extra = {}
|
|
134
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
131
135
|
request = GetClassificationsFromCameraRequest(name=self.name, camera_name=camera_name, n=count, extra=dict_to_struct(extra))
|
|
132
|
-
response: GetClassificationsFromCameraResponse = await self.client.GetClassificationsFromCamera(
|
|
136
|
+
response: GetClassificationsFromCameraResponse = await self.client.GetClassificationsFromCamera(
|
|
137
|
+
request, timeout=timeout, metadata=md
|
|
138
|
+
)
|
|
133
139
|
return list(response.classifications)
|
|
134
140
|
|
|
135
141
|
async def get_classifications(
|
|
@@ -139,9 +145,9 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
139
145
|
*,
|
|
140
146
|
extra: Optional[Mapping[str, Any]] = None,
|
|
141
147
|
timeout: Optional[float] = None,
|
|
148
|
+
**kwargs,
|
|
142
149
|
) -> List[Classification]:
|
|
143
|
-
|
|
144
|
-
extra = {}
|
|
150
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
145
151
|
|
|
146
152
|
mime_type = CameraMimeType.JPEG
|
|
147
153
|
if image.width is None or image.height is None:
|
|
@@ -155,7 +161,7 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
155
161
|
n=count,
|
|
156
162
|
extra=dict_to_struct(extra),
|
|
157
163
|
)
|
|
158
|
-
response: GetClassificationsResponse = await self.client.GetClassifications(request, timeout=timeout)
|
|
164
|
+
response: GetClassificationsResponse = await self.client.GetClassifications(request, timeout=timeout, metadata=md)
|
|
159
165
|
return list(response.classifications)
|
|
160
166
|
|
|
161
167
|
async def get_object_point_clouds(
|
|
@@ -164,16 +170,16 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
164
170
|
*,
|
|
165
171
|
extra: Optional[Mapping[str, Any]] = None,
|
|
166
172
|
timeout: Optional[float] = None,
|
|
173
|
+
**kwargs,
|
|
167
174
|
) -> List[PointCloudObject]:
|
|
168
|
-
|
|
169
|
-
extra = {}
|
|
175
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
170
176
|
request = GetObjectPointCloudsRequest(
|
|
171
177
|
name=self.name,
|
|
172
178
|
camera_name=camera_name,
|
|
173
179
|
mime_type=CameraMimeType.PCD,
|
|
174
180
|
extra=dict_to_struct(extra),
|
|
175
181
|
)
|
|
176
|
-
response: GetObjectPointCloudsResponse = await self.client.GetObjectPointClouds(request, timeout=timeout)
|
|
182
|
+
response: GetObjectPointCloudsResponse = await self.client.GetObjectPointClouds(request, timeout=timeout, metadata=md)
|
|
177
183
|
return list(response.objects)
|
|
178
184
|
|
|
179
185
|
async def get_properties(
|
|
@@ -181,14 +187,14 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
181
187
|
*,
|
|
182
188
|
extra: Optional[Mapping[str, Any]] = None,
|
|
183
189
|
timeout: Optional[float] = None,
|
|
190
|
+
**kwargs,
|
|
184
191
|
) -> Vision.Properties:
|
|
185
|
-
|
|
186
|
-
extra = {}
|
|
192
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
187
193
|
request = GetPropertiesRequest(
|
|
188
194
|
name=self.name,
|
|
189
195
|
extra=dict_to_struct(extra),
|
|
190
196
|
)
|
|
191
|
-
response: GetPropertiesResponse = await self.client.GetProperties(request, timeout=timeout)
|
|
197
|
+
response: GetPropertiesResponse = await self.client.GetProperties(request, timeout=timeout, metadata=md)
|
|
192
198
|
return response
|
|
193
199
|
|
|
194
200
|
async def do_command(
|
|
@@ -196,8 +202,9 @@ class VisionClient(Vision, ReconfigurableResourceRPCClientBase):
|
|
|
196
202
|
command: Mapping[str, ValueTypes],
|
|
197
203
|
*,
|
|
198
204
|
timeout: Optional[float] = None,
|
|
199
|
-
**
|
|
205
|
+
**kwargs,
|
|
200
206
|
) -> Mapping[str, ValueTypes]:
|
|
207
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
201
208
|
request = DoCommandRequest(name=self.name, command=dict_to_struct(command))
|
|
202
|
-
response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout)
|
|
209
|
+
response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout, metadata=md)
|
|
203
210
|
return struct_to_dict(response.result)
|
viam/services/vision/service.py
CHANGED
|
@@ -26,7 +26,7 @@ from viam.utils import dict_to_struct, struct_to_dict
|
|
|
26
26
|
from .vision import Vision
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
class VisionRPCService(UnimplementedVisionServiceBase, ResourceRPCServiceBase):
|
|
29
|
+
class VisionRPCService(UnimplementedVisionServiceBase, ResourceRPCServiceBase[Vision]):
|
|
30
30
|
"""
|
|
31
31
|
gRPC service for a Vision service
|
|
32
32
|
"""
|
|
@@ -50,9 +50,11 @@ class VisionRPCService(UnimplementedVisionServiceBase, ResourceRPCServiceBase):
|
|
|
50
50
|
)
|
|
51
51
|
img = None
|
|
52
52
|
if result.image is not None:
|
|
53
|
-
|
|
53
|
+
mime_type = CameraMimeType.from_string(result.image.mime_type)
|
|
54
|
+
# TODO(RSDK-11728): remove this fmt logic once we deleted the format field
|
|
55
|
+
fmt = mime_type.to_proto() # Will be Format.FORMAT_UNSPECIFIED if an unsupported/custom mime type is set
|
|
54
56
|
img_bytes = result.image.data
|
|
55
|
-
img = Image(source_name=request.camera_name, format=fmt, image=img_bytes)
|
|
57
|
+
img = Image(source_name=request.camera_name, mime_type=mime_type, format=fmt, image=img_bytes)
|
|
56
58
|
response = CaptureAllFromCameraResponse(
|
|
57
59
|
image=img,
|
|
58
60
|
detections=result.detections,
|
|
@@ -79,8 +81,7 @@ class VisionRPCService(UnimplementedVisionServiceBase, ResourceRPCServiceBase):
|
|
|
79
81
|
extra = struct_to_dict(request.extra)
|
|
80
82
|
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
image = ViamImage(request.image, mime_type)
|
|
84
|
+
image = ViamImage(request.image, CameraMimeType.from_string(request.mime_type))
|
|
84
85
|
|
|
85
86
|
result = await vision.get_detections(image, extra=extra, timeout=timeout)
|
|
86
87
|
response = GetDetectionsResponse(detections=result)
|
|
@@ -105,8 +106,7 @@ class VisionRPCService(UnimplementedVisionServiceBase, ResourceRPCServiceBase):
|
|
|
105
106
|
extra = struct_to_dict(request.extra)
|
|
106
107
|
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
image = ViamImage(request.image, mime_type)
|
|
109
|
+
image = ViamImage(request.image, CameraMimeType.from_string(request.mime_type))
|
|
110
110
|
|
|
111
111
|
result = await vision.get_classifications(image, request.n, extra=extra, timeout=timeout)
|
|
112
112
|
response = GetClassificationsResponse(classifications=result)
|
|
@@ -119,7 +119,7 @@ class VisionRPCService(UnimplementedVisionServiceBase, ResourceRPCServiceBase):
|
|
|
119
119
|
extra = struct_to_dict(request.extra)
|
|
120
120
|
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
121
121
|
result = await vision.get_object_point_clouds(request.camera_name, extra=extra, timeout=timeout)
|
|
122
|
-
response = GetObjectPointCloudsResponse(mime_type=CameraMimeType.PCD
|
|
122
|
+
response = GetObjectPointCloudsResponse(mime_type=CameraMimeType.PCD, objects=result)
|
|
123
123
|
await stream.send_message(response)
|
|
124
124
|
|
|
125
125
|
async def GetProperties(self, stream: Stream[GetPropertiesRequest, GetPropertiesResponse]) -> None:
|
viam/services/vision/vision.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import Final, List, Mapping, Optional
|
|
|
5
5
|
from viam.media.video import ViamImage
|
|
6
6
|
from viam.proto.common import PointCloudObject
|
|
7
7
|
from viam.proto.service.vision import Classification, Detection, GetPropertiesResponse
|
|
8
|
-
from viam.resource.types import RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE
|
|
8
|
+
from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE
|
|
9
9
|
from viam.utils import ValueTypes
|
|
10
10
|
|
|
11
11
|
from ..service_base import ServiceBase
|
|
@@ -60,10 +60,10 @@ class Vision(ServiceBase):
|
|
|
60
60
|
vision implementations. This cannot be used on its own. If the ``__init__()`` function is
|
|
61
61
|
overridden, it must call the ``super().__init__()`` function.
|
|
62
62
|
|
|
63
|
-
For more information, see `Computer Vision service <https://docs.viam.com/services/vision/>`_.
|
|
63
|
+
For more information, see `Computer Vision service <https://docs.viam.com/dev/reference/apis/services/vision/>`_.
|
|
64
64
|
"""
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
API: Final = API( # pyright: ignore [reportIncompatibleVariableOverride]
|
|
67
67
|
RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE, "vision"
|
|
68
68
|
)
|
|
69
69
|
|
|
@@ -93,17 +93,16 @@ class Vision(ServiceBase):
|
|
|
93
93
|
|
|
94
94
|
::
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
my_detector = VisionClient.from_robot(machine, "my_detector")
|
|
97
97
|
|
|
98
|
-
#
|
|
99
|
-
my_detector = VisionClient.from_robot(robot, "my_detector")
|
|
100
|
-
|
|
101
|
-
# capture all from the next image from the camera
|
|
98
|
+
# Get the captured data for a camera
|
|
102
99
|
result = await my_detector.capture_all_from_camera(
|
|
103
|
-
|
|
100
|
+
"my_camera",
|
|
104
101
|
return_image=True,
|
|
105
102
|
return_detections=True,
|
|
106
103
|
)
|
|
104
|
+
image = result.image
|
|
105
|
+
detections = result.detections
|
|
107
106
|
|
|
108
107
|
Args:
|
|
109
108
|
camera_name (str): The name of the camera to use for detection
|
|
@@ -117,7 +116,7 @@ class Vision(ServiceBase):
|
|
|
117
116
|
It can return the image from the camera along with its associated detections, classifications,
|
|
118
117
|
and objects, as well as any extra info the model may provide.
|
|
119
118
|
|
|
120
|
-
For more information, see `Computer Vision service <https://docs.viam.com/services/vision
|
|
119
|
+
For more information, see `Computer Vision service <https://docs.viam.com/dev/reference/apis/services/vision/#captureallfromcamera>`_.
|
|
121
120
|
"""
|
|
122
121
|
...
|
|
123
122
|
|
|
@@ -133,13 +132,10 @@ class Vision(ServiceBase):
|
|
|
133
132
|
|
|
134
133
|
::
|
|
135
134
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
# Grab the detector you configured on your machine
|
|
139
|
-
my_detector = VisionClient.from_robot(robot, "my_detector")
|
|
135
|
+
my_detector = VisionClient.from_robot(robot=machine, "my_detector")
|
|
140
136
|
|
|
141
|
-
# Get detections
|
|
142
|
-
detections = await my_detector.get_detections_from_camera(
|
|
137
|
+
# Get detections for the next image from the specified camera
|
|
138
|
+
detections = await my_detector.get_detections_from_camera("my_camera")
|
|
143
139
|
|
|
144
140
|
Args:
|
|
145
141
|
camera_name (str): The name of the camera to use for detection
|
|
@@ -152,7 +148,7 @@ class Vision(ServiceBase):
|
|
|
152
148
|
confidence score of the labels, around the found objects in the next 2D image
|
|
153
149
|
from the given camera, with the given detector applied to it.
|
|
154
150
|
|
|
155
|
-
For more information, see `Computer Vision service <https://docs.viam.com/services/vision
|
|
151
|
+
For more information, see `Computer Vision service <https://docs.viam.com/dev/reference/apis/services/vision/#getdetectionsfromcamera>`_.
|
|
156
152
|
"""
|
|
157
153
|
...
|
|
158
154
|
|
|
@@ -168,20 +164,17 @@ class Vision(ServiceBase):
|
|
|
168
164
|
|
|
169
165
|
::
|
|
170
166
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
# Get the detector you configured on your machine
|
|
175
|
-
my_detector = VisionClient.from_robot(robot, "my_detector")
|
|
167
|
+
my_camera = Camera.from_robot(robot=machine, "my_camera")
|
|
168
|
+
my_detector = VisionClient.from_robot(robot=machine, "my_detector")
|
|
176
169
|
|
|
177
170
|
# Get an image from the camera
|
|
178
|
-
img = await
|
|
171
|
+
img = await my_camera.get_image()
|
|
179
172
|
|
|
180
|
-
# Get detections
|
|
173
|
+
# Get detections for that image
|
|
181
174
|
detections = await my_detector.get_detections(img)
|
|
182
175
|
|
|
183
176
|
Args:
|
|
184
|
-
image (
|
|
177
|
+
image (ViamImage): The image to get detections for
|
|
185
178
|
|
|
186
179
|
Raises:
|
|
187
180
|
ViamError: Raised if given an image without a specified width and height
|
|
@@ -191,7 +184,7 @@ class Vision(ServiceBase):
|
|
|
191
184
|
confidence score of the labels, around the found objects in the next 2D image
|
|
192
185
|
from the given camera, with the given detector applied to it.
|
|
193
186
|
|
|
194
|
-
For more information, see `Computer Vision service <https://docs.viam.com/services/vision
|
|
187
|
+
For more information, see `Computer Vision service <https://docs.viam.com/dev/reference/apis/services/vision/#getdetections>`_.
|
|
195
188
|
"""
|
|
196
189
|
...
|
|
197
190
|
|
|
@@ -208,14 +201,11 @@ class Vision(ServiceBase):
|
|
|
208
201
|
|
|
209
202
|
::
|
|
210
203
|
|
|
211
|
-
|
|
204
|
+
my_classifier = VisionClient.from_robot(robot=machine, "my_classifier")
|
|
212
205
|
|
|
213
|
-
#
|
|
214
|
-
my_classifier = VisionClient.from_robot(robot, "my_classifier")
|
|
215
|
-
|
|
216
|
-
# Get the 2 classifications with the highest confidence scores from the next image from the camera
|
|
206
|
+
# Get the 2 classifications with the highest confidence scores for the next image from the camera
|
|
217
207
|
classifications = await my_classifier.get_classifications_from_camera(
|
|
218
|
-
|
|
208
|
+
"my_camera", 2)
|
|
219
209
|
|
|
220
210
|
Args:
|
|
221
211
|
camera_name (str): The name of the camera to use for detection
|
|
@@ -224,7 +214,7 @@ class Vision(ServiceBase):
|
|
|
224
214
|
returns:
|
|
225
215
|
List[viam.proto.service.vision.Classification]: The list of Classifications
|
|
226
216
|
|
|
227
|
-
For more information, see `Computer Vision service <https://docs.viam.com/services/vision
|
|
217
|
+
For more information, see `Computer Vision service <https://docs.viam.com/dev/reference/apis/services/vision/#getclassificationsfromcamera>`_.
|
|
228
218
|
"""
|
|
229
219
|
...
|
|
230
220
|
|
|
@@ -241,26 +231,23 @@ class Vision(ServiceBase):
|
|
|
241
231
|
|
|
242
232
|
::
|
|
243
233
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
# Get the classifier you configured on your machine
|
|
248
|
-
my_classifier = VisionClient.from_robot(robot, "my_classifier")
|
|
234
|
+
my_camera = Camera.from_robot(robot=machine, "my_camera")
|
|
235
|
+
my_classifier = VisionClient.from_robot(robot=machine, "my_classifier")
|
|
249
236
|
|
|
250
237
|
# Get an image from the camera
|
|
251
|
-
img = await
|
|
238
|
+
img = await my_camera.get_image()
|
|
252
239
|
|
|
253
|
-
# Get the 2 classifications with the highest confidence scores
|
|
240
|
+
# Get the 2 classifications with the highest confidence scores for the image
|
|
254
241
|
classifications = await my_classifier.get_classifications(img, 2)
|
|
255
242
|
|
|
256
243
|
Args:
|
|
257
|
-
image (
|
|
244
|
+
image (ViamImage): The image to get detections for
|
|
258
245
|
count (int): The number of classifications desired
|
|
259
246
|
|
|
260
247
|
Returns:
|
|
261
248
|
List[viam.proto.service.vision.Classification]: The list of Classifications
|
|
262
249
|
|
|
263
|
-
For more information, see `Computer Vision service <https://docs.viam.com/services/vision
|
|
250
|
+
For more information, see `Computer Vision service <https://docs.viam.com/dev/reference/apis/services/vision/#getclassifications>`_.
|
|
264
251
|
"""
|
|
265
252
|
...
|
|
266
253
|
|
|
@@ -283,12 +270,9 @@ class Vision(ServiceBase):
|
|
|
283
270
|
import numpy as np
|
|
284
271
|
import open3d as o3d
|
|
285
272
|
|
|
286
|
-
|
|
287
|
-
cam1 = Camera.from_robot(robot, "cam1")
|
|
288
|
-
# Grab the object segmenter you configured on your machine
|
|
289
|
-
my_segmenter = VisionClient.from_robot(robot, "my_segmenter")
|
|
273
|
+
my_segmenter = VisionClient.from_robot(robot=machine, "my_segmenter")
|
|
290
274
|
# Get the objects from the camera output
|
|
291
|
-
objects = await my_segmenter.get_object_point_clouds(
|
|
275
|
+
objects = await my_segmenter.get_object_point_clouds("my_camera")
|
|
292
276
|
# write the first object point cloud into a temporary file
|
|
293
277
|
with open("/tmp/pointcloud_data.pcd", "wb") as f:
|
|
294
278
|
f.write(objects[0].point_cloud)
|
|
@@ -301,7 +285,7 @@ class Vision(ServiceBase):
|
|
|
301
285
|
Returns:
|
|
302
286
|
List[viam.proto.common.PointCloudObject]: The pointcloud objects with metadata
|
|
303
287
|
|
|
304
|
-
For more information, see `Computer Vision service <https://docs.viam.com/services/vision
|
|
288
|
+
For more information, see `Computer Vision service <https://docs.viam.com/dev/reference/apis/services/vision/#getobjectpointclouds>`_.
|
|
305
289
|
"""
|
|
306
290
|
...
|
|
307
291
|
|
|
@@ -318,15 +302,14 @@ class Vision(ServiceBase):
|
|
|
318
302
|
|
|
319
303
|
::
|
|
320
304
|
|
|
321
|
-
|
|
322
|
-
my_detector = VisionClient.from_robot(robot, "my_detector")
|
|
305
|
+
my_detector = VisionClient.from_robot(robot=machine, "my_detector")
|
|
323
306
|
properties = await my_detector.get_properties()
|
|
324
|
-
properties.detections_supported
|
|
325
|
-
properties.classifications_supported
|
|
307
|
+
detections_supported = properties.detections_supported
|
|
308
|
+
classifications_supported = properties.classifications_supported
|
|
326
309
|
|
|
327
310
|
Returns:
|
|
328
311
|
Properties: The properties of the vision service
|
|
329
312
|
|
|
330
|
-
For more information, see `Computer Vision service <https://docs.viam.com/services/vision
|
|
313
|
+
For more information, see `Computer Vision service <https://docs.viam.com/dev/reference/apis/services/vision/#getproperties>`_.
|
|
331
314
|
"""
|
|
332
315
|
...
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from viam.proto.service.worldstatestore import StreamTransformChangesResponse, TransformChangeType
|
|
2
|
+
from viam.resource.registry import Registry, ResourceRegistration
|
|
3
|
+
|
|
4
|
+
from .client import WorldStateStoreClient
|
|
5
|
+
from .service import WorldStateStoreService
|
|
6
|
+
from .worldstatestore import WorldStateStore
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"WorldStateStore",
|
|
10
|
+
"WorldStateStoreClient",
|
|
11
|
+
"WorldStateStoreService",
|
|
12
|
+
"StreamTransformChangesResponse",
|
|
13
|
+
"TransformChangeType",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
Registry.register_api(
|
|
17
|
+
ResourceRegistration(WorldStateStore, WorldStateStoreService, lambda name, channel: WorldStateStoreClient(name, channel))
|
|
18
|
+
)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from typing import Any, AsyncGenerator, List, Mapping, Optional
|
|
2
|
+
|
|
3
|
+
from grpclib.client import Channel
|
|
4
|
+
|
|
5
|
+
from viam.proto.common import DoCommandRequest, DoCommandResponse, Transform
|
|
6
|
+
from viam.proto.service.worldstatestore import (
|
|
7
|
+
GetTransformRequest,
|
|
8
|
+
GetTransformResponse,
|
|
9
|
+
ListUUIDsRequest,
|
|
10
|
+
ListUUIDsResponse,
|
|
11
|
+
StreamTransformChangesRequest,
|
|
12
|
+
StreamTransformChangesResponse,
|
|
13
|
+
WorldStateStoreServiceStub,
|
|
14
|
+
)
|
|
15
|
+
from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase
|
|
16
|
+
from viam.utils import ValueTypes, dict_to_struct, struct_to_dict
|
|
17
|
+
|
|
18
|
+
from .worldstatestore import WorldStateStore
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class WorldStateStoreClient(WorldStateStore, ReconfigurableResourceRPCClientBase):
|
|
22
|
+
"""
|
|
23
|
+
gRPC client for the WorldStateStore service.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
client: WorldStateStoreServiceStub
|
|
27
|
+
|
|
28
|
+
def __init__(self, name: str, channel: Channel):
|
|
29
|
+
self.channel = channel
|
|
30
|
+
self.client = WorldStateStoreServiceStub(channel)
|
|
31
|
+
super().__init__(name)
|
|
32
|
+
|
|
33
|
+
async def list_uuids(
|
|
34
|
+
self,
|
|
35
|
+
*,
|
|
36
|
+
extra: Optional[Mapping[str, Any]] = None,
|
|
37
|
+
timeout: Optional[float] = None,
|
|
38
|
+
**kwargs,
|
|
39
|
+
) -> List[bytes]:
|
|
40
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
41
|
+
request = ListUUIDsRequest(
|
|
42
|
+
name=self.name,
|
|
43
|
+
extra=dict_to_struct(extra),
|
|
44
|
+
)
|
|
45
|
+
response: ListUUIDsResponse = await self.client.ListUUIDs(request, timeout=timeout, metadata=md)
|
|
46
|
+
return list(response.uuids)
|
|
47
|
+
|
|
48
|
+
async def get_transform(
|
|
49
|
+
self,
|
|
50
|
+
uuid: bytes,
|
|
51
|
+
*,
|
|
52
|
+
extra: Optional[Mapping[str, Any]] = None,
|
|
53
|
+
timeout: Optional[float] = None,
|
|
54
|
+
**kwargs,
|
|
55
|
+
) -> "Transform":
|
|
56
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
57
|
+
request = GetTransformRequest(
|
|
58
|
+
name=self.name,
|
|
59
|
+
uuid=uuid,
|
|
60
|
+
extra=dict_to_struct(extra),
|
|
61
|
+
)
|
|
62
|
+
response: GetTransformResponse = await self.client.GetTransform(request, timeout=timeout, metadata=md)
|
|
63
|
+
return response.transform
|
|
64
|
+
|
|
65
|
+
async def stream_transform_changes(
|
|
66
|
+
self,
|
|
67
|
+
*,
|
|
68
|
+
extra: Optional[Mapping[str, Any]] = None,
|
|
69
|
+
timeout: Optional[float] = None,
|
|
70
|
+
**kwargs,
|
|
71
|
+
) -> AsyncGenerator[StreamTransformChangesResponse, None]:
|
|
72
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
73
|
+
request = StreamTransformChangesRequest(
|
|
74
|
+
name=self.name,
|
|
75
|
+
extra=dict_to_struct(extra),
|
|
76
|
+
)
|
|
77
|
+
responses = await self.client.StreamTransformChanges(request, timeout=timeout, metadata=md)
|
|
78
|
+
for response in responses:
|
|
79
|
+
yield response
|
|
80
|
+
|
|
81
|
+
async def do_command(
|
|
82
|
+
self,
|
|
83
|
+
command: Mapping[str, ValueTypes],
|
|
84
|
+
*,
|
|
85
|
+
timeout: Optional[float] = None,
|
|
86
|
+
**kwargs,
|
|
87
|
+
) -> Mapping[str, ValueTypes]:
|
|
88
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
89
|
+
request = DoCommandRequest(
|
|
90
|
+
name=self.name,
|
|
91
|
+
command=dict_to_struct(command),
|
|
92
|
+
)
|
|
93
|
+
response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout, metadata=md)
|
|
94
|
+
return struct_to_dict(response.result)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from grpclib.server import Stream
|
|
2
|
+
|
|
3
|
+
from viam.proto.common import DoCommandRequest, DoCommandResponse
|
|
4
|
+
from viam.proto.service.worldstatestore import (
|
|
5
|
+
GetTransformRequest,
|
|
6
|
+
GetTransformResponse,
|
|
7
|
+
ListUUIDsRequest,
|
|
8
|
+
ListUUIDsResponse,
|
|
9
|
+
StreamTransformChangesRequest,
|
|
10
|
+
StreamTransformChangesResponse,
|
|
11
|
+
UnimplementedWorldStateStoreServiceBase,
|
|
12
|
+
)
|
|
13
|
+
from viam.resource.rpc_service_base import ResourceRPCServiceBase
|
|
14
|
+
from viam.utils import dict_to_struct, struct_to_dict
|
|
15
|
+
|
|
16
|
+
from .worldstatestore import WorldStateStore
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class WorldStateStoreService(UnimplementedWorldStateStoreServiceBase, ResourceRPCServiceBase[WorldStateStore]):
|
|
20
|
+
RESOURCE_TYPE = WorldStateStore
|
|
21
|
+
|
|
22
|
+
async def ListUUIDs(self, stream: Stream[ListUUIDsRequest, ListUUIDsResponse]) -> None:
|
|
23
|
+
request = await stream.recv_message()
|
|
24
|
+
assert request is not None
|
|
25
|
+
service = self.get_resource(request.name)
|
|
26
|
+
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
27
|
+
uuids = await service.list_uuids(extra=struct_to_dict(request.extra), timeout=timeout)
|
|
28
|
+
await stream.send_message(ListUUIDsResponse(uuids=uuids))
|
|
29
|
+
|
|
30
|
+
async def GetTransform(self, stream: Stream[GetTransformRequest, GetTransformResponse]) -> None:
|
|
31
|
+
request = await stream.recv_message()
|
|
32
|
+
assert request is not None
|
|
33
|
+
service = self.get_resource(request.name)
|
|
34
|
+
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
35
|
+
transform = await service.get_transform(uuid=request.uuid, extra=struct_to_dict(request.extra), timeout=timeout)
|
|
36
|
+
await stream.send_message(GetTransformResponse(transform=transform))
|
|
37
|
+
|
|
38
|
+
async def StreamTransformChanges(
|
|
39
|
+
self,
|
|
40
|
+
stream: Stream[StreamTransformChangesRequest, StreamTransformChangesResponse],
|
|
41
|
+
) -> None:
|
|
42
|
+
request = await stream.recv_message()
|
|
43
|
+
assert request is not None
|
|
44
|
+
service = self.get_resource(request.name)
|
|
45
|
+
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
46
|
+
async for change in service.stream_transform_changes(extra=struct_to_dict(request.extra), timeout=timeout):
|
|
47
|
+
await stream.send_message(change)
|
|
48
|
+
|
|
49
|
+
async def DoCommand(self, stream: Stream[DoCommandRequest, DoCommandResponse]) -> None:
|
|
50
|
+
request = await stream.recv_message()
|
|
51
|
+
assert request is not None
|
|
52
|
+
worldstatestore = self.get_resource(request.name)
|
|
53
|
+
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
54
|
+
result = await worldstatestore.do_command(struct_to_dict(request.command), timeout=timeout)
|
|
55
|
+
await stream.send_message(DoCommandResponse(result=dict_to_struct(result)))
|