@viamrobotics/sdk 0.0.12 → 0.0.14

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.
package/README.md CHANGED
@@ -5,7 +5,19 @@
5
5
  > **Warning**
6
6
  > This is an alpha release of the Viam TypeScript SDK. Stability is not guaranteed. Breaking changes are likely to occur, and occur often.
7
7
 
8
+ ## Usage
9
+
10
+ ### Installation
11
+
12
+ ```
13
+ npm install --save @viamrobotics/sdk
14
+ ```
15
+
16
+ ### Examples
17
+
18
+ [The examples directory](examples) contains small apps that demonstrate how to use this SDK to operate a robot running Viam.
19
+
8
20
  ## License
9
21
  Copyright 2022 Viam Inc.
10
22
 
11
- Apache 2.0 - See [LICENSE](https://github.com/viamrobotics/viam-typescript-sdk/blob/main/LICENSE) file
23
+ Apache 2.0 - See [LICENSE](LICENSE) file
package/dist/Client.d.ts CHANGED
@@ -10,7 +10,6 @@ import { MotionServiceClient } from './gen/service/motion/v1/motion_pb_service.e
10
10
  import { MotorServiceClient } from './gen/component/motor/v1/motor_pb_service.esm';
11
11
  import { MovementSensorServiceClient } from './gen/component/movementsensor/v1/movementsensor_pb_service.esm';
12
12
  import { NavigationServiceClient } from './gen/service/navigation/v1/navigation_pb_service.esm';
13
- import { RobotServiceClient } from './gen/robot/v1/robot_pb_service.esm';
14
13
  import { SLAMServiceClient } from './gen/service/slam/v1/slam_pb_service.esm';
15
14
  import { SensorsServiceClient } from './gen/service/sensors/v1/sensors_pb_service.esm';
16
15
  import { ServoServiceClient } from './gen/component/servo/v1/servo_pb_service.esm';
@@ -41,7 +40,6 @@ export default class Client {
41
40
  private connectResolve;
42
41
  private savedAuthEntity;
43
42
  private savedCreds;
44
- private robotServiceClient;
45
43
  private armServiceClient;
46
44
  private baseServiceClient;
47
45
  private boardServiceClient;
@@ -60,7 +58,6 @@ export default class Client {
60
58
  constructor(serviceHost: string, webrtcOptions?: WebRTCOptions, sessionOptions?: SessionOptions);
61
59
  get sessionId(): string;
62
60
  private static readonly notConnectedYetStr;
63
- get robotService(): RobotServiceClient;
64
61
  get armService(): ArmServiceClient;
65
62
  get baseService(): BaseServiceClient;
66
63
  get boardService(): BoardServiceClient;
@@ -1,9 +1,9 @@
1
- import type { baseApi, commonApi } from '../../main';
2
1
  import type { Extra } from '../../types';
2
+ import type { commonApi } from '../../main';
3
3
  export interface Base {
4
- moveStraight(distanceMm: number, mmPerSec: number, extra?: Extra): Promise<baseApi.MoveStraightResponse>;
5
- spin(angleDeg: number, degsPerSec: number, extra?: Extra): Promise<baseApi.SpinResponse>;
6
- setPower(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: Extra): Promise<baseApi.SetPowerResponse>;
7
- setVelocity(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: Extra): Promise<baseApi.SetVelocityResponse>;
8
- stop(extra?: Extra): Promise<baseApi.StopResponse>;
4
+ moveStraight(distanceMm: number, mmPerSec: number, extra?: Extra): Promise<void>;
5
+ spin(angleDeg: number, degsPerSec: number, extra?: Extra): Promise<void>;
6
+ setPower(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: Extra): Promise<void>;
7
+ setVelocity(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: Extra): Promise<void>;
8
+ stop(extra?: Extra): Promise<void>;
9
9
  }
@@ -1,13 +1,15 @@
1
- import { Client, baseApi, commonApi } from '../../main';
1
+ import { Client, commonApi } from '../../main';
2
2
  import type { Base } from './Base';
3
+ import type { Options } from '../../types';
3
4
  export declare class BaseClient implements Base {
4
5
  private client;
5
- private name;
6
- constructor(client: Client, name: string);
6
+ private readonly name;
7
+ private readonly options;
8
+ constructor(client: Client, name: string, options?: Options);
7
9
  private get baseService();
8
- moveStraight(distanceMm: number, mmPerSec: number, extra?: {}): Promise<baseApi.MoveStraightResponse>;
9
- spin(angleDeg: number, degsPerSec: number, extra?: {}): Promise<baseApi.SpinResponse>;
10
- setPower(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: {}): Promise<baseApi.SetPowerResponse>;
11
- setVelocity(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: {}): Promise<baseApi.SetVelocityResponse>;
12
- stop(extra?: {}): Promise<baseApi.StopResponse>;
10
+ moveStraight(distanceMm: number, mmPerSec: number, extra?: {}): Promise<void>;
11
+ spin(angleDeg: number, degsPerSec: number, extra?: {}): Promise<void>;
12
+ setPower(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: {}): Promise<void>;
13
+ setVelocity(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: {}): Promise<void>;
14
+ stop(extra?: {}): Promise<void>;
13
15
  }
@@ -2,12 +2,12 @@ import type { Extra } from '../../types';
2
2
  import type { boardApi } from '../../main';
3
3
  export interface Board {
4
4
  status(extra?: Extra): Promise<boardApi.StatusResponse>;
5
- setGPIO(pin: string, high: boolean, extra?: Extra): Promise<boardApi.SetGPIOResponse>;
6
- getGPIO(pin: string, extra?: Extra): Promise<boardApi.GetGPIOResponse>;
7
- pWM(pin: string, extra?: Extra): Promise<boardApi.PWMResponse>;
8
- setPWM(pin: string, dutyCyle: number, extra?: Extra): Promise<boardApi.SetPWMResponse>;
9
- pWMFrequency(pin: string, extra?: Extra): Promise<boardApi.PWMFrequencyResponse>;
10
- setPWMFrequency(pin: string, frequencyHz: number, extra?: Extra): Promise<boardApi.SetPWMFrequencyResponse>;
11
- readAnalogReader(boardName: string, analogReader: string, extra?: Extra): Promise<boardApi.ReadAnalogReaderResponse>;
12
- getDigitalInterruptValue(boardName: string, digitalInteruptName: string, extra?: Extra): Promise<boardApi.GetDigitalInterruptValueResponse>;
5
+ setGPIO(pin: string, high: boolean, extra?: Extra): Promise<void>;
6
+ getGPIO(pin: string, extra?: Extra): Promise<boolean>;
7
+ getPWM(pin: string, extra?: Extra): Promise<number>;
8
+ setPWM(pin: string, dutyCyle: number, extra?: Extra): Promise<void>;
9
+ getPWMFrequency(pin: string, extra?: Extra): Promise<number>;
10
+ setPWMFrequency(pin: string, frequencyHz: number, extra?: Extra): Promise<void>;
11
+ readAnalogReader(boardName: string, analogReader: string, extra?: Extra): Promise<number>;
12
+ getDigitalInterruptValue(boardName: string, digitalInteruptName: string, extra?: Extra): Promise<number>;
13
13
  }
@@ -1,18 +1,20 @@
1
1
  import type { Board } from './Board';
2
2
  import type Client from '../../Client';
3
+ import type { Options } from '../../types';
3
4
  import { boardApi } from '../../main';
4
5
  export declare class BoardClient implements Board {
5
6
  private client;
6
- private name;
7
- constructor(client: Client, name: string);
7
+ private readonly name;
8
+ private readonly options;
9
+ constructor(client: Client, name: string, options?: Options);
8
10
  private get boardService();
9
11
  status(extra?: {}): Promise<boardApi.StatusResponse>;
10
- setGPIO(pin: string, high: boolean, extra?: {}): Promise<boardApi.SetGPIOResponse>;
11
- getGPIO(pin: string, extra?: {}): Promise<boardApi.GetGPIOResponse>;
12
- pWM(pin: string, extra?: {}): Promise<boardApi.PWMResponse>;
13
- setPWM(pin: string, dutyCyle: number, extra?: {}): Promise<boardApi.SetPWMResponse>;
14
- pWMFrequency(pin: string, extra?: {}): Promise<boardApi.PWMFrequencyResponse>;
15
- setPWMFrequency(pin: string, frequencyHz: number, extra?: {}): Promise<boardApi.SetPWMFrequencyResponse>;
16
- readAnalogReader(boardName: string, analogReader: string, extra?: {}): Promise<boardApi.ReadAnalogReaderResponse>;
17
- getDigitalInterruptValue(boardName: string, digitalInteruptName: string, extra?: {}): Promise<boardApi.GetDigitalInterruptValueResponse>;
12
+ setGPIO(pin: string, high: boolean, extra?: {}): Promise<void>;
13
+ getGPIO(pin: string, extra?: {}): Promise<boolean>;
14
+ getPWM(pin: string, extra?: {}): Promise<number>;
15
+ setPWM(pin: string, dutyCyle: number, extra?: {}): Promise<void>;
16
+ getPWMFrequency(pin: string, extra?: {}): Promise<number>;
17
+ setPWMFrequency(pin: string, frequencyHz: number, extra?: {}): Promise<void>;
18
+ readAnalogReader(boardName: string, analogReader: string, extra?: {}): Promise<number>;
19
+ getDigitalInterruptValue(boardName: string, digitalInteruptName: string, extra?: {}): Promise<number>;
18
20
  }
@@ -1,10 +1,12 @@
1
1
  import { type Camera, MimeType } from './Camera';
2
2
  import type Client from '../../Client';
3
+ import type { Options } from '../../types';
3
4
  import pb from '../../gen/component/camera/v1/camera_pb.esm';
4
5
  export declare class CameraClient implements Camera {
5
6
  private client;
6
7
  private readonly name;
7
- constructor(client: Client, name: string);
8
+ private readonly options;
9
+ constructor(client: Client, name: string, options?: Options);
8
10
  private get cameraService();
9
11
  getImage(mimeType: MimeType): Promise<Uint8Array>;
10
12
  renderFrame(mimeType: MimeType): Promise<Blob>;
@@ -1,16 +1,17 @@
1
1
  import type Client from '../../Client';
2
2
  import type { Motor } from './Motor';
3
- import { motorApi } from '../../main';
3
+ import type { Options } from '../../types';
4
4
  export declare class MotorClient implements Motor {
5
5
  private client;
6
- private name;
7
- constructor(client: Client, name: string);
6
+ private readonly name;
7
+ private readonly options;
8
+ constructor(client: Client, name: string, options?: Options);
8
9
  private get motorService();
9
- setPower(power: number, extra?: {}): Promise<motorApi.SetPowerResponse>;
10
- goFor(rpm: number, revolutions: number, extra?: {}): Promise<motorApi.GoForResponse>;
11
- goTo(rpm: number, positionRevolutions: number, extra?: {}): Promise<motorApi.GoToResponse>;
12
- resetZeroPosition(offset: number, extra?: {}): Promise<motorApi.ResetZeroPositionResponse>;
13
- motorStop(extra?: {}): Promise<motorApi.StopResponse>;
10
+ setPower(power: number, extra?: {}): Promise<void>;
11
+ goFor(rpm: number, revolutions: number, extra?: {}): Promise<void>;
12
+ goTo(rpm: number, positionRevolutions: number, extra?: {}): Promise<void>;
13
+ resetZeroPosition(offset: number, extra?: {}): Promise<void>;
14
+ motorStop(extra?: {}): Promise<void>;
14
15
  getProperties(extra?: {}): Promise<{
15
16
  positionReporting: boolean;
16
17
  }>;
@@ -1,14 +1,13 @@
1
1
  import type { Extra } from '../../types';
2
- import type { motorApi } from '../../main';
3
2
  export interface Properties {
4
3
  positionReporting: boolean;
5
4
  }
6
5
  export interface Motor {
7
- setPower(power: number, extra?: Extra): Promise<motorApi.SetPowerResponse>;
8
- goFor(rpm: number, revolutions: number, extra?: Extra): Promise<motorApi.GoForResponse>;
9
- goTo(rpm: number, positionRevolutions: number, extra?: Extra): Promise<motorApi.GoToResponse>;
10
- resetZeroPosition(offset: number, extra?: Extra): Promise<motorApi.ResetZeroPositionResponse>;
11
- motorStop(extra?: Extra): Promise<motorApi.StopResponse>;
6
+ setPower(power: number, extra?: Extra): Promise<void>;
7
+ goFor(rpm: number, revolutions: number, extra?: Extra): Promise<void>;
8
+ goTo(rpm: number, positionRevolutions: number, extra?: Extra): Promise<void>;
9
+ resetZeroPosition(offset: number, extra?: Extra): Promise<void>;
10
+ motorStop(extra?: Extra): Promise<void>;
12
11
  getProperties(extra?: Extra): Promise<Properties>;
13
12
  getPosition(extra?: Extra): Promise<number>;
14
13
  isPowered(extra?: Extra): Promise<readonly [boolean, number]>;
@@ -0,0 +1,22 @@
1
+ import type { PoseInFrame, ResourceName, Transform } from '../../gen/common/v1/common_pb.esm';
2
+ import type Client from '../../Client';
3
+ import type { Duration } from 'google-protobuf/google/protobuf/duration_pb';
4
+ import type { Robot } from './Robot';
5
+ import proto from '../../gen/robot/v1/robot_pb.esm';
6
+ export declare class RobotClient implements Robot {
7
+ private client;
8
+ constructor(client: Client);
9
+ private get robotService();
10
+ getOperations(): Promise<proto.Operation[]>;
11
+ cancelOperation(id: string): Promise<void>;
12
+ blockForOperation(id: string): Promise<void>;
13
+ stopAll(): Promise<void>;
14
+ frameSystemConfig(transforms: Transform[]): Promise<proto.FrameSystemConfig[]>;
15
+ transformPose(source: PoseInFrame, destination: string, supplementalTransforms: Transform[]): Promise<import("../../gen/common/v1/common_pb").PoseInFrame>;
16
+ transformPCD(pointCloudPCD: Uint8Array, source: string, destination: string): Promise<Uint8Array>;
17
+ discoverComponents(queries: proto.DiscoveryQuery[]): Promise<proto.Discovery[]>;
18
+ resourceNames(): Promise<import("../../gen/common/v1/common_pb").ResourceName[]>;
19
+ resourceRPCSubtypes(): Promise<proto.ResourceRPCSubtype[]>;
20
+ getStatus(resourceNames: ResourceName[]): Promise<proto.Status[]>;
21
+ streamStatus(resourceNames: ResourceName[], duration: Duration): Promise<proto.Status[]>;
22
+ }
@@ -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[]>;
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,3 @@
1
+ export type { Robot } from './robot/Robot';
2
+ export { RobotClient } from './robot/Client';
3
+ export * as robotApi from '../gen/robot/v1/robot_pb.esm';
@@ -1,10 +1,12 @@
1
1
  import type Client from '../../Client';
2
+ import type { Options } from '../../types';
2
3
  import type { Sensor } from './Sensor';
3
4
  import { sensorApi } from '../../main';
4
5
  export declare class SensorClient implements Sensor {
5
6
  private client;
6
- private name;
7
- constructor(client: Client, name: string);
7
+ private readonly name;
8
+ private readonly options;
9
+ constructor(client: Client, name: string, options?: Options);
8
10
  private get sensorService();
9
11
  getReadings(extra?: {}): Promise<sensorApi.GetReadingsResponse>;
10
12
  }
@@ -1,8 +1,10 @@
1
1
  import type Client from '../../Client';
2
+ import type { Options } from '../../types';
2
3
  import type { Stream } from './Stream';
3
4
  export declare class StreamClient implements Stream {
4
5
  private client;
5
- constructor(client: Client);
6
+ private readonly options;
7
+ constructor(client: Client, options?: Options);
6
8
  private get streamService();
7
9
  add(name: string): Promise<void>;
8
10
  remove(name: string): Promise<void>;
package/dist/main.d.ts CHANGED
@@ -23,12 +23,12 @@ import motionApi from './gen/service/motion/v1/motion_pb.esm';
23
23
  import motorApi from './gen/component/motor/v1/motor_pb.esm';
24
24
  import movementSensorApi from './gen/component/movementsensor/v1/movementsensor_pb.esm';
25
25
  import navigationApi from './gen/service/navigation/v1/navigation_pb.esm';
26
- import robotApi from './gen/robot/v1/robot_pb.esm';
27
26
  import sensorApi from './gen/component/sensor/v1/sensor_pb.esm';
28
27
  import sensorsApi from './gen/service/sensors/v1/sensors_pb.esm';
29
28
  import servoApi from './gen/component/servo/v1/servo_pb.esm';
30
29
  import slamApi from './gen/service/slam/v1/slam_pb.esm';
31
30
  import streamApi from './gen/proto/stream/v1/stream_pb.esm';
32
31
  import visionApi from './gen/service/vision/v1/vision_pb.esm';
33
- export { commonApi, armApi, baseApi, boardApi, cameraApi, gantryApi, genericApi, gripperApi, inputControllerApi, motorApi, motionApi, movementSensorApi, servoApi, robotApi, navigationApi, sensorApi, sensorsApi, slamApi, visionApi, streamApi, Camera, Motor, Base, Board, Sensor, BaseClient, BoardClient, CameraClient, Client, MotorClient, SensorClient, StreamClient };
34
- export type { ResponseStream, ServiceError } from './gen/robot/v1/robot_pb_service.esm';
32
+ export { type Robot, RobotClient, robotApi } from './components/robot';
33
+ export { commonApi, armApi, baseApi, boardApi, cameraApi, gantryApi, genericApi, gripperApi, inputControllerApi, motorApi, motionApi, movementSensorApi, servoApi, navigationApi, sensorApi, sensorsApi, slamApi, visionApi, streamApi, Camera, Motor, Base, Board, Sensor, BaseClient, BoardClient, CameraClient, Client, MotorClient, SensorClient, StreamClient, };
34
+ export type { ResponseStream, ServiceError, } from './gen/robot/v1/robot_pb_service.esm';