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
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import abc
|
|
2
|
-
from
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Any, Dict, Final, Optional, Tuple
|
|
3
4
|
|
|
4
5
|
from viam.components.component_base import ComponentBase
|
|
5
|
-
from viam.resource.types import RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT
|
|
6
|
+
from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT
|
|
7
|
+
|
|
8
|
+
from . import KinematicsFileFormat
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
class Gripper(ComponentBase):
|
|
@@ -17,13 +20,24 @@ class Gripper(ComponentBase):
|
|
|
17
20
|
|
|
18
21
|
from viam.components.gripper import Gripper
|
|
19
22
|
|
|
20
|
-
For more information, see `Gripper component <https://docs.viam.com/components/gripper/>`_.
|
|
23
|
+
For more information, see `Gripper component <https://docs.viam.com/dev/reference/apis/components/gripper/>`_.
|
|
21
24
|
"""
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
API: Final = API( # pyright: ignore [reportIncompatibleVariableOverride]
|
|
24
27
|
RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT, "gripper"
|
|
25
28
|
)
|
|
26
29
|
|
|
30
|
+
@dataclass
|
|
31
|
+
class HoldingStatus:
|
|
32
|
+
"""
|
|
33
|
+
HoldingStatus represents whether the gripper is currently holding onto an object. The
|
|
34
|
+
additional ``meta`` attribute contains other optional contextual information (i.e. confidence
|
|
35
|
+
interval, pressure, etc.)
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
is_holding_something: bool
|
|
39
|
+
meta: Optional[Dict[str, Any]] = None
|
|
40
|
+
|
|
27
41
|
@abc.abstractmethod
|
|
28
42
|
async def open(
|
|
29
43
|
self,
|
|
@@ -37,12 +51,12 @@ class Gripper(ComponentBase):
|
|
|
37
51
|
|
|
38
52
|
::
|
|
39
53
|
|
|
40
|
-
my_gripper = Gripper.from_robot(robot=
|
|
54
|
+
my_gripper = Gripper.from_robot(robot=machine, name="my_gripper")
|
|
41
55
|
|
|
42
56
|
# Open the gripper.
|
|
43
57
|
await my_gripper.open()
|
|
44
58
|
|
|
45
|
-
For more information, see `Gripper component <https://docs.viam.com/components/gripper
|
|
59
|
+
For more information, see `Gripper component <https://docs.viam.com/dev/reference/apis/components/gripper/#open>`_.
|
|
46
60
|
"""
|
|
47
61
|
...
|
|
48
62
|
|
|
@@ -59,7 +73,7 @@ class Gripper(ComponentBase):
|
|
|
59
73
|
|
|
60
74
|
::
|
|
61
75
|
|
|
62
|
-
my_gripper = Gripper.from_robot(robot=
|
|
76
|
+
my_gripper = Gripper.from_robot(robot=machine, name="my_gripper")
|
|
63
77
|
|
|
64
78
|
# Grab with the gripper.
|
|
65
79
|
grabbed = await my_gripper.grab()
|
|
@@ -67,10 +81,37 @@ class Gripper(ComponentBase):
|
|
|
67
81
|
Returns:
|
|
68
82
|
bool: Indicates if the gripper grabbed something.
|
|
69
83
|
|
|
70
|
-
For more information, see `Gripper component <https://docs.viam.com/components/gripper
|
|
84
|
+
For more information, see `Gripper component <https://docs.viam.com/dev/reference/apis/components/gripper/#grab>`_.
|
|
71
85
|
"""
|
|
72
86
|
...
|
|
73
87
|
|
|
88
|
+
@abc.abstractmethod
|
|
89
|
+
async def is_holding_something(
|
|
90
|
+
self,
|
|
91
|
+
*,
|
|
92
|
+
extra: Optional[Dict[str, Any]] = None,
|
|
93
|
+
timeout: Optional[float] = None,
|
|
94
|
+
**kwargs,
|
|
95
|
+
) -> HoldingStatus:
|
|
96
|
+
"""
|
|
97
|
+
Get information about whether the gripper is currently holding onto an object.
|
|
98
|
+
|
|
99
|
+
::
|
|
100
|
+
|
|
101
|
+
my_gripper = Gripper.from_robot(robot=machine, name="my_gripper")
|
|
102
|
+
|
|
103
|
+
# Grab with the gripper.
|
|
104
|
+
holding_status = await my_gripper.is_holding_something()
|
|
105
|
+
# get the boolean result
|
|
106
|
+
is_holding_something = holding_status.is_holding_something
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
HoldingStatus: see documentation on `HoldingStatus` for more information
|
|
110
|
+
|
|
111
|
+
For more information, see `Gripper component <https://docs.viam.com/dev/reference/apis/components/gripper/#grab>`_.
|
|
112
|
+
|
|
113
|
+
"""
|
|
114
|
+
|
|
74
115
|
@abc.abstractmethod
|
|
75
116
|
async def stop(
|
|
76
117
|
self,
|
|
@@ -84,12 +125,12 @@ class Gripper(ComponentBase):
|
|
|
84
125
|
|
|
85
126
|
::
|
|
86
127
|
|
|
87
|
-
my_gripper = Gripper.from_robot(robot=
|
|
128
|
+
my_gripper = Gripper.from_robot(robot=machine, name="my_gripper")
|
|
88
129
|
|
|
89
130
|
# Stop the gripper.
|
|
90
131
|
await my_gripper.stop()
|
|
91
132
|
|
|
92
|
-
For more information, see `Gripper component <https://docs.viam.com/components/gripper
|
|
133
|
+
For more information, see `Gripper component <https://docs.viam.com/dev/reference/apis/components/gripper/#stop>`_.
|
|
93
134
|
"""
|
|
94
135
|
...
|
|
95
136
|
|
|
@@ -100,7 +141,7 @@ class Gripper(ComponentBase):
|
|
|
100
141
|
|
|
101
142
|
::
|
|
102
143
|
|
|
103
|
-
my_gripper = Gripper.from_robot(robot=
|
|
144
|
+
my_gripper = Gripper.from_robot(robot=machine, name="my_gripper")
|
|
104
145
|
|
|
105
146
|
# Check whether the gripper is currently moving.
|
|
106
147
|
moving = await my_gripper.is_moving()
|
|
@@ -109,6 +150,40 @@ class Gripper(ComponentBase):
|
|
|
109
150
|
Returns:
|
|
110
151
|
bool: Whether the gripper is moving.
|
|
111
152
|
|
|
112
|
-
For more information, see `Gripper component <https://docs.viam.com/components/gripper
|
|
153
|
+
For more information, see `Gripper component <https://docs.viam.com/dev/reference/apis/components/gripper/#is_moving>`_.
|
|
154
|
+
"""
|
|
155
|
+
...
|
|
156
|
+
|
|
157
|
+
@abc.abstractmethod
|
|
158
|
+
async def get_kinematics(
|
|
159
|
+
self,
|
|
160
|
+
*,
|
|
161
|
+
extra: Optional[Dict[str, Any]] = None,
|
|
162
|
+
timeout: Optional[float] = None,
|
|
163
|
+
**kwargs,
|
|
164
|
+
) -> Tuple[KinematicsFileFormat.ValueType, bytes]:
|
|
165
|
+
"""
|
|
166
|
+
Get the kinematics information associated with the gripper.
|
|
167
|
+
|
|
168
|
+
::
|
|
169
|
+
|
|
170
|
+
my_gripper = Gripper.from_robot(robot=machine, name="my_gripper")
|
|
171
|
+
|
|
172
|
+
# Get the kinematics information associated with the gripper.
|
|
173
|
+
kinematics = await my_gripper.get_kinematics()
|
|
174
|
+
|
|
175
|
+
# Get the format of the kinematics file.
|
|
176
|
+
k_file = kinematics[0]
|
|
177
|
+
|
|
178
|
+
# Get the byte contents of the file.
|
|
179
|
+
k_bytes = kinematics[1]
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
Tuple[KinematicsFileFormat.ValueType, bytes]: A tuple containing two values; the first [0] value represents the format of the
|
|
183
|
+
file, either in URDF format (``KinematicsFileFormat.KINEMATICS_FILE_FORMAT_URDF``) or
|
|
184
|
+
Viam's kinematic parameter format (spatial vector algebra) (``KinematicsFileFormat.KINEMATICS_FILE_FORMAT_SVA``),
|
|
185
|
+
and the second [1] value represents the byte contents of the file.
|
|
186
|
+
|
|
187
|
+
For more information, see `Gripper component <https://docs.viam.com/dev/reference/apis/components/gripper/#getkinematics>`_.
|
|
113
188
|
"""
|
|
114
189
|
...
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
from grpclib.server import Stream
|
|
2
2
|
|
|
3
|
-
from viam.proto.common import
|
|
3
|
+
from viam.proto.common import (
|
|
4
|
+
DoCommandRequest,
|
|
5
|
+
DoCommandResponse,
|
|
6
|
+
GetGeometriesRequest,
|
|
7
|
+
GetGeometriesResponse,
|
|
8
|
+
GetKinematicsRequest,
|
|
9
|
+
GetKinematicsResponse,
|
|
10
|
+
)
|
|
4
11
|
from viam.proto.component.gripper import (
|
|
5
12
|
GrabRequest,
|
|
6
13
|
GrabResponse,
|
|
7
14
|
GripperServiceBase,
|
|
15
|
+
IsHoldingSomethingRequest,
|
|
16
|
+
IsHoldingSomethingResponse,
|
|
8
17
|
IsMovingRequest,
|
|
9
18
|
IsMovingResponse,
|
|
10
19
|
OpenRequest,
|
|
@@ -62,6 +71,17 @@ class GripperRPCService(GripperServiceBase, ResourceRPCServiceBase[Gripper]):
|
|
|
62
71
|
response = IsMovingResponse(is_moving=is_moving)
|
|
63
72
|
await stream.send_message(response)
|
|
64
73
|
|
|
74
|
+
async def IsHoldingSomething(self, stream: Stream[IsHoldingSomethingRequest, IsHoldingSomethingResponse]) -> None:
|
|
75
|
+
request = await stream.recv_message()
|
|
76
|
+
assert request is not None
|
|
77
|
+
name = request.name
|
|
78
|
+
gripper = self.get_resource(name)
|
|
79
|
+
holding_status = await gripper.is_holding_something()
|
|
80
|
+
response = IsHoldingSomethingResponse(
|
|
81
|
+
is_holding_something=holding_status.is_holding_something, meta=dict_to_struct(holding_status.meta)
|
|
82
|
+
)
|
|
83
|
+
await stream.send_message(response)
|
|
84
|
+
|
|
65
85
|
async def DoCommand(self, stream: Stream[DoCommandRequest, DoCommandResponse]) -> None:
|
|
66
86
|
request = await stream.recv_message()
|
|
67
87
|
assert request is not None
|
|
@@ -74,8 +94,17 @@ class GripperRPCService(GripperServiceBase, ResourceRPCServiceBase[Gripper]):
|
|
|
74
94
|
async def GetGeometries(self, stream: Stream[GetGeometriesRequest, GetGeometriesResponse]) -> None:
|
|
75
95
|
request = await stream.recv_message()
|
|
76
96
|
assert request is not None
|
|
77
|
-
|
|
97
|
+
gripper = self.get_resource(request.name)
|
|
78
98
|
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
79
|
-
geometries = await
|
|
99
|
+
geometries = await gripper.get_geometries(extra=struct_to_dict(request.extra), timeout=timeout)
|
|
80
100
|
response = GetGeometriesResponse(geometries=geometries)
|
|
81
101
|
await stream.send_message(response)
|
|
102
|
+
|
|
103
|
+
async def GetKinematics(self, stream: Stream[GetKinematicsRequest, GetKinematicsResponse]) -> None:
|
|
104
|
+
request = await stream.recv_message()
|
|
105
|
+
assert request is not None
|
|
106
|
+
gripper = self.get_resource(request.name)
|
|
107
|
+
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
108
|
+
format, kinematics_data = await gripper.get_kinematics(extra=struct_to_dict(request.extra), timeout=timeout)
|
|
109
|
+
response = GetKinematicsResponse(format=format, kinematics_data=kinematics_data)
|
|
110
|
+
await stream.send_message(response)
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
from viam.proto.component.inputcontroller import Status as InputStatus
|
|
2
|
-
from viam.proto.robot import Status
|
|
3
1
|
from viam.resource.registry import Registry, ResourceRegistration
|
|
4
|
-
from viam.utils import message_to_struct
|
|
5
2
|
|
|
6
3
|
from .client import ControllerClient
|
|
7
4
|
from .input import Control, ControlFunction, Controller, Event, EventType
|
|
@@ -15,14 +12,4 @@ __all__ = [
|
|
|
15
12
|
"EventType",
|
|
16
13
|
]
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
async def create_status(component: Controller) -> Status:
|
|
20
|
-
return Status(
|
|
21
|
-
name=Controller.get_resource_name(component.name),
|
|
22
|
-
status=message_to_struct(InputStatus(events=[event.proto for event in (await component.get_events()).values()])),
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Registry.register_subtype(
|
|
27
|
-
ResourceRegistration(Controller, InputControllerRPCService, lambda name, channel: ControllerClient(name, channel), create_status)
|
|
28
|
-
)
|
|
15
|
+
Registry.register_api(ResourceRegistration(Controller, InputControllerRPCService, lambda name, channel: ControllerClient(name, channel)))
|
viam/components/input/client.py
CHANGED
|
@@ -21,7 +21,7 @@ from viam.proto.component.inputcontroller import (
|
|
|
21
21
|
StreamEventsResponse,
|
|
22
22
|
TriggerEventRequest,
|
|
23
23
|
)
|
|
24
|
-
from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase
|
|
24
|
+
from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase, ResourceRPCClientBase
|
|
25
25
|
from viam.utils import ValueTypes, dict_to_struct, get_geometries, struct_to_dict
|
|
26
26
|
|
|
27
27
|
from .input import Control, ControlFunction, Controller, Event, EventType
|
|
@@ -48,12 +48,11 @@ class ControllerClient(Controller, ReconfigurableResourceRPCClientBase):
|
|
|
48
48
|
*,
|
|
49
49
|
extra: Optional[Dict[str, Any]] = None,
|
|
50
50
|
timeout: Optional[float] = None,
|
|
51
|
-
**
|
|
51
|
+
**kwargs,
|
|
52
52
|
) -> List[Control]:
|
|
53
|
-
|
|
54
|
-
extra = {}
|
|
53
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
55
54
|
request = GetControlsRequest(controller=self.name, extra=dict_to_struct(extra))
|
|
56
|
-
response: GetControlsResponse = await self.client.GetControls(request, timeout=timeout)
|
|
55
|
+
response: GetControlsResponse = await self.client.GetControls(request, timeout=timeout, metadata=md)
|
|
57
56
|
return [Control(control) for control in response.controls]
|
|
58
57
|
|
|
59
58
|
async def get_events(
|
|
@@ -61,12 +60,11 @@ class ControllerClient(Controller, ReconfigurableResourceRPCClientBase):
|
|
|
61
60
|
*,
|
|
62
61
|
extra: Optional[Dict[str, Any]] = None,
|
|
63
62
|
timeout: Optional[float] = None,
|
|
64
|
-
**
|
|
63
|
+
**kwargs,
|
|
65
64
|
) -> Dict[Control, Event]:
|
|
66
|
-
|
|
67
|
-
extra = {}
|
|
65
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
68
66
|
request = GetEventsRequest(controller=self.name, extra=dict_to_struct(extra))
|
|
69
|
-
response: GetEventsResponse = await self.client.GetEvents(request, timeout=timeout)
|
|
67
|
+
response: GetEventsResponse = await self.client.GetEvents(request, timeout=timeout, metadata=md)
|
|
70
68
|
return {Control(event.control): Event.from_proto(event) for (event) in response.events}
|
|
71
69
|
|
|
72
70
|
def register_control_callback(
|
|
@@ -75,10 +73,9 @@ class ControllerClient(Controller, ReconfigurableResourceRPCClientBase):
|
|
|
75
73
|
triggers: List[EventType],
|
|
76
74
|
function: Optional[ControlFunction],
|
|
77
75
|
extra: Optional[Dict[str, Any]] = None,
|
|
78
|
-
**
|
|
76
|
+
**kwargs,
|
|
79
77
|
):
|
|
80
|
-
|
|
81
|
-
extra = {}
|
|
78
|
+
md = kwargs.get("metadata", self.Metadata())
|
|
82
79
|
self._callback_extra = dict_to_struct(extra)
|
|
83
80
|
with self._lock:
|
|
84
81
|
callbacks = self.callbacks.get(control, {})
|
|
@@ -99,7 +96,7 @@ class ControllerClient(Controller, ReconfigurableResourceRPCClientBase):
|
|
|
99
96
|
except Exception:
|
|
100
97
|
LOGGER.exception("Exception raised by task = %r", task)
|
|
101
98
|
|
|
102
|
-
task = asyncio.create_task(self._stream_events(), name=f"{viam._TASK_PREFIX}-input_stream_events")
|
|
99
|
+
task = asyncio.create_task(self._stream_events(md), name=f"{viam._TASK_PREFIX}-input_stream_events")
|
|
103
100
|
task.add_done_callback(handle_task_result)
|
|
104
101
|
|
|
105
102
|
def reset_channel(self, channel: Channel):
|
|
@@ -115,19 +112,18 @@ class ControllerClient(Controller, ReconfigurableResourceRPCClientBase):
|
|
|
115
112
|
*,
|
|
116
113
|
extra: Optional[Dict[str, Any]] = None,
|
|
117
114
|
timeout: Optional[float] = None,
|
|
118
|
-
**
|
|
115
|
+
**kwargs,
|
|
119
116
|
):
|
|
120
|
-
|
|
121
|
-
extra = {}
|
|
117
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
122
118
|
request = TriggerEventRequest(controller=self.name, event=event.proto, extra=dict_to_struct(extra))
|
|
123
119
|
try:
|
|
124
|
-
await self.client.TriggerEvent(request, timeout=timeout)
|
|
120
|
+
await self.client.TriggerEvent(request, timeout=timeout, metadata=md)
|
|
125
121
|
except GRPCError as e:
|
|
126
122
|
if e.status == Status.UNIMPLEMENTED and ("does not support triggering events" in e.message if e.message else False):
|
|
127
123
|
raise NotSupportedError(f"Input controller named {self.name} does not support triggering events")
|
|
128
124
|
raise e
|
|
129
125
|
|
|
130
|
-
async def _stream_events(self):
|
|
126
|
+
async def _stream_events(self, metadata: ResourceRPCClientBase.Metadata):
|
|
131
127
|
with self._stream_lock:
|
|
132
128
|
if self._is_streaming:
|
|
133
129
|
return
|
|
@@ -136,6 +132,7 @@ class ControllerClient(Controller, ReconfigurableResourceRPCClientBase):
|
|
|
136
132
|
if not self.callbacks:
|
|
137
133
|
return
|
|
138
134
|
|
|
135
|
+
md = metadata.proto
|
|
139
136
|
request = StreamEventsRequest(controller=self.name, events=[], extra=self._callback_extra)
|
|
140
137
|
with self._lock:
|
|
141
138
|
for control, callbacks in self.callbacks.items():
|
|
@@ -147,7 +144,7 @@ class ControllerClient(Controller, ReconfigurableResourceRPCClientBase):
|
|
|
147
144
|
request.events.append(event)
|
|
148
145
|
|
|
149
146
|
try:
|
|
150
|
-
async with self.client.StreamEvents.open() as stream:
|
|
147
|
+
async with self.client.StreamEvents.open(metadata=md) as stream:
|
|
151
148
|
await stream.send_message(request, end=True)
|
|
152
149
|
self._send_connection_status(True)
|
|
153
150
|
reply: StreamEventsResponse
|
|
@@ -185,11 +182,13 @@ class ControllerClient(Controller, ReconfigurableResourceRPCClientBase):
|
|
|
185
182
|
command: Mapping[str, ValueTypes],
|
|
186
183
|
*,
|
|
187
184
|
timeout: Optional[float] = None,
|
|
188
|
-
**
|
|
185
|
+
**kwargs,
|
|
189
186
|
) -> Mapping[str, ValueTypes]:
|
|
187
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
190
188
|
request = DoCommandRequest(name=self.name, command=dict_to_struct(command))
|
|
191
|
-
response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout)
|
|
189
|
+
response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout, metadata=md)
|
|
192
190
|
return struct_to_dict(response.result)
|
|
193
191
|
|
|
194
|
-
async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> List[Geometry]:
|
|
195
|
-
|
|
192
|
+
async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs) -> List[Geometry]:
|
|
193
|
+
md = kwargs.get("metadata", self.Metadata())
|
|
194
|
+
return await get_geometries(self.client, self.name, extra, timeout, md)
|
viam/components/input/input.py
CHANGED
|
@@ -10,7 +10,7 @@ from typing_extensions import Self
|
|
|
10
10
|
from viam.components.component_base import ComponentBase
|
|
11
11
|
from viam.errors import NotSupportedError
|
|
12
12
|
from viam.proto.component.inputcontroller import Event as PBEvent
|
|
13
|
-
from viam.resource.types import RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT
|
|
13
|
+
from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class EventType(str, Enum):
|
|
@@ -140,10 +140,10 @@ class Controller(ComponentBase):
|
|
|
140
140
|
|
|
141
141
|
from viam.components.input import Control, Controller, EventType
|
|
142
142
|
|
|
143
|
-
For more information, see `Input Controller component <https://docs.viam.com/components/input-controller/>`_.
|
|
143
|
+
For more information, see `Input Controller component <https://docs.viam.com/dev/reference/apis/components/input-controller/>`_.
|
|
144
144
|
"""
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
API: Final = API( # pyright: ignore [reportIncompatibleVariableOverride]
|
|
147
147
|
RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT, "input_controller"
|
|
148
148
|
)
|
|
149
149
|
|
|
@@ -156,7 +156,7 @@ class Controller(ComponentBase):
|
|
|
156
156
|
|
|
157
157
|
# Get the controller from the machine.
|
|
158
158
|
my_controller = Controller.from_robot(
|
|
159
|
-
robot=
|
|
159
|
+
robot=machine, "my_controller")
|
|
160
160
|
|
|
161
161
|
# Get the list of Controls provided by the controller.
|
|
162
162
|
controls = await my_controller.get_controls()
|
|
@@ -167,7 +167,7 @@ class Controller(ComponentBase):
|
|
|
167
167
|
Returns:
|
|
168
168
|
List[Control]: List of controls provided by the Controller
|
|
169
169
|
|
|
170
|
-
For more information, see `Input Controller component <https://docs.viam.com/components/input-controller
|
|
170
|
+
For more information, see `Input Controller component <https://docs.viam.com/dev/reference/apis/components/input-controller/#getcontrols>`_.
|
|
171
171
|
"""
|
|
172
172
|
...
|
|
173
173
|
|
|
@@ -183,7 +183,7 @@ class Controller(ComponentBase):
|
|
|
183
183
|
|
|
184
184
|
# Get the controller from the machine.
|
|
185
185
|
my_controller = Controller.from_robot(
|
|
186
|
-
robot=
|
|
186
|
+
robot=machine, "my_controller")
|
|
187
187
|
|
|
188
188
|
# Get the most recent Event for each Control.
|
|
189
189
|
recent_events = await my_controller.get_events()
|
|
@@ -194,7 +194,7 @@ class Controller(ComponentBase):
|
|
|
194
194
|
Returns:
|
|
195
195
|
Dict[Control, Event]: The most recent event for each input
|
|
196
196
|
|
|
197
|
-
For more information, see `Input Controller component <https://docs.viam.com/components/input-controller
|
|
197
|
+
For more information, see `Input Controller component <https://docs.viam.com/dev/reference/apis/components/input-controller/#getevents>`_.
|
|
198
198
|
"""
|
|
199
199
|
...
|
|
200
200
|
|
|
@@ -214,6 +214,8 @@ class Controller(ComponentBase):
|
|
|
214
214
|
|
|
215
215
|
::
|
|
216
216
|
|
|
217
|
+
from viam.components.input import Control, EventType
|
|
218
|
+
|
|
217
219
|
# Define a function to handle pressing the Start Menu Button "BUTTON_START" on
|
|
218
220
|
# your controller, printing out the start time.
|
|
219
221
|
def print_start_time(event):
|
|
@@ -245,10 +247,10 @@ class Controller(ComponentBase):
|
|
|
245
247
|
|
|
246
248
|
# Get your controller from the machine.
|
|
247
249
|
my_controller = Controller.from_robot(
|
|
248
|
-
robot=
|
|
250
|
+
robot=machine, "my_controller")
|
|
249
251
|
|
|
250
252
|
# Run the handleController function.
|
|
251
|
-
await
|
|
253
|
+
await handle_controller(my_controller)
|
|
252
254
|
|
|
253
255
|
# ... < INSERT ANY OTHER CODE FOR MAIN FUNCTION >
|
|
254
256
|
|
|
@@ -259,7 +261,7 @@ class Controller(ComponentBase):
|
|
|
259
261
|
function (ControlFunction): The function to run on
|
|
260
262
|
specific triggers
|
|
261
263
|
|
|
262
|
-
For more information, see `Input Controller component <https://docs.viam.com/components/input-controller
|
|
264
|
+
For more information, see `Input Controller component <https://docs.viam.com/dev/reference/apis/components/input-controller/#registercontrolcallback>`_.
|
|
263
265
|
"""
|
|
264
266
|
...
|
|
265
267
|
|
|
@@ -275,17 +277,21 @@ class Controller(ComponentBase):
|
|
|
275
277
|
|
|
276
278
|
::
|
|
277
279
|
|
|
280
|
+
# Get your controller from the machine.
|
|
281
|
+
my_controller = Controller.from_robot(
|
|
282
|
+
robot=machine, "my_controller")
|
|
283
|
+
|
|
278
284
|
# Define a "Button is Pressed" event for the control BUTTON_START.
|
|
279
285
|
button_is_pressed_event = Event(
|
|
280
286
|
time(), EventType.BUTTON_PRESS, Control.BUTTON_START, 1.0)
|
|
281
287
|
|
|
282
288
|
# Trigger the event on your controller. Set this trigger to timeout if it has
|
|
283
289
|
# not completed in 7 seconds.
|
|
284
|
-
await
|
|
290
|
+
await my_controller.trigger_event(event=button_is_pressed_event, timeout=7.0)
|
|
285
291
|
|
|
286
292
|
Args:
|
|
287
293
|
event (Event): The event to trigger
|
|
288
294
|
|
|
289
|
-
For more information, see `Input Controller component <https://docs.viam.com/components/input-controller
|
|
295
|
+
For more information, see `Input Controller component <https://docs.viam.com/dev/reference/apis/components/input-controller/#triggerevent>`_.
|
|
290
296
|
"""
|
|
291
297
|
raise NotSupportedError(f"Input controller named {self.name} does not support triggering events")
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
|
|
3
|
-
from viam.proto.component.motor import Status as MotorStatus
|
|
4
|
-
from viam.proto.robot import Status
|
|
5
1
|
from viam.resource.registry import Registry, ResourceRegistration
|
|
6
|
-
from viam.utils import message_to_struct
|
|
7
2
|
|
|
8
3
|
from .client import MotorClient
|
|
9
4
|
from .motor import Motor
|
|
@@ -13,19 +8,4 @@ __all__ = [
|
|
|
13
8
|
"Motor",
|
|
14
9
|
]
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
async def create_status(component: Motor) -> Status:
|
|
18
|
-
((is_powered, _), position, is_moving) = await asyncio.gather(
|
|
19
|
-
component.is_powered(),
|
|
20
|
-
component.get_position(),
|
|
21
|
-
component.is_moving(),
|
|
22
|
-
)
|
|
23
|
-
s = MotorStatus(
|
|
24
|
-
is_powered=is_powered,
|
|
25
|
-
position=position,
|
|
26
|
-
is_moving=is_moving,
|
|
27
|
-
)
|
|
28
|
-
return Status(name=Motor.get_resource_name(component.name), status=message_to_struct(s))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Registry.register_subtype(ResourceRegistration(Motor, MotorRPCService, lambda name, channel: MotorClient(name, channel), create_status))
|
|
11
|
+
Registry.register_api(ResourceRegistration(Motor, MotorRPCService, lambda name, channel: MotorClient(name, channel)))
|