@viamrobotics/sdk 0.0.54 → 0.0.55-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.
- package/README.md +5 -1
- package/dist/components/servo/client.d.ts +20 -0
- package/dist/components/servo/servo.d.ts +12 -0
- package/dist/components/servo.d.ts +2 -0
- package/dist/gen/google/api/client_pb.d.ts +3 -0
- package/dist/main.d.ts +2 -19
- package/dist/main.es.js +42 -1
- package/dist/main.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
## (In)stability Notice
|
|
8
8
|
|
|
9
9
|
> **Warning**
|
|
10
|
-
> This is
|
|
10
|
+
> This is a beta release of the Viam TypeScript SDK. Stability is not guaranteed. Breaking changes are likely to occur, and occur often.
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
@@ -21,6 +21,10 @@ npm install --save @viamrobotics/sdk
|
|
|
21
21
|
|
|
22
22
|
[The examples directory](https://github.com/viamrobotics/viam-typescript-sdk/tree/main/examples) contains small apps that demonstrate how to use this SDK to operate a robot running Viam.
|
|
23
23
|
|
|
24
|
+
### Documentation
|
|
25
|
+
|
|
26
|
+
[https://ts.viam.dev](https://ts.viam.dev/)
|
|
27
|
+
|
|
24
28
|
## License
|
|
25
29
|
Copyright 2022-2023 Viam Inc.
|
|
26
30
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RobotClient } from '../../robot';
|
|
2
|
+
import type { Options, StructType } from '../../types';
|
|
3
|
+
import type { Servo } from './servo';
|
|
4
|
+
/**
|
|
5
|
+
* A gRPC-web client for the Servo component.
|
|
6
|
+
*
|
|
7
|
+
* @group Clients
|
|
8
|
+
*/
|
|
9
|
+
export declare class ServoClient implements Servo {
|
|
10
|
+
private client;
|
|
11
|
+
private readonly name;
|
|
12
|
+
private readonly options;
|
|
13
|
+
constructor(client: RobotClient, name: string, options?: Options);
|
|
14
|
+
private get servoService();
|
|
15
|
+
move(angleDeg: number, extra?: StructType): Promise<void>;
|
|
16
|
+
getPosition(extra?: StructType): Promise<number>;
|
|
17
|
+
stop(extra?: {}): Promise<void>;
|
|
18
|
+
isMoving(): Promise<boolean>;
|
|
19
|
+
doCommand(command: StructType): Promise<StructType>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Resource, StructType } from '../../types';
|
|
2
|
+
/** Represents a physical servo. */
|
|
3
|
+
export interface Servo extends Resource {
|
|
4
|
+
/** Move the servo by a given angle in degrees. */
|
|
5
|
+
move(angleDeg: number, extra?: StructType): Promise<void>;
|
|
6
|
+
/** Return the current set angle of the servo in degrees. */
|
|
7
|
+
getPosition(extra?: StructType): Promise<number>;
|
|
8
|
+
/** Stop the servo. */
|
|
9
|
+
stop(extra?: StructType): Promise<void>;
|
|
10
|
+
/** Return true if the servo is in motion. */
|
|
11
|
+
isMoving(): Promise<boolean>;
|
|
12
|
+
}
|
package/dist/main.d.ts
CHANGED
|
@@ -282,29 +282,12 @@ export { default as navigationApi } from './gen/service/navigation/v1/navigation
|
|
|
282
282
|
*
|
|
283
283
|
* Generated with https://github.com/improbable-eng/grpc-web
|
|
284
284
|
*
|
|
285
|
-
* @
|
|
286
|
-
*
|
|
287
|
-
* ```ts
|
|
288
|
-
* import { grpc } from '@improbable-eng/grpc-web';
|
|
289
|
-
*
|
|
290
|
-
* const client = {}; // replace with a connected robot client
|
|
291
|
-
*
|
|
292
|
-
* const request = new servoApi.GetPositionRequest();
|
|
293
|
-
* request.setName('myservo');
|
|
294
|
-
*
|
|
295
|
-
* client.servoService.getPosition(
|
|
296
|
-
* request,
|
|
297
|
-
* new grpc.Metadata(),
|
|
298
|
-
* (error, response) => {
|
|
299
|
-
* // do something with error or response
|
|
300
|
-
* }
|
|
301
|
-
* );
|
|
302
|
-
* ```
|
|
303
|
-
*
|
|
285
|
+
* @deprecated Use {@link ServoClient} instead.
|
|
304
286
|
* @alpha
|
|
305
287
|
* @group Raw Protobufs
|
|
306
288
|
*/
|
|
307
289
|
export { default as servoApi } from './gen/component/servo/v1/servo_pb';
|
|
290
|
+
export { type Servo, ServoClient } from './components/servo';
|
|
308
291
|
/**
|
|
309
292
|
* Raw Protobuf interfaces for a Slam service.
|
|
310
293
|
*
|
package/dist/main.es.js
CHANGED
|
@@ -40741,7 +40741,47 @@ class DataManagerClient {
|
|
|
40741
40741
|
);
|
|
40742
40742
|
}
|
|
40743
40743
|
}
|
|
40744
|
-
|
|
40744
|
+
class ServoClient {
|
|
40745
|
+
client;
|
|
40746
|
+
name;
|
|
40747
|
+
options;
|
|
40748
|
+
constructor(e, s, i = {}) {
|
|
40749
|
+
this.client = e.createServiceClient(ServoServiceClient_1), this.name = s, this.options = i;
|
|
40750
|
+
}
|
|
40751
|
+
get servoService() {
|
|
40752
|
+
return this.client;
|
|
40753
|
+
}
|
|
40754
|
+
async move(e, s = {}) {
|
|
40755
|
+
const { servoService: i } = this, u = new servo_pb.MoveRequest();
|
|
40756
|
+
u.setName(this.name), u.setAngleDeg(e), u.setExtra(struct_pb.Struct.fromJavaScript(s)), this.options.requestLogger?.(u), await promisify(
|
|
40757
|
+
i.move.bind(i),
|
|
40758
|
+
u
|
|
40759
|
+
);
|
|
40760
|
+
}
|
|
40761
|
+
async getPosition(e = {}) {
|
|
40762
|
+
const { servoService: s } = this, i = new servo_pb.GetPositionRequest();
|
|
40763
|
+
return i.setName(this.name), i.setExtra(struct_pb.Struct.fromJavaScript(e)), this.options.requestLogger?.(i), (await promisify(s.getPosition.bind(s), i)).getPositionDeg();
|
|
40764
|
+
}
|
|
40765
|
+
async stop(e = {}) {
|
|
40766
|
+
const { servoService: s } = this, i = new servo_pb.StopRequest();
|
|
40767
|
+
i.setName(this.name), i.setExtra(struct_pb.Struct.fromJavaScript(e)), this.options.requestLogger?.(i), await promisify(
|
|
40768
|
+
s.stop.bind(s),
|
|
40769
|
+
i
|
|
40770
|
+
);
|
|
40771
|
+
}
|
|
40772
|
+
async isMoving() {
|
|
40773
|
+
const { servoService: e } = this, s = new servo_pb.IsMovingRequest();
|
|
40774
|
+
return s.setName(this.name), this.options.requestLogger?.(s), (await promisify(
|
|
40775
|
+
e.isMoving.bind(e),
|
|
40776
|
+
s
|
|
40777
|
+
)).getIsMoving();
|
|
40778
|
+
}
|
|
40779
|
+
async doCommand(e) {
|
|
40780
|
+
const { servoService: s } = this;
|
|
40781
|
+
return doCommandFromClient(s, this.name, e, this.options);
|
|
40782
|
+
}
|
|
40783
|
+
}
|
|
40784
|
+
const version = "0.0.55-rc.0";
|
|
40745
40785
|
export {
|
|
40746
40786
|
ArmClient,
|
|
40747
40787
|
BaseClient,
|
|
@@ -40757,6 +40797,7 @@ export {
|
|
|
40757
40797
|
MovementSensorClient,
|
|
40758
40798
|
RobotClient,
|
|
40759
40799
|
SensorClient,
|
|
40800
|
+
ServoClient,
|
|
40760
40801
|
StreamClient,
|
|
40761
40802
|
arm_pb as armApi,
|
|
40762
40803
|
base_pb as baseApi,
|