@viamrobotics/sdk 0.0.23 → 0.0.25

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,28 +1,36 @@
1
- import type { Pose, WorldState } from '../../gen/common/v1/common_pb.esm';
1
+ import type { WorldState } from '../../gen/common/v1/common_pb.esm';
2
2
  import type { JointPositions } from '../../gen/component/arm/v1/arm_pb.esm';
3
- import type { Extra } from '../../types';
3
+ import type { Extra, Pose } from '../../types';
4
4
  /** Represents a physical robot arm that exists in three-dimensional space. */
5
5
  export interface Arm {
6
6
  /** Get the position of the end of the arm expressed as a pose */
7
- GetEndPosition: (extra?: Extra) => Promise<Pose>;
7
+ getEndPosition: (extra?: Extra) => Promise<Pose>;
8
8
  /**
9
- * Move the end of the arm to the pose, avoiding obstacles in the worldstate
9
+ * Move the end of the arm to the pose, avoiding obstacles in the worldstate.
10
10
  *
11
11
  * @param pose - The destination pose for the arm
12
12
  * @param world - The obstacles for the arm to avoid
13
13
  */
14
- MoveToPosition: (pose: Pose, world: WorldState, extra?: Extra) => Promise<void>;
14
+ moveToPosition: (pose: Pose, world?: WorldState, extra?: Extra) => Promise<void>;
15
15
  /**
16
- * Move each joint of the arm based on the angles on the joint poisitons
16
+ * Move each joint of the arm based on the angles on the joint poisitons.
17
17
  * parameter
18
18
  *
19
- * @param jointPositions - Destination joint positons
19
+ * @param jointPositionsList - List of angles (0-360) to move each joint to.
20
20
  */
21
- MoveToJointPositions: (jointPositions: JointPositions, extra?: Extra) => Promise<void>;
22
- /** Gets the current position of each joint */
23
- GetJointPositions: (extra: Extra) => Promise<JointPositions>;
24
- /** Stops the motion of the arm */
25
- Stop: (extra: Extra) => Promise<void>;
26
- /** Get if the arm is currently moving */
27
- IsMoving: () => Promise<boolean>;
21
+ moveToJointPositions: (jointPositionsList: number[], extra?: Extra) => Promise<void>;
22
+ /**
23
+ *Gets the current position of each joint.
24
+ *
25
+ */
26
+ getJointPositions: (extra: Extra) => Promise<JointPositions>;
27
+ /**
28
+ * Stops the motion of the arm.
29
+ * */
30
+ stop: (extra: Extra) => Promise<void>;
31
+ /**
32
+ *
33
+ * Get if the arm is currently moving.
34
+ */
35
+ isMoving: () => Promise<boolean>;
28
36
  }
@@ -1,8 +1,8 @@
1
- import type { Pose, WorldState } from '../../gen/common/v1/common_pb.esm';
2
1
  import type Client from '../../Client';
3
2
  import pb from '../../gen/component/arm/v1/arm_pb.esm';
4
- import type { Options } from '../../types';
3
+ import type { Options, Pose } from '../../types';
5
4
  import type { Arm } from './Arm';
5
+ import commonPB from '../../gen/common/v1/common_pb.esm';
6
6
  /** A gRPC-web client for the Arm component. */
7
7
  export declare class ArmClient implements Arm {
8
8
  private client;
@@ -10,10 +10,18 @@ export declare class ArmClient implements Arm {
10
10
  private readonly options;
11
11
  constructor(client: Client, name: string, options?: Options);
12
12
  private get ArmService();
13
- GetEndPosition(extra?: {}): Promise<import("../../gen/common/v1/common_pb").Pose>;
14
- MoveToPosition(pose: Pose, world: WorldState, extra?: {}): Promise<void>;
15
- MoveToJointPositions(jointPositions: pb.JointPositions, extra?: {}): Promise<void>;
16
- GetJointPositions(extra?: {}): Promise<pb.JointPositions>;
17
- Stop(extra?: {}): Promise<void>;
18
- IsMoving(): Promise<boolean>;
13
+ getEndPosition(extra?: {}): Promise<{
14
+ x: number;
15
+ y: number;
16
+ z: number;
17
+ ox: number;
18
+ oy: number;
19
+ oz: number;
20
+ theta: number;
21
+ }>;
22
+ moveToPosition(pose: Pose, world?: commonPB.WorldState, extra?: {}): Promise<void>;
23
+ moveToJointPositions(jointPositionsList: number[], extra?: {}): Promise<void>;
24
+ getJointPositions(extra?: {}): Promise<pb.JointPositions>;
25
+ stop(extra?: {}): Promise<void>;
26
+ isMoving(): Promise<boolean>;
19
27
  }
package/dist/main.d.ts CHANGED
@@ -26,10 +26,10 @@ import streamApi from './gen/proto/stream/v1/stream_pb.esm';
26
26
  import visionApi from './gen/service/vision/v1/vision_pb.esm';
27
27
  export { type Robot, RobotClient } from './components/robot';
28
28
  export { type Arm, ArmClient } from './components/arm';
29
- export { type BaseClient } from './components/base';
30
- export { type BoardClient } from './components/board';
31
- export { type CameraClient } from './components/camera';
32
- export { type MotorClient } from './components/motor';
29
+ export { BaseClient } from './components/base';
30
+ export { BoardClient } from './components/board';
31
+ export { CameraClient } from './components/camera';
32
+ export { MotorClient } from './components/motor';
33
33
  export { type MovementSensor, MovementSensorClient, } from './components/movementsensor';
34
34
  export { type Sensor, SensorClient } from './components/sensor';
35
35
  export { type Stream, StreamClient } from './extra/stream';
package/dist/main.es.js CHANGED
@@ -419093,26 +419093,38 @@ class ArmClient {
419093
419093
  get ArmService() {
419094
419094
  return this.client;
419095
419095
  }
419096
- async GetEndPosition(e = {}) {
419096
+ async getEndPosition(e = {}) {
419097
419097
  const r = this.ArmService, p = new arm_pb.GetEndPositionRequest();
419098
419098
  p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p);
419099
419099
  const n = (await promisify(r.getEndPosition.bind(r), p)).getPose();
419100
419100
  if (!n)
419101
419101
  throw new Error("no pose");
419102
- return n;
419102
+ return {
419103
+ x: n.getX(),
419104
+ y: n.getY(),
419105
+ z: n.getZ(),
419106
+ ox: n.getOX(),
419107
+ oy: n.getOY(),
419108
+ oz: n.getOZ(),
419109
+ theta: n.getTheta()
419110
+ };
419103
419111
  }
419104
- async MoveToPosition(e, r, p = {}) {
419105
- const t = this.ArmService, n = new arm_pb.MoveToPositionRequest();
419106
- n.setTo(e), n.setWorldState(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419112
+ async moveToPosition(e, r, p = {}) {
419113
+ const t = this.ArmService, n = new common_pb$e.Pose();
419114
+ n.setX(e.x), n.setY(e.y), n.setZ(e.z), n.setOX(e.ox), n.setOY(e.oy), n.setOZ(e.oz), n.setTheta(e.theta);
419115
+ const i = new arm_pb.MoveToPositionRequest();
419116
+ i.setName(this.name), i.setTo(n), i.setWorldState(r), i.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(i), await promisify(
419107
419117
  t.moveToPosition.bind(t),
419108
- n
419118
+ i
419109
419119
  );
419110
419120
  }
419111
- async MoveToJointPositions(e, r = {}) {
419112
- const p = this.ArmService, t = new arm_pb.MoveToJointPositionsRequest();
419113
- t.setName(this.name), t.setPositions(e), t.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(t), await promisify(p.moveToJointPositions.bind(p), t);
419121
+ async moveToJointPositions(e, r = {}) {
419122
+ const p = this.ArmService, t = new arm_pb.JointPositions();
419123
+ t.setValuesList(e);
419124
+ const n = new arm_pb.MoveToJointPositionsRequest();
419125
+ n.setName(this.name), n.setPositions(t), n.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(n), await promisify(p.moveToJointPositions.bind(p), n);
419114
419126
  }
419115
- async GetJointPositions(e = {}) {
419127
+ async getJointPositions(e = {}) {
419116
419128
  const r = this.ArmService, p = new arm_pb.GetJointPositionsRequest();
419117
419129
  p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p);
419118
419130
  const n = (await promisify(r.getJointPositions.bind(r), p)).getPositions();
@@ -419120,14 +419132,14 @@ class ArmClient {
419120
419132
  throw new Error("no pose");
419121
419133
  return n;
419122
419134
  }
419123
- async Stop(e = {}) {
419135
+ async stop(e = {}) {
419124
419136
  const r = this.ArmService, p = new arm_pb.StopRequest();
419125
419137
  p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p), await promisify(
419126
419138
  r.getJointPositions.bind(r),
419127
419139
  p
419128
419140
  );
419129
419141
  }
419130
- async IsMoving() {
419142
+ async isMoving() {
419131
419143
  const e = this.ArmService, r = new arm_pb.IsMovingRequest();
419132
419144
  return this.options.requestLogger?.(r), (await promisify(
419133
419145
  e.isMoving.bind(e),
@@ -419135,6 +419147,117 @@ class ArmClient {
419135
419147
  )).getIsMoving();
419136
419148
  }
419137
419149
  }
419150
+ class BaseClient {
419151
+ client;
419152
+ name;
419153
+ options;
419154
+ constructor(e, r, p = {}) {
419155
+ this.client = e.createServiceClient(BaseServiceClient_1), this.name = r, this.options = p;
419156
+ }
419157
+ get baseService() {
419158
+ return this.client;
419159
+ }
419160
+ async moveStraight(e, r, p = {}) {
419161
+ const t = this.baseService, n = new base_pb.MoveStraightRequest();
419162
+ n.setName(this.name), n.setMmPerSec(r), n.setDistanceMm(e), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419163
+ t.moveStraight.bind(t),
419164
+ n
419165
+ );
419166
+ }
419167
+ async spin(e, r, p = {}) {
419168
+ const t = this.baseService, n = new base_pb.SpinRequest();
419169
+ n.setName(this.name), n.setAngleDeg(e), n.setDegsPerSec(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419170
+ t.spin.bind(t),
419171
+ n
419172
+ );
419173
+ }
419174
+ async setPower(e, r, p = {}) {
419175
+ 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(
419177
+ t.setPower.bind(t),
419178
+ n
419179
+ );
419180
+ }
419181
+ async setVelocity(e, r, p = {}) {
419182
+ 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(
419184
+ t.setVelocity.bind(t),
419185
+ n
419186
+ );
419187
+ }
419188
+ async stop(e = {}) {
419189
+ const r = this.baseService, p = new base_pb.StopRequest();
419190
+ p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p), await promisify(
419191
+ r.stop.bind(r),
419192
+ p
419193
+ );
419194
+ }
419195
+ }
419196
+ class BoardClient {
419197
+ client;
419198
+ name;
419199
+ options;
419200
+ constructor(e, r, p = {}) {
419201
+ this.client = e.createServiceClient(BoardServiceClient_1), this.name = r, this.options = p;
419202
+ }
419203
+ get boardService() {
419204
+ return this.client;
419205
+ }
419206
+ async status(e = {}) {
419207
+ const r = this.boardService, p = new board_pb.StatusRequest();
419208
+ return p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p), await promisify(
419209
+ r.status.bind(r),
419210
+ p
419211
+ );
419212
+ }
419213
+ async setGPIO(e, r, p = {}) {
419214
+ const t = this.boardService, n = new board_pb.SetGPIORequest();
419215
+ n.setName(this.name), n.setPin(e), n.setHigh(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419216
+ t.setGPIO.bind(t),
419217
+ n
419218
+ );
419219
+ }
419220
+ async getGPIO(e, r = {}) {
419221
+ const p = this.boardService, t = new board_pb.GetGPIORequest();
419222
+ return t.setName(this.name), t.setPin(e), t.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(t), (await promisify(
419223
+ p.getGPIO.bind(p),
419224
+ t
419225
+ )).getHigh();
419226
+ }
419227
+ async getPWM(e, r = {}) {
419228
+ const p = this.boardService, t = new board_pb.PWMRequest();
419229
+ return t.setName(this.name), t.setPin(e), t.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(t), (await promisify(
419230
+ p.pWM.bind(p),
419231
+ t
419232
+ )).getDutyCyclePct();
419233
+ }
419234
+ async setPWM(e, r, p = {}) {
419235
+ const t = this.boardService, n = new board_pb.SetPWMRequest();
419236
+ n.setName(this.name), n.setPin(e), n.setDutyCyclePct(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419237
+ t.setPWM.bind(t),
419238
+ n
419239
+ );
419240
+ }
419241
+ async getPWMFrequency(e, r = {}) {
419242
+ const p = this.boardService, t = new board_pb.PWMFrequencyRequest();
419243
+ return t.setName(this.name), t.setPin(e), t.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(t), (await promisify(p.pWMFrequency.bind(p), t)).getFrequencyHz();
419244
+ }
419245
+ async setPWMFrequency(e, r, p = {}) {
419246
+ const t = this.boardService, n = new board_pb.SetPWMFrequencyRequest();
419247
+ n.setName(this.name), n.setPin(e), n.setFrequencyHz(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
419248
+ t.setPWMFrequency.bind(t),
419249
+ n
419250
+ );
419251
+ }
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();
419255
+ }
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();
419259
+ }
419260
+ }
419138
419261
  var commonjsGlobal$2 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, camera_pb = {}, googleProtobuf$2 = {};
419139
419262
  (function(exports) {
419140
419263
  var $jscomp = $jscomp || {};
@@ -431331,6 +431454,103 @@ CameraServiceClient.prototype.doCommand = function o(e, r, p) {
431331
431454
  }
431332
431455
  };
431333
431456
  };
431457
+ var CameraServiceClient_1 = CameraServiceClient;
431458
+ class CameraClient {
431459
+ client;
431460
+ name;
431461
+ options;
431462
+ constructor(e, r, p = {}) {
431463
+ this.client = e.createServiceClient(CameraServiceClient_1), this.name = r, this.options = p;
431464
+ }
431465
+ get cameraService() {
431466
+ return this.client;
431467
+ }
431468
+ async getImage(e) {
431469
+ const r = this.cameraService, p = new camera_pb$1.GetImageRequest();
431470
+ return p.setName(this.name), p.setMimeType(e), this.options.requestLogger?.(p), (await promisify(
431471
+ r.getImage.bind(r),
431472
+ p
431473
+ )).getImage_asU8();
431474
+ }
431475
+ async renderFrame(e) {
431476
+ const r = this.cameraService, p = new camera_pb$1.GetPointCloudRequest();
431477
+ p.setName(this.name), p.setMimeType(e), this.options.requestLogger?.(p);
431478
+ const t = await promisify(
431479
+ r.renderFrame.bind(r),
431480
+ p
431481
+ );
431482
+ return new Blob([t.getData_asU8()], { type: e });
431483
+ }
431484
+ async getPointCloud() {
431485
+ 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();
431487
+ }
431488
+ async getProperties() {
431489
+ const e = this.cameraService, r = new camera_pb$1.GetPropertiesRequest();
431490
+ return r.setName(this.name), this.options.requestLogger?.(r), (await promisify(e.getProperties.bind(e), r)).toObject();
431491
+ }
431492
+ }
431493
+ class MotorClient {
431494
+ client;
431495
+ name;
431496
+ options;
431497
+ constructor(e, r, p = {}) {
431498
+ this.client = e.createServiceClient(MotorServiceClient_1), this.name = r, this.options = p;
431499
+ }
431500
+ get motorService() {
431501
+ return this.client;
431502
+ }
431503
+ async setPower(e, r = {}) {
431504
+ const p = this.motorService, t = new motor_pb.SetPowerRequest();
431505
+ t.setName(this.name), t.setPowerPct(e), t.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(t), await promisify(
431506
+ p.setPower.bind(p),
431507
+ t
431508
+ );
431509
+ }
431510
+ async goFor(e, r, p = {}) {
431511
+ const t = this.motorService, n = new motor_pb.GoForRequest();
431512
+ n.setName(this.name), n.setRpm(e), n.setRevolutions(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
431513
+ t.goFor.bind(t),
431514
+ n
431515
+ );
431516
+ }
431517
+ async goTo(e, r, p = {}) {
431518
+ const t = this.motorService, n = new motor_pb.GoToRequest();
431519
+ n.setName(this.name), n.setRpm(e), n.setPositionRevolutions(r), n.setExtra(struct_pb$2.Struct.fromJavaScript(p)), this.options.requestLogger?.(n), await promisify(
431520
+ t.goTo.bind(t),
431521
+ n
431522
+ );
431523
+ }
431524
+ async resetZeroPosition(e, r = {}) {
431525
+ const p = this.motorService, t = new motor_pb.ResetZeroPositionRequest();
431526
+ t.setName(this.name), t.setOffset(e), t.setExtra(struct_pb$2.Struct.fromJavaScript(r)), this.options.requestLogger?.(t), await promisify(p.resetZeroPosition.bind(p), t);
431527
+ }
431528
+ async stop(e = {}) {
431529
+ const r = this.motorService, p = new motor_pb.StopRequest();
431530
+ p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p), await promisify(
431531
+ r.stop.bind(r),
431532
+ p
431533
+ );
431534
+ }
431535
+ /** @deprecated Use {@link MotorClient#stop} instead. */
431536
+ motorStop(e = {}) {
431537
+ return this.stop(e);
431538
+ }
431539
+ async getProperties(e = {}) {
431540
+ const r = this.motorService, p = new motor_pb.GetPropertiesRequest();
431541
+ 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() };
431542
+ }
431543
+ async getPosition(e = {}) {
431544
+ const r = this.motorService, p = new motor_pb.GetPositionRequest();
431545
+ return p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p), (await promisify(r.getPosition.bind(r), p)).getPosition();
431546
+ }
431547
+ async isPowered(e = {}) {
431548
+ const r = this.motorService, p = new motor_pb.IsPoweredRequest();
431549
+ p.setName(this.name), p.setExtra(struct_pb$2.Struct.fromJavaScript(e)), this.options.requestLogger?.(p);
431550
+ const t = await promisify(r.isPowered.bind(r), p);
431551
+ return [t.getIsOn(), t.getPowerPct()];
431552
+ }
431553
+ }
431334
431554
  var commonjsGlobal$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, sensor_pb = {}, googleProtobuf$1 = {};
431335
431555
  (function(exports) {
431336
431556
  var $jscomp = $jscomp || {};
@@ -447769,10 +447989,14 @@ class StreamClient extends EventDispatcher {
447769
447989
  export {
447770
447990
  ArmClient,
447771
447991
  Base,
447992
+ BaseClient,
447772
447993
  Board,
447994
+ BoardClient,
447773
447995
  Camera,
447996
+ CameraClient,
447774
447997
  Client,
447775
447998
  Motor,
447999
+ MotorClient,
447776
448000
  MovementSensorClient,
447777
448001
  RobotClient,
447778
448002
  SensorClient,