viam-sdk 0.3.0__py3-none-linux_armv6l.whl → 0.66.0__py3-none-linux_armv6l.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.
Potentially problematic release.
This version of viam-sdk might be problematic. Click here for more details.
- viam/__init__.py +29 -2
- viam/app/_logs.py +34 -0
- viam/app/app_client.py +2696 -0
- viam/app/billing_client.py +185 -0
- viam/app/data_client.py +2231 -0
- viam/app/ml_training_client.py +249 -0
- viam/app/provisioning_client.py +93 -0
- viam/app/viam_client.py +275 -0
- viam/components/arm/__init__.py +3 -26
- viam/components/arm/arm.py +123 -8
- viam/components/arm/client.py +37 -24
- viam/components/arm/service.py +35 -32
- 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_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 +6 -11
- viam/components/base/base.py +134 -8
- viam/components/base/client.py +51 -23
- viam/components/base/service.py +33 -30
- viam/components/board/__init__.py +3 -12
- viam/components/board/board.py +247 -91
- viam/components/board/client.py +149 -83
- viam/components/board/service.py +63 -33
- 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 +3 -3
- viam/components/camera/camera.py +62 -27
- viam/components/camera/client.py +59 -27
- viam/components/camera/service.py +42 -65
- viam/components/component_base.py +28 -5
- viam/components/encoder/__init__.py +1 -1
- viam/components/encoder/client.py +25 -14
- viam/components/encoder/encoder.py +48 -10
- viam/components/encoder/service.py +14 -18
- viam/components/gantry/__init__.py +1 -13
- viam/components/gantry/client.py +80 -25
- viam/components/gantry/gantry.py +123 -9
- viam/components/gantry/service.py +51 -29
- viam/components/generic/__init__.py +1 -1
- viam/components/generic/client.py +21 -8
- viam/components/generic/generic.py +10 -2
- viam/components/generic/service.py +12 -7
- viam/components/gripper/__init__.py +3 -13
- viam/components/gripper/client.py +69 -21
- viam/components/gripper/gripper.py +123 -3
- viam/components/gripper/service.py +44 -22
- viam/components/input/__init__.py +1 -14
- viam/components/input/client.py +55 -23
- viam/components/input/input.py +106 -3
- viam/components/input/service.py +16 -21
- viam/components/motor/__init__.py +1 -21
- viam/components/motor/client.py +56 -33
- viam/components/motor/motor.py +127 -4
- viam/components/motor/service.py +33 -44
- viam/components/movement_sensor/__init__.py +1 -1
- viam/components/movement_sensor/client.py +102 -45
- viam/components/movement_sensor/movement_sensor.py +130 -61
- viam/components/movement_sensor/service.py +38 -41
- viam/components/pose_tracker/__init__.py +1 -1
- viam/components/pose_tracker/client.py +18 -7
- viam/components/pose_tracker/pose_tracker.py +4 -2
- viam/components/pose_tracker/service.py +12 -10
- viam/components/power_sensor/__init__.py +17 -0
- viam/components/power_sensor/client.py +86 -0
- viam/components/power_sensor/power_sensor.py +104 -0
- viam/components/power_sensor/service.py +72 -0
- viam/components/sensor/__init__.py +2 -1
- viam/components/sensor/client.py +26 -10
- viam/components/sensor/sensor.py +22 -4
- viam/components/sensor/service.py +20 -11
- viam/components/servo/__init__.py +1 -13
- viam/components/servo/client.py +47 -21
- viam/components/servo/service.py +15 -22
- viam/components/servo/servo.py +61 -2
- 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 +98 -0
- viam/errors.py +10 -0
- viam/gen/app/agent/v1/agent_grpc.py +29 -0
- viam/gen/app/agent/v1/agent_pb2.py +47 -0
- viam/gen/app/agent/v1/agent_pb2.pyi +280 -0
- viam/gen/app/cloudslam/v1/__init__.py +0 -0
- viam/gen/app/cloudslam/v1/cloud_slam_grpc.py +70 -0
- viam/gen/app/cloudslam/v1/cloud_slam_pb2.py +54 -0
- viam/gen/app/cloudslam/v1/cloud_slam_pb2.pyi +384 -0
- viam/gen/app/data/v1/data_grpc.py +197 -8
- viam/gen/app/data/v1/data_pb2.py +238 -99
- viam/gen/app/data/v1/data_pb2.pyi +1222 -259
- viam/gen/app/datapipelines/__init__.py +0 -0
- viam/gen/app/datapipelines/v1/__init__.py +0 -0
- 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/__init__.py +0 -0
- viam/gen/app/dataset/v1/__init__.py +0 -0
- viam/gen/app/dataset/v1/dataset_grpc.py +68 -0
- viam/gen/app/dataset/v1/dataset_pb2.py +44 -0
- viam/gen/app/dataset/v1/dataset_pb2.pyi +214 -0
- viam/gen/app/datasync/v1/data_sync_grpc.py +21 -4
- viam/gen/app/datasync/v1/data_sync_pb2.py +62 -128
- viam/gen/app/datasync/v1/data_sync_pb2.pyi +156 -199
- 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 +51 -3
- viam/gen/app/mltraining/v1/ml_training_pb2.py +135 -58
- viam/gen/app/mltraining/v1/ml_training_pb2.pyi +328 -39
- viam/gen/app/packages/v1/packages_grpc.py +15 -1
- viam/gen/app/packages/v1/packages_pb2.py +44 -64
- viam/gen/app/packages/v1/packages_pb2.pyi +75 -85
- viam/gen/app/v1/app_grpc.py +644 -3
- viam/gen/app/v1/app_pb2.py +695 -295
- viam/gen/app/v1/app_pb2.pyi +4488 -635
- viam/gen/app/v1/billing_grpc.py +53 -11
- viam/gen/app/v1/billing_pb2.py +94 -39
- viam/gen/app/v1/billing_pb2.pyi +391 -191
- viam/gen/app/v1/end_user_grpc.py +59 -0
- viam/gen/app/v1/end_user_pb2.py +55 -0
- viam/gen/app/v1/end_user_pb2.pyi +181 -0
- viam/gen/app/v1/robot_grpc.py +16 -1
- viam/gen/app/v1/robot_pb2.py +122 -94
- viam/gen/app/v1/robot_pb2.pyi +463 -123
- viam/gen/common/v1/common_pb2.py +87 -58
- viam/gen/common/v1/common_pb2.pyi +456 -149
- viam/gen/component/arm/v1/arm_grpc.py +58 -2
- viam/gen/component/arm/v1/arm_pb2.py +68 -51
- viam/gen/component/arm/v1/arm_pb2.pyi +108 -42
- 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_grpc.py +25 -2
- viam/gen/component/audioinput/v1/audioinput_pb2.py +36 -31
- viam/gen/component/audioinput/v1/audioinput_pb2.pyi +22 -22
- 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_grpc.py +42 -2
- viam/gen/component/base/v1/base_pb2.py +58 -47
- viam/gen/component/base/v1/base_pb2.pyi +65 -30
- viam/gen/component/board/v1/board_grpc.py +59 -7
- viam/gen/component/board/v1/board_pb2.py +94 -73
- viam/gen/component/board/v1/board_pb2.pyi +165 -68
- 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_grpc.py +38 -2
- viam/gen/component/camera/v1/camera_pb2.py +60 -43
- viam/gen/component/camera/v1/camera_pb2.pyi +191 -37
- viam/gen/component/encoder/v1/encoder_grpc.py +25 -2
- viam/gen/component/encoder/v1/encoder_pb2.py +36 -31
- viam/gen/component/encoder/v1/encoder_pb2.pyi +15 -15
- viam/gen/component/gantry/v1/gantry_grpc.py +47 -2
- viam/gen/component/gantry/v1/gantry_pb2.py +56 -43
- viam/gen/component/gantry/v1/gantry_pb2.pyi +67 -31
- viam/gen/component/generic/v1/generic_grpc.py +16 -2
- viam/gen/component/generic/v1/generic_pb2.py +16 -11
- viam/gen/component/gripper/v1/gripper_grpc.py +44 -2
- viam/gen/component/gripper/v1/gripper_pb2.py +48 -35
- viam/gen/component/gripper/v1/gripper_pb2.pyi +62 -24
- viam/gen/component/inputcontroller/v1/input_controller_grpc.py +28 -2
- viam/gen/component/inputcontroller/v1/input_controller_pb2.py +46 -41
- viam/gen/component/inputcontroller/v1/input_controller_pb2.pyi +32 -36
- viam/gen/component/motor/v1/motor_grpc.py +51 -2
- viam/gen/component/motor/v1/motor_pb2.py +78 -67
- viam/gen/component/motor/v1/motor_pb2.pyi +75 -46
- viam/gen/component/movementsensor/v1/movementsensor_grpc.py +48 -2
- viam/gen/component/movementsensor/v1/movementsensor_pb2.py +70 -63
- viam/gen/component/movementsensor/v1/movementsensor_pb2.pyi +84 -57
- viam/gen/component/posetracker/v1/pose_tracker_grpc.py +19 -2
- viam/gen/component/posetracker/v1/pose_tracker_pb2.py +26 -21
- viam/gen/component/posetracker/v1/pose_tracker_pb2.pyi +9 -13
- viam/gen/component/powersensor/__init__.py +0 -0
- viam/gen/component/powersensor/v1/__init__.py +0 -0
- viam/gen/component/powersensor/v1/powersensor_grpc.py +62 -0
- viam/gen/component/powersensor/v1/powersensor_pb2.py +42 -0
- viam/gen/component/powersensor/v1/powersensor_pb2.pyi +124 -0
- viam/gen/component/sensor/v1/sensor_grpc.py +21 -5
- viam/gen/component/sensor/v1/sensor_pb2.py +18 -22
- viam/gen/component/sensor/v1/sensor_pb2.pyi +1 -69
- viam/gen/component/servo/v1/servo_grpc.py +28 -2
- viam/gen/component/servo/v1/servo_pb2.py +42 -37
- viam/gen/component/servo/v1/servo_pb2.pyi +22 -26
- 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_grpc.py +15 -0
- viam/gen/component/testecho/v1/testecho_pb2.py +29 -26
- viam/gen/component/testecho/v1/testecho_pb2.pyi +16 -20
- viam/gen/module/v1/module_grpc.py +18 -0
- viam/gen/module/v1/module_pb2.py +36 -33
- viam/gen/module/v1/module_pb2.pyi +39 -34
- viam/gen/opentelemetry/__init__.py +0 -0
- viam/gen/opentelemetry/proto/__init__.py +0 -0
- viam/gen/opentelemetry/proto/common/__init__.py +0 -0
- viam/gen/opentelemetry/proto/common/v1/__init__.py +0 -0
- viam/gen/opentelemetry/proto/common/v1/common_grpc.py +0 -0
- viam/gen/opentelemetry/proto/common/v1/common_pb2.py +27 -0
- viam/gen/opentelemetry/proto/common/v1/common_pb2.pyi +208 -0
- viam/gen/opentelemetry/proto/resource/__init__.py +0 -0
- viam/gen/opentelemetry/proto/resource/v1/__init__.py +0 -0
- viam/gen/opentelemetry/proto/resource/v1/resource_grpc.py +0 -0
- viam/gen/opentelemetry/proto/resource/v1/resource_pb2.py +18 -0
- viam/gen/opentelemetry/proto/resource/v1/resource_pb2.pyi +59 -0
- viam/gen/opentelemetry/proto/trace/__init__.py +0 -0
- viam/gen/opentelemetry/proto/trace/v1/__init__.py +0 -0
- viam/gen/opentelemetry/proto/trace/v1/trace_grpc.py +0 -0
- viam/gen/opentelemetry/proto/trace/v1/trace_pb2.py +37 -0
- viam/gen/opentelemetry/proto/trace/v1/trace_pb2.pyi +402 -0
- viam/gen/proto/rpc/examples/echo/v1/echo_grpc.py +12 -0
- viam/gen/proto/rpc/examples/echo/v1/echo_pb2.py +25 -22
- viam/gen/proto/rpc/examples/echo/v1/echo_pb2.pyi +13 -17
- viam/gen/proto/rpc/examples/echoresource/v1/echoresource_grpc.py +12 -0
- viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.py +23 -20
- viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.pyi +13 -17
- viam/gen/proto/rpc/v1/auth_grpc.py +11 -0
- viam/gen/proto/rpc/v1/auth_pb2.py +27 -24
- viam/gen/proto/rpc/v1/auth_pb2.pyi +12 -16
- viam/gen/proto/rpc/webrtc/v1/grpc_pb2.py +35 -32
- viam/gen/proto/rpc/webrtc/v1/grpc_pb2.pyi +37 -41
- viam/gen/proto/rpc/webrtc/v1/signaling_grpc.py +15 -0
- viam/gen/proto/rpc/webrtc/v1/signaling_pb2.py +62 -57
- viam/gen/proto/rpc/webrtc/v1/signaling_pb2.pyi +78 -69
- viam/gen/provisioning/__init__.py +0 -0
- viam/gen/provisioning/v1/__init__.py +0 -0
- viam/gen/provisioning/v1/provisioning_grpc.py +59 -0
- viam/gen/provisioning/v1/provisioning_pb2.py +45 -0
- viam/gen/provisioning/v1/provisioning_pb2.pyi +229 -0
- viam/gen/robot/v1/robot_grpc.py +144 -15
- viam/gen/robot/v1/robot_pb2.py +193 -119
- viam/gen/robot/v1/robot_pb2.pyi +565 -137
- viam/gen/service/datamanager/v1/data_manager_grpc.py +20 -2
- viam/gen/service/datamanager/v1/data_manager_pb2.py +27 -17
- viam/gen/service/datamanager/v1/data_manager_pb2.pyi +52 -10
- 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/__init__.py +0 -0
- viam/gen/service/generic/v1/__init__.py +0 -0
- viam/gen/service/generic/v1/generic_grpc.py +29 -0
- viam/gen/service/generic/v1/generic_pb2.py +21 -0
- viam/gen/service/generic/v1/generic_pb2.pyi +6 -0
- viam/gen/service/mlmodel/v1/mlmodel_grpc.py +9 -0
- viam/gen/service/mlmodel/v1/mlmodel_pb2.py +76 -29
- viam/gen/service/mlmodel/v1/mlmodel_pb2.pyi +307 -28
- viam/gen/service/motion/v1/motion_grpc.py +42 -4
- viam/gen/service/motion/v1/motion_pb2.py +119 -51
- viam/gen/service/motion/v1/motion_pb2.pyi +595 -120
- viam/gen/service/navigation/v1/navigation_grpc.py +49 -1
- viam/gen/service/navigation/v1/navigation_pb2.py +76 -51
- viam/gen/service/navigation/v1/navigation_pb2.pyi +188 -33
- viam/gen/service/sensors/v1/sensors_grpc.py +12 -0
- viam/gen/service/sensors/v1/sensors_pb2.py +60 -29
- viam/gen/service/sensors/v1/sensors_pb2.pyi +18 -21
- viam/gen/service/shell/v1/shell_grpc.py +27 -1
- viam/gen/service/shell/v1/shell_pb2.py +37 -15
- viam/gen/service/shell/v1/shell_pb2.pyi +260 -7
- viam/gen/service/slam/v1/slam_grpc.py +24 -2
- viam/gen/service/slam/v1/slam_pb2.py +44 -30
- viam/gen/service/slam/v1/slam_pb2.pyi +128 -27
- 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_grpc.py +39 -1
- viam/gen/service/vision/v1/vision_pb2.py +61 -45
- viam/gen/service/vision/v1/vision_pb2.pyi +180 -41
- 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/__init__.py +0 -0
- viam/gen/stream/v1/__init__.py +0 -0
- viam/gen/stream/v1/stream_grpc.py +59 -0
- viam/gen/stream/v1/stream_pb2.py +39 -0
- viam/gen/stream/v1/stream_pb2.pyi +161 -0
- viam/gen/tagger/v1/tagger_pb2.py +9 -8
- viam/logging.py +160 -17
- viam/media/__init__.py +0 -9
- viam/media/audio.py +22 -10
- viam/media/utils/__init__.py +0 -0
- viam/media/utils/pil/__init__.py +55 -0
- viam/media/{viam_rgba_plugin.py → utils/pil/viam_rgba_plugin.py} +10 -16
- viam/media/viam_rgba.py +10 -0
- viam/media/video.py +197 -73
- viam/module/module.py +191 -44
- viam/module/resource_data_consumer.py +41 -0
- viam/module/service.py +9 -1
- viam/module/types.py +4 -5
- viam/operations.py +4 -3
- viam/proto/app/__init__.py +361 -5
- viam/proto/app/agent/__init__.py +28 -0
- viam/proto/app/billing.py +51 -27
- viam/proto/app/cloudslam/__init__.py +48 -0
- viam/proto/app/data/__init__.py +103 -17
- viam/proto/app/datapipelines/__init__.py +56 -0
- viam/proto/app/dataset/__init__.py +40 -0
- viam/proto/app/datasync/__init__.py +11 -5
- viam/proto/app/end_user.py +34 -0
- viam/proto/app/mlinference/__init__.py +15 -0
- viam/proto/app/mltraining/__init__.py +25 -1
- viam/proto/app/packages/__init__.py +3 -3
- viam/proto/app/robot.py +19 -1
- viam/proto/common/__init__.py +35 -8
- viam/proto/component/arm/__init__.py +9 -1
- viam/proto/component/audioin/__init__.py +16 -0
- viam/proto/component/audioinput/__init__.py +3 -1
- viam/proto/component/audioout/__init__.py +15 -0
- viam/proto/component/base/__init__.py +7 -1
- viam/proto/component/board/__init__.py +13 -5
- viam/proto/component/button/__init__.py +15 -0
- viam/proto/component/camera/__init__.py +9 -1
- viam/proto/component/encoder/__init__.py +3 -1
- viam/proto/component/gantry/__init__.py +7 -1
- viam/proto/component/generic/__init__.py +3 -1
- viam/proto/component/gripper/__init__.py +7 -1
- viam/proto/component/inputcontroller/__init__.py +7 -1
- viam/proto/component/motor/__init__.py +7 -1
- viam/proto/component/movementsensor/__init__.py +7 -1
- viam/proto/component/posetracker/__init__.py +7 -1
- viam/proto/component/powersensor/__init__.py +30 -0
- viam/proto/component/sensor/__init__.py +3 -4
- viam/proto/component/servo/__init__.py +3 -1
- viam/proto/component/switch/__init__.py +26 -0
- viam/proto/component/testecho/__init__.py +3 -1
- viam/proto/module/__init__.py +3 -1
- viam/proto/opentelemetry/__init__.py +0 -0
- viam/proto/opentelemetry/proto/__init__.py +0 -0
- viam/proto/opentelemetry/proto/common/__init__.py +15 -0
- viam/proto/opentelemetry/proto/resource/__init__.py +10 -0
- viam/proto/opentelemetry/proto/trace/__init__.py +15 -0
- viam/proto/provisioning/__init__.py +42 -0
- viam/proto/robot/__init__.py +57 -9
- viam/proto/rpc/auth.py +11 -1
- viam/proto/rpc/examples/echo/__init__.py +3 -1
- viam/proto/rpc/examples/echoresource/__init__.py +7 -1
- viam/proto/rpc/webrtc/grpc.py +3 -1
- viam/proto/rpc/webrtc/signaling.py +5 -1
- viam/proto/service/datamanager/__init__.py +15 -2
- viam/proto/service/discovery/__init__.py +15 -0
- viam/proto/service/generic/__init__.py +12 -0
- viam/proto/service/mlmodel/__init__.py +27 -1
- viam/proto/service/motion/__init__.py +35 -5
- viam/proto/service/navigation/__init__.py +19 -1
- viam/proto/service/sensors/__init__.py +3 -1
- viam/proto/service/shell/__init__.py +25 -2
- viam/proto/service/slam/__init__.py +13 -1
- viam/proto/service/video/__init__.py +15 -0
- viam/proto/service/vision/__init__.py +11 -1
- viam/proto/service/worldstatestore/__init__.py +32 -0
- viam/proto/stream/__init__.py +36 -0
- viam/py.typed +0 -0
- viam/resource/base.py +45 -8
- viam/resource/easy_resource.py +149 -0
- viam/resource/manager.py +35 -14
- viam/resource/registry.py +40 -52
- viam/resource/rpc_client_base.py +33 -1
- viam/resource/rpc_service_base.py +15 -8
- viam/resource/types.py +39 -26
- viam/robot/client.py +458 -91
- viam/robot/service.py +13 -107
- viam/rpc/dial.py +133 -15
- viam/rpc/libviam_rust_utils.so +0 -0
- viam/rpc/server.py +59 -15
- 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 +18 -0
- viam/services/generic/client.py +58 -0
- viam/services/generic/generic.py +58 -0
- viam/services/generic/service.py +29 -0
- viam/services/mlmodel/__init__.py +15 -1
- viam/services/mlmodel/client.py +20 -15
- viam/services/mlmodel/mlmodel.py +44 -7
- viam/services/mlmodel/service.py +9 -13
- viam/services/mlmodel/utils.py +101 -0
- viam/services/motion/__init__.py +15 -3
- viam/services/motion/client.py +109 -150
- viam/services/motion/motion.py +380 -0
- viam/services/motion/service.py +132 -0
- viam/services/navigation/__init__.py +11 -0
- viam/services/navigation/client.py +99 -0
- viam/services/navigation/navigation.py +250 -0
- viam/services/navigation/service.py +137 -0
- viam/services/service_base.py +43 -4
- viam/services/service_client_base.py +4 -4
- viam/services/slam/__init__.py +4 -1
- viam/services/slam/client.py +21 -11
- viam/services/slam/service.py +16 -19
- viam/services/slam/slam.py +66 -5
- viam/services/vision/__init__.py +8 -0
- viam/services/vision/client.py +115 -111
- viam/services/vision/service.py +143 -0
- viam/services/vision/vision.py +317 -0
- 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 +254 -0
- viam/streams.py +44 -0
- viam/utils.py +143 -15
- viam/version_metadata.py +4 -0
- viam_sdk-0.66.0.dist-info/METADATA +157 -0
- viam_sdk-0.66.0.dist-info/RECORD +531 -0
- {viam_sdk-0.3.0.dist-info → viam_sdk-0.66.0.dist-info}/WHEEL +1 -1
- viam/components/audio_input/__init__.py +0 -18
- viam/components/audio_input/audio_input.py +0 -79
- viam/components/audio_input/client.py +0 -60
- viam/components/audio_input/service.py +0 -118
- viam/components/types.py +0 -5
- viam/gen/app/model/v1/model_grpc.py +0 -39
- viam/gen/app/model/v1/model_pb2.py +0 -71
- viam/gen/app/model/v1/model_pb2.pyi +0 -285
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_grpc.py +0 -21
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.py +0 -18
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.pyi +0 -49
- viam/media/media.py +0 -53
- viam/proto/app/model/__init__.py +0 -40
- viam/proto/rpc/examples/fileupload/__init__.py +0 -13
- viam/services/sensors/__init__.py +0 -5
- viam/services/sensors/client.py +0 -63
- viam_sdk-0.3.0.dist-info/LICENSE +0 -202
- viam_sdk-0.3.0.dist-info/METADATA +0 -122
- viam_sdk-0.3.0.dist-info/RECORD +0 -372
- /viam/{gen/app/model → app}/__init__.py +0 -0
- /viam/gen/app/{model/v1 → agent}/__init__.py +0 -0
- /viam/gen/{proto/rpc/examples/fileupload → app/agent/v1}/__init__.py +0 -0
- /viam/gen/{proto/rpc/examples/fileupload/v1 → app/cloudslam}/__init__.py +0 -0
- /LICENSE → /viam_sdk-0.66.0.dist-info/licenses/LICENSE +0 -0
viam/robot/client.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import sys
|
|
2
3
|
from dataclasses import dataclass
|
|
4
|
+
from datetime import datetime
|
|
3
5
|
from threading import RLock
|
|
4
6
|
from typing import Any, Dict, List, Optional, Union
|
|
5
7
|
|
|
8
|
+
from grpclib import GRPCError, Status
|
|
6
9
|
from grpclib.client import Channel
|
|
7
10
|
from typing_extensions import Self
|
|
8
11
|
|
|
@@ -10,25 +13,31 @@ import viam
|
|
|
10
13
|
from viam import logging
|
|
11
14
|
from viam.components.component_base import ComponentBase
|
|
12
15
|
from viam.errors import ResourceNotFoundError
|
|
13
|
-
from viam.proto.common import PoseInFrame, ResourceName, Transform
|
|
16
|
+
from viam.proto.common import LogEntry, PoseInFrame, ResourceName, Transform
|
|
14
17
|
from viam.proto.robot import (
|
|
15
18
|
BlockForOperationRequest,
|
|
16
19
|
CancelOperationRequest,
|
|
17
|
-
DiscoverComponentsRequest,
|
|
18
|
-
DiscoverComponentsResponse,
|
|
19
|
-
Discovery,
|
|
20
|
-
DiscoveryQuery,
|
|
21
20
|
FrameSystemConfig,
|
|
22
21
|
FrameSystemConfigRequest,
|
|
23
22
|
FrameSystemConfigResponse,
|
|
23
|
+
GetCloudMetadataRequest,
|
|
24
|
+
GetCloudMetadataResponse,
|
|
25
|
+
GetMachineStatusRequest,
|
|
26
|
+
GetMachineStatusResponse,
|
|
27
|
+
GetModelsFromModulesRequest,
|
|
28
|
+
GetModelsFromModulesResponse,
|
|
24
29
|
GetOperationsRequest,
|
|
25
30
|
GetOperationsResponse,
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
GetVersionRequest,
|
|
32
|
+
GetVersionResponse,
|
|
33
|
+
LogRequest,
|
|
34
|
+
ModuleModel,
|
|
28
35
|
Operation,
|
|
29
36
|
ResourceNamesRequest,
|
|
30
37
|
ResourceNamesResponse,
|
|
38
|
+
RestartModuleRequest,
|
|
31
39
|
RobotServiceStub,
|
|
40
|
+
ShutdownRequest,
|
|
32
41
|
StopAllRequest,
|
|
33
42
|
StopExtraParameters,
|
|
34
43
|
TransformPoseRequest,
|
|
@@ -38,16 +47,17 @@ from viam.resource.base import ResourceBase
|
|
|
38
47
|
from viam.resource.manager import ResourceManager
|
|
39
48
|
from viam.resource.registry import Registry
|
|
40
49
|
from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase, ResourceRPCClientBase
|
|
41
|
-
from viam.resource.types import RESOURCE_TYPE_COMPONENT, RESOURCE_TYPE_SERVICE
|
|
42
|
-
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
|
|
43
52
|
from viam.services.service_base import ServiceBase
|
|
44
|
-
from viam.
|
|
53
|
+
from viam.sessions_client import SessionsClient
|
|
54
|
+
from viam.utils import datetime_to_timestamp, dict_to_struct
|
|
45
55
|
|
|
46
56
|
LOGGER = logging.getLogger(__name__)
|
|
47
57
|
|
|
48
58
|
|
|
49
59
|
class RobotClient:
|
|
50
|
-
"""gRPC client for a
|
|
60
|
+
"""gRPC client for a machine. This class should be used for all interactions with a machine.
|
|
51
61
|
|
|
52
62
|
There are 2 ways to instantiate a robot client::
|
|
53
63
|
|
|
@@ -56,21 +66,51 @@ class RobotClient:
|
|
|
56
66
|
|
|
57
67
|
You can use the client standalone or within a context::
|
|
58
68
|
|
|
59
|
-
|
|
60
|
-
async with await RobotClient.with_channel(...) as
|
|
69
|
+
machine = await RobotClient.at_address(...)
|
|
70
|
+
async with await RobotClient.with_channel(...) as machine: ...
|
|
61
71
|
|
|
62
|
-
You must ``close()`` the
|
|
72
|
+
You must ``close()`` the machine to release resources.
|
|
63
73
|
|
|
64
|
-
Note:
|
|
74
|
+
Note: Machines used within a context are automatically closed UNLESS created with a channel. Machines created using ``with_channel`` are
|
|
65
75
|
not automatically closed.
|
|
76
|
+
|
|
77
|
+
Establish a Connection::
|
|
78
|
+
|
|
79
|
+
import asyncio
|
|
80
|
+
|
|
81
|
+
from viam.rpc.dial import DialOptions, Credentials
|
|
82
|
+
from viam.robot.client import RobotClient
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
async def connect():
|
|
86
|
+
opts = RobotClient.Options.with_api_key(
|
|
87
|
+
# Replace "<API-KEY>" (including brackets) with your machine's API key
|
|
88
|
+
api_key='<API-KEY>',
|
|
89
|
+
# Replace "<API-KEY-ID>" (including brackets) with your machine's API key ID
|
|
90
|
+
api_key_id='<API-KEY-ID>'
|
|
91
|
+
)
|
|
92
|
+
return await RobotClient.at_address('<ADDRESS-FROM-THE-VIAM-APP>', opts)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
async def main():
|
|
96
|
+
# Make a RobotClient
|
|
97
|
+
machine = await connect()
|
|
98
|
+
print('Resources:')
|
|
99
|
+
print(machine.resource_names)
|
|
100
|
+
await machine.close()
|
|
101
|
+
|
|
102
|
+
if __name__ == '__main__':
|
|
103
|
+
asyncio.run(main())
|
|
104
|
+
|
|
105
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
66
106
|
"""
|
|
67
107
|
|
|
68
108
|
@dataclass
|
|
69
109
|
class Options:
|
|
70
110
|
refresh_interval: int = 0
|
|
71
111
|
"""
|
|
72
|
-
How often to refresh the status
|
|
73
|
-
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
|
|
74
114
|
"""
|
|
75
115
|
|
|
76
116
|
dial_options: Optional[DialOptions] = None
|
|
@@ -85,49 +125,122 @@ class RobotClient:
|
|
|
85
125
|
|
|
86
126
|
check_connection_interval: int = 10
|
|
87
127
|
"""
|
|
88
|
-
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
|
|
89
129
|
"""
|
|
90
130
|
|
|
91
131
|
attempt_reconnect_interval: int = 1
|
|
92
132
|
"""
|
|
93
|
-
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
|
|
94
134
|
"""
|
|
95
135
|
|
|
136
|
+
disable_sessions: bool = False
|
|
137
|
+
"""
|
|
138
|
+
Whether sessions are disabled
|
|
139
|
+
"""
|
|
140
|
+
|
|
141
|
+
@classmethod
|
|
142
|
+
def with_api_key(cls, api_key: str, api_key_id: str, **kwargs) -> Self:
|
|
143
|
+
"""
|
|
144
|
+
Create RobotClient.Options with an API key for credentials and default values for other arguments.
|
|
145
|
+
|
|
146
|
+
::
|
|
147
|
+
|
|
148
|
+
# Replace "<API-KEY>" (including brackets) with your machine's API key
|
|
149
|
+
api_key = '<API-KEY>'
|
|
150
|
+
# Replace "<API-KEY-ID>" (including brackets) with your machine's API key ID
|
|
151
|
+
api_key_id = '<API-KEY-ID>'
|
|
152
|
+
|
|
153
|
+
opts = RobotClient.Options.with_api_key(api_key, api_key_id)
|
|
154
|
+
|
|
155
|
+
machine = await RobotClient.at_address('<ADDRESS-FROM-THE-VIAM-APP>', opts)
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
api_key (str): your API key
|
|
159
|
+
api_key_id (str): your API key ID. Must be a valid UUID
|
|
160
|
+
|
|
161
|
+
Raises:
|
|
162
|
+
ValueError: Raised if the api_key_id is not a valid UUID
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
Self: the RobotClient.Options
|
|
166
|
+
|
|
167
|
+
For more information, see `Establish a connection <https://docs.viam.com/appendix/apis/robot/#establish-a-connection>`_.
|
|
168
|
+
"""
|
|
169
|
+
self = cls(**kwargs)
|
|
170
|
+
dial_opts = DialOptions.with_api_key(api_key, api_key_id)
|
|
171
|
+
self.dial_options = dial_opts
|
|
172
|
+
return self
|
|
173
|
+
|
|
96
174
|
@classmethod
|
|
97
175
|
async def at_address(cls, address: str, options: Options) -> Self:
|
|
98
|
-
"""Create a robot client that is connected to the
|
|
176
|
+
"""Create a robot client that is connected to the machine at the provided address.
|
|
177
|
+
|
|
178
|
+
::
|
|
179
|
+
|
|
180
|
+
async def connect():
|
|
181
|
+
|
|
182
|
+
opts = RobotClient.Options.with_api_key(
|
|
183
|
+
# Replace "<API-KEY>" (including brackets) with your machine's API key
|
|
184
|
+
api_key='<API-KEY>',
|
|
185
|
+
# Replace "<API-KEY-ID>" (including brackets) with your machine's API key ID
|
|
186
|
+
api_key_id='<API-KEY-ID>'
|
|
187
|
+
)
|
|
188
|
+
return await RobotClient.at_address('MACHINE ADDRESS', opts)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
async def main():
|
|
192
|
+
# Make a RobotClient
|
|
193
|
+
machine = await connect()
|
|
99
194
|
|
|
100
195
|
Args:
|
|
101
|
-
address (str): Address of the
|
|
196
|
+
address (str): Address of the machine (IP address, URL, etc.)
|
|
102
197
|
options (Options): Options for connecting and refreshing
|
|
103
198
|
|
|
104
199
|
Returns:
|
|
105
200
|
Self: the RobotClient
|
|
201
|
+
|
|
202
|
+
For more information, see `Establish a connection <https://docs.viam.com/appendix/apis/robot/#establish-a-connection>`_.
|
|
106
203
|
"""
|
|
107
204
|
logging.setLevel(options.log_level)
|
|
108
205
|
channel = await dial(address, options.dial_options)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return
|
|
206
|
+
machine = await cls._with_channel(channel, options, True, robot_addr=address)
|
|
207
|
+
machine._address = address
|
|
208
|
+
return machine
|
|
112
209
|
|
|
113
210
|
@classmethod
|
|
114
211
|
async def with_channel(cls, channel: Union[Channel, ViamChannel], options: Options) -> Self:
|
|
115
|
-
"""Create a
|
|
212
|
+
"""Create a machine that is connected to a machine over the given channel.
|
|
116
213
|
|
|
117
|
-
Any
|
|
214
|
+
Any machines created using this method will *NOT* automatically close the channel upon exit.
|
|
215
|
+
|
|
216
|
+
::
|
|
217
|
+
|
|
218
|
+
from viam.robot.client import RobotClient
|
|
219
|
+
from viam.rpc.dial import DialOptions, dial
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
async def connect_with_channel() -> RobotClient:
|
|
223
|
+
async with await dial('ADDRESS', DialOptions()) as channel:
|
|
224
|
+
return await RobotClient.with_channel(channel, RobotClient.Options())
|
|
225
|
+
|
|
226
|
+
machine = await connect_with_channel()
|
|
118
227
|
|
|
119
228
|
Args:
|
|
120
|
-
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``
|
|
121
230
|
options (Options): Options for refreshing. Any connection options will be ignored.
|
|
122
231
|
|
|
123
232
|
Returns:
|
|
124
233
|
Self: the RobotClient
|
|
234
|
+
|
|
235
|
+
For more information, see `Establish a connection <https://docs.viam.com/appendix/apis/robot/#establish-a-connection>`_.
|
|
125
236
|
"""
|
|
126
237
|
logging.setLevel(options.log_level)
|
|
127
238
|
return await cls._with_channel(channel, options, False)
|
|
128
239
|
|
|
129
240
|
@classmethod
|
|
130
|
-
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
|
+
):
|
|
131
244
|
"""INTERNAL USE ONLY"""
|
|
132
245
|
|
|
133
246
|
self = cls()
|
|
@@ -138,6 +251,7 @@ class RobotClient:
|
|
|
138
251
|
else:
|
|
139
252
|
self._channel = channel.channel
|
|
140
253
|
self._viam_channel = channel
|
|
254
|
+
|
|
141
255
|
self._connected = True
|
|
142
256
|
self._client = RobotServiceStub(self._channel)
|
|
143
257
|
self._manager = ResourceManager()
|
|
@@ -146,13 +260,16 @@ class RobotClient:
|
|
|
146
260
|
self._should_close_channel = close_channel
|
|
147
261
|
self._options = options
|
|
148
262
|
self._address = self._channel._path if self._channel._path else f"{self._channel._host}:{self._channel._port}"
|
|
263
|
+
self._sessions_client = SessionsClient(
|
|
264
|
+
self._channel, self._address, self._options.dial_options, disabled=self._options.disable_sessions, robot_addr=robot_addr
|
|
265
|
+
)
|
|
149
266
|
|
|
150
267
|
try:
|
|
151
268
|
await self.refresh()
|
|
152
269
|
except Exception:
|
|
153
|
-
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.")
|
|
154
271
|
await self.close()
|
|
155
|
-
raise ConnectionError("Unable to establish a connection to the
|
|
272
|
+
raise ConnectionError("Unable to establish a connection to the machine.")
|
|
156
273
|
|
|
157
274
|
if options.refresh_interval > 0:
|
|
158
275
|
self._refresh_task = asyncio.create_task(
|
|
@@ -180,10 +297,17 @@ class RobotClient:
|
|
|
180
297
|
_resource_names: List[ResourceName]
|
|
181
298
|
_should_close_channel: bool
|
|
182
299
|
_closed: bool = False
|
|
300
|
+
_sessions_client: SessionsClient
|
|
183
301
|
|
|
184
302
|
async def refresh(self):
|
|
185
303
|
"""
|
|
186
|
-
Manually refresh the underlying parts of this
|
|
304
|
+
Manually refresh the underlying parts of this machine.
|
|
305
|
+
|
|
306
|
+
::
|
|
307
|
+
|
|
308
|
+
await machine.refresh()
|
|
309
|
+
|
|
310
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
187
311
|
"""
|
|
188
312
|
response: ResourceNamesResponse = await self._client.ResourceNames(ResourceNamesRequest())
|
|
189
313
|
resource_names: List[ResourceName] = list(response.resources)
|
|
@@ -196,15 +320,15 @@ class RobotClient:
|
|
|
196
320
|
if rname.subtype == "remote":
|
|
197
321
|
continue
|
|
198
322
|
|
|
199
|
-
self._create_or_reset_client(rname)
|
|
323
|
+
await self._create_or_reset_client(rname)
|
|
200
324
|
|
|
201
325
|
for rname in self.resource_names:
|
|
202
326
|
if rname not in resource_names:
|
|
203
|
-
self._manager.remove_resource(rname)
|
|
327
|
+
await self._manager.remove_resource(rname)
|
|
204
328
|
|
|
205
329
|
self._resource_names = resource_names
|
|
206
330
|
|
|
207
|
-
def _create_or_reset_client(self, resourceName: ResourceName):
|
|
331
|
+
async def _create_or_reset_client(self, resourceName: ResourceName):
|
|
208
332
|
if resourceName in self._manager.resources:
|
|
209
333
|
res = self._manager.get_resource(ResourceBase, resourceName)
|
|
210
334
|
|
|
@@ -216,14 +340,14 @@ class RobotClient:
|
|
|
216
340
|
if isinstance(res, ReconfigurableResourceRPCClientBase):
|
|
217
341
|
res.reset_channel(self._channel)
|
|
218
342
|
else:
|
|
219
|
-
self._manager.remove_resource(resourceName)
|
|
343
|
+
await self._manager.remove_resource(resourceName)
|
|
220
344
|
self._manager.register(
|
|
221
|
-
Registry.
|
|
345
|
+
Registry.lookup_api(API.from_resource_name(resourceName)).create_rpc_client(resourceName.name, self._channel)
|
|
222
346
|
)
|
|
223
347
|
else:
|
|
224
348
|
try:
|
|
225
349
|
self._manager.register(
|
|
226
|
-
Registry.
|
|
350
|
+
Registry.lookup_api(API.from_resource_name(resourceName)).create_rpc_client(resourceName.name, self._channel)
|
|
227
351
|
)
|
|
228
352
|
except ResourceNotFoundError:
|
|
229
353
|
pass
|
|
@@ -247,16 +371,16 @@ class RobotClient:
|
|
|
247
371
|
|
|
248
372
|
# Failure to grab resources could be for spurious, non-networking reasons. Try three times just to be safe.
|
|
249
373
|
connection_error = None
|
|
250
|
-
for
|
|
374
|
+
for _ in range(3):
|
|
251
375
|
try:
|
|
252
|
-
|
|
376
|
+
await self._client.ResourceNames(ResourceNamesRequest(), timeout=1)
|
|
253
377
|
connection_error = None
|
|
254
378
|
break
|
|
255
379
|
except Exception as e:
|
|
256
380
|
connection_error = e
|
|
257
381
|
await asyncio.sleep(0.1)
|
|
258
382
|
if connection_error:
|
|
259
|
-
msg = "Lost connection to
|
|
383
|
+
msg = "Lost connection to machine."
|
|
260
384
|
if reconnect_every > 0:
|
|
261
385
|
msg += (
|
|
262
386
|
f" Attempting to reconnect to {self._address} every {reconnect_every} second{'s' if reconnect_every != 1 else ''}"
|
|
@@ -268,16 +392,23 @@ class RobotClient:
|
|
|
268
392
|
if reconnect_every <= 0:
|
|
269
393
|
continue
|
|
270
394
|
|
|
271
|
-
|
|
395
|
+
if self._connected:
|
|
396
|
+
continue
|
|
397
|
+
|
|
398
|
+
reconnect_attempts = self._options.dial_options.max_reconnect_attempts if self._options.dial_options else 3
|
|
399
|
+
|
|
400
|
+
for _ in range(reconnect_attempts):
|
|
272
401
|
try:
|
|
273
|
-
|
|
402
|
+
self._sessions_client.reset()
|
|
403
|
+
|
|
404
|
+
channel = await _dial_inner(self._address, self._options.dial_options)
|
|
274
405
|
|
|
275
406
|
client: RobotServiceStub
|
|
276
407
|
if isinstance(channel, Channel):
|
|
277
408
|
client = RobotServiceStub(channel)
|
|
278
409
|
else:
|
|
279
410
|
client = RobotServiceStub(channel.channel)
|
|
280
|
-
|
|
411
|
+
await client.ResourceNames(ResourceNamesRequest())
|
|
281
412
|
|
|
282
413
|
if isinstance(channel, Channel):
|
|
283
414
|
self._channel = channel
|
|
@@ -286,14 +417,27 @@ class RobotClient:
|
|
|
286
417
|
self._channel = channel.channel
|
|
287
418
|
self._viam_channel = channel
|
|
288
419
|
self._client = RobotServiceStub(self._channel)
|
|
420
|
+
direct_dial_address = self._channel._path if self._channel._path else f"{self._channel._host}:{self._channel._port}"
|
|
421
|
+
self._sessions_client = SessionsClient(
|
|
422
|
+
channel=self._channel,
|
|
423
|
+
direct_dial_address=direct_dial_address,
|
|
424
|
+
dial_options=self._options.dial_options,
|
|
425
|
+
disabled=self._options.disable_sessions,
|
|
426
|
+
robot_addr=self._address,
|
|
427
|
+
)
|
|
289
428
|
|
|
290
429
|
await self.refresh()
|
|
291
430
|
self._connected = True
|
|
292
|
-
LOGGER.debug("Successfully reconnected
|
|
431
|
+
LOGGER.debug("Successfully reconnected machine")
|
|
432
|
+
break
|
|
293
433
|
except Exception as e:
|
|
294
434
|
LOGGER.error(f"Failed to reconnect, trying again in {reconnect_every}sec", exc_info=e)
|
|
435
|
+
self._sessions_client.reset()
|
|
295
436
|
self._close_channel()
|
|
296
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()
|
|
297
441
|
|
|
298
442
|
def get_component(self, name: ResourceName) -> ComponentBase:
|
|
299
443
|
"""Get a component using its ResourceName.
|
|
@@ -302,7 +446,7 @@ class RobotClient:
|
|
|
302
446
|
method for obtaining components.
|
|
303
447
|
::
|
|
304
448
|
|
|
305
|
-
arm = Arm.from_robot(robot=
|
|
449
|
+
arm = Arm.from_robot(robot=machine, name="my_arm")
|
|
306
450
|
|
|
307
451
|
Because this function returns a generic ``ComponentBase`` rather than the specific
|
|
308
452
|
component type, it will be necessary to cast the returned component to the desired component. This can be done using a few
|
|
@@ -310,14 +454,14 @@ class RobotClient:
|
|
|
310
454
|
|
|
311
455
|
- Assertion::
|
|
312
456
|
|
|
313
|
-
arm =
|
|
457
|
+
arm = machine.get_component(Arm.get_resource_name("my_arm"))
|
|
314
458
|
assert isinstance(arm, Arm)
|
|
315
459
|
end_pos = await arm.get_end_position()
|
|
316
460
|
|
|
317
461
|
- Explicit cast::
|
|
318
462
|
|
|
319
463
|
from typing import cast
|
|
320
|
-
arm =
|
|
464
|
+
arm = machine.get_component(Arm.get_resource_name("my_arm"))
|
|
321
465
|
arm = cast(Arm, arm)
|
|
322
466
|
end_pos = await arm.get_end_position()
|
|
323
467
|
|
|
@@ -326,7 +470,7 @@ class RobotClient:
|
|
|
326
470
|
- Note: If using an IDE, a type error may be shown which can be ignored.
|
|
327
471
|
::
|
|
328
472
|
|
|
329
|
-
arm: Arm =
|
|
473
|
+
arm: Arm = machine.get_component(Arm.get_resource_name("my_arm")) # type: ignore
|
|
330
474
|
end_pos = await arm.get_end_position()
|
|
331
475
|
|
|
332
476
|
Args:
|
|
@@ -338,6 +482,8 @@ class RobotClient:
|
|
|
338
482
|
|
|
339
483
|
Returns:
|
|
340
484
|
ComponentBase: The component
|
|
485
|
+
|
|
486
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
341
487
|
"""
|
|
342
488
|
if name.type != RESOURCE_TYPE_COMPONENT:
|
|
343
489
|
raise ValueError(f"ResourceName does not describe a component: {name}")
|
|
@@ -351,20 +497,20 @@ class RobotClient:
|
|
|
351
497
|
method for obtaining services.
|
|
352
498
|
::
|
|
353
499
|
|
|
354
|
-
service = MyService.from_robot(robot=
|
|
500
|
+
service = MyService.from_robot(robot=machine, name="my_service")
|
|
355
501
|
|
|
356
502
|
Because this function returns a generic ``ServiceBase`` rather than a specific service type, it will be necessary to cast the
|
|
357
503
|
returned service to the desired service. This can be done using a few methods:
|
|
358
504
|
|
|
359
505
|
- Assertion::
|
|
360
506
|
|
|
361
|
-
service =
|
|
507
|
+
service = machine.get_service(MyService.get_resource_name("my_service"))
|
|
362
508
|
assert isinstance(service, MyService)
|
|
363
509
|
|
|
364
510
|
- Explicit cast::
|
|
365
511
|
|
|
366
512
|
from typing import cast
|
|
367
|
-
service =
|
|
513
|
+
service = machine.get_service(MyService.get_resource_name("my_service"))
|
|
368
514
|
service = cast(MyService, my_service)
|
|
369
515
|
|
|
370
516
|
- Declare type on variable assignment
|
|
@@ -372,7 +518,7 @@ class RobotClient:
|
|
|
372
518
|
- Note: If using an IDE, a type error may be shown which can be ignored.
|
|
373
519
|
::
|
|
374
520
|
|
|
375
|
-
service: MyService =
|
|
521
|
+
service: MyService = machine.get_service(MyService.get_resource_name("my_service")) # type: ignore
|
|
376
522
|
|
|
377
523
|
Args:
|
|
378
524
|
name (viam.proto.common.ResourceName): The service's ResourceName
|
|
@@ -383,6 +529,8 @@ class RobotClient:
|
|
|
383
529
|
|
|
384
530
|
Returns:
|
|
385
531
|
ServiceBase: The service
|
|
532
|
+
|
|
533
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
386
534
|
"""
|
|
387
535
|
if name.type != RESOURCE_TYPE_SERVICE:
|
|
388
536
|
raise ValueError(f"ResourceName does not describe a service: {name}")
|
|
@@ -394,8 +542,14 @@ class RobotClient:
|
|
|
394
542
|
"""
|
|
395
543
|
Get a list of all resource names
|
|
396
544
|
|
|
545
|
+
::
|
|
546
|
+
|
|
547
|
+
resource_names = machine.resource_names
|
|
548
|
+
|
|
397
549
|
Returns:
|
|
398
550
|
List[viam.proto.common.ResourceName]: The list of resource names
|
|
551
|
+
|
|
552
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
399
553
|
"""
|
|
400
554
|
with self._lock:
|
|
401
555
|
return [r for r in self._resource_names]
|
|
@@ -411,7 +565,13 @@ class RobotClient:
|
|
|
411
565
|
|
|
412
566
|
async def close(self):
|
|
413
567
|
"""
|
|
414
|
-
Cleanly close the underlying connections and stop any periodic tasks
|
|
568
|
+
Cleanly close the underlying connections and stop any periodic tasks.
|
|
569
|
+
|
|
570
|
+
::
|
|
571
|
+
|
|
572
|
+
await machine.close()
|
|
573
|
+
|
|
574
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
415
575
|
"""
|
|
416
576
|
LOGGER.debug("Closing RobotClient")
|
|
417
577
|
if self._closed:
|
|
@@ -423,6 +583,8 @@ class RobotClient:
|
|
|
423
583
|
except RuntimeError:
|
|
424
584
|
pass
|
|
425
585
|
|
|
586
|
+
self._sessions_client.reset()
|
|
587
|
+
|
|
426
588
|
# Cancel all tasks created by VIAM
|
|
427
589
|
LOGGER.debug("Closing tasks spawned by Viam")
|
|
428
590
|
tasks = [task for task in asyncio.all_tasks() if task.get_name().startswith(viam._TASK_PREFIX)]
|
|
@@ -443,33 +605,22 @@ class RobotClient:
|
|
|
443
605
|
async def __aexit__(self, exc_type, exc_value, traceback):
|
|
444
606
|
await self.close()
|
|
445
607
|
|
|
446
|
-
##########
|
|
447
|
-
# STATUS #
|
|
448
|
-
##########
|
|
449
|
-
async def get_status(self, components: Optional[List[ResourceName]] = None):
|
|
450
|
-
"""
|
|
451
|
-
Get the status of the robot's components. You can optionally
|
|
452
|
-
provide a list of ``ResourceName`` for which you want statuses.
|
|
453
|
-
|
|
454
|
-
Args:
|
|
455
|
-
components (Optional[List[viam.proto.common.ResourceName]]): Optional list of
|
|
456
|
-
``ResourceName`` for components you want statuses.
|
|
457
|
-
"""
|
|
458
|
-
names = components if components is not None else []
|
|
459
|
-
request = GetStatusRequest(resource_names=names)
|
|
460
|
-
response: GetStatusResponse = await self._client.GetStatus(request)
|
|
461
|
-
return list(response.status)
|
|
462
|
-
|
|
463
608
|
##############
|
|
464
609
|
# OPERATIONS #
|
|
465
610
|
##############
|
|
466
611
|
|
|
467
612
|
async def get_operations(self) -> List[Operation]:
|
|
468
613
|
"""
|
|
469
|
-
Get the list of operations currently running on the
|
|
614
|
+
Get the list of operations currently running on the machine.
|
|
615
|
+
|
|
616
|
+
::
|
|
617
|
+
|
|
618
|
+
operations = await machine.get_operations()
|
|
470
619
|
|
|
471
620
|
Returns:
|
|
472
|
-
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.
|
|
622
|
+
|
|
623
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
473
624
|
"""
|
|
474
625
|
request = GetOperationsRequest()
|
|
475
626
|
response: GetOperationsResponse = await self._client.GetOperations(request)
|
|
@@ -477,21 +628,33 @@ class RobotClient:
|
|
|
477
628
|
|
|
478
629
|
async def cancel_operation(self, id: str):
|
|
479
630
|
"""
|
|
480
|
-
Cancels the specified operation on the
|
|
631
|
+
Cancels the specified operation on the machine.
|
|
632
|
+
|
|
633
|
+
::
|
|
634
|
+
|
|
635
|
+
await machine.cancel_operation("INSERT OPERATION ID")
|
|
481
636
|
|
|
482
637
|
Args:
|
|
483
|
-
id (str): ID of operation to
|
|
638
|
+
id (str): ID of operation to cancel.
|
|
639
|
+
|
|
640
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
484
641
|
"""
|
|
485
642
|
request = CancelOperationRequest(id=id)
|
|
486
643
|
await self._client.CancelOperation(request)
|
|
487
644
|
|
|
488
645
|
async def block_for_operation(self, id: str):
|
|
489
646
|
"""
|
|
490
|
-
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
|
|
491
648
|
has finished or has been cancelled.
|
|
492
649
|
|
|
650
|
+
::
|
|
651
|
+
|
|
652
|
+
await machine.block_for_operation("INSERT OPERATION ID")
|
|
653
|
+
|
|
493
654
|
Args:
|
|
494
655
|
id (str): ID of operation to block on.
|
|
656
|
+
|
|
657
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
495
658
|
"""
|
|
496
659
|
request = BlockForOperationRequest(id=id)
|
|
497
660
|
await self._client.BlockForOperation(request)
|
|
@@ -502,10 +665,18 @@ class RobotClient:
|
|
|
502
665
|
|
|
503
666
|
async def get_frame_system_config(self, additional_transforms: Optional[List[Transform]] = None) -> List[FrameSystemConfig]:
|
|
504
667
|
"""
|
|
505
|
-
Get the configuration of the frame system of a given
|
|
668
|
+
Get the configuration of the frame system of a given machine.
|
|
669
|
+
|
|
670
|
+
::
|
|
671
|
+
|
|
672
|
+
# Get a list of each of the reference frames configured on the machine.
|
|
673
|
+
frame_system = await machine.get_frame_system_config()
|
|
674
|
+
print(f"frame system configuration: {frame_system}")
|
|
506
675
|
|
|
507
676
|
Returns:
|
|
508
|
-
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.
|
|
678
|
+
|
|
679
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
509
680
|
"""
|
|
510
681
|
request = FrameSystemConfigRequest(supplemental_transforms=additional_transforms)
|
|
511
682
|
response: FrameSystemConfigResponse = await self._client.FrameSystemConfig(request)
|
|
@@ -517,11 +688,36 @@ class RobotClient:
|
|
|
517
688
|
"""
|
|
518
689
|
Transform a given source Pose from the reference frame to a new specified destination which is a reference frame.
|
|
519
690
|
|
|
691
|
+
::
|
|
692
|
+
|
|
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")
|
|
711
|
+
|
|
520
712
|
Args:
|
|
521
713
|
|
|
522
714
|
query (viam.proto.common.PoseInFrame): The pose that should be transformed.
|
|
523
715
|
destination (str) : The name of the reference frame to transform the given pose to.
|
|
524
716
|
|
|
717
|
+
Returns:
|
|
718
|
+
PoseInFrame: The pose and the reference frame for the new destination.
|
|
719
|
+
|
|
720
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
525
721
|
"""
|
|
526
722
|
request = TransformPoseRequest(source=query, destination=destination, supplemental_transforms=additional_transforms)
|
|
527
723
|
response: TransformPoseResponse = await self._client.TransformPose(request)
|
|
@@ -530,25 +726,30 @@ class RobotClient:
|
|
|
530
726
|
async def transform_point_cloud(self):
|
|
531
727
|
raise NotImplementedError()
|
|
532
728
|
|
|
533
|
-
|
|
534
|
-
#
|
|
535
|
-
|
|
729
|
+
#################
|
|
730
|
+
# MODULE MODELS #
|
|
731
|
+
#################
|
|
536
732
|
|
|
537
|
-
async def
|
|
733
|
+
async def get_models_from_modules(
|
|
538
734
|
self,
|
|
539
|
-
|
|
540
|
-
) -> List[Discovery]:
|
|
735
|
+
) -> List[ModuleModel]:
|
|
541
736
|
"""
|
|
542
|
-
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.
|
|
543
739
|
|
|
544
|
-
|
|
740
|
+
::
|
|
545
741
|
|
|
546
|
-
|
|
742
|
+
# Get module models
|
|
743
|
+
module_models = await machine.get_models_from_modules(qs)
|
|
744
|
+
|
|
745
|
+
Args:
|
|
547
746
|
|
|
747
|
+
Returns:
|
|
748
|
+
List[ModuleModel]: A list of discovered models.
|
|
548
749
|
"""
|
|
549
|
-
request =
|
|
550
|
-
response:
|
|
551
|
-
return list(response.
|
|
750
|
+
request = GetModelsFromModulesRequest()
|
|
751
|
+
response: GetModelsFromModulesResponse = await self._client.GetModelsFromModules(request)
|
|
752
|
+
return list(response.models)
|
|
552
753
|
|
|
553
754
|
############
|
|
554
755
|
# STOP ALL #
|
|
@@ -556,15 +757,181 @@ class RobotClient:
|
|
|
556
757
|
|
|
557
758
|
async def stop_all(self, extra: Dict[ResourceName, Dict[str, Any]] = {}):
|
|
558
759
|
"""
|
|
559
|
-
Cancel all current and outstanding operations for the
|
|
760
|
+
Cancel all current and outstanding operations for the machine and stop all actuators and movement.
|
|
761
|
+
|
|
762
|
+
::
|
|
763
|
+
|
|
764
|
+
# Cancel all current and outstanding operations for the machine and stop all actuators and movement.
|
|
765
|
+
await machine.stop_all()
|
|
560
766
|
|
|
561
767
|
Args:
|
|
562
768
|
extra (Dict[viam.proto.common.ResourceName, Dict[str, Any]]): Any extra parameters to pass to the resources' ``stop`` methods,
|
|
563
|
-
keyed on the resource's ``ResourceName
|
|
769
|
+
keyed on the resource's ``ResourceName``.
|
|
564
770
|
|
|
771
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
565
772
|
"""
|
|
773
|
+
|
|
566
774
|
ep: List[StopExtraParameters] = []
|
|
567
775
|
for name, params in extra.items():
|
|
568
776
|
ep.append(StopExtraParameters(name=name, params=dict_to_struct(params)))
|
|
569
777
|
request = StopAllRequest(extra=ep)
|
|
570
778
|
await self._client.StopAll(request)
|
|
779
|
+
|
|
780
|
+
#######
|
|
781
|
+
# LOG #
|
|
782
|
+
#######
|
|
783
|
+
|
|
784
|
+
async def log(self, name: str, level: str, time: datetime, message: str, stack: str):
|
|
785
|
+
"""Send log from Python module over gRPC.
|
|
786
|
+
|
|
787
|
+
Create a LogEntry object from the log to send to RDK.
|
|
788
|
+
|
|
789
|
+
Args:
|
|
790
|
+
name (str): The logger's name.
|
|
791
|
+
level (str): The level of the log.
|
|
792
|
+
time (datetime): The log creation time.
|
|
793
|
+
message (str): The log message.
|
|
794
|
+
stack (str): The stack information of the log.
|
|
795
|
+
|
|
796
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
797
|
+
"""
|
|
798
|
+
entry = LogEntry(level=level, time=datetime_to_timestamp(time), logger_name=name, message=message, stack=stack)
|
|
799
|
+
request = LogRequest(logs=[entry])
|
|
800
|
+
await self._client.Log(request)
|
|
801
|
+
|
|
802
|
+
######################
|
|
803
|
+
# Get Cloud Metadata #
|
|
804
|
+
######################
|
|
805
|
+
|
|
806
|
+
async def get_cloud_metadata(self) -> GetCloudMetadataResponse:
|
|
807
|
+
"""
|
|
808
|
+
Get app-related information about the machine.
|
|
809
|
+
|
|
810
|
+
::
|
|
811
|
+
|
|
812
|
+
metadata = await machine.get_cloud_metadata()
|
|
813
|
+
print(metadata.machine_id)
|
|
814
|
+
print(metadata.machine_part_id)
|
|
815
|
+
print(metadata.primary_org_id)
|
|
816
|
+
print(metadata.location_id)
|
|
817
|
+
|
|
818
|
+
Returns:
|
|
819
|
+
viam.proto.robot.GetCloudMetadataResponse: App-related metadata.
|
|
820
|
+
|
|
821
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
822
|
+
"""
|
|
823
|
+
|
|
824
|
+
request = GetCloudMetadataRequest()
|
|
825
|
+
return await self._client.GetCloudMetadata(request)
|
|
826
|
+
|
|
827
|
+
############
|
|
828
|
+
# Shutdown #
|
|
829
|
+
############
|
|
830
|
+
|
|
831
|
+
async def shutdown(self):
|
|
832
|
+
"""
|
|
833
|
+
Shutdown shuts down the machine.
|
|
834
|
+
|
|
835
|
+
::
|
|
836
|
+
|
|
837
|
+
await machine.shutdown()
|
|
838
|
+
|
|
839
|
+
Raises:
|
|
840
|
+
GRPCError: Raised with DeadlineExceeded status if shutdown request times out, 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
|
|
843
|
+
shutting down when response is ready.
|
|
844
|
+
|
|
845
|
+
For more information, see `Machine Management API <https://docs.viam.com/appendix/apis/robot/>`_.
|
|
846
|
+
"""
|
|
847
|
+
request = ShutdownRequest()
|
|
848
|
+
try:
|
|
849
|
+
await self._client.Shutdown(request)
|
|
850
|
+
LOGGER.info("robot shutdown successful")
|
|
851
|
+
except GRPCError as e:
|
|
852
|
+
if e.status == Status.INTERNAL or e.status == Status.UNKNOWN:
|
|
853
|
+
LOGGER.info("robot shutdown successful")
|
|
854
|
+
elif e.status == Status.UNAVAILABLE:
|
|
855
|
+
LOGGER.warn("server unavailable, likely due to successful robot shutdown")
|
|
856
|
+
raise e
|
|
857
|
+
elif e.status == Status.DEADLINE_EXCEEDED:
|
|
858
|
+
LOGGER.warn("request timeout, robot shutdown may still be successful")
|
|
859
|
+
raise e
|
|
860
|
+
else:
|
|
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)
|