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/robot/client.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import sys
|
|
2
3
|
from dataclasses import dataclass
|
|
3
4
|
from datetime import datetime
|
|
4
5
|
from threading import RLock
|
|
@@ -16,23 +17,25 @@ from viam.proto.common import LogEntry, PoseInFrame, ResourceName, Transform
|
|
|
16
17
|
from viam.proto.robot import (
|
|
17
18
|
BlockForOperationRequest,
|
|
18
19
|
CancelOperationRequest,
|
|
19
|
-
DiscoverComponentsRequest,
|
|
20
|
-
DiscoverComponentsResponse,
|
|
21
|
-
Discovery,
|
|
22
|
-
DiscoveryQuery,
|
|
23
20
|
FrameSystemConfig,
|
|
24
21
|
FrameSystemConfigRequest,
|
|
25
22
|
FrameSystemConfigResponse,
|
|
26
23
|
GetCloudMetadataRequest,
|
|
27
24
|
GetCloudMetadataResponse,
|
|
25
|
+
GetMachineStatusRequest,
|
|
26
|
+
GetMachineStatusResponse,
|
|
27
|
+
GetModelsFromModulesRequest,
|
|
28
|
+
GetModelsFromModulesResponse,
|
|
28
29
|
GetOperationsRequest,
|
|
29
30
|
GetOperationsResponse,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
GetVersionRequest,
|
|
32
|
+
GetVersionResponse,
|
|
32
33
|
LogRequest,
|
|
34
|
+
ModuleModel,
|
|
33
35
|
Operation,
|
|
34
36
|
ResourceNamesRequest,
|
|
35
37
|
ResourceNamesResponse,
|
|
38
|
+
RestartModuleRequest,
|
|
36
39
|
RobotServiceStub,
|
|
37
40
|
ShutdownRequest,
|
|
38
41
|
StopAllRequest,
|
|
@@ -44,8 +47,8 @@ from viam.resource.base import ResourceBase
|
|
|
44
47
|
from viam.resource.manager import ResourceManager
|
|
45
48
|
from viam.resource.registry import Registry
|
|
46
49
|
from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase, ResourceRPCClientBase
|
|
47
|
-
from viam.resource.types import RESOURCE_TYPE_COMPONENT, RESOURCE_TYPE_SERVICE
|
|
48
|
-
from viam.rpc.dial import DialOptions, ViamChannel, dial
|
|
50
|
+
from viam.resource.types import API, RESOURCE_TYPE_COMPONENT, RESOURCE_TYPE_SERVICE
|
|
51
|
+
from viam.rpc.dial import DialOptions, ViamChannel, _dial_inner, dial
|
|
49
52
|
from viam.services.service_base import ServiceBase
|
|
50
53
|
from viam.sessions_client import SessionsClient
|
|
51
54
|
from viam.utils import datetime_to_timestamp, dict_to_struct
|
|
@@ -54,7 +57,7 @@ LOGGER = logging.getLogger(__name__)
|
|
|
54
57
|
|
|
55
58
|
|
|
56
59
|
class RobotClient:
|
|
57
|
-
"""gRPC client for a
|
|
60
|
+
"""gRPC client for a machine. This class should be used for all interactions with a machine.
|
|
58
61
|
|
|
59
62
|
There are 2 ways to instantiate a robot client::
|
|
60
63
|
|
|
@@ -63,12 +66,12 @@ class RobotClient:
|
|
|
63
66
|
|
|
64
67
|
You can use the client standalone or within a context::
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
async with await RobotClient.with_channel(...) as
|
|
69
|
+
machine = await RobotClient.at_address(...)
|
|
70
|
+
async with await RobotClient.with_channel(...) as machine: ...
|
|
68
71
|
|
|
69
|
-
You must ``close()`` the
|
|
72
|
+
You must ``close()`` the machine to release resources.
|
|
70
73
|
|
|
71
|
-
Note:
|
|
74
|
+
Note: Machines used within a context are automatically closed UNLESS created with a channel. Machines created using ``with_channel`` are
|
|
72
75
|
not automatically closed.
|
|
73
76
|
|
|
74
77
|
Establish a Connection::
|
|
@@ -91,10 +94,10 @@ class RobotClient:
|
|
|
91
94
|
|
|
92
95
|
async def main():
|
|
93
96
|
# Make a RobotClient
|
|
94
|
-
|
|
97
|
+
machine = await connect()
|
|
95
98
|
print('Resources:')
|
|
96
|
-
print(
|
|
97
|
-
await
|
|
99
|
+
print(machine.resource_names)
|
|
100
|
+
await machine.close()
|
|
98
101
|
|
|
99
102
|
if __name__ == '__main__':
|
|
100
103
|
asyncio.run(main())
|
|
@@ -106,8 +109,8 @@ class RobotClient:
|
|
|
106
109
|
class Options:
|
|
107
110
|
refresh_interval: int = 0
|
|
108
111
|
"""
|
|
109
|
-
How often to refresh the status
|
|
110
|
-
If not set, the
|
|
112
|
+
How often to refresh the status of the parts of the machine in seconds.
|
|
113
|
+
If not set, the machine will not be refreshed automatically
|
|
111
114
|
"""
|
|
112
115
|
|
|
113
116
|
dial_options: Optional[DialOptions] = None
|
|
@@ -122,12 +125,12 @@ class RobotClient:
|
|
|
122
125
|
|
|
123
126
|
check_connection_interval: int = 10
|
|
124
127
|
"""
|
|
125
|
-
The frequency (in seconds) at which to check if the
|
|
128
|
+
The frequency (in seconds) at which to check if the machine is still connected. 0 (zero) signifies no connection checks
|
|
126
129
|
"""
|
|
127
130
|
|
|
128
131
|
attempt_reconnect_interval: int = 1
|
|
129
132
|
"""
|
|
130
|
-
The frequency (in seconds) at which to attempt to reconnect a disconnected
|
|
133
|
+
The frequency (in seconds) at which to attempt to reconnect a disconnected machine. 0 (zero) signifies no reconnection attempts
|
|
131
134
|
"""
|
|
132
135
|
|
|
133
136
|
disable_sessions: bool = False
|
|
@@ -149,7 +152,7 @@ class RobotClient:
|
|
|
149
152
|
|
|
150
153
|
opts = RobotClient.Options.with_api_key(api_key, api_key_id)
|
|
151
154
|
|
|
152
|
-
|
|
155
|
+
machine = await RobotClient.at_address('<ADDRESS-FROM-THE-VIAM-APP>', opts)
|
|
153
156
|
|
|
154
157
|
Args:
|
|
155
158
|
api_key (str): your API key
|
|
@@ -170,7 +173,7 @@ class RobotClient:
|
|
|
170
173
|
|
|
171
174
|
@classmethod
|
|
172
175
|
async def at_address(cls, address: str, options: Options) -> Self:
|
|
173
|
-
"""Create a robot client that is connected to the
|
|
176
|
+
"""Create a robot client that is connected to the machine at the provided address.
|
|
174
177
|
|
|
175
178
|
::
|
|
176
179
|
|
|
@@ -182,15 +185,15 @@ class RobotClient:
|
|
|
182
185
|
# Replace "<API-KEY-ID>" (including brackets) with your machine's API key ID
|
|
183
186
|
api_key_id='<API-KEY-ID>'
|
|
184
187
|
)
|
|
185
|
-
return await RobotClient.at_address('ADDRESS
|
|
188
|
+
return await RobotClient.at_address('MACHINE ADDRESS', opts)
|
|
186
189
|
|
|
187
190
|
|
|
188
191
|
async def main():
|
|
189
192
|
# Make a RobotClient
|
|
190
|
-
|
|
193
|
+
machine = await connect()
|
|
191
194
|
|
|
192
195
|
Args:
|
|
193
|
-
address (str): Address of the
|
|
196
|
+
address (str): Address of the machine (IP address, URL, etc.)
|
|
194
197
|
options (Options): Options for connecting and refreshing
|
|
195
198
|
|
|
196
199
|
Returns:
|
|
@@ -200,15 +203,15 @@ class RobotClient:
|
|
|
200
203
|
"""
|
|
201
204
|
logging.setLevel(options.log_level)
|
|
202
205
|
channel = await dial(address, options.dial_options)
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return
|
|
206
|
+
machine = await cls._with_channel(channel, options, True, robot_addr=address)
|
|
207
|
+
machine._address = address
|
|
208
|
+
return machine
|
|
206
209
|
|
|
207
210
|
@classmethod
|
|
208
211
|
async def with_channel(cls, channel: Union[Channel, ViamChannel], options: Options) -> Self:
|
|
209
|
-
"""Create a
|
|
212
|
+
"""Create a machine that is connected to a machine over the given channel.
|
|
210
213
|
|
|
211
|
-
Any
|
|
214
|
+
Any machines created using this method will *NOT* automatically close the channel upon exit.
|
|
212
215
|
|
|
213
216
|
::
|
|
214
217
|
|
|
@@ -220,10 +223,10 @@ class RobotClient:
|
|
|
220
223
|
async with await dial('ADDRESS', DialOptions()) as channel:
|
|
221
224
|
return await RobotClient.with_channel(channel, RobotClient.Options())
|
|
222
225
|
|
|
223
|
-
|
|
226
|
+
machine = await connect_with_channel()
|
|
224
227
|
|
|
225
228
|
Args:
|
|
226
|
-
channel (ViamChannel): The channel that is connected to a
|
|
229
|
+
channel (ViamChannel): The channel that is connected to a machine, obtained by ``viam.rpc.dial``
|
|
227
230
|
options (Options): Options for refreshing. Any connection options will be ignored.
|
|
228
231
|
|
|
229
232
|
Returns:
|
|
@@ -235,7 +238,9 @@ class RobotClient:
|
|
|
235
238
|
return await cls._with_channel(channel, options, False)
|
|
236
239
|
|
|
237
240
|
@classmethod
|
|
238
|
-
async def _with_channel(
|
|
241
|
+
async def _with_channel(
|
|
242
|
+
cls, channel: Union[Channel, ViamChannel], options: Options, close_channel: bool, robot_addr: Optional[str] = None
|
|
243
|
+
):
|
|
239
244
|
"""INTERNAL USE ONLY"""
|
|
240
245
|
|
|
241
246
|
self = cls()
|
|
@@ -256,15 +261,15 @@ class RobotClient:
|
|
|
256
261
|
self._options = options
|
|
257
262
|
self._address = self._channel._path if self._channel._path else f"{self._channel._host}:{self._channel._port}"
|
|
258
263
|
self._sessions_client = SessionsClient(
|
|
259
|
-
self._channel, self._address, self._options.dial_options, disabled=self._options.disable_sessions
|
|
264
|
+
self._channel, self._address, self._options.dial_options, disabled=self._options.disable_sessions, robot_addr=robot_addr
|
|
260
265
|
)
|
|
261
266
|
|
|
262
267
|
try:
|
|
263
268
|
await self.refresh()
|
|
264
269
|
except Exception:
|
|
265
|
-
LOGGER.error("Unable to establish a connection to the
|
|
270
|
+
LOGGER.error("Unable to establish a connection to the machine. Ensure the machine is online and reachable and try again.")
|
|
266
271
|
await self.close()
|
|
267
|
-
raise ConnectionError("Unable to establish a connection to the
|
|
272
|
+
raise ConnectionError("Unable to establish a connection to the machine.")
|
|
268
273
|
|
|
269
274
|
if options.refresh_interval > 0:
|
|
270
275
|
self._refresh_task = asyncio.create_task(
|
|
@@ -296,11 +301,11 @@ class RobotClient:
|
|
|
296
301
|
|
|
297
302
|
async def refresh(self):
|
|
298
303
|
"""
|
|
299
|
-
Manually refresh the underlying parts of this
|
|
304
|
+
Manually refresh the underlying parts of this machine.
|
|
300
305
|
|
|
301
306
|
::
|
|
302
307
|
|
|
303
|
-
await
|
|
308
|
+
await machine.refresh()
|
|
304
309
|
|
|
305
310
|
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
306
311
|
"""
|
|
@@ -337,12 +342,12 @@ class RobotClient:
|
|
|
337
342
|
else:
|
|
338
343
|
await self._manager.remove_resource(resourceName)
|
|
339
344
|
self._manager.register(
|
|
340
|
-
Registry.
|
|
345
|
+
Registry.lookup_api(API.from_resource_name(resourceName)).create_rpc_client(resourceName.name, self._channel)
|
|
341
346
|
)
|
|
342
347
|
else:
|
|
343
348
|
try:
|
|
344
349
|
self._manager.register(
|
|
345
|
-
Registry.
|
|
350
|
+
Registry.lookup_api(API.from_resource_name(resourceName)).create_rpc_client(resourceName.name, self._channel)
|
|
346
351
|
)
|
|
347
352
|
except ResourceNotFoundError:
|
|
348
353
|
pass
|
|
@@ -375,7 +380,7 @@ class RobotClient:
|
|
|
375
380
|
connection_error = e
|
|
376
381
|
await asyncio.sleep(0.1)
|
|
377
382
|
if connection_error:
|
|
378
|
-
msg = "Lost connection to
|
|
383
|
+
msg = "Lost connection to machine."
|
|
379
384
|
if reconnect_every > 0:
|
|
380
385
|
msg += (
|
|
381
386
|
f" Attempting to reconnect to {self._address} every {reconnect_every} second{'s' if reconnect_every != 1 else ''}"
|
|
@@ -396,7 +401,7 @@ class RobotClient:
|
|
|
396
401
|
try:
|
|
397
402
|
self._sessions_client.reset()
|
|
398
403
|
|
|
399
|
-
channel = await
|
|
404
|
+
channel = await _dial_inner(self._address, self._options.dial_options)
|
|
400
405
|
|
|
401
406
|
client: RobotServiceStub
|
|
402
407
|
if isinstance(channel, Channel):
|
|
@@ -418,17 +423,21 @@ class RobotClient:
|
|
|
418
423
|
direct_dial_address=direct_dial_address,
|
|
419
424
|
dial_options=self._options.dial_options,
|
|
420
425
|
disabled=self._options.disable_sessions,
|
|
426
|
+
robot_addr=self._address,
|
|
421
427
|
)
|
|
422
428
|
|
|
423
429
|
await self.refresh()
|
|
424
430
|
self._connected = True
|
|
425
|
-
LOGGER.debug("Successfully reconnected
|
|
431
|
+
LOGGER.debug("Successfully reconnected machine")
|
|
426
432
|
break
|
|
427
433
|
except Exception as e:
|
|
428
434
|
LOGGER.error(f"Failed to reconnect, trying again in {reconnect_every}sec", exc_info=e)
|
|
429
435
|
self._sessions_client.reset()
|
|
430
436
|
self._close_channel()
|
|
431
437
|
await asyncio.sleep(reconnect_every)
|
|
438
|
+
if not self._connected:
|
|
439
|
+
# We failed to reconnect, sys.exit() so that this thread doesn't stick around forever.
|
|
440
|
+
sys.exit()
|
|
432
441
|
|
|
433
442
|
def get_component(self, name: ResourceName) -> ComponentBase:
|
|
434
443
|
"""Get a component using its ResourceName.
|
|
@@ -437,7 +446,7 @@ class RobotClient:
|
|
|
437
446
|
method for obtaining components.
|
|
438
447
|
::
|
|
439
448
|
|
|
440
|
-
arm = Arm.from_robot(robot=
|
|
449
|
+
arm = Arm.from_robot(robot=machine, name="my_arm")
|
|
441
450
|
|
|
442
451
|
Because this function returns a generic ``ComponentBase`` rather than the specific
|
|
443
452
|
component type, it will be necessary to cast the returned component to the desired component. This can be done using a few
|
|
@@ -445,14 +454,14 @@ class RobotClient:
|
|
|
445
454
|
|
|
446
455
|
- Assertion::
|
|
447
456
|
|
|
448
|
-
arm =
|
|
457
|
+
arm = machine.get_component(Arm.get_resource_name("my_arm"))
|
|
449
458
|
assert isinstance(arm, Arm)
|
|
450
459
|
end_pos = await arm.get_end_position()
|
|
451
460
|
|
|
452
461
|
- Explicit cast::
|
|
453
462
|
|
|
454
463
|
from typing import cast
|
|
455
|
-
arm =
|
|
464
|
+
arm = machine.get_component(Arm.get_resource_name("my_arm"))
|
|
456
465
|
arm = cast(Arm, arm)
|
|
457
466
|
end_pos = await arm.get_end_position()
|
|
458
467
|
|
|
@@ -461,7 +470,7 @@ class RobotClient:
|
|
|
461
470
|
- Note: If using an IDE, a type error may be shown which can be ignored.
|
|
462
471
|
::
|
|
463
472
|
|
|
464
|
-
arm: Arm =
|
|
473
|
+
arm: Arm = machine.get_component(Arm.get_resource_name("my_arm")) # type: ignore
|
|
465
474
|
end_pos = await arm.get_end_position()
|
|
466
475
|
|
|
467
476
|
Args:
|
|
@@ -488,20 +497,20 @@ class RobotClient:
|
|
|
488
497
|
method for obtaining services.
|
|
489
498
|
::
|
|
490
499
|
|
|
491
|
-
service = MyService.from_robot(robot=
|
|
500
|
+
service = MyService.from_robot(robot=machine, name="my_service")
|
|
492
501
|
|
|
493
502
|
Because this function returns a generic ``ServiceBase`` rather than a specific service type, it will be necessary to cast the
|
|
494
503
|
returned service to the desired service. This can be done using a few methods:
|
|
495
504
|
|
|
496
505
|
- Assertion::
|
|
497
506
|
|
|
498
|
-
service =
|
|
507
|
+
service = machine.get_service(MyService.get_resource_name("my_service"))
|
|
499
508
|
assert isinstance(service, MyService)
|
|
500
509
|
|
|
501
510
|
- Explicit cast::
|
|
502
511
|
|
|
503
512
|
from typing import cast
|
|
504
|
-
service =
|
|
513
|
+
service = machine.get_service(MyService.get_resource_name("my_service"))
|
|
505
514
|
service = cast(MyService, my_service)
|
|
506
515
|
|
|
507
516
|
- Declare type on variable assignment
|
|
@@ -509,7 +518,7 @@ class RobotClient:
|
|
|
509
518
|
- Note: If using an IDE, a type error may be shown which can be ignored.
|
|
510
519
|
::
|
|
511
520
|
|
|
512
|
-
service: MyService =
|
|
521
|
+
service: MyService = machine.get_service(MyService.get_resource_name("my_service")) # type: ignore
|
|
513
522
|
|
|
514
523
|
Args:
|
|
515
524
|
name (viam.proto.common.ResourceName): The service's ResourceName
|
|
@@ -535,7 +544,7 @@ class RobotClient:
|
|
|
535
544
|
|
|
536
545
|
::
|
|
537
546
|
|
|
538
|
-
resource_names =
|
|
547
|
+
resource_names = machine.resource_names
|
|
539
548
|
|
|
540
549
|
Returns:
|
|
541
550
|
List[viam.proto.common.ResourceName]: The list of resource names
|
|
@@ -560,7 +569,7 @@ class RobotClient:
|
|
|
560
569
|
|
|
561
570
|
::
|
|
562
571
|
|
|
563
|
-
await
|
|
572
|
+
await machine.close()
|
|
564
573
|
|
|
565
574
|
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
566
575
|
"""
|
|
@@ -596,44 +605,20 @@ class RobotClient:
|
|
|
596
605
|
async def __aexit__(self, exc_type, exc_value, traceback):
|
|
597
606
|
await self.close()
|
|
598
607
|
|
|
599
|
-
##########
|
|
600
|
-
# STATUS #
|
|
601
|
-
##########
|
|
602
|
-
async def get_status(self, components: Optional[List[ResourceName]] = None):
|
|
603
|
-
"""
|
|
604
|
-
Get the status of the robot's components. You can optionally
|
|
605
|
-
provide a list of ``ResourceName`` for which you want statuses.
|
|
606
|
-
|
|
607
|
-
::
|
|
608
|
-
|
|
609
|
-
# Get the status of the resources on the machine.
|
|
610
|
-
statuses = await robot.get_status()
|
|
611
|
-
|
|
612
|
-
Args:
|
|
613
|
-
components (Optional[List[viam.proto.common.ResourceName]]): Optional list of
|
|
614
|
-
``ResourceName`` for components you want statuses.
|
|
615
|
-
|
|
616
|
-
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
617
|
-
"""
|
|
618
|
-
names = components if components is not None else []
|
|
619
|
-
request = GetStatusRequest(resource_names=names)
|
|
620
|
-
response: GetStatusResponse = await self._client.GetStatus(request)
|
|
621
|
-
return list(response.status)
|
|
622
|
-
|
|
623
608
|
##############
|
|
624
609
|
# OPERATIONS #
|
|
625
610
|
##############
|
|
626
611
|
|
|
627
612
|
async def get_operations(self) -> List[Operation]:
|
|
628
613
|
"""
|
|
629
|
-
Get the list of operations currently running on the
|
|
614
|
+
Get the list of operations currently running on the machine.
|
|
630
615
|
|
|
631
616
|
::
|
|
632
617
|
|
|
633
|
-
operations = await
|
|
618
|
+
operations = await machine.get_operations()
|
|
634
619
|
|
|
635
620
|
Returns:
|
|
636
|
-
List[viam.proto.robot.Operation]: The list of operations currently running on a given
|
|
621
|
+
List[viam.proto.robot.Operation]: The list of operations currently running on a given machine.
|
|
637
622
|
|
|
638
623
|
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
639
624
|
"""
|
|
@@ -643,11 +628,11 @@ class RobotClient:
|
|
|
643
628
|
|
|
644
629
|
async def cancel_operation(self, id: str):
|
|
645
630
|
"""
|
|
646
|
-
Cancels the specified operation on the
|
|
631
|
+
Cancels the specified operation on the machine.
|
|
647
632
|
|
|
648
633
|
::
|
|
649
634
|
|
|
650
|
-
await
|
|
635
|
+
await machine.cancel_operation("INSERT OPERATION ID")
|
|
651
636
|
|
|
652
637
|
Args:
|
|
653
638
|
id (str): ID of operation to cancel.
|
|
@@ -659,12 +644,12 @@ class RobotClient:
|
|
|
659
644
|
|
|
660
645
|
async def block_for_operation(self, id: str):
|
|
661
646
|
"""
|
|
662
|
-
Blocks on the specified operation on the
|
|
647
|
+
Blocks on the specified operation on the machine. This function will only return when the specific operation
|
|
663
648
|
has finished or has been cancelled.
|
|
664
649
|
|
|
665
650
|
::
|
|
666
651
|
|
|
667
|
-
await
|
|
652
|
+
await machine.block_for_operation("INSERT OPERATION ID")
|
|
668
653
|
|
|
669
654
|
Args:
|
|
670
655
|
id (str): ID of operation to block on.
|
|
@@ -680,16 +665,16 @@ class RobotClient:
|
|
|
680
665
|
|
|
681
666
|
async def get_frame_system_config(self, additional_transforms: Optional[List[Transform]] = None) -> List[FrameSystemConfig]:
|
|
682
667
|
"""
|
|
683
|
-
Get the configuration of the frame system of a given
|
|
668
|
+
Get the configuration of the frame system of a given machine.
|
|
684
669
|
|
|
685
670
|
::
|
|
686
671
|
|
|
687
672
|
# Get a list of each of the reference frames configured on the machine.
|
|
688
|
-
frame_system = await
|
|
673
|
+
frame_system = await machine.get_frame_system_config()
|
|
689
674
|
print(f"frame system configuration: {frame_system}")
|
|
690
675
|
|
|
691
676
|
Returns:
|
|
692
|
-
List[viam.proto.robot.FrameSystemConfig]: The configuration of a given
|
|
677
|
+
List[viam.proto.robot.FrameSystemConfig]: The configuration of a given machine's frame system.
|
|
693
678
|
|
|
694
679
|
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
695
680
|
"""
|
|
@@ -705,7 +690,24 @@ class RobotClient:
|
|
|
705
690
|
|
|
706
691
|
::
|
|
707
692
|
|
|
708
|
-
|
|
693
|
+
from viam.proto.common import Pose, PoseInFrame
|
|
694
|
+
|
|
695
|
+
pose = Pose(
|
|
696
|
+
x=1.0, # X coordinate in mm
|
|
697
|
+
y=2.0, # Y coordinate in mm
|
|
698
|
+
z=3.0, # Z coordinate in mm
|
|
699
|
+
o_x=0.0, # X component of orientation vector
|
|
700
|
+
o_y=0.0, # Y component of orientation vector
|
|
701
|
+
o_z=0.0, # Z component of orientation vector
|
|
702
|
+
theta=0.0 # Orientation angle in degrees
|
|
703
|
+
)
|
|
704
|
+
|
|
705
|
+
pose_in_frame = PoseInFrame(
|
|
706
|
+
reference_frame="world",
|
|
707
|
+
pose=pose
|
|
708
|
+
)
|
|
709
|
+
|
|
710
|
+
transformed_pose = await machine.transform_pose(pose_in_frame, "world")
|
|
709
711
|
|
|
710
712
|
Args:
|
|
711
713
|
|
|
@@ -724,40 +726,30 @@ class RobotClient:
|
|
|
724
726
|
async def transform_point_cloud(self):
|
|
725
727
|
raise NotImplementedError()
|
|
726
728
|
|
|
727
|
-
|
|
728
|
-
#
|
|
729
|
-
|
|
729
|
+
#################
|
|
730
|
+
# MODULE MODELS #
|
|
731
|
+
#################
|
|
730
732
|
|
|
731
|
-
async def
|
|
733
|
+
async def get_models_from_modules(
|
|
732
734
|
self,
|
|
733
|
-
|
|
734
|
-
) -> List[Discovery]:
|
|
735
|
+
) -> List[ModuleModel]:
|
|
735
736
|
"""
|
|
736
|
-
Get
|
|
737
|
+
Get a list of all models provided by local and registry modules on the machine.
|
|
738
|
+
This includes models that are not currently configured on the machine.
|
|
737
739
|
|
|
738
740
|
::
|
|
739
741
|
|
|
740
|
-
#
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
# Define a list of discovery queries.
|
|
744
|
-
qs = [q]
|
|
745
|
-
|
|
746
|
-
# Get component configurations with these queries.
|
|
747
|
-
component_configs = await robot.discover_components(qs)
|
|
742
|
+
# Get module models
|
|
743
|
+
module_models = await machine.get_models_from_modules(qs)
|
|
748
744
|
|
|
749
745
|
Args:
|
|
750
746
|
|
|
751
|
-
queries (List[viam.proto.robot.DiscoveryQuery]): The list of component models to lookup configurations for.
|
|
752
|
-
|
|
753
747
|
Returns:
|
|
754
|
-
List[
|
|
755
|
-
|
|
756
|
-
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
748
|
+
List[ModuleModel]: A list of discovered models.
|
|
757
749
|
"""
|
|
758
|
-
request =
|
|
759
|
-
response:
|
|
760
|
-
return list(response.
|
|
750
|
+
request = GetModelsFromModulesRequest()
|
|
751
|
+
response: GetModelsFromModulesResponse = await self._client.GetModelsFromModules(request)
|
|
752
|
+
return list(response.models)
|
|
761
753
|
|
|
762
754
|
############
|
|
763
755
|
# STOP ALL #
|
|
@@ -765,16 +757,12 @@ class RobotClient:
|
|
|
765
757
|
|
|
766
758
|
async def stop_all(self, extra: Dict[ResourceName, Dict[str, Any]] = {}):
|
|
767
759
|
"""
|
|
768
|
-
Cancel all current and outstanding operations for the
|
|
760
|
+
Cancel all current and outstanding operations for the machine and stop all actuators and movement.
|
|
769
761
|
|
|
770
762
|
::
|
|
771
763
|
|
|
772
|
-
# Cancel all current and outstanding operations for the
|
|
773
|
-
await
|
|
774
|
-
|
|
775
|
-
::
|
|
776
|
-
|
|
777
|
-
await robot.stop_all()
|
|
764
|
+
# Cancel all current and outstanding operations for the machine and stop all actuators and movement.
|
|
765
|
+
await machine.stop_all()
|
|
778
766
|
|
|
779
767
|
Args:
|
|
780
768
|
extra (Dict[viam.proto.common.ResourceName, Dict[str, Any]]): Any extra parameters to pass to the resources' ``stop`` methods,
|
|
@@ -817,11 +805,11 @@ class RobotClient:
|
|
|
817
805
|
|
|
818
806
|
async def get_cloud_metadata(self) -> GetCloudMetadataResponse:
|
|
819
807
|
"""
|
|
820
|
-
Get app-related information about the
|
|
808
|
+
Get app-related information about the machine.
|
|
821
809
|
|
|
822
810
|
::
|
|
823
811
|
|
|
824
|
-
metadata = machine.get_cloud_metadata()
|
|
812
|
+
metadata = await machine.get_cloud_metadata()
|
|
825
813
|
print(metadata.machine_id)
|
|
826
814
|
print(metadata.machine_part_id)
|
|
827
815
|
print(metadata.primary_org_id)
|
|
@@ -844,10 +832,14 @@ class RobotClient:
|
|
|
844
832
|
"""
|
|
845
833
|
Shutdown shuts down the machine.
|
|
846
834
|
|
|
835
|
+
::
|
|
836
|
+
|
|
837
|
+
await machine.shutdown()
|
|
838
|
+
|
|
847
839
|
Raises:
|
|
848
840
|
GRPCError: Raised with DeadlineExceeded status if shutdown request times out, or if
|
|
849
|
-
|
|
850
|
-
status Unavailable if server is unavailable, or if
|
|
841
|
+
the machine server shuts down before having a chance to send a response. Raised with
|
|
842
|
+
status Unavailable if server is unavailable, or if machine server is in the process of
|
|
851
843
|
shutting down when response is ready.
|
|
852
844
|
|
|
853
845
|
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
@@ -867,3 +859,79 @@ class RobotClient:
|
|
|
867
859
|
raise e
|
|
868
860
|
else:
|
|
869
861
|
raise e
|
|
862
|
+
|
|
863
|
+
######################
|
|
864
|
+
# Get Version #
|
|
865
|
+
######################
|
|
866
|
+
|
|
867
|
+
async def get_version(self) -> GetVersionResponse:
|
|
868
|
+
"""
|
|
869
|
+
Get version information about the machine.
|
|
870
|
+
|
|
871
|
+
::
|
|
872
|
+
|
|
873
|
+
result = await machine.get_version()
|
|
874
|
+
print(result.platform)
|
|
875
|
+
print(result.version)
|
|
876
|
+
print(result.api_version)
|
|
877
|
+
|
|
878
|
+
Returns:
|
|
879
|
+
viam.proto.robot.GetVersionResponse: Machine version related information.
|
|
880
|
+
|
|
881
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
882
|
+
"""
|
|
883
|
+
|
|
884
|
+
request = GetVersionRequest()
|
|
885
|
+
return await self._client.GetVersion(request)
|
|
886
|
+
|
|
887
|
+
######################
|
|
888
|
+
# Get Machine Status #
|
|
889
|
+
######################
|
|
890
|
+
|
|
891
|
+
async def get_machine_status(self) -> GetMachineStatusResponse:
|
|
892
|
+
"""
|
|
893
|
+
Get status information about the machine's resources and configuration.
|
|
894
|
+
|
|
895
|
+
::
|
|
896
|
+
|
|
897
|
+
machine_status = await machine.get_machine_status()
|
|
898
|
+
machine_state = machine_status.state
|
|
899
|
+
resource_statuses = machine_status.resources
|
|
900
|
+
cloud_metadata = machine_status.resources[0].cloud_metadata
|
|
901
|
+
config_status = machine_status.config
|
|
902
|
+
|
|
903
|
+
Returns:
|
|
904
|
+
viam.proto.robot.GetMachineStatusResponse: current status of the machine (initializing or running), current status of the resources (List[ResourceStatus]) and the revision of the config of the machine.
|
|
905
|
+
|
|
906
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
907
|
+
"""
|
|
908
|
+
|
|
909
|
+
request = GetMachineStatusRequest()
|
|
910
|
+
return await self._client.GetMachineStatus(request)
|
|
911
|
+
|
|
912
|
+
##################
|
|
913
|
+
# Restart Module #
|
|
914
|
+
##################
|
|
915
|
+
|
|
916
|
+
async def restart_module(self, id: Optional[str] = None, name: Optional[str] = None):
|
|
917
|
+
"""
|
|
918
|
+
Restarts a module running on the machine with the given id or name.
|
|
919
|
+
|
|
920
|
+
::
|
|
921
|
+
|
|
922
|
+
await machine.restart_module(id="namespace:module:model", name="my_model")
|
|
923
|
+
|
|
924
|
+
Args:
|
|
925
|
+
id (str): The id matching the module_id field of the registry module in your part configuration.
|
|
926
|
+
name (str): The name matching the name field of the local/registry module in your part configuration.
|
|
927
|
+
|
|
928
|
+
Raises:
|
|
929
|
+
GRPCError: If a module can't be found matching the provided ID or name.
|
|
930
|
+
|
|
931
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
932
|
+
"""
|
|
933
|
+
|
|
934
|
+
id = id if id else ""
|
|
935
|
+
name = name if name else ""
|
|
936
|
+
request = RestartModuleRequest(module_id=id, module_name=name)
|
|
937
|
+
await self._client.RestartModule(request)
|