@viamrobotics/sdk 0.2.4 → 0.2.5-next.1

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,5 +1,5 @@
1
1
  import type { Credentials } from '@viamrobotics/rpc/src/dial';
2
- import type { grpc } from '@improbable-eng/grpc-web';
2
+ import { grpc } from '@improbable-eng/grpc-web';
3
3
  import { EventDispatcher } from '../events';
4
4
  import proto from '../gen/robot/v1/robot_pb';
5
5
  import type { PoseInFrame, ResourceName, Transform } from '../gen/common/v1/common_pb';
@@ -30,6 +30,11 @@ interface WebRTCOptions {
30
30
  reconnectMaxAttempts?: number;
31
31
  reconnectMaxWait?: number;
32
32
  }
33
+ interface DirectOptions {
34
+ noReconnect?: boolean;
35
+ reconnectMaxAttempts?: number;
36
+ reconnectMaxWait?: number;
37
+ }
33
38
  interface SessionOptions {
34
39
  disabled: boolean;
35
40
  }
@@ -46,7 +51,9 @@ declare abstract class ServiceClient {
46
51
  export declare class RobotClient extends EventDispatcher implements Robot {
47
52
  private readonly serviceHost;
48
53
  private readonly webrtcOptions;
54
+ private readonly directOptions;
49
55
  private readonly sessionOptions;
56
+ private gRPCConnectionManager;
50
57
  private sessionManager;
51
58
  private peerConn;
52
59
  private transportFactory;
@@ -71,7 +78,10 @@ export declare class RobotClient extends EventDispatcher implements Robot {
71
78
  private sensorsServiceClient;
72
79
  private servoServiceClient;
73
80
  private slamServiceClient;
74
- constructor(serviceHost: string, webrtcOptions?: WebRTCOptions, sessionOptions?: SessionOptions);
81
+ constructor(serviceHost: string, webrtcOptions?: WebRTCOptions, sessionOptions?: SessionOptions, directOptions?: DirectOptions);
82
+ private get noReconnect();
83
+ private get reconnectMaxAttempts();
84
+ private get reconnectMaxWait();
75
85
  get sessionId(): string;
76
86
  private static readonly notConnectedYetStr;
77
87
  get robotService(): RobotServiceClient;
@@ -9,6 +9,9 @@ export interface DialDirectConf {
9
9
  host: string;
10
10
  credential?: Credential;
11
11
  disableSessions?: boolean;
12
+ noReconnect?: boolean;
13
+ reconnectMaxAttempts?: number;
14
+ reconnectMaxWait?: number;
12
15
  }
13
16
  interface ICEServer {
14
17
  urls: string;
@@ -27,11 +30,11 @@ export interface DialWebRTCConf {
27
30
  host: string;
28
31
  credential?: Credential;
29
32
  disableSessions?: boolean;
33
+ noReconnect?: boolean;
30
34
  reconnectMaxAttempts?: number;
31
35
  reconnectMaxWait?: number;
32
36
  signalingAddress: string;
33
37
  iceServers?: ICEServer[];
34
- noReconnect?: boolean;
35
38
  }
36
39
  /** Options required to dial a robot. */
37
40
  export type DialConf = DialDirectConf | DialWebRTCConf;
@@ -0,0 +1,12 @@
1
+ import { grpc } from '@improbable-eng/grpc-web';
2
+ export default class GRPCConnectionManager {
3
+ private innerTransportFactory;
4
+ private client;
5
+ private heartbeatIntervalMs;
6
+ connecting: Promise<void> | undefined;
7
+ private connectResolve;
8
+ private connectReject;
9
+ constructor(serviceHost: string, transportFactory: grpc.TransportFactory);
10
+ heartbeat(): void;
11
+ start(): Promise<void>;
12
+ }
@@ -1,5 +1,5 @@
1
1
  import type { RobotClient } from '../../robot';
2
- import type { Options, Pose, PoseInFrame, ResourceName, StructType, Transform, WorldState } from '../../types';
2
+ import type { GeoObstacle, GeoPoint, Options, Pose, PoseInFrame, ResourceName, StructType, Transform, WorldState } from '../../types';
3
3
  import { type Constraints } from './types';
4
4
  import type { Motion } from './motion';
5
5
  /**
@@ -15,6 +15,7 @@ export declare class MotionClient implements Motion {
15
15
  private get service();
16
16
  move(destination: PoseInFrame, componentName: ResourceName, worldState?: WorldState, constraints?: Constraints, extra?: {}): Promise<boolean>;
17
17
  moveOnMap(destination: Pose, componentName: ResourceName, slamServiceName: ResourceName, extra?: {}): Promise<boolean>;
18
+ moveOnGlobe(destination: GeoPoint, componentName: ResourceName, movementSensorName: ResourceName, heading?: number, obstaclesList?: GeoObstacle[], linearMetersPerSec?: number, angularDegPerSec?: number, extra?: {}): Promise<boolean>;
18
19
  moveSingleComponent(destination: PoseInFrame, componentName: ResourceName, worldState?: WorldState, extra?: {}): Promise<boolean>;
19
20
  getPose(componentName: ResourceName, destinationFrame: string, supplementalTransforms: Transform[], extra?: {}): Promise<import("../../gen/common/v1/common_pb").PoseInFrame.AsObject>;
20
21
  doCommand(command: StructType): Promise<StructType>;
@@ -1,4 +1,4 @@
1
- import type { Pose, PoseInFrame, Resource, ResourceName, StructType, Transform, WorldState } from '../../types';
1
+ import type { GeoObstacle, GeoPoint, Pose, PoseInFrame, Resource, ResourceName, StructType, Transform, WorldState } from '../../types';
2
2
  import type { Constraints } from './types';
3
3
  /**
4
4
  * A service that coordinates motion planning across all of the components in a
@@ -20,31 +20,53 @@ export interface Motion extends Resource {
20
20
  */
21
21
  move: (destination: PoseInFrame, componentName: ResourceName, worldState?: WorldState, constraints?: Constraints, extra?: StructType) => Promise<boolean>;
22
22
  /**
23
- * @param destination - Specify a destination to, which can be any pose with
23
+ * Move a component to a `Pose` in respect to the origin of the SLAM map.
24
+ *
25
+ * @param destination - Specify a destination to, which can be any `Pose` with
24
26
  * respect to the SLAM map's origin.
25
27
  * @param componentName - Component on the robot to move to the specified
26
28
  * destination.
27
- * @param slamServiceName - Name of the slam service from which the SLAM map
29
+ * @param slamServiceName - Name of the `SLAM` service from which the SLAM map
28
30
  * is requested
29
31
  */
30
32
  moveOnMap: (destination: Pose, componentName: ResourceName, slamServiceName: ResourceName, extra?: StructType) => Promise<boolean>;
31
33
  /**
34
+ * Move a component to a specific latitude and longitude, using a `Movement
35
+ * Sensor` to determine the location.
36
+ *
37
+ * @param destination - Destination for the component to move to, represented
38
+ * as a `GeoPoint`.
39
+ * @param componentName - The name of the component to move.
40
+ * @param movementSensorName - The name of the `Movement Sensor` used to check
41
+ * the robot's location.
42
+ * @param obstaclesList - Obstacles to consider when planning the motion of
43
+ * the component.
44
+ * @param heading - Compass heading, in degrees, to achieve at destination
45
+ * @param linearMetersPerSec - Linear velocity to target when moving.
46
+ * @param angularDegPerSec - Angular velocity to target when moving.
47
+ */
48
+ moveOnGlobe: (destination: GeoPoint, componentName: ResourceName, movementSensorName: ResourceName, heading?: number, obstaclesList?: GeoObstacle[], linearMetersPerSec?: number, angularDegPerSec?: number, extra?: StructType) => Promise<boolean>;
49
+ /**
50
+ * Move a single component.
51
+ *
32
52
  * @param destination - Destination to move to, which can a pose in the
33
53
  * reference frame of any frame in the robot's frame system.
34
54
  * @param componentName - Component on the robot to move to the specified
35
55
  * destination.
36
56
  * @param worldState - Avoid obstacles by specifying their geometries in the
37
- * world state. Augment the frame system of the robot by specifying
57
+ * `WorldState`. Augment the frame system of the robot by specifying
38
58
  * additional transforms to add to it for the duration of the Move.
39
59
  */
40
60
  moveSingleComponent: (destination: PoseInFrame, componentName: ResourceName, worldState?: WorldState, extra?: StructType) => Promise<boolean>;
41
61
  /**
42
- * @param componentName - The component whose pose is being requested.
43
- * @param destinationFrame - The reference frame in which the component's pose
44
- * should be provided, if unset this defaults to the "world" reference
45
- * frame.
46
- * @param supplementalTransforms - Pose information on any additional
47
- * reference frames that are needed to compute the component's pose.
62
+ * Get the current location and orientation of a component.
63
+ *
64
+ * @param componentName - The component whose `Pose` is being requested.
65
+ * @param destinationFrame - The reference frame in which the component's
66
+ * `Pose` should be provided, if unset this defaults to the "world"
67
+ * reference frame.
68
+ * @param supplementalTransforms - `Pose` information on any additional
69
+ * reference frames that are needed to compute the component's `Pose`.
48
70
  */
49
71
  getPose: (componentName: ResourceName, destinationFrame: string, supplementalTransforms: Transform[], extra?: StructType) => Promise<PoseInFrame>;
50
72
  }
@@ -0,0 +1,25 @@
1
+ import pb from '../../gen/service/navigation/v1/navigation_pb';
2
+ import { RobotClient } from '../../robot';
3
+ import type { GeoPoint, Options, StructType } from '../../types';
4
+ import type { ModeMap } from './types';
5
+ import type { Navigation } from './navigation';
6
+ /**
7
+ * A gRPC-web client for a Navigation service.
8
+ *
9
+ * @group Clients
10
+ */
11
+ export declare class NavigationClient implements Navigation {
12
+ private client;
13
+ private readonly name;
14
+ private readonly options;
15
+ constructor(client: RobotClient, name: string, options?: Options);
16
+ private get service();
17
+ getMode(extra?: {}): Promise<0 | 2 | 1>;
18
+ setMode(mode: ModeMap[keyof ModeMap], extra?: {}): Promise<void>;
19
+ getLocation(extra?: {}): Promise<import("../../gen/common/v1/common_pb").GeoPoint.AsObject>;
20
+ getWayPoints(extra?: {}): Promise<pb.Waypoint.AsObject[]>;
21
+ addWayPoint(location: GeoPoint, extra?: {}): Promise<void>;
22
+ removeWayPoint(id: string, extra?: {}): Promise<void>;
23
+ getObstacles(extra?: {}): Promise<import("../../gen/common/v1/common_pb").GeoObstacle.AsObject[]>;
24
+ doCommand(command: StructType): Promise<StructType>;
25
+ }
@@ -0,0 +1,36 @@
1
+ import type { GeoObstacle, GeoPoint, Resource, StructType } from '../../types';
2
+ import type { ModeMap, Waypoint } from './types';
3
+ /**
4
+ * A service that uses GPS to automatically navigate a robot to user defined
5
+ * endpoints.
6
+ */
7
+ export interface Navigation extends Resource {
8
+ /** Get the mode the robot is operating in. */
9
+ getMode: (extra?: StructType) => Promise<ModeMap[keyof ModeMap]>;
10
+ /**
11
+ * Set the mode the robot is operating in.
12
+ *
13
+ * @param mode - The mode for the service to operate in.
14
+ */
15
+ setMode: (mode: ModeMap[keyof ModeMap], extra?: StructType) => Promise<void>;
16
+ /** Get the current location of the robot. */
17
+ getLocation: (extra?: StructType) => Promise<GeoPoint>;
18
+ /** Get an array of waypoints currently in the service's data storage. */
19
+ getWayPoints: (extra?: StructType) => Promise<Array<Waypoint>>;
20
+ /**
21
+ * Add a waypoint to the service's data storage.
22
+ *
23
+ * @param location - The current location of the robot n the navigation
24
+ * service with latitude and longitude values.
25
+ */
26
+ addWayPoint: (location: GeoPoint, extra?: StructType) => Promise<void>;
27
+ /**
28
+ * Remove a waypoint from the service's data storage.
29
+ *
30
+ * @param id - The MongoDB ObjectID of the waypoint to remove from the
31
+ * service's data storage.
32
+ */
33
+ removeWayPoint: (id: string, extra?: StructType) => Promise<void>;
34
+ /** Get a list of obstacles. */
35
+ getObstacles: (extra?: StructType) => Promise<Array<GeoObstacle>>;
36
+ }
@@ -0,0 +1,3 @@
1
+ import pb from '../../gen/service/navigation/v1/navigation_pb';
2
+ export type ModeMap = pb.ModeMap;
3
+ export type Waypoint = pb.Waypoint.AsObject;
@@ -0,0 +1,3 @@
1
+ export type { Navigation } from './navigation/navigation';
2
+ export type { ModeMap, Waypoint } from './navigation/types';
3
+ export { NavigationClient } from './navigation/client';
@@ -0,0 +1,21 @@
1
+ import pb from '../../gen/service/slam/v1/slam_pb';
2
+ import { RobotClient } from '../../robot';
3
+ import type { Options, StructType } from '../../types';
4
+ import type { Slam } from './slam';
5
+ /**
6
+ * A gRPC-web client for a SLAM service.
7
+ *
8
+ * @group Clients
9
+ */
10
+ export declare class SlamClient implements Slam {
11
+ private client;
12
+ private readonly name;
13
+ private readonly options;
14
+ constructor(client: RobotClient, name: string, options?: Options);
15
+ private get service();
16
+ getPosition(): Promise<pb.GetPositionResponse.AsObject>;
17
+ getPointCloudMap(): Promise<Uint8Array>;
18
+ getInternalState(): Promise<Uint8Array>;
19
+ getLatestMapInfo(): Promise<Date>;
20
+ doCommand(command: StructType): Promise<StructType>;
21
+ }
@@ -0,0 +1,22 @@
1
+ import type { Resource } from '../../types';
2
+ import type { GetPositionResponse } from './types';
3
+ /**
4
+ * A service that allows your robot to create a map of its surroundings and find
5
+ * its location within that map.
6
+ */
7
+ export interface Slam extends Resource {
8
+ /**
9
+ * Get the current position of the specified source component in the point
10
+ * cloud SLAM map.
11
+ */
12
+ getPosition: () => Promise<GetPositionResponse>;
13
+ /** Get the point cloud SLAM map. */
14
+ getPointCloudMap: () => Promise<Uint8Array>;
15
+ /**
16
+ * Get the internal state of the SLAM algorithm required to continue
17
+ * mapping/localization.
18
+ */
19
+ getInternalState: () => Promise<Uint8Array>;
20
+ /** Get the timestamp of the last update to the point cloud SLAM map. */
21
+ getLatestMapInfo: () => Promise<Date>;
22
+ }
@@ -0,0 +1,2 @@
1
+ import pb from '../../gen/service/slam/v1/slam_pb';
2
+ export type GetPositionResponse = pb.GetPositionResponse.AsObject;
@@ -0,0 +1,3 @@
1
+ export type { Slam } from './slam/slam';
2
+ export type { GetPositionResponse } from './slam/types';
3
+ export { SlamClient } from './slam/client';
package/dist/types.d.ts CHANGED
@@ -13,6 +13,7 @@ export interface Resource {
13
13
  doCommand: (command: StructType) => Promise<StructType>;
14
14
  }
15
15
  export type ResourceName = common.ResourceName.AsObject;
16
+ export type GeoObstacle = common.GeoObstacle.AsObject;
16
17
  export type GeoPoint = common.GeoPoint.AsObject;
17
18
  export type Vector3 = common.Vector3.AsObject;
18
19
  export type Orientation = common.Orientation.AsObject;
package/dist/utils.d.ts CHANGED
@@ -22,4 +22,8 @@ export declare const encodeResourceName: (obj: common.ResourceName.AsObject) =>
22
22
  export declare const encodeTransform: (obj: common.Transform.AsObject) => common.Transform;
23
23
  /** Convert a WorldState object to a Protobuf Datatype. */
24
24
  export declare const encodeWorldState: (obj: common.WorldState.AsObject) => common.WorldState;
25
+ /** Convert a GeoPoint object to a Protobuf Datatype */
26
+ export declare const encodeGeoPoint: (obj: common.GeoPoint.AsObject) => common.GeoPoint;
27
+ /** Convert a GeoObstacle object to a Protobuf Datatype */
28
+ export declare const encodeGeoObstacle: (obj: common.GeoObstacle.AsObject) => common.GeoObstacle;
25
29
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viamrobotics/sdk",
3
- "version": "0.2.4",
3
+ "version": "0.2.5-next.1",
4
4
  "description": "",
5
5
  "main": "./dist/main.umd.js",
6
6
  "module": "./dist/main.es.js",