viam-sdk 0.25.2__py3-none-linux_armv7l.whl → 0.62.0__py3-none-linux_armv7l.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- viam/app/_logs.py +3 -6
- viam/app/app_client.py +606 -262
- viam/app/billing_client.py +60 -18
- viam/app/data_client.py +1086 -315
- viam/app/ml_training_client.py +51 -48
- viam/app/provisioning_client.py +3 -5
- viam/app/viam_client.py +105 -11
- viam/components/arm/__init__.py +1 -25
- viam/components/arm/arm.py +21 -22
- viam/components/arm/client.py +27 -30
- viam/components/arm/service.py +3 -3
- viam/components/audio_in/__init__.py +24 -0
- viam/components/audio_in/audio_in.py +74 -0
- viam/components/audio_in/client.py +76 -0
- viam/components/audio_in/service.py +83 -0
- viam/components/audio_input/__init__.py +1 -1
- viam/components/audio_input/audio_input.py +4 -3
- viam/components/audio_input/client.py +19 -8
- viam/components/audio_input/service.py +10 -0
- viam/components/audio_out/__init__.py +21 -0
- viam/components/audio_out/audio_out.py +72 -0
- viam/components/audio_out/client.py +67 -0
- viam/components/audio_out/service.py +63 -0
- viam/components/base/__init__.py +2 -10
- viam/components/base/base.py +20 -20
- viam/components/base/client.py +27 -30
- viam/components/board/__init__.py +2 -25
- viam/components/board/board.py +39 -77
- viam/components/board/client.py +39 -73
- viam/components/button/__init__.py +10 -0
- viam/components/button/button.py +41 -0
- viam/components/button/client.py +52 -0
- viam/components/button/service.py +46 -0
- viam/components/camera/__init__.py +1 -1
- viam/components/camera/camera.py +31 -22
- viam/components/camera/client.py +30 -20
- viam/components/camera/service.py +14 -12
- viam/components/component_base.py +10 -7
- viam/components/encoder/__init__.py +1 -1
- viam/components/encoder/client.py +15 -16
- viam/components/encoder/encoder.py +9 -9
- viam/components/gantry/__init__.py +1 -13
- viam/components/gantry/client.py +41 -28
- viam/components/gantry/gantry.py +48 -17
- viam/components/gantry/service.py +21 -5
- viam/components/generic/__init__.py +1 -1
- viam/components/generic/client.py +11 -7
- viam/components/generic/generic.py +3 -3
- viam/components/gripper/__init__.py +3 -12
- viam/components/gripper/client.py +43 -20
- viam/components/gripper/gripper.py +87 -12
- viam/components/gripper/service.py +32 -3
- viam/components/input/__init__.py +1 -14
- viam/components/input/client.py +22 -23
- viam/components/input/input.py +18 -12
- viam/components/motor/__init__.py +1 -21
- viam/components/motor/client.py +36 -42
- viam/components/motor/motor.py +24 -24
- viam/components/movement_sensor/__init__.py +1 -1
- viam/components/movement_sensor/client.py +33 -40
- viam/components/movement_sensor/movement_sensor.py +12 -12
- viam/components/pose_tracker/__init__.py +1 -1
- viam/components/pose_tracker/client.py +9 -8
- viam/components/pose_tracker/pose_tracker.py +2 -2
- viam/components/power_sensor/__init__.py +1 -1
- viam/components/power_sensor/client.py +15 -18
- viam/components/power_sensor/power_sensor.py +12 -12
- viam/components/sensor/__init__.py +1 -1
- viam/components/sensor/client.py +9 -8
- viam/components/sensor/sensor.py +5 -5
- viam/components/servo/__init__.py +1 -13
- viam/components/servo/client.py +18 -18
- viam/components/servo/servo.py +12 -12
- viam/components/switch/__init__.py +10 -0
- viam/components/switch/client.py +83 -0
- viam/components/switch/service.py +72 -0
- viam/components/switch/switch.py +95 -0
- viam/gen/app/agent/v1/agent_pb2.py +40 -29
- viam/gen/app/agent/v1/agent_pb2.pyi +73 -11
- viam/gen/app/cloudslam/v1/cloud_slam_pb2.py +45 -42
- viam/gen/app/data/v1/data_grpc.py +98 -2
- viam/gen/app/data/v1/data_pb2.py +238 -119
- viam/gen/app/data/v1/data_pb2.pyi +804 -34
- viam/gen/app/datapipelines/v1/data_pipelines_grpc.py +84 -0
- viam/gen/app/datapipelines/v1/data_pipelines_pb2.py +57 -0
- viam/gen/app/datapipelines/v1/data_pipelines_pb2.pyi +387 -0
- viam/gen/app/dataset/v1/dataset_grpc.py +10 -2
- viam/gen/app/dataset/v1/dataset_pb2.py +38 -31
- viam/gen/app/dataset/v1/dataset_pb2.pyi +36 -1
- viam/gen/app/datasync/v1/data_sync_grpc.py +1 -1
- viam/gen/app/datasync/v1/data_sync_pb2.py +61 -51
- viam/gen/app/datasync/v1/data_sync_pb2.pyi +52 -12
- viam/gen/app/mlinference/__init__.py +0 -0
- viam/gen/app/mlinference/v1/__init__.py +0 -0
- viam/gen/app/mlinference/v1/ml_inference_grpc.py +28 -0
- viam/gen/app/mlinference/v1/ml_inference_pb2.py +23 -0
- viam/gen/app/mlinference/v1/ml_inference_pb2.pyi +63 -0
- viam/gen/app/mltraining/v1/ml_training_grpc.py +18 -2
- viam/gen/app/mltraining/v1/ml_training_pb2.py +134 -101
- viam/gen/app/mltraining/v1/ml_training_pb2.pyi +193 -7
- viam/gen/app/packages/v1/packages_pb2.py +43 -40
- viam/gen/app/v1/app_grpc.py +290 -2
- viam/gen/app/v1/app_pb2.py +670 -453
- viam/gen/app/v1/app_pb2.pyi +3133 -947
- viam/gen/app/v1/billing_grpc.py +34 -2
- viam/gen/app/v1/billing_pb2.py +94 -35
- viam/gen/app/v1/billing_pb2.pyi +314 -61
- viam/gen/app/v1/end_user_pb2.py +50 -29
- viam/gen/app/v1/robot_pb2.py +120 -111
- viam/gen/app/v1/robot_pb2.pyi +137 -15
- viam/gen/common/v1/common_pb2.py +86 -66
- viam/gen/common/v1/common_pb2.pyi +184 -8
- viam/gen/component/arm/v1/arm_grpc.py +18 -2
- viam/gen/component/arm/v1/arm_pb2.py +68 -55
- viam/gen/component/arm/v1/arm_pb2.pyi +73 -3
- viam/gen/component/audioin/__init__.py +0 -0
- viam/gen/component/audioin/v1/__init__.py +0 -0
- viam/gen/component/audioin/v1/audioin_grpc.py +54 -0
- viam/gen/component/audioin/v1/audioin_pb2.py +34 -0
- viam/gen/component/audioin/v1/audioin_pb2.pyi +94 -0
- viam/gen/component/audioinput/v1/audioinput_pb2.py +35 -32
- viam/gen/component/audioout/__init__.py +0 -0
- viam/gen/component/audioout/v1/__init__.py +0 -0
- viam/gen/component/audioout/v1/audioout_grpc.py +54 -0
- viam/gen/component/audioout/v1/audioout_pb2.py +32 -0
- viam/gen/component/audioout/v1/audioout_pb2.pyi +47 -0
- viam/gen/component/base/v1/base_pb2.py +57 -54
- viam/gen/component/board/v1/board_pb2.py +93 -90
- viam/gen/component/button/__init__.py +0 -0
- viam/gen/component/button/v1/__init__.py +0 -0
- viam/gen/component/button/v1/button_grpc.py +38 -0
- viam/gen/component/button/v1/button_pb2.py +28 -0
- viam/gen/component/button/v1/button_pb2.pyi +39 -0
- viam/gen/component/camera/v1/camera_pb2.py +58 -55
- viam/gen/component/camera/v1/camera_pb2.pyi +31 -7
- viam/gen/component/encoder/v1/encoder_pb2.py +35 -32
- viam/gen/component/gantry/v1/gantry_grpc.py +9 -1
- viam/gen/component/gantry/v1/gantry_pb2.py +56 -51
- viam/gen/component/generic/v1/generic_pb2.py +15 -12
- viam/gen/component/gripper/v1/gripper_grpc.py +18 -2
- viam/gen/component/gripper/v1/gripper_pb2.py +48 -37
- viam/gen/component/gripper/v1/gripper_pb2.pyi +43 -1
- viam/gen/component/inputcontroller/v1/input_controller_pb2.py +45 -42
- viam/gen/component/motor/v1/motor_pb2.py +77 -74
- viam/gen/component/movementsensor/v1/movementsensor_pb2.py +69 -66
- viam/gen/component/posetracker/v1/pose_tracker_pb2.py +25 -22
- viam/gen/component/powersensor/v1/powersensor_pb2.py +33 -30
- viam/gen/component/sensor/v1/sensor_pb2.py +17 -14
- viam/gen/component/servo/v1/servo_pb2.py +41 -38
- viam/gen/component/switch/__init__.py +0 -0
- viam/gen/component/switch/v1/__init__.py +0 -0
- viam/gen/component/switch/v1/switch_grpc.py +54 -0
- viam/gen/component/switch/v1/switch_pb2.py +40 -0
- viam/gen/component/switch/v1/switch_pb2.pyi +116 -0
- viam/gen/component/testecho/v1/testecho_pb2.py +29 -26
- viam/gen/module/v1/module_pb2.py +36 -33
- viam/gen/module/v1/module_pb2.pyi +7 -2
- viam/gen/proto/rpc/examples/echo/v1/echo_pb2.py +26 -23
- viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.py +23 -20
- viam/gen/proto/rpc/v1/auth_pb2.py +27 -24
- viam/gen/proto/rpc/webrtc/v1/grpc_pb2.py +35 -32
- viam/gen/proto/rpc/webrtc/v1/signaling_pb2.py +62 -57
- viam/gen/proto/rpc/webrtc/v1/signaling_pb2.pyi +18 -4
- viam/gen/provisioning/v1/provisioning_grpc.py +10 -2
- viam/gen/provisioning/v1/provisioning_pb2.py +38 -31
- viam/gen/provisioning/v1/provisioning_pb2.pyi +20 -2
- viam/gen/robot/v1/robot_grpc.py +61 -29
- viam/gen/robot/v1/robot_pb2.py +186 -155
- viam/gen/robot/v1/robot_pb2.pyi +278 -59
- viam/gen/service/datamanager/v1/data_manager_grpc.py +11 -2
- viam/gen/service/datamanager/v1/data_manager_pb2.py +27 -17
- viam/gen/service/datamanager/v1/data_manager_pb2.pyi +47 -1
- viam/gen/service/discovery/__init__.py +0 -0
- viam/gen/service/discovery/v1/__init__.py +0 -0
- viam/gen/service/discovery/v1/discovery_grpc.py +39 -0
- viam/gen/service/discovery/v1/discovery_pb2.py +29 -0
- viam/gen/service/discovery/v1/discovery_pb2.pyi +51 -0
- viam/gen/service/generic/v1/generic_pb2.py +13 -10
- viam/gen/service/mlmodel/v1/mlmodel_pb2.py +75 -72
- viam/gen/service/motion/v1/motion_pb2.py +118 -85
- viam/gen/service/motion/v1/motion_pb2.pyi +130 -68
- viam/gen/service/navigation/v1/navigation_pb2.py +75 -72
- viam/gen/service/sensors/v1/sensors_pb2.py +59 -56
- viam/gen/service/shell/v1/shell_pb2.py +35 -32
- viam/gen/service/slam/v1/slam_pb2.py +43 -40
- viam/gen/service/slam/v1/slam_pb2.pyi +1 -1
- viam/gen/service/video/__init__.py +0 -0
- viam/gen/service/video/v1/__init__.py +0 -0
- viam/gen/service/video/v1/video_grpc.py +39 -0
- viam/gen/service/video/v1/video_pb2.py +29 -0
- viam/gen/service/video/v1/video_pb2.pyi +72 -0
- viam/gen/service/vision/v1/vision_pb2.py +60 -57
- viam/gen/service/vision/v1/vision_pb2.pyi +28 -3
- viam/gen/service/worldstatestore/__init__.py +0 -0
- viam/gen/service/worldstatestore/v1/__init__.py +0 -0
- viam/gen/service/worldstatestore/v1/world_state_store_grpc.py +55 -0
- viam/gen/service/worldstatestore/v1/world_state_store_pb2.py +39 -0
- viam/gen/service/worldstatestore/v1/world_state_store_pb2.pyi +171 -0
- viam/gen/stream/v1/stream_grpc.py +17 -1
- viam/gen/stream/v1/stream_pb2.py +34 -21
- viam/gen/stream/v1/stream_pb2.pyi +79 -1
- viam/gen/tagger/v1/tagger_pb2.py +9 -8
- viam/logging.py +77 -18
- viam/media/audio.py +28 -0
- viam/media/utils/pil/__init__.py +7 -3
- viam/media/video.py +80 -17
- viam/module/module.py +111 -38
- viam/module/resource_data_consumer.py +41 -0
- viam/module/service.py +9 -1
- viam/module/types.py +2 -4
- viam/proto/app/__init__.py +199 -0
- viam/proto/app/agent/__init__.py +5 -2
- viam/proto/app/billing.py +31 -4
- viam/proto/app/cloudslam/__init__.py +1 -0
- viam/proto/app/data/__init__.py +63 -0
- viam/proto/app/datapipelines/__init__.py +56 -0
- viam/proto/app/dataset/__init__.py +5 -0
- viam/proto/app/datasync/__init__.py +3 -0
- viam/proto/app/end_user.py +1 -0
- viam/proto/app/mlinference/__init__.py +15 -0
- viam/proto/app/mltraining/__init__.py +13 -0
- viam/proto/app/packages/__init__.py +1 -0
- viam/proto/app/robot.py +7 -0
- viam/proto/common/__init__.py +15 -0
- viam/proto/component/arm/__init__.py +7 -0
- viam/proto/component/audioin/__init__.py +16 -0
- viam/proto/component/audioinput/__init__.py +1 -0
- viam/proto/component/audioout/__init__.py +15 -0
- viam/proto/component/base/__init__.py +1 -0
- viam/proto/component/board/__init__.py +1 -0
- viam/proto/component/button/__init__.py +15 -0
- viam/proto/component/camera/__init__.py +1 -0
- viam/proto/component/encoder/__init__.py +1 -0
- viam/proto/component/gantry/__init__.py +1 -0
- viam/proto/component/generic/__init__.py +1 -0
- viam/proto/component/gripper/__init__.py +5 -0
- viam/proto/component/inputcontroller/__init__.py +1 -0
- viam/proto/component/motor/__init__.py +1 -0
- viam/proto/component/movementsensor/__init__.py +1 -0
- viam/proto/component/posetracker/__init__.py +1 -0
- viam/proto/component/powersensor/__init__.py +1 -0
- viam/proto/component/sensor/__init__.py +1 -0
- viam/proto/component/servo/__init__.py +1 -0
- viam/proto/component/switch/__init__.py +26 -0
- viam/proto/component/testecho/__init__.py +1 -0
- viam/proto/module/__init__.py +1 -0
- viam/proto/provisioning/__init__.py +5 -0
- viam/proto/robot/__init__.py +29 -8
- viam/proto/rpc/auth.py +1 -0
- viam/proto/rpc/examples/echo/__init__.py +1 -0
- viam/proto/rpc/examples/echoresource/__init__.py +1 -0
- viam/proto/rpc/webrtc/grpc.py +1 -0
- viam/proto/rpc/webrtc/signaling.py +3 -0
- viam/proto/service/datamanager/__init__.py +9 -1
- viam/proto/service/discovery/__init__.py +15 -0
- viam/proto/service/generic/__init__.py +1 -0
- viam/proto/service/mlmodel/__init__.py +1 -0
- viam/proto/service/motion/__init__.py +3 -0
- viam/proto/service/navigation/__init__.py +1 -0
- viam/proto/service/sensors/__init__.py +1 -0
- viam/proto/service/shell/__init__.py +1 -0
- viam/proto/service/slam/__init__.py +1 -0
- viam/proto/service/video/__init__.py +15 -0
- viam/proto/service/vision/__init__.py +1 -0
- viam/proto/service/worldstatestore/__init__.py +32 -0
- viam/proto/stream/__init__.py +11 -0
- viam/py.typed +0 -0
- viam/resource/base.py +12 -8
- viam/resource/easy_resource.py +24 -13
- viam/resource/manager.py +6 -5
- viam/resource/registry.py +39 -51
- viam/resource/rpc_client_base.py +33 -1
- viam/resource/types.py +13 -14
- viam/robot/client.py +190 -122
- viam/robot/service.py +2 -50
- viam/rpc/dial.py +54 -4
- viam/rpc/libviam_rust_utils.so +0 -0
- viam/rpc/server.py +25 -11
- viam/rpc/types.py +2 -4
- viam/services/discovery/__init__.py +12 -0
- viam/services/discovery/client.py +55 -0
- viam/services/discovery/discovery.py +52 -0
- viam/services/discovery/service.py +43 -0
- viam/services/generic/__init__.py +1 -1
- viam/services/generic/client.py +8 -5
- viam/services/generic/generic.py +2 -2
- viam/services/mlmodel/__init__.py +1 -1
- viam/services/mlmodel/client.py +17 -7
- viam/services/mlmodel/mlmodel.py +23 -12
- viam/services/mlmodel/service.py +5 -2
- viam/services/mlmodel/utils.py +11 -1
- viam/services/motion/__init__.py +2 -2
- viam/services/motion/client.py +32 -32
- viam/services/motion/motion.py +66 -62
- viam/services/navigation/__init__.py +1 -1
- viam/services/navigation/client.py +30 -20
- viam/services/navigation/navigation.py +23 -23
- viam/services/service_base.py +13 -9
- viam/services/service_client_base.py +3 -3
- viam/services/slam/__init__.py +1 -1
- viam/services/slam/client.py +15 -10
- viam/services/slam/slam.py +11 -11
- viam/services/vision/__init__.py +1 -1
- viam/services/vision/client.py +31 -24
- viam/services/vision/service.py +8 -8
- viam/services/vision/vision.py +36 -53
- viam/services/worldstatestore/__init__.py +18 -0
- viam/services/worldstatestore/client.py +94 -0
- viam/services/worldstatestore/service.py +55 -0
- viam/services/worldstatestore/worldstatestore.py +90 -0
- viam/sessions_client.py +115 -46
- viam/streams.py +3 -6
- viam/utils.py +44 -14
- viam/version_metadata.py +4 -0
- {viam_sdk-0.25.2.dist-info → viam_sdk-0.62.0.dist-info}/METADATA +27 -28
- viam_sdk-0.62.0.dist-info/RECORD +514 -0
- {viam_sdk-0.25.2.dist-info → viam_sdk-0.62.0.dist-info}/WHEEL +1 -1
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_grpc.py +0 -27
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.py +0 -18
- viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.pyi +0 -45
- viam/proto/rpc/examples/fileupload/__init__.py +0 -18
- viam/services/sensors/__init__.py +0 -5
- viam/services/sensors/client.py +0 -65
- viam_sdk-0.25.2.dist-info/LICENSE +0 -202
- viam_sdk-0.25.2.dist-info/RECORD +0 -442
- /viam/gen/{proto/rpc/examples/fileupload → app/datapipelines}/__init__.py +0 -0
- /viam/gen/{proto/rpc/examples/fileupload → app/datapipelines}/v1/__init__.py +0 -0
- /LICENSE → /viam_sdk-0.62.0.dist-info/licenses/LICENSE +0 -0
viam/services/mlmodel/service.py
CHANGED
|
@@ -3,6 +3,7 @@ from grpclib.server import Stream
|
|
|
3
3
|
from viam.proto.service.mlmodel import InferRequest, InferResponse, MetadataRequest, MetadataResponse, MLModelServiceBase
|
|
4
4
|
from viam.resource.rpc_service_base import ResourceRPCServiceBase
|
|
5
5
|
from viam.services.mlmodel.utils import flat_tensors_to_ndarrays, ndarrays_to_flat_tensors
|
|
6
|
+
from viam.utils import struct_to_dict
|
|
6
7
|
|
|
7
8
|
from .mlmodel import MLModel
|
|
8
9
|
|
|
@@ -19,8 +20,9 @@ class MLModelRPCService(MLModelServiceBase, ResourceRPCServiceBase):
|
|
|
19
20
|
assert request is not None
|
|
20
21
|
name = request.name
|
|
21
22
|
mlmodel = self.get_resource(name)
|
|
23
|
+
extra = struct_to_dict(request.extra)
|
|
22
24
|
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
23
|
-
output_tensors = await mlmodel.infer(input_tensors=flat_tensors_to_ndarrays(request.input_tensors), timeout=timeout)
|
|
25
|
+
output_tensors = await mlmodel.infer(input_tensors=flat_tensors_to_ndarrays(request.input_tensors), extra=extra, timeout=timeout)
|
|
24
26
|
response = InferResponse(output_tensors=ndarrays_to_flat_tensors(output_tensors))
|
|
25
27
|
await stream.send_message(response)
|
|
26
28
|
|
|
@@ -29,7 +31,8 @@ class MLModelRPCService(MLModelServiceBase, ResourceRPCServiceBase):
|
|
|
29
31
|
assert request is not None
|
|
30
32
|
name = request.name
|
|
31
33
|
mlmodel = self.get_resource(name)
|
|
34
|
+
extra = struct_to_dict(request.extra)
|
|
32
35
|
timeout = stream.deadline.time_remaining() if stream.deadline else None
|
|
33
|
-
metadata = await mlmodel.metadata(timeout=timeout)
|
|
36
|
+
metadata = await mlmodel.metadata(extra=extra, timeout=timeout)
|
|
34
37
|
response = MetadataResponse(metadata=metadata)
|
|
35
38
|
await stream.send_message(response)
|
viam/services/mlmodel/utils.py
CHANGED
|
@@ -2,6 +2,7 @@ from typing import Dict
|
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
from numpy.typing import NDArray
|
|
5
|
+
from packaging.version import Version
|
|
5
6
|
|
|
6
7
|
from viam.proto.service.mlmodel import (
|
|
7
8
|
FlatTensor,
|
|
@@ -37,7 +38,16 @@ def flat_tensors_to_ndarrays(flat_tensors: FlatTensors) -> Dict[str, NDArray]:
|
|
|
37
38
|
"""Takes flat data (protobuf RepeatedScalarFieldContainer | bytes) to output an ndarray
|
|
38
39
|
of appropriate dtype and shape"""
|
|
39
40
|
make_array = np.frombuffer if dtype == np.int8 or dtype == np.uint8 else np.array
|
|
40
|
-
|
|
41
|
+
# As per proto, int16 and uint16 are stored as uint32. As of numpy v2, this creates
|
|
42
|
+
# some strange interactions with negative values for int16. Specifically, we end up
|
|
43
|
+
# trying to create an np.Int16 value with an out of bounds int due to rollover.
|
|
44
|
+
# Creating our array as a uint32 array initially and then casting to int16 solves this.
|
|
45
|
+
if Version(np.__version__) >= Version("2") and dtype == np.int16:
|
|
46
|
+
arr = np.astype(make_array(flat_data, np.uint32), np.int16) # pyright: ignore [reportAttributeAccessIssue]
|
|
47
|
+
|
|
48
|
+
else:
|
|
49
|
+
arr = make_array(flat_data, dtype)
|
|
50
|
+
return arr.reshape(shape)
|
|
41
51
|
|
|
42
52
|
ndarrays: Dict[str, NDArray] = dict()
|
|
43
53
|
for name, flat_tensor in flat_tensors.tensors.items():
|
viam/services/motion/__init__.py
CHANGED
|
@@ -5,10 +5,10 @@ from .client import MotionClient
|
|
|
5
5
|
from .motion import Motion
|
|
6
6
|
from .service import MotionRPCService
|
|
7
7
|
|
|
8
|
-
__all__ = ["MotionClient", "MotionConfiguration", "Constraints"]
|
|
8
|
+
__all__ = ["Motion", "MotionClient", "MotionConfiguration", "Constraints"]
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
Registry.
|
|
11
|
+
Registry.register_api(
|
|
12
12
|
ResourceRegistration(
|
|
13
13
|
Motion,
|
|
14
14
|
MotionRPCService,
|
viam/services/motion/client.py
CHANGED
|
@@ -10,7 +10,6 @@ from viam.proto.common import (
|
|
|
10
10
|
GeoPoint,
|
|
11
11
|
Pose,
|
|
12
12
|
PoseInFrame,
|
|
13
|
-
ResourceName,
|
|
14
13
|
Transform,
|
|
15
14
|
WorldState,
|
|
16
15
|
)
|
|
@@ -54,16 +53,16 @@ class MotionClient(Motion, ReconfigurableResourceRPCClientBase):
|
|
|
54
53
|
|
|
55
54
|
async def move(
|
|
56
55
|
self,
|
|
57
|
-
component_name:
|
|
56
|
+
component_name: str,
|
|
58
57
|
destination: PoseInFrame,
|
|
59
58
|
world_state: Optional[WorldState] = None,
|
|
60
59
|
constraints: Optional[Constraints] = None,
|
|
61
60
|
*,
|
|
62
61
|
extra: Optional[Mapping[str, Any]] = None,
|
|
63
62
|
timeout: Optional[float] = None,
|
|
63
|
+
**kwargs,
|
|
64
64
|
) -> bool:
|
|
65
|
-
|
|
66
|
-
extra = {}
|
|
65
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
67
66
|
request = MoveRequest(
|
|
68
67
|
name=self.name,
|
|
69
68
|
destination=destination,
|
|
@@ -72,14 +71,14 @@ class MotionClient(Motion, ReconfigurableResourceRPCClientBase):
|
|
|
72
71
|
constraints=constraints,
|
|
73
72
|
extra=dict_to_struct(extra),
|
|
74
73
|
)
|
|
75
|
-
response: MoveResponse = await self.client.Move(request, timeout=timeout)
|
|
74
|
+
response: MoveResponse = await self.client.Move(request, timeout=timeout, metadata=md)
|
|
76
75
|
return response.success
|
|
77
76
|
|
|
78
77
|
async def move_on_globe(
|
|
79
78
|
self,
|
|
80
|
-
component_name:
|
|
79
|
+
component_name: str,
|
|
81
80
|
destination: GeoPoint,
|
|
82
|
-
movement_sensor_name:
|
|
81
|
+
movement_sensor_name: str,
|
|
83
82
|
obstacles: Optional[Sequence[GeoGeometry]] = None,
|
|
84
83
|
heading: Optional[float] = None,
|
|
85
84
|
configuration: Optional[MotionConfiguration] = None,
|
|
@@ -87,9 +86,9 @@ class MotionClient(Motion, ReconfigurableResourceRPCClientBase):
|
|
|
87
86
|
bounding_regions: Optional[Sequence[GeoGeometry]] = None,
|
|
88
87
|
extra: Optional[Mapping[str, ValueTypes]] = None,
|
|
89
88
|
timeout: Optional[float] = None,
|
|
89
|
+
**kwargs,
|
|
90
90
|
) -> str:
|
|
91
|
-
|
|
92
|
-
extra = {}
|
|
91
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
93
92
|
request = MoveOnGlobeRequest(
|
|
94
93
|
name=self.name,
|
|
95
94
|
component_name=component_name,
|
|
@@ -101,22 +100,22 @@ class MotionClient(Motion, ReconfigurableResourceRPCClientBase):
|
|
|
101
100
|
bounding_regions=bounding_regions,
|
|
102
101
|
extra=dict_to_struct(extra),
|
|
103
102
|
)
|
|
104
|
-
response: MoveOnGlobeResponse = await self.client.MoveOnGlobe(request, timeout=timeout)
|
|
103
|
+
response: MoveOnGlobeResponse = await self.client.MoveOnGlobe(request, timeout=timeout, metadata=md)
|
|
105
104
|
return response.execution_id
|
|
106
105
|
|
|
107
106
|
async def move_on_map(
|
|
108
107
|
self,
|
|
109
|
-
component_name:
|
|
108
|
+
component_name: str,
|
|
110
109
|
destination: Pose,
|
|
111
|
-
slam_service_name:
|
|
110
|
+
slam_service_name: str,
|
|
112
111
|
configuration: Optional[MotionConfiguration] = None,
|
|
113
112
|
obstacles: Optional[Sequence[Geometry]] = None,
|
|
114
113
|
*,
|
|
115
114
|
extra: Optional[Mapping[str, ValueTypes]] = None,
|
|
116
115
|
timeout: Optional[float] = None,
|
|
116
|
+
**kwargs,
|
|
117
117
|
) -> str:
|
|
118
|
-
|
|
119
|
-
extra = {}
|
|
118
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
120
119
|
request = MoveOnMapRequest(
|
|
121
120
|
name=self.name,
|
|
122
121
|
destination=destination,
|
|
@@ -126,38 +125,38 @@ class MotionClient(Motion, ReconfigurableResourceRPCClientBase):
|
|
|
126
125
|
obstacles=obstacles,
|
|
127
126
|
extra=dict_to_struct(extra),
|
|
128
127
|
)
|
|
129
|
-
response: MoveOnMapResponse = await self.client.MoveOnMap(request, timeout=timeout)
|
|
128
|
+
response: MoveOnMapResponse = await self.client.MoveOnMap(request, timeout=timeout, metadata=md)
|
|
130
129
|
return response.execution_id
|
|
131
130
|
|
|
132
131
|
async def stop_plan(
|
|
133
132
|
self,
|
|
134
|
-
component_name:
|
|
133
|
+
component_name: str,
|
|
135
134
|
*,
|
|
136
135
|
extra: Optional[Mapping[str, ValueTypes]] = None,
|
|
137
136
|
timeout: Optional[float] = None,
|
|
137
|
+
**kwargs,
|
|
138
138
|
):
|
|
139
|
-
|
|
140
|
-
extra = {}
|
|
139
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
141
140
|
|
|
142
141
|
request = StopPlanRequest(
|
|
143
142
|
name=self.name,
|
|
144
143
|
component_name=component_name,
|
|
145
144
|
extra=dict_to_struct(extra),
|
|
146
145
|
)
|
|
147
|
-
_: StopPlanResponse = await self.client.StopPlan(request, timeout=timeout)
|
|
146
|
+
_: StopPlanResponse = await self.client.StopPlan(request, timeout=timeout, metadata=md)
|
|
148
147
|
return
|
|
149
148
|
|
|
150
149
|
async def get_plan(
|
|
151
150
|
self,
|
|
152
|
-
component_name:
|
|
151
|
+
component_name: str,
|
|
153
152
|
last_plan_only: bool = False,
|
|
154
153
|
execution_id: Optional[str] = None,
|
|
155
154
|
*,
|
|
156
155
|
extra: Optional[Mapping[str, ValueTypes]] = None,
|
|
157
156
|
timeout: Optional[float] = None,
|
|
157
|
+
**kwargs,
|
|
158
158
|
) -> GetPlanResponse:
|
|
159
|
-
|
|
160
|
-
extra = {}
|
|
159
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
161
160
|
|
|
162
161
|
request = GetPlanRequest(
|
|
163
162
|
name=self.name,
|
|
@@ -166,7 +165,7 @@ class MotionClient(Motion, ReconfigurableResourceRPCClientBase):
|
|
|
166
165
|
execution_id=execution_id,
|
|
167
166
|
extra=dict_to_struct(extra),
|
|
168
167
|
)
|
|
169
|
-
response: GetPlanResponse = await self.client.GetPlan(request, timeout=timeout)
|
|
168
|
+
response: GetPlanResponse = await self.client.GetPlan(request, timeout=timeout, metadata=md)
|
|
170
169
|
return response
|
|
171
170
|
|
|
172
171
|
async def list_plan_statuses(
|
|
@@ -175,29 +174,29 @@ class MotionClient(Motion, ReconfigurableResourceRPCClientBase):
|
|
|
175
174
|
*,
|
|
176
175
|
extra: Optional[Mapping[str, ValueTypes]] = None,
|
|
177
176
|
timeout: Optional[float] = None,
|
|
177
|
+
**kwargs,
|
|
178
178
|
) -> Sequence[PlanStatusWithID]:
|
|
179
|
-
|
|
180
|
-
extra = {}
|
|
179
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
181
180
|
|
|
182
181
|
request = ListPlanStatusesRequest(
|
|
183
182
|
name=self.name,
|
|
184
183
|
only_active_plans=only_active_plans,
|
|
185
184
|
extra=dict_to_struct(extra),
|
|
186
185
|
)
|
|
187
|
-
response: ListPlanStatusesResponse = await self.client.ListPlanStatuses(request, timeout=timeout)
|
|
186
|
+
response: ListPlanStatusesResponse = await self.client.ListPlanStatuses(request, timeout=timeout, metadata=md)
|
|
188
187
|
return response.plan_statuses_with_ids
|
|
189
188
|
|
|
190
189
|
async def get_pose(
|
|
191
190
|
self,
|
|
192
|
-
component_name:
|
|
191
|
+
component_name: str,
|
|
193
192
|
destination_frame: str,
|
|
194
193
|
supplemental_transforms: Optional[Sequence[Transform]] = None,
|
|
195
194
|
*,
|
|
196
195
|
extra: Optional[Mapping[str, Any]] = None,
|
|
197
196
|
timeout: Optional[float] = None,
|
|
197
|
+
**kwargs,
|
|
198
198
|
) -> PoseInFrame:
|
|
199
|
-
|
|
200
|
-
extra = {}
|
|
199
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
201
200
|
request = GetPoseRequest(
|
|
202
201
|
name=self.name,
|
|
203
202
|
component_name=component_name,
|
|
@@ -205,10 +204,11 @@ class MotionClient(Motion, ReconfigurableResourceRPCClientBase):
|
|
|
205
204
|
supplemental_transforms=supplemental_transforms,
|
|
206
205
|
extra=dict_to_struct(extra),
|
|
207
206
|
)
|
|
208
|
-
response: GetPoseResponse = await self.client.GetPose(request, timeout=timeout)
|
|
207
|
+
response: GetPoseResponse = await self.client.GetPose(request, timeout=timeout, metadata=md)
|
|
209
208
|
return response.pose
|
|
210
209
|
|
|
211
|
-
async def do_command(self, command: Mapping[str, ValueTypes], *, timeout: Optional[float] = None, **
|
|
210
|
+
async def do_command(self, command: Mapping[str, ValueTypes], *, timeout: Optional[float] = None, **kwargs) -> Mapping[str, ValueTypes]:
|
|
211
|
+
md = kwargs.get("metadata", self.Metadata()).proto
|
|
212
212
|
request = DoCommandRequest(name=self.name, command=dict_to_struct(command))
|
|
213
|
-
response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout)
|
|
213
|
+
response: DoCommandResponse = await self.client.DoCommand(request, timeout=timeout, metadata=md)
|
|
214
214
|
return struct_to_dict(response.result)
|
viam/services/motion/motion.py
CHANGED
|
@@ -7,9 +7,9 @@ if sys.version_info >= (3, 10):
|
|
|
7
7
|
else:
|
|
8
8
|
from typing_extensions import TypeAlias
|
|
9
9
|
|
|
10
|
-
from viam.proto.common import GeoGeometry, Geometry, GeoPoint, Pose, PoseInFrame,
|
|
10
|
+
from viam.proto.common import GeoGeometry, Geometry, GeoPoint, Pose, PoseInFrame, Transform, WorldState
|
|
11
11
|
from viam.proto.service.motion import Constraints, GetPlanResponse, MotionConfiguration, PlanStatusWithID
|
|
12
|
-
from viam.resource.types import RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE
|
|
12
|
+
from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE
|
|
13
13
|
from viam.utils import ValueTypes
|
|
14
14
|
|
|
15
15
|
from ..service_base import ServiceBase
|
|
@@ -21,19 +21,19 @@ class Motion(ServiceBase):
|
|
|
21
21
|
The motion planning service calculates a valid path that avoids self collision by default. If additional constraints are supplied in the
|
|
22
22
|
``world_state`` message, the motion planning service will also account for those.
|
|
23
23
|
|
|
24
|
-
For more information, see `Motion service <https://docs.viam.com/services/motion/>`_.
|
|
24
|
+
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/>`_.
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
Plan: "TypeAlias" = GetPlanResponse
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
API: Final = API( # pyright: ignore [reportIncompatibleVariableOverride]
|
|
30
30
|
RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE, "motion"
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
@abc.abstractmethod
|
|
34
34
|
async def move(
|
|
35
35
|
self,
|
|
36
|
-
component_name:
|
|
36
|
+
component_name: str,
|
|
37
37
|
destination: PoseInFrame,
|
|
38
38
|
world_state: Optional[WorldState] = None,
|
|
39
39
|
constraints: Optional[Constraints] = None,
|
|
@@ -44,18 +44,17 @@ class Motion(ServiceBase):
|
|
|
44
44
|
"""Plan and execute a movement to move the component specified to its goal destination.
|
|
45
45
|
|
|
46
46
|
Note: Frames designated with respect to components can also be used as the ``component_name`` when calling for a move. This
|
|
47
|
-
technique allows for planning and moving the frame itself to the ``destination``.
|
|
48
|
-
|
|
47
|
+
technique allows for planning and moving the frame itself to the ``destination``.
|
|
48
|
+
To do so, simply pass in a string into ``component_name``. Ex::
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
success = await MotionServiceClient.move(resource_name, ...)
|
|
50
|
+
success = await MotionServiceClient.move("externalFrame", ...)
|
|
52
51
|
|
|
53
52
|
::
|
|
54
53
|
|
|
55
|
-
motion = MotionClient.from_robot(robot=
|
|
54
|
+
motion = MotionClient.from_robot(robot=machine, name="builtin")
|
|
56
55
|
|
|
57
|
-
# Assumes
|
|
58
|
-
gripper_name =
|
|
56
|
+
# Assumes "my_gripper" on the machine
|
|
57
|
+
gripper_name = "my_gripper"
|
|
59
58
|
my_frame = "my_gripper_offset"
|
|
60
59
|
|
|
61
60
|
goal_pose = Pose(x=0, y=0, z=300, o_x=0, o_y=0, o_z=1, theta=0)
|
|
@@ -69,27 +68,35 @@ class Motion(ServiceBase):
|
|
|
69
68
|
extra={})
|
|
70
69
|
|
|
71
70
|
Args:
|
|
72
|
-
component_name (
|
|
71
|
+
component_name (str): Name of a component on a given robot.
|
|
73
72
|
destination (viam.proto.common.PoseInFrame): The destination to move to, expressed as a ``Pose`` and the frame in which it was
|
|
74
73
|
observed.
|
|
75
74
|
world_state (viam.proto.common.WorldState): When supplied, the motion service will create a plan that obeys any constraints
|
|
76
75
|
expressed in the WorldState message.
|
|
77
76
|
constraints (viam.proto.service.motion.Constraints): When supplied, the motion service will create a plan that obeys any
|
|
78
|
-
specified constraints.
|
|
77
|
+
specified constraints. These can include:
|
|
78
|
+
- LinearConstraint: Specifies that the component being moved should move linearly relative to its goal.
|
|
79
|
+
- OrientationConstraint: Specifies that the component being moved will not deviate its orientation beyond some threshold
|
|
80
|
+
relative to the goal.
|
|
81
|
+
- CollisionSpecification: Used to selectively apply obstacle avoidance to specific parts of the robot.
|
|
82
|
+
- PseudolinearConstraint: Specifies that the component being moved should not deviate from the straight-line path to their
|
|
83
|
+
goal by more than a factor proportional to the distance from start to goal. For example, if a component is moving 100mm,
|
|
84
|
+
then a LineToleranceFactor of 1.0 means that the component will remain within a 100mm radius of the straight-line
|
|
85
|
+
start-goal path.
|
|
79
86
|
|
|
80
87
|
Returns:
|
|
81
88
|
bool: Whether the move was successful.
|
|
82
89
|
|
|
83
|
-
For more information, see `Motion service <https://docs.viam.com/services/motion
|
|
90
|
+
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/#move>`_.
|
|
84
91
|
"""
|
|
85
92
|
...
|
|
86
93
|
|
|
87
94
|
@abc.abstractmethod
|
|
88
95
|
async def move_on_globe(
|
|
89
96
|
self,
|
|
90
|
-
component_name:
|
|
97
|
+
component_name: str,
|
|
91
98
|
destination: GeoPoint,
|
|
92
|
-
movement_sensor_name:
|
|
99
|
+
movement_sensor_name: str,
|
|
93
100
|
obstacles: Optional[Sequence[GeoGeometry]] = None,
|
|
94
101
|
heading: Optional[float] = None,
|
|
95
102
|
configuration: Optional[MotionConfiguration] = None,
|
|
@@ -110,26 +117,25 @@ class Motion(ServiceBase):
|
|
|
110
117
|
|
|
111
118
|
::
|
|
112
119
|
|
|
113
|
-
motion = MotionClient.from_robot(robot=
|
|
120
|
+
motion = MotionClient.from_robot(robot=machine, name="builtin")
|
|
114
121
|
|
|
115
|
-
# Get the
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"my_movement_sensor")
|
|
122
|
+
# Get the names of the base and movement sensor
|
|
123
|
+
my_base_name = "my_base"
|
|
124
|
+
mvmnt_sensor_name = "my_movement_sensor"
|
|
119
125
|
# Define a destination GeoPoint at the GPS coordinates [0, 0]
|
|
120
126
|
my_destination = movement_sensor.GeoPoint(latitude=0, longitude=0)
|
|
121
127
|
|
|
122
128
|
# Move the base component to the designated geographic location, as reported by the movement sensor
|
|
123
129
|
execution_id = await motion.move_on_globe(
|
|
124
|
-
component_name=
|
|
130
|
+
component_name=my_base_name,
|
|
125
131
|
destination=my_destination,
|
|
126
|
-
movement_sensor_name=
|
|
132
|
+
movement_sensor_name=mvmnt_sensor_name)
|
|
127
133
|
|
|
128
134
|
Args:
|
|
129
|
-
component_name (
|
|
135
|
+
component_name (str): The name of the base to move.
|
|
130
136
|
destination (GeoPoint): The location of the component's destination, represented in geographic notation as a
|
|
131
137
|
GeoPoint (lat, lng).
|
|
132
|
-
movement_sensor_name (
|
|
138
|
+
movement_sensor_name (str): The name of the movement sensor that you want to use to check
|
|
133
139
|
the machine's location.
|
|
134
140
|
obstacles (Optional[Sequence[GeoGeometry]]): Obstacles to consider when planning the motion of the component,
|
|
135
141
|
with each represented as a GeoGeometry. Default: None
|
|
@@ -155,16 +161,16 @@ class Motion(ServiceBase):
|
|
|
155
161
|
Returns:
|
|
156
162
|
str: ExecutionID of the ``move_on_globe()`` call, which can be used to track execution progress.
|
|
157
163
|
|
|
158
|
-
For more information, see `Motion service <https://docs.viam.com/services/motion
|
|
164
|
+
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/#moveonglobe>`_.
|
|
159
165
|
"""
|
|
160
166
|
...
|
|
161
167
|
|
|
162
168
|
@abc.abstractmethod
|
|
163
169
|
async def move_on_map(
|
|
164
170
|
self,
|
|
165
|
-
component_name:
|
|
171
|
+
component_name: str,
|
|
166
172
|
destination: Pose,
|
|
167
|
-
slam_service_name:
|
|
173
|
+
slam_service_name: str,
|
|
168
174
|
configuration: Optional[MotionConfiguration] = None,
|
|
169
175
|
obstacles: Optional[Sequence[Geometry]] = None,
|
|
170
176
|
*,
|
|
@@ -184,25 +190,25 @@ class Motion(ServiceBase):
|
|
|
184
190
|
|
|
185
191
|
::
|
|
186
192
|
|
|
187
|
-
motion = MotionClient.from_robot(robot=
|
|
193
|
+
motion = MotionClient.from_robot(robot=machine, name="builtin")
|
|
188
194
|
|
|
189
|
-
# Get the
|
|
190
|
-
|
|
191
|
-
my_slam_service_name =
|
|
195
|
+
# Get the names of the base component and SLAM service
|
|
196
|
+
my_base_name = "my_base"
|
|
197
|
+
my_slam_service_name = "my_slam_service"
|
|
192
198
|
|
|
193
199
|
# Define a destination pose with respect to the origin of the map from the SLAM service "my_slam_service"
|
|
194
200
|
my_pose = Pose(y=10)
|
|
195
201
|
|
|
196
202
|
# Move the base component to the destination pose of Y=10, a location of
|
|
197
203
|
# (0, 10, 0) in respect to the origin of the map
|
|
198
|
-
execution_id = await motion.move_on_map(component_name=
|
|
204
|
+
execution_id = await motion.move_on_map(component_name=my_base_name,
|
|
199
205
|
destination=my_pose,
|
|
200
206
|
slam_service_name=my_slam_service_name)
|
|
201
207
|
|
|
202
208
|
Args:
|
|
203
|
-
component_name (
|
|
209
|
+
component_name (str): The name of the base to move.
|
|
204
210
|
destination (Pose): The destination, which can be any Pose with respect to the SLAM map's origin.
|
|
205
|
-
slam_service_name (
|
|
211
|
+
slam_service_name (str): The name of the SLAM service from which the SLAM map is requested.
|
|
206
212
|
configuration (Optional[MotionConfiguration]): The configuration you want to set across this machine for this motion service.
|
|
207
213
|
This parameter and each of its fields are optional.
|
|
208
214
|
|
|
@@ -222,14 +228,14 @@ class Motion(ServiceBase):
|
|
|
222
228
|
Returns:
|
|
223
229
|
str: ExecutionID of the ``move_on_map()`` call, which can be used to track execution progress.
|
|
224
230
|
|
|
225
|
-
For more information, see `Motion service <https://docs.viam.com/services/motion
|
|
231
|
+
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/#moveonmap>`_.
|
|
226
232
|
"""
|
|
227
233
|
...
|
|
228
234
|
|
|
229
235
|
@abc.abstractmethod
|
|
230
236
|
async def stop_plan(
|
|
231
237
|
self,
|
|
232
|
-
component_name:
|
|
238
|
+
component_name: str,
|
|
233
239
|
*,
|
|
234
240
|
extra: Optional[Mapping[str, ValueTypes]] = None,
|
|
235
241
|
timeout: Optional[float] = None,
|
|
@@ -238,23 +244,25 @@ class Motion(ServiceBase):
|
|
|
238
244
|
|
|
239
245
|
::
|
|
240
246
|
|
|
247
|
+
motion = MotionClient.from_robot(robot=machine, name="builtin")
|
|
248
|
+
|
|
241
249
|
# Assuming a `move_on_globe()` started the execution
|
|
242
250
|
# Stop the base component which was instructed to move by `move_on_globe()`
|
|
243
251
|
# or `move_on_map()`
|
|
244
|
-
|
|
252
|
+
my_base_name = "my_base"
|
|
245
253
|
await motion.stop_plan(component_name=mvmnt_sensor)
|
|
246
254
|
|
|
247
255
|
Args:
|
|
248
|
-
component_name (
|
|
256
|
+
component_name (str): The component to stop
|
|
249
257
|
|
|
250
|
-
For more information, see `Motion service <https://docs.viam.com/services/motion
|
|
258
|
+
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/#stopplan>`_.
|
|
251
259
|
"""
|
|
252
260
|
...
|
|
253
261
|
|
|
254
262
|
@abc.abstractmethod
|
|
255
263
|
async def get_plan(
|
|
256
264
|
self,
|
|
257
|
-
component_name:
|
|
265
|
+
component_name: str,
|
|
258
266
|
last_plan_only: bool = False,
|
|
259
267
|
execution_id: Optional[str] = None,
|
|
260
268
|
*,
|
|
@@ -280,20 +288,20 @@ class Motion(ServiceBase):
|
|
|
280
288
|
|
|
281
289
|
::
|
|
282
290
|
|
|
283
|
-
motion = MotionClient.from_robot(robot=
|
|
284
|
-
|
|
291
|
+
motion = MotionClient.from_robot(robot=machine, name="builtin")
|
|
292
|
+
my_base_name = "my_base"
|
|
285
293
|
# Get the plan(s) of the base component which was instructed to move by `MoveOnGlobe()` or `MoveOnMap()`
|
|
286
|
-
resp = await motion.get_plan(component_name=
|
|
294
|
+
resp = await motion.get_plan(component_name=my_base_name)
|
|
287
295
|
|
|
288
296
|
Args:
|
|
289
|
-
component_name (
|
|
297
|
+
component_name (str): The component to stop
|
|
290
298
|
last_plan_only (Optional[bool]): If supplied, the response will only return the last plan for the component / execution.
|
|
291
299
|
execution_id (Optional[str]): If supplied, the response will only return plans with the provided execution_id.
|
|
292
300
|
|
|
293
301
|
Returns:
|
|
294
302
|
``GetPlanResponse`` (GetPlanResponse): The current PlanWithStatus & replan history which matches the request
|
|
295
303
|
|
|
296
|
-
For more information, see `Motion service <https://docs.viam.com/services/motion
|
|
304
|
+
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/#getplan>`_.
|
|
297
305
|
"""
|
|
298
306
|
...
|
|
299
307
|
|
|
@@ -315,7 +323,7 @@ class Motion(ServiceBase):
|
|
|
315
323
|
|
|
316
324
|
::
|
|
317
325
|
|
|
318
|
-
motion = MotionClient.from_robot(robot=
|
|
326
|
+
motion = MotionClient.from_robot(robot=machine, name="builtin")
|
|
319
327
|
# List the plan statuses of the motion service within the TTL
|
|
320
328
|
resp = await motion.list_plan_statuses()
|
|
321
329
|
|
|
@@ -326,14 +334,14 @@ class Motion(ServiceBase):
|
|
|
326
334
|
``ListPlanStatusesResponse`` (ListPlanStatusesResponse): List of last known statuses with the
|
|
327
335
|
associated IDs of all plans within the TTL ordered by timestamp in ascending order.
|
|
328
336
|
|
|
329
|
-
For more information, see `Motion service <https://docs.viam.com/services/motion
|
|
337
|
+
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/#listplanstatuses>`_.
|
|
330
338
|
"""
|
|
331
339
|
...
|
|
332
340
|
|
|
333
341
|
@abc.abstractmethod
|
|
334
342
|
async def get_pose(
|
|
335
343
|
self,
|
|
336
|
-
component_name:
|
|
344
|
+
component_name: str,
|
|
337
345
|
destination_frame: str,
|
|
338
346
|
supplemental_transforms: Optional[Sequence[Transform]] = None,
|
|
339
347
|
*,
|
|
@@ -345,25 +353,21 @@ class Motion(ServiceBase):
|
|
|
345
353
|
|
|
346
354
|
::
|
|
347
355
|
|
|
348
|
-
# Note that the example uses the ``
|
|
349
|
-
# (``
|
|
350
|
-
|
|
351
|
-
# Create a `component_name`:
|
|
352
|
-
component_name = Arm.get_resource_name("arm")
|
|
356
|
+
# Note that the example uses the ``Gripper`` class, but any component class that inherits from ``ComponentBase`` will work
|
|
357
|
+
# (``Arm``, ``Base``, etc).
|
|
353
358
|
|
|
354
359
|
from viam.components.gripper import Gripper
|
|
355
360
|
from viam.services.motion import MotionClient
|
|
356
361
|
|
|
357
362
|
# Assume that the connect function is written and will return a valid machine.
|
|
358
|
-
|
|
363
|
+
machine = await connect()
|
|
359
364
|
|
|
360
|
-
motion = MotionClient.from_robot(robot=
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
destination_frame="world")
|
|
365
|
+
motion = MotionClient.from_robot(robot=machine, name="builtin")
|
|
366
|
+
gripperPoseInWorld = await motion.get_pose(component_name="my_gripper",
|
|
367
|
+
destination_frame="world")
|
|
364
368
|
|
|
365
369
|
Args:
|
|
366
|
-
component_name (
|
|
370
|
+
component_name (str): Name of a component on a robot.
|
|
367
371
|
destination_frame (str): Name of the desired reference frame.
|
|
368
372
|
supplemental_transforms (Optional[List[viam.proto.common.Transform]]): Transforms used to augment the robot's frame while
|
|
369
373
|
calculating pose.
|
|
@@ -371,6 +375,6 @@ class Motion(ServiceBase):
|
|
|
371
375
|
Returns:
|
|
372
376
|
``Pose`` (PoseInFrame): Pose of the given component and the frame in which it was observed.
|
|
373
377
|
|
|
374
|
-
For more information, see `Motion service <https://docs.viam.com/services/motion
|
|
378
|
+
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/#getpose>`_.
|
|
375
379
|
"""
|
|
376
380
|
...
|
|
@@ -8,4 +8,4 @@ from .service import NavigationRPCService
|
|
|
8
8
|
|
|
9
9
|
__all__ = ["GeoPoint", "GeoGeometry", "NavigationClient", "Navigation", "Waypoint", "Mode", "Path", "MapType"]
|
|
10
10
|
|
|
11
|
-
Registry.
|
|
11
|
+
Registry.register_api(ResourceRegistration(Navigation, NavigationRPCService, lambda name, channel: NavigationClient(name, channel)))
|