@viamrobotics/sdk 0.39.0 → 0.40.0

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.
@@ -53,6 +53,7 @@ export declare class RobotClient extends EventDispatcher implements Robot {
53
53
  private gantryServiceClient;
54
54
  private genericServiceClient;
55
55
  private gripperServiceClient;
56
+ private mlModelServiceClient;
56
57
  private movementSensorServiceClient;
57
58
  private powerSensorServiceClient;
58
59
  private inputControllerServiceClient;
@@ -566,6 +567,23 @@ export declare class RobotClient extends EventDispatcher implements Robot {
566
567
  };
567
568
  };
568
569
  }>;
570
+ get mlModelService(): PromiseClient<{
571
+ readonly typeName: "viam.service.mlmodel.v1.MLModelService";
572
+ readonly methods: {
573
+ readonly infer: {
574
+ readonly name: "Infer";
575
+ readonly I: typeof import("../gen/service/mlmodel/v1/mlmodel_pb").InferRequest;
576
+ readonly O: typeof import("../gen/service/mlmodel/v1/mlmodel_pb").InferResponse;
577
+ readonly kind: import("@bufbuild/protobuf").MethodKind.Unary;
578
+ };
579
+ readonly metadata: {
580
+ readonly name: "Metadata";
581
+ readonly I: typeof import("../gen/service/mlmodel/v1/mlmodel_pb").MetadataRequest;
582
+ readonly O: typeof import("../gen/service/mlmodel/v1/mlmodel_pb").MetadataResponse;
583
+ readonly kind: import("@bufbuild/protobuf").MethodKind.Unary;
584
+ };
585
+ };
586
+ }>;
569
587
  get movementSensorService(): PromiseClient<{
570
588
  readonly typeName: "viam.component.movementsensor.v1.MovementSensorService";
571
589
  readonly methods: {
@@ -702,7 +720,11 @@ export declare class RobotClient extends EventDispatcher implements Robot {
702
720
  readonly doCommand: {
703
721
  readonly name: "DoCommand";
704
722
  readonly I: typeof import("../gen/common/v1/common_pb").DoCommandRequest;
705
- readonly O: typeof import("../gen/common/v1/common_pb").DoCommandResponse;
723
+ readonly O: typeof import("../gen/common/v1/common_pb").DoCommandResponse; /**
724
+ * A gRPC-web client for a Robot.
725
+ *
726
+ * @group Clients
727
+ */
706
728
  readonly kind: import("@bufbuild/protobuf").MethodKind.Unary;
707
729
  };
708
730
  readonly getGeometries: {
@@ -736,7 +758,11 @@ export declare class RobotClient extends EventDispatcher implements Robot {
736
758
  };
737
759
  readonly setRPM: {
738
760
  readonly name: "SetRPM";
739
- readonly I: typeof import("../gen/component/motor/v1/motor_pb").SetRPMRequest;
761
+ readonly I: typeof import("../gen/component/motor/v1/motor_pb").SetRPMRequest; /**
762
+ * A gRPC-web client for a Robot.
763
+ *
764
+ * @group Clients
765
+ */
740
766
  readonly O: typeof import("../gen/component/motor/v1/motor_pb").SetRPMResponse;
741
767
  readonly kind: import("@bufbuild/protobuf").MethodKind.Unary;
742
768
  };
@@ -8,21 +8,39 @@ export type CloudMetadata = proto.GetCloudMetadataResponse;
8
8
  type Callback = (args: unknown) => void;
9
9
  export interface Robot {
10
10
  /**
11
- * Get the list of sessions currently connected to the robot.
11
+ * Get the list of sessions currently connected to the machine.
12
+ *
13
+ * @example
14
+ *
15
+ * ```ts
16
+ * const sessions = await machine.getSessions();
17
+ * ```
12
18
  *
13
19
  * @group Sessions
14
20
  * @alpha
15
21
  */
16
22
  getSessions(): Promise<proto.Session[]>;
17
23
  /**
18
- * Get the list of operations currently running on the robot.
24
+ * Get the list of operations currently running on the machine.
25
+ *
26
+ * @example
27
+ *
28
+ * ```ts
29
+ * const operations = await machine.getOperations();
30
+ * ```
19
31
  *
20
32
  * @group Operations
21
33
  * @alpha
22
34
  */
23
35
  getOperations(): Promise<proto.Operation[]>;
24
36
  /**
25
- * Cancels the specified operation on the robot.
37
+ * Cancels the specified operation on the machine.
38
+ *
39
+ * @example
40
+ *
41
+ * ```ts
42
+ * await machine.cancelOperation('INSERT OPERATION ID');
43
+ * ```
26
44
  *
27
45
  * @param id - ID of operation to kill.
28
46
  * @group Operations
@@ -30,9 +48,15 @@ export interface Robot {
30
48
  */
31
49
  cancelOperation(id: string): Promise<void>;
32
50
  /**
33
- * Blocks on the specified operation on the robot. This function will only
51
+ * Blocks on the specified operation on the machine. This function will only
34
52
  * return when the specific operation has finished or has been cancelled.
35
53
  *
54
+ * @example
55
+ *
56
+ * ```ts
57
+ * await machine.blockForOperation('INSERT OPERATION ID');
58
+ * ```
59
+ *
36
60
  * @param id - ID of operation to block on.
37
61
  * @group Operations
38
62
  * @alpha
@@ -42,6 +66,12 @@ export interface Robot {
42
66
  * Cancel all current and outstanding operations for the robot and stop all
43
67
  * actuators and movement.
44
68
  *
69
+ * @example
70
+ *
71
+ * ```ts
72
+ * await machine.stopAll();
73
+ * ```
74
+ *
45
75
  * @param extra - Any extra parameters to pass to the components' `stop`
46
76
  * methods, keyed on the component's resource name.
47
77
  * @group Operations
@@ -49,7 +79,13 @@ export interface Robot {
49
79
  */
50
80
  stopAll(extra?: Map<string, Struct>): Promise<void>;
51
81
  /**
52
- * Get the configuration of the frame system of a given robot.
82
+ * Get the configuration of the frame system of a given machine.
83
+ *
84
+ * @example
85
+ *
86
+ * ```ts
87
+ * const frameSystemConfig = await machine.frameSystemConfig();
88
+ * ```
53
89
  *
54
90
  * @group Frame System
55
91
  * @alpha
@@ -87,12 +123,24 @@ export interface Robot {
87
123
  /**
88
124
  * Get the list of models provided by modules on the machine.
89
125
  *
126
+ * @example
127
+ *
128
+ * ```ts
129
+ * const models = await machine.getModelsFromModules();
130
+ * ```
131
+ *
90
132
  * @group Resources
91
133
  * @alpha
92
134
  */
93
135
  getModelsFromModules(): Promise<ModuleModel[]>;
94
136
  /**
95
- * Get a list of all resources on the robot.
137
+ * Get a list of all resources on the machine.
138
+ *
139
+ * @example
140
+ *
141
+ * ```ts
142
+ * const resourceNames = await machine.resourceNames();
143
+ * ```
96
144
  *
97
145
  * @group Resources
98
146
  * @alpha
@@ -101,6 +149,12 @@ export interface Robot {
101
149
  /**
102
150
  * Get a list of all resource types.
103
151
  *
152
+ * @example
153
+ *
154
+ * ```ts
155
+ * const resourceRPCSubtypes = await machine.resourceRPCSubtypes();
156
+ * ```
157
+ *
104
158
  * @group Resources
105
159
  * @alpha
106
160
  */
@@ -120,14 +174,26 @@ export interface Robot {
120
174
  */
121
175
  on: (type: MachineConnectionEvent | 'connectionstatechange', listener: Callback) => void;
122
176
  /**
123
- * Get app-related information about the robot.
177
+ * Get app-related information about the machine.
178
+ *
179
+ * @example
180
+ *
181
+ * ```ts
182
+ * const cloudMetadata = await machine.getCloudMetadata();
183
+ * ```
124
184
  *
125
185
  * @group App/Cloud
126
186
  * @alpha
127
187
  */
128
188
  getCloudMetadata(): Promise<CloudMetadata>;
129
189
  /**
130
- * Get the current status of the robot.
190
+ * Get the current status of the machine.
191
+ *
192
+ * @example
193
+ *
194
+ * ```ts
195
+ * const machineStatus = await machine.getMachineStatus();
196
+ * ```
131
197
  *
132
198
  * @alpha
133
199
  */
@@ -135,6 +201,12 @@ export interface Robot {
135
201
  /**
136
202
  * Restarts a module running on the machine with the given id or name.
137
203
  *
204
+ * @example
205
+ *
206
+ * ```ts
207
+ * await machine.restartModule('namespace:module:model', 'my_model_name');
208
+ * ```
209
+ *
138
210
  * @param moduleId - The id matching the module_id field of the registry
139
211
  * module in your part configuration
140
212
  * @param moduleName - The name matching the name field of the local/registry
@@ -0,0 +1,13 @@
1
+ import type { CallOptions } from '@connectrpc/connect';
2
+ import type { FlatTensors, MLModel } from './ml-model';
3
+ import { type Options } from '../../types';
4
+ import type { RobotClient } from '../../robot';
5
+ export declare class MLModelClient implements MLModel {
6
+ private client;
7
+ private readonly name;
8
+ private readonly options;
9
+ callOptions: CallOptions;
10
+ constructor(client: RobotClient, name: string, options?: Options);
11
+ metadata(extra?: {}, callOptions?: CallOptions): Promise<import("../../gen/service/mlmodel/v1/mlmodel_pb").MetadataResponse>;
12
+ infer(inputTensors: FlatTensors, extra?: {}, callOptions?: CallOptions): Promise<import("../../gen/service/mlmodel/v1/mlmodel_pb").InferResponse>;
13
+ }
@@ -0,0 +1,2 @@
1
+ export type { MLModel, FlatTensors } from './ml-model';
2
+ export { MLModelClient } from './client';
@@ -0,0 +1,7 @@
1
+ import type { Struct } from '@bufbuild/protobuf';
2
+ import type * as mlModelAPI from '../../gen/service/mlmodel/v1/mlmodel_pb';
3
+ export type FlatTensors = mlModelAPI.FlatTensors;
4
+ export interface MLModel {
5
+ metadata: (extra?: Struct) => Promise<mlModelAPI.MetadataResponse>;
6
+ infer: (inputTensors: FlatTensors, extra?: Struct) => Promise<mlModelAPI.InferResponse>;
7
+ }
@@ -7,6 +7,13 @@ export interface Vision extends Resource {
7
7
  /**
8
8
  * Get a list of detections in the next image given a camera.
9
9
  *
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * const vision = new VIAM.VisionClient(machine, 'my_vision');
14
+ * const detections = await vision.getDetectionsFromCamera('my_camera');
15
+ * ```
16
+ *
10
17
  * @param cameraName - The name of the camera to use for detection.
11
18
  * @returns - The list of Detections.
12
19
  */
@@ -14,6 +21,22 @@ export interface Vision extends Resource {
14
21
  /**
15
22
  * Get a list of detections in the given image.
16
23
  *
24
+ * @example
25
+ *
26
+ * ```ts
27
+ * const camera = new VIAM.CameraClient(machine, 'my_camera');
28
+ * const vision = new VIAM.VisionClient(machine, 'my_vision');
29
+ *
30
+ * const mimeType = 'image/jpeg';
31
+ * const image = await camera.getImage(mimeType);
32
+ * const detections = await vision.getDetections(
33
+ * image,
34
+ * 600,
35
+ * 600,
36
+ * mimeType
37
+ * );
38
+ * ```
39
+ *
17
40
  * @param image - The image from which to get detections.
18
41
  * @param width - The width of the image.
19
42
  * @param height - The height of the image.
@@ -24,6 +47,16 @@ export interface Vision extends Resource {
24
47
  /**
25
48
  * Get a list of classifications in the next image given a camera.
26
49
  *
50
+ * @example
51
+ *
52
+ * ```ts
53
+ * const vision = new VIAM.VisionClient(machine, 'my_vision');
54
+ * const classifications = await vision.getClassificationsFromCamera(
55
+ * 'my_camera',
56
+ * 10
57
+ * );
58
+ * ```
59
+ *
27
60
  * @param cameraName - The name of the camera to use for classification.
28
61
  * @param count - The number of Classifications requested.
29
62
  * @returns - The list of Classifications.
@@ -32,6 +65,23 @@ export interface Vision extends Resource {
32
65
  /**
33
66
  * Get a list of classifications in the given image.
34
67
  *
68
+ * @example
69
+ *
70
+ * ```ts
71
+ * const camera = new VIAM.CameraClient(machine, 'my_camera');
72
+ * const vision = new VIAM.VisionClient(machine, 'my_vision');
73
+ *
74
+ * const mimeType = 'image/jpeg';
75
+ * const image = await camera.getImage(mimeType);
76
+ * const classifications = await vision.getClassifications(
77
+ * image,
78
+ * 600,
79
+ * 600,
80
+ * mimeType,
81
+ * 10
82
+ * );
83
+ * ```
84
+ *
35
85
  * @param image - The image from which to get classifications.
36
86
  * @param width - The width of the image.
37
87
  * @param height - The height of the image.
@@ -44,6 +94,14 @@ export interface Vision extends Resource {
44
94
  * Returns a list of the 3D point cloud objects and associated metadata in the
45
95
  * latest picture obtained from the specified 3D camera.
46
96
  *
97
+ * @example
98
+ *
99
+ * ```ts
100
+ * const vision = new VIAM.VisionClient(machine, 'my_vision');
101
+ * const pointCloudObjects =
102
+ * await vision.getObjectPointClouds('my_camera');
103
+ * ```
104
+ *
47
105
  * @param cameraName - The name of the camera.
48
106
  * @returns - The list of PointCloudObjects
49
107
  */
@@ -53,6 +111,13 @@ export interface Vision extends Resource {
53
111
  * booleans indicating whether classifications, detections, and 3d
54
112
  * segmentation are supported.
55
113
  *
114
+ * @example
115
+ *
116
+ * ```ts
117
+ * const vision = new VIAM.VisionClient(machine, 'my_vision');
118
+ * const properties = await vision.getProperties();
119
+ * ```
120
+ *
56
121
  * @returns - The properties of the vision service
57
122
  */
58
123
  getProperties: (extra?: Struct) => Promise<Properties>;
@@ -60,6 +125,18 @@ export interface Vision extends Resource {
60
125
  * Returns the requested image, classifications, detections, and 3d point
61
126
  * cloud objects in the next image given a camera.
62
127
  *
128
+ * @example
129
+ *
130
+ * ```ts
131
+ * const vision = new VIAM.VisionClient(machine, 'my_vision');
132
+ * const captureAll = await vision.captureAllFromCamera('my_camera', {
133
+ * returnImage: true,
134
+ * returnClassifications: true,
135
+ * returnDetections: true,
136
+ * returnObjectPointClouds: true,
137
+ * });
138
+ * ```
139
+ *
63
140
  * @param cameraName - The name of the camera to use for classification,
64
141
  * detection, and segmentation.
65
142
  * @param opts - The fields desired in the response.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viamrobotics/sdk",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "",
5
5
  "main": "./dist/main.umd.js",
6
6
  "module": "./dist/main.es.js",