@viamrobotics/sdk 0.9.2 → 0.10.0-rc.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.
@@ -1,4 +1,4 @@
1
- import type { Credentials } from '@viamrobotics/rpc/src/dial';
1
+ import { type Credentials } from '@viamrobotics/rpc';
2
2
  import { grpc } from '@improbable-eng/grpc-web';
3
3
  import { EventDispatcher } from '../events';
4
4
  import proto from '../gen/robot/v1/robot_pb';
@@ -43,6 +43,7 @@ export interface ConnectOptions {
43
43
  authEntity?: string;
44
44
  creds?: Credentials;
45
45
  priority?: number;
46
+ dialTimeout?: number;
46
47
  }
47
48
  declare abstract class ServiceClient {
48
49
  serviceHost: string;
@@ -113,7 +114,7 @@ export declare class RobotClient extends EventDispatcher implements Robot {
113
114
  get peerConnection(): RTCPeerConnection | undefined;
114
115
  disconnect(): Promise<void>;
115
116
  isConnected(): boolean;
116
- connect({ authEntity, creds, priority, }?: ConnectOptions): Promise<void>;
117
+ connect({ authEntity, creds, priority, dialTimeout, }?: ConnectOptions): Promise<void>;
117
118
  getOperations(): Promise<proto.Operation[]>;
118
119
  cancelOperation(id: string): Promise<void>;
119
120
  blockForOperation(id: string): Promise<void>;
@@ -12,6 +12,7 @@ export interface DialDirectConf {
12
12
  noReconnect?: boolean;
13
13
  reconnectMaxAttempts?: number;
14
14
  reconnectMaxWait?: number;
15
+ dialTimeout?: number;
15
16
  }
16
17
  interface ICEServer {
17
18
  urls: string;
@@ -36,6 +37,7 @@ export interface DialWebRTCConf {
36
37
  signalingAddress: string;
37
38
  iceServers?: ICEServer[];
38
39
  priority?: number;
40
+ dialTimeout?: number;
39
41
  }
40
42
  /** Options required to dial a robot. */
41
43
  export type DialConf = DialDirectConf | DialWebRTCConf;
@@ -15,7 +15,7 @@ export declare class MotionClient implements Motion {
15
15
  constructor(client: RobotClient, name: string, options?: Options);
16
16
  private get service();
17
17
  move(destination: PoseInFrame, componentName: ResourceName, worldState?: WorldState, constraints?: Constraints, extra?: {}): Promise<boolean>;
18
- moveOnMap(destination: Pose, componentName: ResourceName, slamServiceName: ResourceName, extra?: {}): Promise<boolean>;
18
+ moveOnMap(destination: Pose, componentName: ResourceName, slamServiceName: ResourceName, motionConfig?: MotionConfiguration, extra?: {}): Promise<string>;
19
19
  moveOnGlobe(destination: GeoPoint, componentName: ResourceName, movementSensorName: ResourceName, heading?: number, obstaclesList?: GeoObstacle[], motionConfig?: MotionConfiguration, extra?: {}): Promise<string>;
20
20
  stopPlan(componentName: ResourceName, extra?: {}): Promise<null>;
21
21
  getPlan(componentName: ResourceName, lastPlanOnly?: boolean, executionId?: string, extra?: {}): Promise<pb.GetPlanResponse.AsObject>;
@@ -20,7 +20,13 @@ export interface Motion extends Resource {
20
20
  */
21
21
  move: (destination: PoseInFrame, componentName: ResourceName, worldState?: WorldState, constraints?: Constraints, extra?: StructType) => Promise<boolean>;
22
22
  /**
23
- * Move a component to a `Pose` in respect to the origin of the SLAM map.
23
+ * Move a component to a `Pose` in respect to the origin of the SLAM map,
24
+ * using a `SLAM` service to check the location. moveOnMap()`is non blocking,
25
+ * meaning the motion service will move the component to the destination Pose
26
+ * after`moveOnMap()`returns. Each successful`moveOnMap()`call retuns a unique
27
+ * ExectionID which you can use to identify all plans generated durring
28
+ * the`moveOnMap()`call. You can monitor the progress of the`moveOnMap()`call
29
+ * by querying`getPlan()`and`listPlanStatuses()`.
24
30
  *
25
31
  * @param destination - Specify a destination to, which can be any `Pose` with
26
32
  * respect to the SLAM map's origin.
@@ -28,8 +34,9 @@ export interface Motion extends Resource {
28
34
  * destination.
29
35
  * @param slamServiceName - Name of the `SLAM` service from which the SLAM map
30
36
  * is requested
37
+ * @param motionConfiguration - Optional motion configuration options.
31
38
  */
32
- moveOnMap: (destination: Pose, componentName: ResourceName, slamServiceName: ResourceName, extra?: StructType) => Promise<boolean>;
39
+ moveOnMap: (destination: Pose, componentName: ResourceName, slamServiceName: ResourceName, motionConfiguration?: MotionConfiguration, extra?: StructType) => Promise<string>;
33
40
  /**
34
41
  * Move a component to a specific latitude and longitude, using a
35
42
  * `MovementSensor` to check the location. `moveOnGlobe()` is non blocking,
@@ -51,23 +58,25 @@ export interface Motion extends Resource {
51
58
  */
52
59
  moveOnGlobe: (destination: GeoPoint, componentName: ResourceName, movementSensorName: ResourceName, heading?: number, obstaclesList?: GeoObstacle[], motionConfiguration?: MotionConfiguration, extra?: StructType) => Promise<string>;
53
60
  /**
54
- * Stop a component being moved by an in progress `moveOnGlobe()` call.
61
+ * Stop a component being moved by an in progress `moveOnGlobe()` or
62
+ * `moveOnMap()` call.
55
63
  *
56
64
  * @param componentName - The component to stop
57
65
  */
58
66
  stopPlan: (componentName: ResourceName, extra?: StructType) => Promise<null>;
59
67
  /**
60
- * By default: returns the plan history of the most recent
61
- * `move_on_globe_new()` call to move a component. The plan history for
62
- * executions before the most recent can be requested by providing an
63
- * ExecutionID in the request. Returns a result if both of the following
64
- * conditions are met:
68
+ * By default: returns the plan history of the most recent `moveOnGlobe()` or
69
+ * `moveOnMap()` call to move a component. The plan history for executions
70
+ * before the most recent can be requested by providing an ExecutionID in the
71
+ * request. Returns a result if both of the following conditions are met:
72
+ *
73
+ * - The execution (call to `moveOnGlobe()` or `moveOnMap()`) is still executing
74
+ * **or** changed state within the last 24 hours
75
+ * - The robot has not reinitialized
65
76
  *
66
- * - The execution (call to `move_on_globe_new()`) is still executing **or**
67
- * changed state within the last 24 hours
68
- * - The robot has not reinitialized Plans never change. Replans always create
69
- * new plans. Replans share the ExecutionID of the previously executing
70
- * plan. All repeated fields are in time ascending order.
77
+ * Plans never change. Replans always create new plans. Replans share the
78
+ * ExecutionID of the previously executing plan. All repeated fields are in
79
+ * chronological order.
71
80
  *
72
81
  * @param componentName - The component to query
73
82
  * @param destinationFrame - The reference frame in which the component's
@@ -78,14 +87,17 @@ export interface Motion extends Resource {
78
87
  */
79
88
  getPlan: (componentName: ResourceName, lastPlanOnly?: boolean, executionId?: string, extra?: StructType) => Promise<GetPlanResponse>;
80
89
  /**
81
- * Get the current location and orientation of a component.
90
+ * Returns the statuses of plans created by MoveOnGlobe calls that meet at
91
+ * least one of the following conditions since the motion service
92
+ * initialized:
82
93
  *
83
- * @param componentName - The component whose `Pose` is being requested.
84
- * @param destinationFrame - The reference frame in which the component's
85
- * `Pose` should be provided, if unset this defaults to the "world"
86
- * reference frame.
87
- * @param supplementalTransforms - `Pose` information on any additional
88
- * reference frames that are needed to compute the component's `Pose`.
94
+ * - The plan’s status is in progress
95
+ * - The plan’s status changed state within the last 24 hours
96
+ *
97
+ * All repeated fields are in chronological order.
98
+ *
99
+ * @param onlyActivePlans - If true, the response will only return plans which
100
+ * are executing.
89
101
  */
90
102
  listPlanStatuses: (onlyActivePlans?: boolean, extra?: StructType) => Promise<ListPlanStatusesResponse>;
91
103
  /**
@@ -16,7 +16,6 @@ export declare class SlamClient implements Slam {
16
16
  getPosition(): Promise<pb.GetPositionResponse.AsObject>;
17
17
  getPointCloudMap: () => Promise<Uint8Array>;
18
18
  getInternalState: () => Promise<Uint8Array>;
19
- getLatestMapInfo(): Promise<Date>;
20
19
  getProperties(): Promise<pb.GetPropertiesResponse.AsObject>;
21
20
  doCommand(command: StructType): Promise<StructType>;
22
21
  }
@@ -17,8 +17,6 @@ export interface Slam extends Resource {
17
17
  * mapping/localization.
18
18
  */
19
19
  getInternalState: () => Promise<Uint8Array>;
20
- /** Get the timestamp of the last update to the point cloud SLAM map. */
21
- getLatestMapInfo: () => Promise<Date>;
22
20
  /** Gets information on the properties of the current SLAM service. */
23
21
  getProperties: () => Promise<SlamProperties>;
24
22
  }
@@ -0,0 +1,23 @@
1
+ import pb from '../../gen/service/vision/v1/vision_pb';
2
+ import type { MimeType } from '../../main';
3
+ import type { RobotClient } from '../../robot';
4
+ import type { Options, StructType } from '../../types';
5
+ import type { Vision } from './vision';
6
+ /**
7
+ * A gRPC-web client for a Vision service.
8
+ *
9
+ * @group Clients
10
+ */
11
+ export declare class VisionClient implements Vision {
12
+ private client;
13
+ private readonly name;
14
+ private readonly options;
15
+ constructor(client: RobotClient, name: string, options?: Options);
16
+ private get service();
17
+ getDetectionsFromCamera(cameraName: string, extra?: StructType): Promise<pb.Detection.AsObject[]>;
18
+ getDetections(image: Uint8Array, width: number, height: number, mimeType: MimeType, extra?: StructType): Promise<pb.Detection.AsObject[]>;
19
+ getClassificationsFromCamera(cameraName: string, count: number, extra?: StructType): Promise<pb.Classification.AsObject[]>;
20
+ getClassifications(image: Uint8Array, width: number, height: number, mimeType: MimeType, count: number, extra?: StructType): Promise<pb.Classification.AsObject[]>;
21
+ getObjectPointClouds(cameraName: string, extra?: StructType): Promise<import("../../gen/common/v1/common_pb").PointCloudObject.AsObject[]>;
22
+ doCommand(command: StructType): Promise<StructType>;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import pb from '../../gen/service/vision/v1/vision_pb';
2
+ import commonPB from '../../gen/common/v1/common_pb';
3
+ export type Detection = pb.Detection.AsObject;
4
+ export type Classification = pb.Classification.AsObject;
5
+ export type PointCloudObject = commonPB.PointCloudObject.AsObject;
@@ -0,0 +1,50 @@
1
+ import type { MimeType } from '../../main';
2
+ import type { Resource, StructType } from '../../types';
3
+ import type { Classification, Detection, PointCloudObject } from './types';
4
+ /** A service that enables various computer vision algorithms */
5
+ export interface Vision extends Resource {
6
+ /**
7
+ * Get a list of detections in the next image given a camera.
8
+ *
9
+ * @param cameraName - The name of the camera to use for detection.
10
+ * @returns - The list of Detections.
11
+ */
12
+ getDetectionsFromCamera: (cameraName: string, extra?: StructType) => Promise<Detection[]>;
13
+ /**
14
+ * Get a list of detections in the given image.
15
+ *
16
+ * @param image - The image from which to get detections.
17
+ * @param width - The width of the image.
18
+ * @param height - The height of the image.
19
+ * @param mimeType - The MimeType of the image.
20
+ * @returns - The list of Detections.
21
+ */
22
+ getDetections: (image: Uint8Array, width: number, height: number, mimeType: MimeType, extra?: StructType) => Promise<Detection[]>;
23
+ /**
24
+ * Get a list of classifications in the next image given a camera.
25
+ *
26
+ * @param cameraName - The name of the camera to use for classification.
27
+ * @param count - The number of Classifications requested.
28
+ * @returns - The list of Classifications.
29
+ */
30
+ getClassificationsFromCamera: (cameraName: string, count: number, extra?: StructType) => Promise<Classification[]>;
31
+ /**
32
+ * Get a list of classifications in the given image.
33
+ *
34
+ * @param image - The image from which to get classifications.
35
+ * @param width - The width of the image.
36
+ * @param height - The height of the image.
37
+ * @param mimeType - The MimeType of the image.
38
+ * @param count - The number of Classifications requested.
39
+ * @returns - The list of Classifications.
40
+ */
41
+ getClassifications: (image: Uint8Array, width: number, height: number, mimeType: MimeType, count: number, extra?: StructType) => Promise<Classification[]>;
42
+ /**
43
+ * Returns a list of the 3D point cloud objects and associated metadata in the
44
+ * latest picture obtained from the specified 3D camera.
45
+ *
46
+ * @param cameraName - The name of the camera.
47
+ * @returns - The list of PointCloudObjects
48
+ */
49
+ getObjectPointClouds: (cameraName: string, extra?: StructType) => Promise<PointCloudObject[]>;
50
+ }
@@ -0,0 +1,3 @@
1
+ export type { Vision } from './vision/vision';
2
+ export type { Detection, Classification, PointCloudObject, } from './vision/types';
3
+ export { VisionClient } from './vision/client';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viamrobotics/sdk",
3
- "version": "0.9.2",
3
+ "version": "0.10.0-rc.0",
4
4
  "description": "",
5
5
  "main": "./dist/main.umd.js",
6
6
  "module": "./dist/main.es.js",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "homepage": "https://github.com/viamrobotics/viam-typescript-sdk#readme",
47
47
  "dependencies": {
48
- "@viamrobotics/rpc": "^0.1.39",
48
+ "@viamrobotics/rpc": "^0.2.3",
49
49
  "exponential-backoff": "^3.1.1"
50
50
  },
51
51
  "devDependencies": {
@@ -53,9 +53,10 @@
53
53
  "@improbable-eng/grpc-web": "^0.15.0",
54
54
  "@improbable-eng/grpc-web-fake-transport": "^0.15.0",
55
55
  "@types/google-protobuf": "^3.15.6",
56
+ "@types/node": "^20.11.10",
56
57
  "@typescript-eslint/eslint-plugin": "^6.17.0",
57
58
  "@typescript-eslint/parser": "^6.17.0",
58
- "@viamrobotics/eslint-config": "^0.3.0",
59
+ "@viamrobotics/eslint-config": "^0.4.0",
59
60
  "@viamrobotics/prettier-config": "^0.3.4",
60
61
  "@viamrobotics/typescript-config": "^0.1.0",
61
62
  "concurrently": "^8.0.1",
@@ -63,6 +64,7 @@
63
64
  "eslint": "^8.56.0",
64
65
  "eslint-config-prettier": "^9.1.0",
65
66
  "eslint-plugin-tsdoc": "^0.2.17",
67
+ "eslint-plugin-vitest": "^0.3.20",
66
68
  "google-protobuf": "^3.21.2",
67
69
  "grpc-web": "^1.4.2",
68
70
  "happy-dom": "^8.2.6",