@viamrobotics/sdk 0.0.25 → 0.0.26

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.
@@ -19,18 +19,10 @@ export interface Arm {
19
19
  * @param jointPositionsList - List of angles (0-360) to move each joint to.
20
20
  */
21
21
  moveToJointPositions: (jointPositionsList: number[], extra?: Extra) => Promise<void>;
22
- /**
23
- *Gets the current position of each joint.
24
- *
25
- */
22
+ /** Gets the current position of each joint. */
26
23
  getJointPositions: (extra: Extra) => Promise<JointPositions>;
27
- /**
28
- * Stops the motion of the arm.
29
- * */
24
+ /** Stops the motion of the arm. */
30
25
  stop: (extra: Extra) => Promise<void>;
31
- /**
32
- *
33
- * Get if the arm is currently moving.
34
- */
26
+ /** Get if the arm is currently moving. */
35
27
  isMoving: () => Promise<boolean>;
36
28
  }
@@ -1,5 +1,4 @@
1
- import type { Extra } from '../../types';
2
- import type { commonApi } from '../../main';
1
+ import type { Extra, Vector3D } from '../../types';
3
2
  /** Represents a physical base of a robot. */
4
3
  export interface Base {
5
4
  /**
@@ -25,14 +24,14 @@ export interface Base {
25
24
  * @param linear - Desired linear power percentage from -1 to 1.
26
25
  * @param angular - Desired angular power percentage from -1 to 1.
27
26
  */
28
- setPower(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: Extra): Promise<void>;
27
+ setPower(linear: Vector3D, angular: Vector3D, extra?: Extra): Promise<void>;
29
28
  /**
30
29
  * Set the linear and angular velocity of a base.
31
30
  *
32
31
  * @param linear - Desired linear velocity in millimeters per second.
33
32
  * @param angular - Desired angular velocity in degrees per second.
34
33
  */
35
- setVelocity(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: Extra): Promise<void>;
34
+ setVelocity(linear: Vector3D, angular: Vector3D, extra?: Extra): Promise<void>;
36
35
  /** Stop a base */
37
36
  stop(extra?: Extra): Promise<void>;
38
37
  }
@@ -1,7 +1,6 @@
1
1
  import type Client from '../../Client';
2
- import type commonApi from '../../gen/common/v1/common_pb.esm';
3
2
  import type { Base } from './Base';
4
- import type { Options } from '../../types';
3
+ import type { Options, Vector3D } from '../../types';
5
4
  /** A gRPC-web client for the Base component. */
6
5
  export declare class BaseClient implements Base {
7
6
  private client;
@@ -11,7 +10,7 @@ export declare class BaseClient implements Base {
11
10
  private get baseService();
12
11
  moveStraight(distanceMm: number, mmPerSec: number, extra?: {}): Promise<void>;
13
12
  spin(angleDeg: number, degsPerSec: number, extra?: {}): Promise<void>;
14
- setPower(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: {}): Promise<void>;
15
- setVelocity(linear: commonApi.Vector3, angular: commonApi.Vector3, extra?: {}): Promise<void>;
13
+ setPower(linear: Vector3D, angular: Vector3D, extra?: {}): Promise<void>;
14
+ setVelocity(linear: Vector3D, angular: Vector3D, extra?: {}): Promise<void>;
16
15
  stop(extra?: {}): Promise<void>;
17
16
  }
@@ -1,12 +1,15 @@
1
1
  import type { Extra } from '../../types';
2
- import type pb from '../../gen/component/board/v1/board_pb.esm';
2
+ interface Status {
3
+ analogs: Record<string, number>;
4
+ digitalInterrupts: Record<string, number>;
5
+ }
3
6
  /**
4
7
  * Represents a physical general purpose compute board that contains various
5
8
  * components such as analog readers, and digital interrupts.
6
9
  */
7
10
  export interface Board {
8
11
  /** Get the status of the board. */
9
- status(extra?: Extra): Promise<pb.StatusResponse>;
12
+ getStatus(extra?: Extra): Promise<Status>;
10
13
  /**
11
14
  * Get the high/low state of the given pin of a board.
12
15
  *
@@ -54,12 +57,13 @@ export interface Board {
54
57
  *
55
58
  * @param analogReader - The name of the analog reader.
56
59
  */
57
- readAnalogReader(boardName: string, analogReader: string, extra?: Extra): Promise<number>;
60
+ readAnalogReader(analogReader: string, extra?: Extra): Promise<number>;
58
61
  /**
59
62
  * Return the current value of the interrupt which is based on the type of
60
63
  * interrupt.
61
64
  *
62
65
  * @param digitalInterruptName - The name of the digital interrupt.
63
66
  */
64
- getDigitalInterruptValue(boardName: string, digitalInterruptName: string, extra?: Extra): Promise<number>;
67
+ getDigitalInterruptValue(digitalInterruptName: string, extra?: Extra): Promise<number>;
65
68
  }
69
+ export {};
@@ -9,13 +9,23 @@ export declare class BoardClient implements Board {
9
9
  private readonly options;
10
10
  constructor(client: Client, name: string, options?: Options);
11
11
  private get boardService();
12
+ private getRawStatusResponse;
13
+ /**
14
+ * Get the status of the board as a raw protobuf response.
15
+ *
16
+ * @deprecated Use {@link BoardClient#getStatus} instead.
17
+ */
12
18
  status(extra?: {}): Promise<pb.StatusResponse>;
19
+ getStatus(extra?: {}): Promise<{
20
+ analogs: Record<string, number>;
21
+ digitalInterrupts: Record<string, number>;
22
+ }>;
13
23
  setGPIO(pin: string, high: boolean, extra?: {}): Promise<void>;
14
24
  getGPIO(pin: string, extra?: {}): Promise<boolean>;
15
25
  getPWM(pin: string, extra?: {}): Promise<number>;
16
26
  setPWM(pin: string, dutyCyle: number, extra?: {}): Promise<void>;
17
27
  getPWMFrequency(pin: string, extra?: {}): Promise<number>;
18
28
  setPWMFrequency(pin: string, frequencyHz: number, extra?: {}): Promise<void>;
19
- readAnalogReader(boardName: string, analogReader: string, extra?: {}): Promise<number>;
20
- getDigitalInterruptValue(boardName: string, digitalInteruptName: string, extra?: {}): Promise<number>;
29
+ readAnalogReader(analogReader: string, extra?: {}): Promise<number>;
30
+ getDigitalInterruptValue(digitalInteruptName: string, extra?: {}): Promise<number>;
21
31
  }
@@ -7,13 +7,7 @@ export interface Properties {
7
7
  /** Camera distortion parameters, if available. */
8
8
  distortionParameters?: DistortionParameters.AsObject;
9
9
  }
10
- export declare enum MimeType {
11
- VIAM_RGBA = "image/vnd.viam.rgba",
12
- JPEG = "image/jpeg",
13
- PNG = "image/png",
14
- PCD = "pointcloud/pcd",
15
- UNSUPPORTED = "unsupported"
16
- }
10
+ export declare type MimeType = 'image/vnd.viam.rgba' | 'image/jpeg' | 'image/png' | 'pointcloud/pcd' | 'unsupported';
17
11
  /** Represents any physical hardware that can capture frames. */
18
12
  export interface Camera {
19
13
  /**
@@ -1,4 +1,4 @@
1
- import { type Camera, MimeType } from './Camera';
1
+ import type { Camera, MimeType } from './Camera';
2
2
  import type Client from '../../Client';
3
3
  import type { Options } from '../../types';
4
4
  import pb from '../../gen/component/camera/v1/camera_pb.esm';
@@ -13,8 +13,6 @@ export declare class MotorClient implements Motor {
13
13
  goTo(rpm: number, positionRevolutions: number, extra?: {}): Promise<void>;
14
14
  resetZeroPosition(offset: number, extra?: {}): Promise<void>;
15
15
  stop(extra?: {}): Promise<void>;
16
- /** @deprecated Use {@link MotorClient#stop} instead. */
17
- motorStop(extra?: {}): Promise<void>;
18
16
  getProperties(extra?: {}): Promise<{
19
17
  positionReporting: boolean;
20
18
  }>;
@@ -9,16 +9,8 @@ export declare class MovementSensorClient implements MovementSensor {
9
9
  private readonly options;
10
10
  constructor(client: Client, name: string, options?: Options);
11
11
  private get movementsensorService();
12
- getLinearVelocity(extra?: {}): Promise<{
13
- x: number;
14
- y: number;
15
- z: number;
16
- }>;
17
- getAngularVelocity(extra?: {}): Promise<{
18
- x: number;
19
- y: number;
20
- z: number;
21
- }>;
12
+ getLinearVelocity(extra?: {}): Promise<import("../../types").Vector3D>;
13
+ getAngularVelocity(extra?: {}): Promise<import("../../types").Vector3D>;
22
14
  getCompassHeading(extra?: {}): Promise<number>;
23
15
  getOrientation(extra?: {}): Promise<{
24
16
  ox: number;
@@ -40,10 +32,6 @@ export declare class MovementSensorClient implements MovementSensor {
40
32
  linearAccelerationSupported: boolean;
41
33
  }>;
42
34
  getAccuracy(extra?: {}): Promise<Record<string, number>>;
43
- getLinearAcceleration(extra?: {}): Promise<{
44
- x: number;
45
- y: number;
46
- z: number;
47
- }>;
35
+ getLinearAcceleration(extra?: {}): Promise<import("../../types").Vector3D>;
48
36
  getReadings(extra?: {}): Promise<Record<string, unknown>>;
49
37
  }
package/dist/main.d.ts CHANGED
@@ -1,9 +1,4 @@
1
1
  import Client from './Client';
2
- import * as Base from './components/base/Base';
3
- import * as Board from './components/board/Board';
4
- import * as Camera from './components/camera/Camera';
5
- import * as Motor from './components/motor/Motor';
6
- export { Base, Board, Camera, Motor };
7
2
  import armApi from './gen/component/arm/v1/arm_pb.esm';
8
3
  import baseApi from './gen/component/base/v1/base_pb.esm';
9
4
  import boardApi from './gen/component/board/v1/board_pb.esm';
@@ -26,10 +21,10 @@ import streamApi from './gen/proto/stream/v1/stream_pb.esm';
26
21
  import visionApi from './gen/service/vision/v1/vision_pb.esm';
27
22
  export { type Robot, RobotClient } from './components/robot';
28
23
  export { type Arm, ArmClient } from './components/arm';
29
- export { BaseClient } from './components/base';
30
- export { BoardClient } from './components/board';
31
- export { CameraClient } from './components/camera';
32
- export { MotorClient } from './components/motor';
24
+ export { type Base, BaseClient } from './components/base';
25
+ export { type Board, BoardClient } from './components/board';
26
+ export { type Camera, CameraClient } from './components/camera';
27
+ export { type Motor, MotorClient } from './components/motor';
33
28
  export { type MovementSensor, MovementSensorClient, } from './components/movementsensor';
34
29
  export { type Sensor, SensorClient } from './components/sensor';
35
30
  export { type Stream, StreamClient } from './extra/stream';
package/dist/main.es.js CHANGED
@@ -215289,18 +215289,6 @@ class Client {
215289
215289
  }
215290
215290
  }
215291
215291
  }
215292
- const Base = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
215293
- __proto__: null
215294
- }, Symbol.toStringTag, { value: "Module" })), Board = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
215295
- __proto__: null
215296
- }, Symbol.toStringTag, { value: "Module" }));
215297
- var MimeType = /* @__PURE__ */ ((o) => (o.VIAM_RGBA = "image/vnd.viam.rgba", o.JPEG = "image/jpeg", o.PNG = "image/png", o.PCD = "pointcloud/pcd", o.UNSUPPORTED = "unsupported", o))(MimeType || {});
215298
- const Camera = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
215299
- __proto__: null,
215300
- MimeType
215301
- }, Symbol.toStringTag, { value: "Module" })), Motor = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
215302
- __proto__: null
215303
- }, Symbol.toStringTag, { value: "Module" }));
215304
215292
  var commonjsGlobal$l = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, arm_pb = {}, googleProtobuf$m = {};
215305
215293
  (function(exports) {
215306
215294
  var $jscomp = $jscomp || {};
@@ -414579,6 +414567,15 @@ const promisify = function(o, e) {
414579
414567
  return new Promise((r, p) => {
414580
414568
  o(e, new grpcWebClient_umdExports.grpc.Metadata(), (t, n) => t ? p(t) : n ? r(n) : p(new Error("no response")));
414581
414569
  });
414570
+ }, encodeVector3D = function(o) {
414571
+ const e = new common_pb$e.Vector3();
414572
+ return e.setX(o.x), e.setY(o.y), e.setZ(o.z), e;
414573
+ }, decodeVector3D = function(o) {
414574
+ return {
414575
+ x: o.getX(),
414576
+ y: o.getY(),
414577
+ z: o.getZ()
414578
+ };
414582
414579
  };
414583
414580
  class RobotClient {
414584
414581
  client;
@@ -419173,14 +419170,14 @@ class BaseClient {
419173
419170
  }
419174
419171
  async setPower(e, r, p = {}) {
419175
419172
  const t = this.baseService, n = new base_pb.SetPowerRequest();
419176
- n.setName(this.name), n.setLinear(e), n.setAngular(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419173
+ n.setName(this.name), n.setLinear(encodeVector3D(e)), n.setAngular(encodeVector3D(r)), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419177
419174
  t.setPower.bind(t),
419178
419175
  n
419179
419176
  );
419180
419177
  }
419181
419178
  async setVelocity(e, r, p = {}) {
419182
419179
  const t = this.baseService, n = new base_pb.SetVelocityRequest();
419183
- n.setName(this.name), n.setLinear(e), n.setAngular(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419180
+ n.setName(this.name), n.setLinear(encodeVector3D(e)), n.setAngular(encodeVector3D(r)), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419184
419181
  t.setVelocity.bind(t),
419185
419182
  n
419186
419183
  );
@@ -419203,13 +419200,33 @@ class BoardClient {
419203
419200
  get boardService() {
419204
419201
  return this.client;
419205
419202
  }
419206
- async status(e = {}) {
419203
+ async getRawStatusResponse(e = {}) {
419207
419204
  const r = this.boardService, p = new board_pb.StatusRequest();
419208
419205
  return p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p), await promisify(
419209
419206
  r.status.bind(r),
419210
419207
  p
419211
419208
  );
419212
419209
  }
419210
+ /**
419211
+ * Get the status of the board as a raw protobuf response.
419212
+ *
419213
+ * @deprecated Use {@link BoardClient#getStatus} instead.
419214
+ */
419215
+ status(e = {}) {
419216
+ return this.getRawStatusResponse(e);
419217
+ }
419218
+ async getStatus(e = {}) {
419219
+ const p = (await this.getRawStatusResponse(e)).getStatus();
419220
+ if (!p)
419221
+ throw new Error("no status");
419222
+ const t = {};
419223
+ for (const [i, s] of p.getAnalogsMap().entries())
419224
+ t[i] = s.getValue();
419225
+ const n = {};
419226
+ for (const [i, s] of p.getDigitalInterruptsMap().entries())
419227
+ n[i] = s.getValue();
419228
+ return { analogs: t, digitalInterrupts: n };
419229
+ }
419213
419230
  async setGPIO(e, r, p = {}) {
419214
419231
  const t = this.boardService, n = new board_pb.SetGPIORequest();
419215
419232
  n.setName(this.name), n.setPin(e), n.setHigh(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
@@ -419249,13 +419266,13 @@ class BoardClient {
419249
419266
  n
419250
419267
  );
419251
419268
  }
419252
- async readAnalogReader(e, r, p = {}) {
419253
- const t = this.boardService, n = new board_pb.ReadAnalogReaderRequest();
419254
- return n.setBoardName(e), n.setAnalogReaderName(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), (await promisify(t.readAnalogReader.bind(t), n)).getValue();
419269
+ async readAnalogReader(e, r = {}) {
419270
+ const p = this.boardService, t = new board_pb.ReadAnalogReaderRequest();
419271
+ return t.setBoardName(this.name), t.setAnalogReaderName(e), t.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(t), (await promisify(p.readAnalogReader.bind(p), t)).getValue();
419255
419272
  }
419256
- async getDigitalInterruptValue(e, r, p = {}) {
419257
- const t = this.boardService, n = new board_pb.GetDigitalInterruptValueRequest();
419258
- return n.setBoardName(e), n.setDigitalInterruptName(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), (await promisify(t.getDigitalInterruptValue.bind(t), n)).getValue();
419273
+ async getDigitalInterruptValue(e, r = {}) {
419274
+ const p = this.boardService, t = new board_pb.GetDigitalInterruptValueRequest();
419275
+ return t.setBoardName(this.name), t.setDigitalInterruptName(e), t.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(t), (await promisify(p.getDigitalInterruptValue.bind(p), t)).getValue();
419259
419276
  }
419260
419277
  }
419261
419278
  var commonjsGlobal$2 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, camera_pb = {}, googleProtobuf$2 = {};
@@ -431455,6 +431472,7 @@ CameraServiceClient.prototype.doCommand = function o(e, r, p) {
431455
431472
  };
431456
431473
  };
431457
431474
  var CameraServiceClient_1 = CameraServiceClient;
431475
+ const PointCloudPCD = "pointcloud/pcd";
431458
431476
  class CameraClient {
431459
431477
  client;
431460
431478
  name;
@@ -431483,7 +431501,7 @@ class CameraClient {
431483
431501
  }
431484
431502
  async getPointCloud() {
431485
431503
  const e = this.cameraService, r = new camera_pb$1.GetPointCloudRequest();
431486
- return r.setName(this.name), r.setMimeType(MimeType.PCD), this.options.requestLogger?.(r), (await promisify(e.getPointCloud.bind(e), r)).getPointCloud_asU8();
431504
+ return r.setName(this.name), r.setMimeType(PointCloudPCD), this.options.requestLogger?.(r), (await promisify(e.getPointCloud.bind(e), r)).getPointCloud_asU8();
431487
431505
  }
431488
431506
  async getProperties() {
431489
431507
  const e = this.cameraService, r = new camera_pb$1.GetPropertiesRequest();
@@ -431532,10 +431550,6 @@ class MotorClient {
431532
431550
  p
431533
431551
  );
431534
431552
  }
431535
- /** @deprecated Use {@link MotorClient#stop} instead. */
431536
- motorStop(e = {}) {
431537
- return this.stop(e);
431538
- }
431539
431553
  async getProperties(e = {}) {
431540
431554
  const r = this.motorService, p = new motor_pb.GetPropertiesRequest();
431541
431555
  return p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p), { positionReporting: (await promisify(r.getProperties.bind(r), p)).getPositionReporting() };
@@ -442714,11 +442728,7 @@ class MovementSensorClient {
442714
442728
  )).getLinearVelocity();
442715
442729
  if (!n)
442716
442730
  throw new Error("no linear velocity");
442717
- return {
442718
- x: n.getX(),
442719
- y: n.getY(),
442720
- z: n.getZ()
442721
- };
442731
+ return decodeVector3D(n);
442722
442732
  }
442723
442733
  async getAngularVelocity(e = {}) {
442724
442734
  const r = this.movementsensorService, p = new movementsensor_pb.GetAngularVelocityRequest();
@@ -442729,11 +442739,7 @@ class MovementSensorClient {
442729
442739
  )).getAngularVelocity();
442730
442740
  if (!n)
442731
442741
  throw new Error("no angular velocity");
442732
- return {
442733
- x: n.getX(),
442734
- y: n.getY(),
442735
- z: n.getZ()
442736
- };
442742
+ return decodeVector3D(n);
442737
442743
  }
442738
442744
  async getCompassHeading(e = {}) {
442739
442745
  const r = this.movementsensorService, p = new movementsensor_pb.GetCompassHeadingRequest();
@@ -442800,11 +442806,7 @@ class MovementSensorClient {
442800
442806
  )).getLinearAcceleration();
442801
442807
  if (!n)
442802
442808
  throw new Error("no linear acceleration");
442803
- return {
442804
- x: n.getX(),
442805
- y: n.getY(),
442806
- z: n.getZ()
442807
- };
442809
+ return decodeVector3D(n);
442808
442810
  }
442809
442811
  getReadings(e = {}) {
442810
442812
  return this.sensorclient.getReadings(e);
@@ -447988,14 +447990,10 @@ class StreamClient extends EventDispatcher {
447988
447990
  }
447989
447991
  export {
447990
447992
  ArmClient,
447991
- Base,
447992
447993
  BaseClient,
447993
- Board,
447994
447994
  BoardClient,
447995
- Camera,
447996
447995
  CameraClient,
447997
447996
  Client,
447998
- Motor,
447999
447997
  MotorClient,
448000
447998
  MovementSensorClient,
448001
447999
  RobotClient,