@viamrobotics/sdk 0.0.30 → 0.0.32

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.
@@ -0,0 +1,100 @@
1
+ import type { Credentials } from '@viamrobotics/rpc/src/dial';
2
+ import type { Robot } from './Robot';
3
+ import proto from '../gen/robot/v1/robot_pb.esm';
4
+ import type { PoseInFrame, ResourceName, Transform } from '../gen/common/v1/common_pb.esm';
5
+ import type { Duration } from 'google-protobuf/google/protobuf/duration_pb';
6
+ import { ArmServiceClient } from '../gen/component/arm/v1/arm_pb_service.esm';
7
+ import { BaseServiceClient } from '../gen/component/base/v1/base_pb_service.esm';
8
+ import { BoardServiceClient } from '../gen/component/board/v1/board_pb_service.esm';
9
+ import { GantryServiceClient } from '../gen/component/gantry/v1/gantry_pb_service.esm';
10
+ import { GenericServiceClient } from '../gen/component/generic/v1/generic_pb_service.esm';
11
+ import { GripperServiceClient } from '../gen/component/gripper/v1/gripper_pb_service.esm';
12
+ import { InputControllerServiceClient } from '../gen/component/inputcontroller/v1/input_controller_pb_service.esm';
13
+ import { MotionServiceClient } from '../gen/service/motion/v1/motion_pb_service.esm';
14
+ import { MotorServiceClient } from '../gen/component/motor/v1/motor_pb_service.esm';
15
+ import { MovementSensorServiceClient } from '../gen/component/movementsensor/v1/movementsensor_pb_service.esm';
16
+ import { NavigationServiceClient } from '../gen/service/navigation/v1/navigation_pb_service.esm';
17
+ import { RobotServiceClient } from '../gen/robot/v1/robot_pb_service.esm';
18
+ import { SLAMServiceClient } from '../gen/service/slam/v1/slam_pb_service.esm';
19
+ import { SensorsServiceClient } from '../gen/service/sensors/v1/sensors_pb_service.esm';
20
+ import { ServoServiceClient } from '../gen/component/servo/v1/servo_pb_service.esm';
21
+ import { VisionServiceClient } from '../gen/service/vision/v1/vision_pb_service.esm';
22
+ import type { grpc } from '@improbable-eng/grpc-web';
23
+ interface WebRTCOptions {
24
+ enabled: boolean;
25
+ host: string;
26
+ signalingAddress: string;
27
+ rtcConfig: RTCConfiguration | undefined;
28
+ }
29
+ interface SessionOptions {
30
+ disabled: boolean;
31
+ }
32
+ declare abstract class ServiceClient {
33
+ serviceHost: string;
34
+ options?: grpc.RpcOptions | undefined;
35
+ constructor(serviceHost: string, options?: grpc.RpcOptions | undefined);
36
+ }
37
+ /** A gRPC-web client for the Robot component. */
38
+ export declare class RobotClient implements Robot {
39
+ private readonly serviceHost;
40
+ private readonly webrtcOptions;
41
+ private readonly sessionOptions;
42
+ private sessionManager;
43
+ private peerConn;
44
+ private transportFactory;
45
+ private connecting;
46
+ private connectResolve;
47
+ private savedAuthEntity;
48
+ private savedCreds;
49
+ private robotServiceClient;
50
+ private armServiceClient;
51
+ private baseServiceClient;
52
+ private boardServiceClient;
53
+ private gantryServiceClient;
54
+ private genericServiceClient;
55
+ private gripperServiceClient;
56
+ private movementSensorServiceClient;
57
+ private inputControllerServiceClient;
58
+ private motorServiceClient;
59
+ private navigationServiceClient;
60
+ private motionServiceClient;
61
+ private visionServiceClient;
62
+ private sensorsServiceClient;
63
+ private servoServiceClient;
64
+ private slamServiceClient;
65
+ constructor(serviceHost: string, webrtcOptions?: WebRTCOptions, sessionOptions?: SessionOptions);
66
+ get sessionId(): string;
67
+ private static readonly notConnectedYetStr;
68
+ get robotService(): RobotServiceClient;
69
+ get armService(): ArmServiceClient;
70
+ get baseService(): BaseServiceClient;
71
+ get boardService(): BoardServiceClient;
72
+ get gantryService(): GantryServiceClient;
73
+ get genericService(): GenericServiceClient;
74
+ get gripperService(): GripperServiceClient;
75
+ get movementSensorService(): MovementSensorServiceClient;
76
+ get inputControllerService(): InputControllerServiceClient;
77
+ get motorService(): MotorServiceClient;
78
+ get navigationService(): NavigationServiceClient;
79
+ get motionService(): MotionServiceClient;
80
+ get visionService(): VisionServiceClient;
81
+ get sensorsService(): SensorsServiceClient;
82
+ get servoService(): ServoServiceClient;
83
+ get slamService(): SLAMServiceClient;
84
+ createServiceClient<T extends ServiceClient>(SC: new (serviceHost: string, options?: grpc.RpcOptions) => T): T;
85
+ disconnect(): Promise<void>;
86
+ connect(authEntity?: string | undefined, creds?: Credentials | undefined): Promise<void>;
87
+ getOperations(): Promise<proto.Operation[]>;
88
+ cancelOperation(id: string): Promise<void>;
89
+ blockForOperation(id: string): Promise<void>;
90
+ stopAll(): Promise<void>;
91
+ frameSystemConfig(transforms: Transform[]): Promise<proto.FrameSystemConfig[]>;
92
+ transformPose(source: PoseInFrame, destination: string, supplementalTransforms: Transform[]): Promise<import("../gen/common/v1/common_pb").PoseInFrame>;
93
+ transformPCD(pointCloudPCD: Uint8Array, source: string, destination: string): Promise<Uint8Array>;
94
+ discoverComponents(queries: proto.DiscoveryQuery[]): Promise<proto.Discovery[]>;
95
+ resourceNames(): Promise<import("../gen/common/v1/common_pb").ResourceName.AsObject[]>;
96
+ resourceRPCSubtypes(): Promise<proto.ResourceRPCSubtype[]>;
97
+ getStatus(resourceNames: ResourceName[]): Promise<proto.Status[]>;
98
+ streamStatus(resourceNames: ResourceName[], duration: Duration): Promise<proto.Status[]>;
99
+ }
100
+ export {};
@@ -0,0 +1,129 @@
1
+ import type { PoseInFrame, ResourceName, Transform } from '../gen/common/v1/common_pb.esm';
2
+ import type { Duration } from 'google-protobuf/google/protobuf/duration_pb';
3
+ import type { Extra } from '../types';
4
+ import type proto from '../gen/robot/v1/robot_pb.esm';
5
+ export interface Robot {
6
+ /**
7
+ * Get the list of operations currently running on the robot.
8
+ *
9
+ * @privateRemarks
10
+ * TODO: this function should return an more idiomatic type instead of just
11
+ * passing along a proto type.
12
+ * @group Operations
13
+ * @alpha
14
+ */
15
+ getOperations(): Promise<proto.Operation[]>;
16
+ /**
17
+ * Cancels the specified operation on the robot.
18
+ *
19
+ * @param id - ID of operation to kill.
20
+ * @group Operations
21
+ * @alpha
22
+ */
23
+ cancelOperation(id: string): Promise<void>;
24
+ /**
25
+ * Blocks on the specified operation on the robot. This function will only
26
+ * return when the specific operation has finished or has been cancelled.
27
+ *
28
+ * @param id (str) - ID of operation to block on.
29
+ * @group Operations
30
+ * @alpha
31
+ */
32
+ blockForOperation(id: string): Promise<void>;
33
+ /**
34
+ * Cancel all current and outstanding operations for the robot and stop all
35
+ * actuators and movement.
36
+ *
37
+ * @param extra - Any extra parameters to pass to the components' `stop`
38
+ * methods, keyed on the component's resource name.
39
+ * @group Operations
40
+ * @alpha
41
+ */
42
+ stopAll(extra?: Map<string, Extra>): Promise<void>;
43
+ /**
44
+ * Get the configuration of the frame system of a given robot.
45
+ *
46
+ * @privateRemarks
47
+ * TODO: this function should return an more idiomatic type instead of just
48
+ * passing along a proto type.
49
+ * @group Frame System
50
+ * @alpha
51
+ */
52
+ frameSystemConfig(transform: Transform[]): Promise<proto.FrameSystemConfig[]>;
53
+ /**
54
+ * Transform a given source Pose from the reference frame to a new specified
55
+ * destination which is a reference frame.
56
+ *
57
+ * @privateRemarks
58
+ * TODO: this function should return an more idiomatic type instead of just
59
+ * passing along a proto type.
60
+ * @param query - The pose that should be transformed
61
+ * @param destination - The name of the reference frame to transform the given
62
+ * @param supplementalTransforms - Pose information on any additional
63
+ * reference frames that are needed to perform the transform
64
+ * @group Frame System
65
+ * @alpha
66
+ */
67
+ transformPose(source: PoseInFrame, destination: string, supplementalTransforms: Transform[]): Promise<PoseInFrame>;
68
+ /**
69
+ * Transform a given source point cloud from the reference frame to a new
70
+ * specified destination which is a reference frame.
71
+ *
72
+ * @param pointCloudPCD - The point clouds to transform. This should be in the
73
+ * PCD format encoded into bytes:
74
+ * https://pointclouds.org/documentation/tutorials/pcd_file_format.html
75
+ * @param source - The reference frame of the point cloud.
76
+ * @param destination - The reference frame into which the source data should
77
+ * be transformed, if unset this defaults to the "world" reference frame. Do
78
+ * not move the robot between the generation of the initial pointcloud and
79
+ * the receipt of the transformed pointcloud because that will make the
80
+ * transformations inaccurate.
81
+ * @group Frame System
82
+ * @alpha
83
+ */
84
+ transformPCD(pointCloudPCD: Uint8Array, source: string, destination: string): Promise<Uint8Array>;
85
+ /**
86
+ * Get the list of discovered component configurations.
87
+ *
88
+ * @privateRemarks
89
+ * TODO: this function should return an more idiomatic type instead of just
90
+ * passing along a proto type.
91
+ * @param queries - The list of component models to discovery.
92
+ * @group Discovery
93
+ * @alpha
94
+ */
95
+ discoverComponents(queries: proto.DiscoveryQuery[]): Promise<proto.Discovery[]>;
96
+ /**
97
+ * Get a list of all resources on the robot.
98
+ *
99
+ * @group Resources
100
+ * @alpha
101
+ */
102
+ resourceNames(): Promise<ResourceName.AsObject[]>;
103
+ /**
104
+ * Get a list of all resource types.
105
+ *
106
+ * @group Resources
107
+ * @alpha
108
+ */
109
+ resourceRPCSubtypes(): Promise<proto.ResourceRPCSubtype[]>;
110
+ /**
111
+ * Get a list of all statuses requested. An empty request signifies all
112
+ * resources.
113
+ *
114
+ * @param resourceNames - The list of resources for which to receive statuses.
115
+ * @group Status
116
+ * @alpha
117
+ */
118
+ getStatus(resourceNames: ResourceName[]): Promise<proto.Status[]>;
119
+ /**
120
+ * Periodically receive the status of all statuses requested. An empty request
121
+ * signifies all resources.
122
+ *
123
+ * @param resourceNames - The list of resources for which to receive statuses.
124
+ * @param duration - How often to send a new status.
125
+ * @group Status
126
+ * @alpha
127
+ */
128
+ streamStatus(resourceNames: ResourceName[], duration: Duration): Promise<proto.Status[]>;
129
+ }
@@ -0,0 +1,19 @@
1
+ import { grpc } from '@improbable-eng/grpc-web';
2
+ export default class SessionManager {
3
+ private readonly innerTransportFactory;
4
+ private client;
5
+ private currentSessionID;
6
+ private sessionsSupported;
7
+ private heartbeatIntervalMs;
8
+ private starting;
9
+ private startResolve;
10
+ private startReject;
11
+ constructor(serviceHost: string, transportFactory: grpc.TransportFactory);
12
+ get transportFactory(): (opts: grpc.TransportOptions) => grpc.Transport;
13
+ get sessionID(): string;
14
+ private getSessionMetadataInner;
15
+ reset(): void;
16
+ private readonly backgroundHeartbeat;
17
+ private heartbeat;
18
+ getSessionMetadata(): Promise<grpc.Metadata>;
19
+ }
@@ -0,0 +1,14 @@
1
+ import type SessionManager from './SessionManager';
2
+ import { grpc } from '@improbable-eng/grpc-web';
3
+ export default class SessionTransport implements grpc.Transport {
4
+ private readonly opts;
5
+ protected readonly transport: grpc.Transport;
6
+ protected readonly sessionManager: SessionManager;
7
+ private mdProm;
8
+ private mdPromResolve;
9
+ constructor(opts: grpc.TransportOptions, innerFactory: grpc.TransportFactory, sessionManager: SessionManager);
10
+ start(metadata: grpc.Metadata): void;
11
+ sendMessage(msgBytes: Uint8Array): void;
12
+ finishSend(): void;
13
+ cancel(): void;
14
+ }
@@ -0,0 +1,27 @@
1
+ import { RobotClient } from './Client';
2
+ interface Credential {
3
+ type: string;
4
+ payload: string;
5
+ }
6
+ /** Options required to dial a robot via gRPC. */
7
+ export interface DialDirectConf {
8
+ authEntity?: string;
9
+ host: string;
10
+ credential?: Credential;
11
+ }
12
+ interface ICEServer {
13
+ urls: string;
14
+ username: string;
15
+ credential: string;
16
+ }
17
+ /** Options required to dial a robot via WebRTC. */
18
+ export interface DialWebRTCConf {
19
+ authEntity?: string;
20
+ host: string;
21
+ credential?: Credential;
22
+ signalingAddress: string;
23
+ iceServers?: ICEServer[];
24
+ }
25
+ declare type Conf = DialDirectConf | DialWebRTCConf;
26
+ export declare const createRobotClient: (conf: Conf) => Promise<RobotClient>;
27
+ export {};
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@viamrobotics/sdk",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "",
5
5
  "main": "./dist/main.umd.js",
6
6
  "module": "./dist/main.es.js",
7
7
  "types": "./dist/main.d.ts",
8
8
  "files": [
9
9
  "dist/robot.*",
10
+ "dist/robot/**/*.d.ts",
10
11
  "dist/events.*",
11
12
  "dist/components/**/*.d.ts",
12
13
  "dist/extra/**/*.d.ts",