viam-sdk 0.3.0__py3-none-linux_armv6l.whl → 0.66.0__py3-none-linux_armv6l.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of viam-sdk might be problematic. Click here for more details.

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