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.
Files changed (328) hide show
  1. viam/app/_logs.py +3 -6
  2. viam/app/app_client.py +606 -262
  3. viam/app/billing_client.py +60 -18
  4. viam/app/data_client.py +1086 -315
  5. viam/app/ml_training_client.py +51 -48
  6. viam/app/provisioning_client.py +3 -5
  7. viam/app/viam_client.py +105 -11
  8. viam/components/arm/__init__.py +1 -25
  9. viam/components/arm/arm.py +21 -22
  10. viam/components/arm/client.py +27 -30
  11. viam/components/arm/service.py +3 -3
  12. viam/components/audio_in/__init__.py +24 -0
  13. viam/components/audio_in/audio_in.py +74 -0
  14. viam/components/audio_in/client.py +76 -0
  15. viam/components/audio_in/service.py +83 -0
  16. viam/components/audio_input/__init__.py +1 -1
  17. viam/components/audio_input/audio_input.py +4 -3
  18. viam/components/audio_input/client.py +19 -8
  19. viam/components/audio_input/service.py +10 -0
  20. viam/components/audio_out/__init__.py +21 -0
  21. viam/components/audio_out/audio_out.py +72 -0
  22. viam/components/audio_out/client.py +67 -0
  23. viam/components/audio_out/service.py +63 -0
  24. viam/components/base/__init__.py +2 -10
  25. viam/components/base/base.py +20 -20
  26. viam/components/base/client.py +27 -30
  27. viam/components/board/__init__.py +2 -25
  28. viam/components/board/board.py +39 -77
  29. viam/components/board/client.py +39 -73
  30. viam/components/button/__init__.py +10 -0
  31. viam/components/button/button.py +41 -0
  32. viam/components/button/client.py +52 -0
  33. viam/components/button/service.py +46 -0
  34. viam/components/camera/__init__.py +1 -1
  35. viam/components/camera/camera.py +31 -22
  36. viam/components/camera/client.py +30 -20
  37. viam/components/camera/service.py +14 -12
  38. viam/components/component_base.py +10 -7
  39. viam/components/encoder/__init__.py +1 -1
  40. viam/components/encoder/client.py +15 -16
  41. viam/components/encoder/encoder.py +9 -9
  42. viam/components/gantry/__init__.py +1 -13
  43. viam/components/gantry/client.py +41 -28
  44. viam/components/gantry/gantry.py +48 -17
  45. viam/components/gantry/service.py +21 -5
  46. viam/components/generic/__init__.py +1 -1
  47. viam/components/generic/client.py +11 -7
  48. viam/components/generic/generic.py +3 -3
  49. viam/components/gripper/__init__.py +3 -12
  50. viam/components/gripper/client.py +43 -20
  51. viam/components/gripper/gripper.py +87 -12
  52. viam/components/gripper/service.py +32 -3
  53. viam/components/input/__init__.py +1 -14
  54. viam/components/input/client.py +22 -23
  55. viam/components/input/input.py +18 -12
  56. viam/components/motor/__init__.py +1 -21
  57. viam/components/motor/client.py +36 -42
  58. viam/components/motor/motor.py +24 -24
  59. viam/components/movement_sensor/__init__.py +1 -1
  60. viam/components/movement_sensor/client.py +33 -40
  61. viam/components/movement_sensor/movement_sensor.py +12 -12
  62. viam/components/pose_tracker/__init__.py +1 -1
  63. viam/components/pose_tracker/client.py +9 -8
  64. viam/components/pose_tracker/pose_tracker.py +2 -2
  65. viam/components/power_sensor/__init__.py +1 -1
  66. viam/components/power_sensor/client.py +15 -18
  67. viam/components/power_sensor/power_sensor.py +12 -12
  68. viam/components/sensor/__init__.py +1 -1
  69. viam/components/sensor/client.py +9 -8
  70. viam/components/sensor/sensor.py +5 -5
  71. viam/components/servo/__init__.py +1 -13
  72. viam/components/servo/client.py +18 -18
  73. viam/components/servo/servo.py +12 -12
  74. viam/components/switch/__init__.py +10 -0
  75. viam/components/switch/client.py +83 -0
  76. viam/components/switch/service.py +72 -0
  77. viam/components/switch/switch.py +95 -0
  78. viam/gen/app/agent/v1/agent_pb2.py +40 -29
  79. viam/gen/app/agent/v1/agent_pb2.pyi +73 -11
  80. viam/gen/app/cloudslam/v1/cloud_slam_pb2.py +45 -42
  81. viam/gen/app/data/v1/data_grpc.py +98 -2
  82. viam/gen/app/data/v1/data_pb2.py +238 -119
  83. viam/gen/app/data/v1/data_pb2.pyi +804 -34
  84. viam/gen/app/datapipelines/v1/data_pipelines_grpc.py +84 -0
  85. viam/gen/app/datapipelines/v1/data_pipelines_pb2.py +57 -0
  86. viam/gen/app/datapipelines/v1/data_pipelines_pb2.pyi +387 -0
  87. viam/gen/app/dataset/v1/dataset_grpc.py +10 -2
  88. viam/gen/app/dataset/v1/dataset_pb2.py +38 -31
  89. viam/gen/app/dataset/v1/dataset_pb2.pyi +36 -1
  90. viam/gen/app/datasync/v1/data_sync_grpc.py +1 -1
  91. viam/gen/app/datasync/v1/data_sync_pb2.py +61 -51
  92. viam/gen/app/datasync/v1/data_sync_pb2.pyi +52 -12
  93. viam/gen/app/mlinference/__init__.py +0 -0
  94. viam/gen/app/mlinference/v1/__init__.py +0 -0
  95. viam/gen/app/mlinference/v1/ml_inference_grpc.py +28 -0
  96. viam/gen/app/mlinference/v1/ml_inference_pb2.py +23 -0
  97. viam/gen/app/mlinference/v1/ml_inference_pb2.pyi +63 -0
  98. viam/gen/app/mltraining/v1/ml_training_grpc.py +18 -2
  99. viam/gen/app/mltraining/v1/ml_training_pb2.py +134 -101
  100. viam/gen/app/mltraining/v1/ml_training_pb2.pyi +193 -7
  101. viam/gen/app/packages/v1/packages_pb2.py +43 -40
  102. viam/gen/app/v1/app_grpc.py +290 -2
  103. viam/gen/app/v1/app_pb2.py +670 -453
  104. viam/gen/app/v1/app_pb2.pyi +3133 -947
  105. viam/gen/app/v1/billing_grpc.py +34 -2
  106. viam/gen/app/v1/billing_pb2.py +94 -35
  107. viam/gen/app/v1/billing_pb2.pyi +314 -61
  108. viam/gen/app/v1/end_user_pb2.py +50 -29
  109. viam/gen/app/v1/robot_pb2.py +120 -111
  110. viam/gen/app/v1/robot_pb2.pyi +137 -15
  111. viam/gen/common/v1/common_pb2.py +86 -66
  112. viam/gen/common/v1/common_pb2.pyi +184 -8
  113. viam/gen/component/arm/v1/arm_grpc.py +18 -2
  114. viam/gen/component/arm/v1/arm_pb2.py +68 -55
  115. viam/gen/component/arm/v1/arm_pb2.pyi +73 -3
  116. viam/gen/component/audioin/__init__.py +0 -0
  117. viam/gen/component/audioin/v1/__init__.py +0 -0
  118. viam/gen/component/audioin/v1/audioin_grpc.py +54 -0
  119. viam/gen/component/audioin/v1/audioin_pb2.py +34 -0
  120. viam/gen/component/audioin/v1/audioin_pb2.pyi +94 -0
  121. viam/gen/component/audioinput/v1/audioinput_pb2.py +35 -32
  122. viam/gen/component/audioout/__init__.py +0 -0
  123. viam/gen/component/audioout/v1/__init__.py +0 -0
  124. viam/gen/component/audioout/v1/audioout_grpc.py +54 -0
  125. viam/gen/component/audioout/v1/audioout_pb2.py +32 -0
  126. viam/gen/component/audioout/v1/audioout_pb2.pyi +47 -0
  127. viam/gen/component/base/v1/base_pb2.py +57 -54
  128. viam/gen/component/board/v1/board_pb2.py +93 -90
  129. viam/gen/component/button/__init__.py +0 -0
  130. viam/gen/component/button/v1/__init__.py +0 -0
  131. viam/gen/component/button/v1/button_grpc.py +38 -0
  132. viam/gen/component/button/v1/button_pb2.py +28 -0
  133. viam/gen/component/button/v1/button_pb2.pyi +39 -0
  134. viam/gen/component/camera/v1/camera_pb2.py +58 -55
  135. viam/gen/component/camera/v1/camera_pb2.pyi +31 -7
  136. viam/gen/component/encoder/v1/encoder_pb2.py +35 -32
  137. viam/gen/component/gantry/v1/gantry_grpc.py +9 -1
  138. viam/gen/component/gantry/v1/gantry_pb2.py +56 -51
  139. viam/gen/component/generic/v1/generic_pb2.py +15 -12
  140. viam/gen/component/gripper/v1/gripper_grpc.py +18 -2
  141. viam/gen/component/gripper/v1/gripper_pb2.py +48 -37
  142. viam/gen/component/gripper/v1/gripper_pb2.pyi +43 -1
  143. viam/gen/component/inputcontroller/v1/input_controller_pb2.py +45 -42
  144. viam/gen/component/motor/v1/motor_pb2.py +77 -74
  145. viam/gen/component/movementsensor/v1/movementsensor_pb2.py +69 -66
  146. viam/gen/component/posetracker/v1/pose_tracker_pb2.py +25 -22
  147. viam/gen/component/powersensor/v1/powersensor_pb2.py +33 -30
  148. viam/gen/component/sensor/v1/sensor_pb2.py +17 -14
  149. viam/gen/component/servo/v1/servo_pb2.py +41 -38
  150. viam/gen/component/switch/__init__.py +0 -0
  151. viam/gen/component/switch/v1/__init__.py +0 -0
  152. viam/gen/component/switch/v1/switch_grpc.py +54 -0
  153. viam/gen/component/switch/v1/switch_pb2.py +40 -0
  154. viam/gen/component/switch/v1/switch_pb2.pyi +116 -0
  155. viam/gen/component/testecho/v1/testecho_pb2.py +29 -26
  156. viam/gen/module/v1/module_pb2.py +36 -33
  157. viam/gen/module/v1/module_pb2.pyi +7 -2
  158. viam/gen/proto/rpc/examples/echo/v1/echo_pb2.py +26 -23
  159. viam/gen/proto/rpc/examples/echoresource/v1/echoresource_pb2.py +23 -20
  160. viam/gen/proto/rpc/v1/auth_pb2.py +27 -24
  161. viam/gen/proto/rpc/webrtc/v1/grpc_pb2.py +35 -32
  162. viam/gen/proto/rpc/webrtc/v1/signaling_pb2.py +62 -57
  163. viam/gen/proto/rpc/webrtc/v1/signaling_pb2.pyi +18 -4
  164. viam/gen/provisioning/v1/provisioning_grpc.py +10 -2
  165. viam/gen/provisioning/v1/provisioning_pb2.py +38 -31
  166. viam/gen/provisioning/v1/provisioning_pb2.pyi +20 -2
  167. viam/gen/robot/v1/robot_grpc.py +61 -29
  168. viam/gen/robot/v1/robot_pb2.py +186 -155
  169. viam/gen/robot/v1/robot_pb2.pyi +278 -59
  170. viam/gen/service/datamanager/v1/data_manager_grpc.py +11 -2
  171. viam/gen/service/datamanager/v1/data_manager_pb2.py +27 -17
  172. viam/gen/service/datamanager/v1/data_manager_pb2.pyi +47 -1
  173. viam/gen/service/discovery/__init__.py +0 -0
  174. viam/gen/service/discovery/v1/__init__.py +0 -0
  175. viam/gen/service/discovery/v1/discovery_grpc.py +39 -0
  176. viam/gen/service/discovery/v1/discovery_pb2.py +29 -0
  177. viam/gen/service/discovery/v1/discovery_pb2.pyi +51 -0
  178. viam/gen/service/generic/v1/generic_pb2.py +13 -10
  179. viam/gen/service/mlmodel/v1/mlmodel_pb2.py +75 -72
  180. viam/gen/service/motion/v1/motion_pb2.py +118 -85
  181. viam/gen/service/motion/v1/motion_pb2.pyi +130 -68
  182. viam/gen/service/navigation/v1/navigation_pb2.py +75 -72
  183. viam/gen/service/sensors/v1/sensors_pb2.py +59 -56
  184. viam/gen/service/shell/v1/shell_pb2.py +35 -32
  185. viam/gen/service/slam/v1/slam_pb2.py +43 -40
  186. viam/gen/service/slam/v1/slam_pb2.pyi +1 -1
  187. viam/gen/service/video/__init__.py +0 -0
  188. viam/gen/service/video/v1/__init__.py +0 -0
  189. viam/gen/service/video/v1/video_grpc.py +39 -0
  190. viam/gen/service/video/v1/video_pb2.py +29 -0
  191. viam/gen/service/video/v1/video_pb2.pyi +72 -0
  192. viam/gen/service/vision/v1/vision_pb2.py +60 -57
  193. viam/gen/service/vision/v1/vision_pb2.pyi +28 -3
  194. viam/gen/service/worldstatestore/__init__.py +0 -0
  195. viam/gen/service/worldstatestore/v1/__init__.py +0 -0
  196. viam/gen/service/worldstatestore/v1/world_state_store_grpc.py +55 -0
  197. viam/gen/service/worldstatestore/v1/world_state_store_pb2.py +39 -0
  198. viam/gen/service/worldstatestore/v1/world_state_store_pb2.pyi +171 -0
  199. viam/gen/stream/v1/stream_grpc.py +17 -1
  200. viam/gen/stream/v1/stream_pb2.py +34 -21
  201. viam/gen/stream/v1/stream_pb2.pyi +79 -1
  202. viam/gen/tagger/v1/tagger_pb2.py +9 -8
  203. viam/logging.py +77 -18
  204. viam/media/audio.py +28 -0
  205. viam/media/utils/pil/__init__.py +7 -3
  206. viam/media/video.py +80 -17
  207. viam/module/module.py +111 -38
  208. viam/module/resource_data_consumer.py +41 -0
  209. viam/module/service.py +9 -1
  210. viam/module/types.py +2 -4
  211. viam/proto/app/__init__.py +199 -0
  212. viam/proto/app/agent/__init__.py +5 -2
  213. viam/proto/app/billing.py +31 -4
  214. viam/proto/app/cloudslam/__init__.py +1 -0
  215. viam/proto/app/data/__init__.py +63 -0
  216. viam/proto/app/datapipelines/__init__.py +56 -0
  217. viam/proto/app/dataset/__init__.py +5 -0
  218. viam/proto/app/datasync/__init__.py +3 -0
  219. viam/proto/app/end_user.py +1 -0
  220. viam/proto/app/mlinference/__init__.py +15 -0
  221. viam/proto/app/mltraining/__init__.py +13 -0
  222. viam/proto/app/packages/__init__.py +1 -0
  223. viam/proto/app/robot.py +7 -0
  224. viam/proto/common/__init__.py +15 -0
  225. viam/proto/component/arm/__init__.py +7 -0
  226. viam/proto/component/audioin/__init__.py +16 -0
  227. viam/proto/component/audioinput/__init__.py +1 -0
  228. viam/proto/component/audioout/__init__.py +15 -0
  229. viam/proto/component/base/__init__.py +1 -0
  230. viam/proto/component/board/__init__.py +1 -0
  231. viam/proto/component/button/__init__.py +15 -0
  232. viam/proto/component/camera/__init__.py +1 -0
  233. viam/proto/component/encoder/__init__.py +1 -0
  234. viam/proto/component/gantry/__init__.py +1 -0
  235. viam/proto/component/generic/__init__.py +1 -0
  236. viam/proto/component/gripper/__init__.py +5 -0
  237. viam/proto/component/inputcontroller/__init__.py +1 -0
  238. viam/proto/component/motor/__init__.py +1 -0
  239. viam/proto/component/movementsensor/__init__.py +1 -0
  240. viam/proto/component/posetracker/__init__.py +1 -0
  241. viam/proto/component/powersensor/__init__.py +1 -0
  242. viam/proto/component/sensor/__init__.py +1 -0
  243. viam/proto/component/servo/__init__.py +1 -0
  244. viam/proto/component/switch/__init__.py +26 -0
  245. viam/proto/component/testecho/__init__.py +1 -0
  246. viam/proto/module/__init__.py +1 -0
  247. viam/proto/provisioning/__init__.py +5 -0
  248. viam/proto/robot/__init__.py +29 -8
  249. viam/proto/rpc/auth.py +1 -0
  250. viam/proto/rpc/examples/echo/__init__.py +1 -0
  251. viam/proto/rpc/examples/echoresource/__init__.py +1 -0
  252. viam/proto/rpc/webrtc/grpc.py +1 -0
  253. viam/proto/rpc/webrtc/signaling.py +3 -0
  254. viam/proto/service/datamanager/__init__.py +9 -1
  255. viam/proto/service/discovery/__init__.py +15 -0
  256. viam/proto/service/generic/__init__.py +1 -0
  257. viam/proto/service/mlmodel/__init__.py +1 -0
  258. viam/proto/service/motion/__init__.py +3 -0
  259. viam/proto/service/navigation/__init__.py +1 -0
  260. viam/proto/service/sensors/__init__.py +1 -0
  261. viam/proto/service/shell/__init__.py +1 -0
  262. viam/proto/service/slam/__init__.py +1 -0
  263. viam/proto/service/video/__init__.py +15 -0
  264. viam/proto/service/vision/__init__.py +1 -0
  265. viam/proto/service/worldstatestore/__init__.py +32 -0
  266. viam/proto/stream/__init__.py +11 -0
  267. viam/py.typed +0 -0
  268. viam/resource/base.py +12 -8
  269. viam/resource/easy_resource.py +24 -13
  270. viam/resource/manager.py +6 -5
  271. viam/resource/registry.py +39 -51
  272. viam/resource/rpc_client_base.py +33 -1
  273. viam/resource/types.py +13 -14
  274. viam/robot/client.py +190 -122
  275. viam/robot/service.py +2 -50
  276. viam/rpc/dial.py +54 -4
  277. viam/rpc/libviam_rust_utils.so +0 -0
  278. viam/rpc/server.py +25 -11
  279. viam/rpc/types.py +2 -4
  280. viam/services/discovery/__init__.py +12 -0
  281. viam/services/discovery/client.py +55 -0
  282. viam/services/discovery/discovery.py +52 -0
  283. viam/services/discovery/service.py +43 -0
  284. viam/services/generic/__init__.py +1 -1
  285. viam/services/generic/client.py +8 -5
  286. viam/services/generic/generic.py +2 -2
  287. viam/services/mlmodel/__init__.py +1 -1
  288. viam/services/mlmodel/client.py +17 -7
  289. viam/services/mlmodel/mlmodel.py +23 -12
  290. viam/services/mlmodel/service.py +5 -2
  291. viam/services/mlmodel/utils.py +11 -1
  292. viam/services/motion/__init__.py +2 -2
  293. viam/services/motion/client.py +32 -32
  294. viam/services/motion/motion.py +66 -62
  295. viam/services/navigation/__init__.py +1 -1
  296. viam/services/navigation/client.py +30 -20
  297. viam/services/navigation/navigation.py +23 -23
  298. viam/services/service_base.py +13 -9
  299. viam/services/service_client_base.py +3 -3
  300. viam/services/slam/__init__.py +1 -1
  301. viam/services/slam/client.py +15 -10
  302. viam/services/slam/slam.py +11 -11
  303. viam/services/vision/__init__.py +1 -1
  304. viam/services/vision/client.py +31 -24
  305. viam/services/vision/service.py +8 -8
  306. viam/services/vision/vision.py +36 -53
  307. viam/services/worldstatestore/__init__.py +18 -0
  308. viam/services/worldstatestore/client.py +94 -0
  309. viam/services/worldstatestore/service.py +55 -0
  310. viam/services/worldstatestore/worldstatestore.py +90 -0
  311. viam/sessions_client.py +115 -46
  312. viam/streams.py +3 -6
  313. viam/utils.py +44 -14
  314. viam/version_metadata.py +4 -0
  315. {viam_sdk-0.25.2.dist-info → viam_sdk-0.62.0.dist-info}/METADATA +27 -28
  316. viam_sdk-0.62.0.dist-info/RECORD +514 -0
  317. {viam_sdk-0.25.2.dist-info → viam_sdk-0.62.0.dist-info}/WHEEL +1 -1
  318. viam/gen/proto/rpc/examples/fileupload/v1/fileupload_grpc.py +0 -27
  319. viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.py +0 -18
  320. viam/gen/proto/rpc/examples/fileupload/v1/fileupload_pb2.pyi +0 -45
  321. viam/proto/rpc/examples/fileupload/__init__.py +0 -18
  322. viam/services/sensors/__init__.py +0 -5
  323. viam/services/sensors/client.py +0 -65
  324. viam_sdk-0.25.2.dist-info/LICENSE +0 -202
  325. viam_sdk-0.25.2.dist-info/RECORD +0 -442
  326. /viam/gen/{proto/rpc/examples/fileupload → app/datapipelines}/__init__.py +0 -0
  327. /viam/gen/{proto/rpc/examples/fileupload → app/datapipelines}/v1/__init__.py +0 -0
  328. /LICENSE → /viam_sdk-0.62.0.dist-info/licenses/LICENSE +0 -0
@@ -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)
@@ -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
- return make_array(flat_data, dtype).reshape(shape)
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():
@@ -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.register_subtype(
11
+ Registry.register_api(
12
12
  ResourceRegistration(
13
13
  Motion,
14
14
  MotionRPCService,
@@ -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: ResourceName,
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
- if extra is None:
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: ResourceName,
79
+ component_name: str,
81
80
  destination: GeoPoint,
82
- movement_sensor_name: ResourceName,
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
- if extra is None:
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: ResourceName,
108
+ component_name: str,
110
109
  destination: Pose,
111
- slam_service_name: ResourceName,
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
- if extra is None:
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: ResourceName,
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
- if extra is None:
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: ResourceName,
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
- if extra is None:
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
- if extra is None:
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: ResourceName,
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
- if extra is None:
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, **__) -> Mapping[str, ValueTypes]:
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)
@@ -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, ResourceName, Transform, WorldState
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, Subtype
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
- SUBTYPE: Final = Subtype( # pyright: ignore [reportIncompatibleVariableOverride]
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: ResourceName,
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``. To do so, simply create a resource name with
48
- originating ReferenceFrame's name. Then pass in the resource name into ``component_name``. Ex::
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
- resource_name = Arm.get_resource_name("externalFrame")
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=robot, name="builtin")
54
+ motion = MotionClient.from_robot(robot=machine, name="builtin")
56
55
 
57
- # Assumes a gripper configured with name "my_gripper" on the machine
58
- gripper_name = Gripper.get_resource_name("my_gripper")
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 (viam.proto.common.ResourceName): Name of a component on a given robot.
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: ResourceName,
97
+ component_name: str,
91
98
  destination: GeoPoint,
92
- movement_sensor_name: ResourceName,
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=robot, name="builtin")
120
+ motion = MotionClient.from_robot(robot=machine, name="builtin")
114
121
 
115
- # Get the ResourceNames of the base and movement sensor
116
- my_base_resource_name = Base.get_resource_name("my_base")
117
- mvmnt_sensor_resource_name = MovementSensor.get_resource_name(
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=my_base_resource_name,
130
+ component_name=my_base_name,
125
131
  destination=my_destination,
126
- movement_sensor_name=mvmnt_sensor_resource_name)
132
+ movement_sensor_name=mvmnt_sensor_name)
127
133
 
128
134
  Args:
129
- component_name (ResourceName): The ResourceName of the base to move.
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 (ResourceName): The ResourceName of the movement sensor that you want to use to check
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: ResourceName,
171
+ component_name: str,
166
172
  destination: Pose,
167
- slam_service_name: ResourceName,
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=robot, name="builtin")
193
+ motion = MotionClient.from_robot(robot=machine, name="builtin")
188
194
 
189
- # Get the ResourceNames of the base component and SLAM service
190
- my_base_resource_name = Base.get_resource_name("my_base")
191
- my_slam_service_name = SLAMClient.get_resource_name("my_slam_service")
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=my_base_resource_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 (ResourceName): The ResourceName of the base to move.
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 (ResourceName): The ResourceName of the SLAM service from which the SLAM map is requested.
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: ResourceName,
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
- my_base_resource_name = Base.get_resource_name("my_base")
252
+ my_base_name = "my_base"
245
253
  await motion.stop_plan(component_name=mvmnt_sensor)
246
254
 
247
255
  Args:
248
- component_name (ResourceName): The component to stop
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: ResourceName,
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=robot, name="builtin")
284
- my_base_resource_name = Base.get_resource_name("my_base")
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=my_base_resource_name)
294
+ resp = await motion.get_plan(component_name=my_base_name)
287
295
 
288
296
  Args:
289
- component_name (ResourceName): The component to stop
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=robot, name="builtin")
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: ResourceName,
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 ``Arm`` class, but any component class that inherits from ``ComponentBase`` will work
349
- # (``Base``, ``Gripper``, etc).
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
- robot = await connect()
363
+ machine = await connect()
359
364
 
360
- motion = MotionClient.from_robot(robot=robot, name="builtin")
361
- gripperName = Gripper.get_resource_name("my_gripper")
362
- gripperPoseInWorld = await motion.get_pose(component_name=gripperName,
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 (viam.proto.common.ResourceName): Name of a component on a robot.
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.register_subtype(ResourceRegistration(Navigation, NavigationRPCService, lambda name, channel: NavigationClient(name, channel)))
11
+ Registry.register_api(ResourceRegistration(Navigation, NavigationRPCService, lambda name, channel: NavigationClient(name, channel)))