@wandelbots/nova-js 2.1.4 → 3.0.0-pr.bugfix-compatible-with-non-dom-envs.115.33da73d
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 +29 -1
- package/dist/LoginWithAuth0.d.ts.map +1 -1
- package/dist/{chunk-6WCKJOFL.js → chunk-4FP7NTKS.js} +51 -1
- package/dist/chunk-4FP7NTKS.js.map +1 -0
- package/dist/{chunk-V3NJLR6P.js → chunk-GVLDRXDW.js} +2 -52
- package/dist/chunk-GVLDRXDW.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -8
- package/dist/lib/AutoReconnectingWebsocket.d.ts +2 -2
- package/dist/lib/AutoReconnectingWebsocket.d.ts.map +1 -1
- package/dist/lib/availableStorage.d.ts +1 -1
- package/dist/lib/availableStorage.d.ts.map +1 -1
- package/dist/lib/v1/NovaClient.d.ts +1 -1
- package/dist/lib/v1/NovaClient.d.ts.map +1 -1
- package/dist/lib/v1/index.cjs +1 -1
- package/dist/lib/v1/index.cjs.map +1 -1
- package/dist/lib/v1/index.js +6 -6
- package/dist/lib/v1/index.js.map +1 -1
- package/dist/lib/v2/NovaCellAPIClient.d.ts +9 -11
- package/dist/lib/v2/NovaCellAPIClient.d.ts.map +1 -1
- package/dist/lib/v2/NovaClient.d.ts +0 -8
- package/dist/lib/v2/NovaClient.d.ts.map +1 -1
- package/dist/lib/v2/index.cjs +29 -772
- package/dist/lib/v2/index.cjs.map +1 -1
- package/dist/lib/v2/index.d.ts +0 -4
- package/dist/lib/v2/index.d.ts.map +1 -1
- package/dist/lib/v2/index.js +32 -764
- package/dist/lib/v2/index.js.map +1 -1
- package/dist/lib/v2/mock/MockNovaInstance.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/LoginWithAuth0.ts +5 -0
- package/src/lib/AutoReconnectingWebsocket.ts +6 -2
- package/src/lib/availableStorage.ts +5 -2
- package/src/lib/v1/NovaClient.ts +7 -1
- package/src/lib/v2/NovaCellAPIClient.ts +22 -22
- package/src/lib/v2/NovaClient.ts +7 -28
- package/src/lib/v2/index.ts +0 -4
- package/src/lib/v2/mock/MockNovaInstance.ts +9 -32
- package/src/types/non-dom.d.ts +118 -0
- package/dist/chunk-6WCKJOFL.js.map +0 -1
- package/dist/chunk-V3NJLR6P.js.map +0 -1
- package/dist/lib/v2/ConnectedMotionGroup.d.ts +0 -41
- package/dist/lib/v2/ConnectedMotionGroup.d.ts.map +0 -1
- package/dist/lib/v2/JoggerConnection.d.ts +0 -53
- package/dist/lib/v2/JoggerConnection.d.ts.map +0 -1
- package/dist/lib/v2/MotionStreamConnection.d.ts +0 -25
- package/dist/lib/v2/MotionStreamConnection.d.ts.map +0 -1
- package/dist/lib/v2/ProgramStateConnection.d.ts +0 -53
- package/dist/lib/v2/ProgramStateConnection.d.ts.map +0 -1
- package/dist/lib/v2/motionStateUpdate.d.ts +0 -4
- package/dist/lib/v2/motionStateUpdate.d.ts.map +0 -1
- package/src/lib/v2/ConnectedMotionGroup.ts +0 -216
- package/src/lib/v2/JoggerConnection.ts +0 -207
- package/src/lib/v2/MotionStreamConnection.ts +0 -201
- package/src/lib/v2/ProgramStateConnection.ts +0 -249
- package/src/lib/v2/motionStateUpdate.ts +0 -55
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { InitializeJoggingRequest, JoggingResponse, JointVelocityRequest, MotionGroupState, TcpVelocityRequest } from "@wandelbots/nova-api/v2";
|
|
2
|
-
import type { AutoReconnectingWebsocket } from "../AutoReconnectingWebsocket";
|
|
3
|
-
import type { NovaClient } from "./NovaClient";
|
|
4
|
-
export type JoggerConnectionOpts = {
|
|
5
|
-
/**
|
|
6
|
-
* When an error message is received from the jogging websocket, it
|
|
7
|
-
* will be passed here. If this handler is not provided, the error will
|
|
8
|
-
* instead be thrown as an unhandled error.
|
|
9
|
-
*/
|
|
10
|
-
onError?: (err: unknown) => void;
|
|
11
|
-
} & Omit<InitializeJoggingRequest, "message_type">;
|
|
12
|
-
export declare class JoggerConnection {
|
|
13
|
-
readonly nova: NovaClient;
|
|
14
|
-
readonly cell: string;
|
|
15
|
-
readonly motionGroupId: string;
|
|
16
|
-
readonly motionGroupState: MotionGroupState;
|
|
17
|
-
readonly opts: JoggerConnectionOpts;
|
|
18
|
-
joggingWebsocket: AutoReconnectingWebsocket | null;
|
|
19
|
-
lastVelocityRequest: JointVelocityRequest | TcpVelocityRequest | null;
|
|
20
|
-
lastResponse: JoggingResponse | null;
|
|
21
|
-
static open(nova: NovaClient, cell: string, motionGroupId: string, opts: JoggerConnectionOpts): Promise<JoggerConnection>;
|
|
22
|
-
constructor(nova: NovaClient, cell: string, motionGroupId: string, motionGroupState: MotionGroupState, opts: JoggerConnectionOpts);
|
|
23
|
-
get jointCount(): number | undefined;
|
|
24
|
-
get activeWebsocket(): AutoReconnectingWebsocket | null;
|
|
25
|
-
stop(): Promise<void>;
|
|
26
|
-
dispose(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Start rotation of a single robot joint at the specified velocity
|
|
29
|
-
*/
|
|
30
|
-
startJointRotation({ joint, velocityRadsPerSec, }: {
|
|
31
|
-
/** Index of the joint to rotate */
|
|
32
|
-
joint: number;
|
|
33
|
-
/** Speed of the rotation in radians per second */
|
|
34
|
-
velocityRadsPerSec: number;
|
|
35
|
-
}): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Start the TCP moving along a specified axis at a given velocity
|
|
38
|
-
*/
|
|
39
|
-
startTCPTranslation({ axis, velocityMmPerSec, useToolCoordinateSystem, }: {
|
|
40
|
-
axis: "x" | "y" | "z";
|
|
41
|
-
velocityMmPerSec: number;
|
|
42
|
-
useToolCoordinateSystem: boolean;
|
|
43
|
-
}): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Start the TCP rotating around a specified axis at a given velocity
|
|
46
|
-
*/
|
|
47
|
-
startTCPRotation({ axis, velocityRadsPerSec, useToolCoordinateSystem, }: {
|
|
48
|
-
axis: "x" | "y" | "z";
|
|
49
|
-
velocityRadsPerSec: number;
|
|
50
|
-
useToolCoordinateSystem: boolean;
|
|
51
|
-
}): Promise<void>;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=JoggerConnection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JoggerConnection.d.ts","sourceRoot":"","sources":["../../../src/lib/v2/JoggerConnection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAG9C,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CACjC,GAAG,IAAI,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAA;AAElD,qBAAa,gBAAgB;IA0BzB,QAAQ,CAAC,IAAI,EAAE,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,aAAa,EAAE,MAAM;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,IAAI,EAAE,oBAAoB;IA3BrC,gBAAgB,EAAE,yBAAyB,GAAG,IAAI,CAAO;IACzD,mBAAmB,EAAE,oBAAoB,GAAG,kBAAkB,GAAG,IAAI,CAAO;IAC5E,YAAY,EAAE,eAAe,GAAG,IAAI,CAAO;WAE9B,IAAI,CACf,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,oBAAoB;gBAejB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,oBAAoB;IA4BrC,IAAI,UAAU,uBAEb;IAED,IAAI,eAAe,qCAElB;IAEK,IAAI;IA0BV,OAAO;IAMP;;OAEG;IACG,kBAAkB,CAAC,EACvB,KAAK,EACL,kBAAkB,GACnB,EAAE;QACD,mCAAmC;QACnC,KAAK,EAAE,MAAM,CAAA;QACb,kDAAkD;QAClD,kBAAkB,EAAE,MAAM,CAAA;KAC3B;IAkBD;;OAEG;IACG,mBAAmB,CAAC,EACxB,IAAI,EACJ,gBAAgB,EAChB,uBAAuB,GACxB,EAAE;QACD,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;QACrB,gBAAgB,EAAE,MAAM,CAAA;QACxB,uBAAuB,EAAE,OAAO,CAAA;KACjC;IAmBD;;OAEG;IACG,gBAAgB,CAAC,EACrB,IAAI,EACJ,kBAAkB,EAClB,uBAAuB,GACxB,EAAE;QACD,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;QACrB,kBAAkB,EAAE,MAAM,CAAA;QAC1B,uBAAuB,EAAE,OAAO,CAAA;KACjC;CAiBF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Controller, MotionGroupPhysical, MotionGroupState } from "@wandelbots/nova-api/v2";
|
|
2
|
-
import type { AutoReconnectingWebsocket } from "../AutoReconnectingWebsocket";
|
|
3
|
-
import type { NovaClient } from "./NovaClient";
|
|
4
|
-
/**
|
|
5
|
-
* Store representing the current state of a connected motion group.
|
|
6
|
-
*/
|
|
7
|
-
export declare class MotionStreamConnection {
|
|
8
|
-
readonly nova: NovaClient;
|
|
9
|
-
readonly controller: Controller;
|
|
10
|
-
readonly motionGroup: MotionGroupPhysical;
|
|
11
|
-
readonly initialMotionState: MotionGroupState;
|
|
12
|
-
readonly motionStateSocket: AutoReconnectingWebsocket;
|
|
13
|
-
static open(nova: NovaClient, motionGroupId: string): Promise<MotionStreamConnection>;
|
|
14
|
-
rapidlyChangingMotionState: MotionGroupState;
|
|
15
|
-
constructor(nova: NovaClient, controller: Controller, motionGroup: MotionGroupPhysical, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket);
|
|
16
|
-
get motionGroupId(): string;
|
|
17
|
-
get controllerId(): string;
|
|
18
|
-
get modelFromController(): string | undefined;
|
|
19
|
-
get wandelscriptIdentifier(): string;
|
|
20
|
-
get joints(): {
|
|
21
|
-
index: number;
|
|
22
|
-
}[];
|
|
23
|
-
dispose(): void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=MotionStreamConnection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MotionStreamConnection.d.ts","sourceRoot":"","sources":["../../../src/lib/v2/MotionStreamConnection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAG7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AA4C9C;;GAEG;AACH,qBAAa,sBAAsB;IAsD/B,QAAQ,CAAC,IAAI,EAAE,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,UAAU;IAC/B,QAAQ,CAAC,WAAW,EAAE,mBAAmB;IACzC,QAAQ,CAAC,kBAAkB,EAAE,gBAAgB;IAC7C,QAAQ,CAAC,iBAAiB,EAAE,yBAAyB;WAzD1C,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM;IAkDzD,0BAA0B,EAAE,gBAAgB,CAAA;gBAGjC,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,mBAAmB,EAChC,kBAAkB,EAAE,gBAAgB,EACpC,iBAAiB,EAAE,yBAAyB;IAyDvD,IAAI,aAAa,WAEhB;IAED,IAAI,YAAY,WAEf;IAED,IAAI,mBAAmB,uBAEtB;IAED,IAAI,sBAAsB,WAGzB;IAED,IAAI,MAAM;;QAMT;IAED,OAAO;CAGR"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { AutoReconnectingWebsocket } from "../AutoReconnectingWebsocket";
|
|
2
|
-
import type { MotionStreamConnection } from "./MotionStreamConnection";
|
|
3
|
-
import type { NovaClient } from "./NovaClient";
|
|
4
|
-
export type ProgramRunnerLogEntry = {
|
|
5
|
-
timestamp: number;
|
|
6
|
-
message: string;
|
|
7
|
-
level?: "warn" | "error";
|
|
8
|
-
};
|
|
9
|
-
export declare enum ProgramState {
|
|
10
|
-
NotStarted = "not started",
|
|
11
|
-
Running = "running",
|
|
12
|
-
Stopped = "stopped",
|
|
13
|
-
Failed = "failed",
|
|
14
|
-
Completed = "completed"
|
|
15
|
-
}
|
|
16
|
-
export type CurrentProgram = {
|
|
17
|
-
id?: string;
|
|
18
|
-
wandelscript?: string;
|
|
19
|
-
state?: ProgramState;
|
|
20
|
-
};
|
|
21
|
-
type ProgramStateMessage = {
|
|
22
|
-
type: string;
|
|
23
|
-
runner: {
|
|
24
|
-
id: string;
|
|
25
|
-
state: ProgramState;
|
|
26
|
-
start_time?: number | null;
|
|
27
|
-
execution_time?: number | null;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Interface for running Wandelscript programs on the Nova instance and
|
|
32
|
-
* tracking their progress and output
|
|
33
|
-
*/
|
|
34
|
-
export declare class ProgramStateConnection {
|
|
35
|
-
readonly nova: NovaClient;
|
|
36
|
-
currentProgram: CurrentProgram;
|
|
37
|
-
logs: ProgramRunnerLogEntry[];
|
|
38
|
-
executionState: "idle" | "starting" | "executing" | "stopping";
|
|
39
|
-
currentlyExecutingProgramRunnerId: string | null;
|
|
40
|
-
programStateSocket: AutoReconnectingWebsocket;
|
|
41
|
-
constructor(nova: NovaClient);
|
|
42
|
-
/** Handle a program state update from the backend */
|
|
43
|
-
handleProgramStateMessage(msg: ProgramStateMessage): Promise<void>;
|
|
44
|
-
/** Call when a program is no longer executing */
|
|
45
|
-
gotoIdleState(): void;
|
|
46
|
-
executeProgram(wandelscript: string, initial_state?: Object, activeRobot?: MotionStreamConnection): Promise<void>;
|
|
47
|
-
stopProgram(): Promise<void>;
|
|
48
|
-
reset(): void;
|
|
49
|
-
log(message: string): void;
|
|
50
|
-
logError(message: string): void;
|
|
51
|
-
}
|
|
52
|
-
export {};
|
|
53
|
-
//# sourceMappingURL=ProgramStateConnection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProgramStateConnection.d.ts","sourceRoot":"","sources":["../../../src/lib/v2/ProgramStateConnection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAExE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB,CAAA;AAED,oBAAY,YAAY;IACtB,UAAU,gBAAgB;IAC1B,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,SAAS,cAAc;CACxB;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE;QACN,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,EAAE,YAAY,CAAA;QACnB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QAC1B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAC/B,CAAA;CACF,CAAA;AAED;;;GAGG;AACH,qBAAa,sBAAsB;IASrB,QAAQ,CAAC,IAAI,EAAE,UAAU;IARrC,cAAc,EAAE,cAAc,CAAK;IACnC,IAAI,EAAE,qBAAqB,EAAE,CAAK;IAElC,cAAc,EAAa,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAA;IACzE,iCAAiC,EAAW,MAAM,GAAG,IAAI,CAAA;IAEzD,kBAAkB,EAAE,yBAAyB,CAAA;gBAExB,IAAI,EAAE,UAAU;IAkBrC,qDAAqD;IAC/C,yBAAyB,CAAC,GAAG,EAAE,mBAAmB;IAgFxD,iDAAiD;IACjD,aAAa;IAOP,cAAc,CAClB,YAAY,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,sBAAsB;IAiDhC,WAAW;IAmBjB,KAAK;IAIL,GAAG,CAAC,OAAO,EAAE,MAAM;IAQnB,QAAQ,CAAC,OAAO,EAAE,MAAM;CAQzB"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TcpPose } from "@wandelbots/nova-api/v2";
|
|
2
|
-
export declare function jointValuesEqual(oldJointValues: number[], newJointValues: number[], changeDeltaThreshold: number): boolean;
|
|
3
|
-
export declare function tcpPoseEqual(oldTcp: TcpPose | undefined, newTcp: TcpPose | undefined, changeDeltaThreshold: number): boolean;
|
|
4
|
-
//# sourceMappingURL=motionStateUpdate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"motionStateUpdate.d.ts","sourceRoot":"","sources":["../../../src/lib/v2/motionStateUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEtD,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EAAE,EACxB,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAeT;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CA2BT"}
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Controller,
|
|
3
|
-
MotionGroupPhysical,
|
|
4
|
-
MotionGroupSpecification,
|
|
5
|
-
MotionGroupState,
|
|
6
|
-
RobotTcp,
|
|
7
|
-
SafetySetup,
|
|
8
|
-
} from "@wandelbots/nova-api/v2"
|
|
9
|
-
import { AxiosError } from "axios"
|
|
10
|
-
import { makeAutoObservable, runInAction } from "mobx"
|
|
11
|
-
import type { AutoReconnectingWebsocket } from "../AutoReconnectingWebsocket"
|
|
12
|
-
import { tryParseJson } from "../converters"
|
|
13
|
-
import { jointValuesEqual, tcpPoseEqual } from "./motionStateUpdate"
|
|
14
|
-
import type { NovaClient } from "./NovaClient"
|
|
15
|
-
|
|
16
|
-
const MOTION_DELTA_THRESHOLD = 0.0001
|
|
17
|
-
|
|
18
|
-
export type MotionGroupOption = {
|
|
19
|
-
selectionId: string
|
|
20
|
-
} & MotionGroupPhysical
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Store representing the current state of a connected motion group.
|
|
24
|
-
*/
|
|
25
|
-
export class ConnectedMotionGroup {
|
|
26
|
-
static async connect(
|
|
27
|
-
nova: NovaClient,
|
|
28
|
-
motionGroupId: string,
|
|
29
|
-
controllers: Controller[],
|
|
30
|
-
) {
|
|
31
|
-
const [_motionGroupIndex, controllerId] = motionGroupId.split("@") as [
|
|
32
|
-
string,
|
|
33
|
-
string,
|
|
34
|
-
]
|
|
35
|
-
const controller = controllers.find((c) => c.controller === controllerId)
|
|
36
|
-
const motionGroup = controller?.motion_groups.find(
|
|
37
|
-
(mg) => mg.motion_group === motionGroupId,
|
|
38
|
-
)
|
|
39
|
-
if (!controller || !motionGroup) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
`Controller ${controllerId} or motion group ${motionGroupId} not found`,
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const motionStateSocket = nova.openReconnectingWebsocket(
|
|
46
|
-
`/motion-groups/${motionGroupId}/state-stream`,
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
// Wait for the first message to get the initial state
|
|
50
|
-
const firstMessage = await motionStateSocket.firstMessage()
|
|
51
|
-
const initialMotionState = tryParseJson(firstMessage.data)
|
|
52
|
-
?.result as MotionGroupState
|
|
53
|
-
|
|
54
|
-
if (!initialMotionState) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`Unable to parse initial motion state message ${firstMessage.data}`,
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
console.log(
|
|
61
|
-
`Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:\n `,
|
|
62
|
-
initialMotionState,
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
// This is used to determine if the robot is virtual or physical
|
|
66
|
-
let isVirtual = false
|
|
67
|
-
try {
|
|
68
|
-
const opMode =
|
|
69
|
-
await nova.api.virtualRobotMode.getOperationMode(controllerId)
|
|
70
|
-
|
|
71
|
-
if (opMode) isVirtual = true
|
|
72
|
-
} catch (err) {
|
|
73
|
-
if (err instanceof AxiosError) {
|
|
74
|
-
console.log(
|
|
75
|
-
`Received ${err.status} from getOperationMode, concluding that ${controllerId} is physical`,
|
|
76
|
-
)
|
|
77
|
-
} else {
|
|
78
|
-
throw err
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Find out what TCPs this motion group has (we need it for jogging)
|
|
83
|
-
const { tcps } = await nova.api.motionGroupInfos.listTcps(motionGroupId)
|
|
84
|
-
|
|
85
|
-
const motionGroupSpecification =
|
|
86
|
-
await nova.api.motionGroupInfos.getMotionGroupSpecification(motionGroupId)
|
|
87
|
-
|
|
88
|
-
const safetySetup =
|
|
89
|
-
await nova.api.motionGroupInfos.getSafetySetup(motionGroupId)
|
|
90
|
-
|
|
91
|
-
return new ConnectedMotionGroup(
|
|
92
|
-
nova,
|
|
93
|
-
controller,
|
|
94
|
-
motionGroup,
|
|
95
|
-
initialMotionState,
|
|
96
|
-
motionStateSocket,
|
|
97
|
-
isVirtual,
|
|
98
|
-
tcps!,
|
|
99
|
-
motionGroupSpecification,
|
|
100
|
-
safetySetup,
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
connectedJoggingCartesianSocket: WebSocket | null = null
|
|
105
|
-
connectedJoggingJointsSocket: WebSocket | null = null
|
|
106
|
-
planData: any | null // tmp
|
|
107
|
-
joggingVelocity: number = 10
|
|
108
|
-
|
|
109
|
-
// Not mobx-observable as this changes very fast; should be observed
|
|
110
|
-
// using animation frames
|
|
111
|
-
rapidlyChangingMotionState: MotionGroupState
|
|
112
|
-
|
|
113
|
-
constructor(
|
|
114
|
-
readonly nova: NovaClient,
|
|
115
|
-
readonly controller: Controller,
|
|
116
|
-
readonly motionGroup: MotionGroupPhysical,
|
|
117
|
-
readonly initialMotionState: MotionGroupState,
|
|
118
|
-
readonly motionStateSocket: AutoReconnectingWebsocket,
|
|
119
|
-
readonly isVirtual: boolean,
|
|
120
|
-
readonly tcps: RobotTcp[],
|
|
121
|
-
readonly motionGroupSpecification: MotionGroupSpecification,
|
|
122
|
-
readonly safetySetup: SafetySetup,
|
|
123
|
-
) {
|
|
124
|
-
this.rapidlyChangingMotionState = initialMotionState
|
|
125
|
-
|
|
126
|
-
motionStateSocket.addEventListener("message", (event) => {
|
|
127
|
-
const motionStateResponse = tryParseJson(event.data)?.result as
|
|
128
|
-
| MotionGroupState
|
|
129
|
-
| undefined
|
|
130
|
-
|
|
131
|
-
if (!motionStateResponse) {
|
|
132
|
-
throw new Error(
|
|
133
|
-
`Failed to get motion state for ${this.motionGroupId}: ${event.data}`,
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// handle motionState message
|
|
138
|
-
if (
|
|
139
|
-
!jointValuesEqual(
|
|
140
|
-
this.rapidlyChangingMotionState.joint_position.joints,
|
|
141
|
-
motionStateResponse.joint_position.joints,
|
|
142
|
-
MOTION_DELTA_THRESHOLD,
|
|
143
|
-
)
|
|
144
|
-
) {
|
|
145
|
-
runInAction(() => {
|
|
146
|
-
this.rapidlyChangingMotionState = motionStateResponse
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// handle tcpPose message
|
|
151
|
-
if (
|
|
152
|
-
!tcpPoseEqual(
|
|
153
|
-
this.rapidlyChangingMotionState.tcp_pose,
|
|
154
|
-
motionStateResponse.tcp_pose,
|
|
155
|
-
MOTION_DELTA_THRESHOLD,
|
|
156
|
-
)
|
|
157
|
-
) {
|
|
158
|
-
runInAction(() => {
|
|
159
|
-
this.rapidlyChangingMotionState.tcp_pose =
|
|
160
|
-
motionStateResponse.tcp_pose
|
|
161
|
-
})
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
makeAutoObservable(this)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
get motionGroupId() {
|
|
168
|
-
return this.motionGroup.motion_group
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
get controllerId() {
|
|
172
|
-
return this.controller.controller
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
get modelFromController() {
|
|
176
|
-
return this.motionGroup.model_from_controller
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
get wandelscriptIdentifier() {
|
|
180
|
-
const num = this.motionGroupId.split("@")[0]
|
|
181
|
-
return `${this.controllerId.replaceAll("-", "_")}_${num}`
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/** Jogging velocity in radians for rotation and joint movement */
|
|
185
|
-
get joggingVelocityRads() {
|
|
186
|
-
return (this.joggingVelocity * Math.PI) / 180
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
get joints() {
|
|
190
|
-
return this.initialMotionState.joint_position.joints.map((_, i) => {
|
|
191
|
-
return {
|
|
192
|
-
index: i,
|
|
193
|
-
}
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
get dhParameters() {
|
|
198
|
-
return this.motionGroupSpecification.dh_parameters
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
get safetyZones() {
|
|
202
|
-
return this.safetySetup.safety_zones
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
dispose() {
|
|
206
|
-
this.motionStateSocket.close()
|
|
207
|
-
if (this.connectedJoggingCartesianSocket)
|
|
208
|
-
this.connectedJoggingCartesianSocket.close()
|
|
209
|
-
if (this.connectedJoggingJointsSocket)
|
|
210
|
-
this.connectedJoggingJointsSocket.close()
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
setJoggingVelocity(velocity: number) {
|
|
214
|
-
this.joggingVelocity = velocity
|
|
215
|
-
}
|
|
216
|
-
}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
InitializeJoggingRequest,
|
|
3
|
-
JoggingResponse,
|
|
4
|
-
JointVelocityRequest,
|
|
5
|
-
MotionGroupState,
|
|
6
|
-
TcpVelocityRequest,
|
|
7
|
-
} from "@wandelbots/nova-api/v2"
|
|
8
|
-
import type { AutoReconnectingWebsocket } from "../AutoReconnectingWebsocket"
|
|
9
|
-
import { tryParseJson } from "../converters"
|
|
10
|
-
import type { NovaClient } from "./NovaClient"
|
|
11
|
-
import { axisToIndex } from "./vectorUtils"
|
|
12
|
-
|
|
13
|
-
export type JoggerConnectionOpts = {
|
|
14
|
-
/**
|
|
15
|
-
* When an error message is received from the jogging websocket, it
|
|
16
|
-
* will be passed here. If this handler is not provided, the error will
|
|
17
|
-
* instead be thrown as an unhandled error.
|
|
18
|
-
*/
|
|
19
|
-
onError?: (err: unknown) => void
|
|
20
|
-
} & Omit<InitializeJoggingRequest, "message_type">
|
|
21
|
-
|
|
22
|
-
export class JoggerConnection {
|
|
23
|
-
// Currently a separate websocket is needed for each mode, pester API people
|
|
24
|
-
// to merge these for simplicity
|
|
25
|
-
joggingWebsocket: AutoReconnectingWebsocket | null = null
|
|
26
|
-
lastVelocityRequest: JointVelocityRequest | TcpVelocityRequest | null = null
|
|
27
|
-
lastResponse: JoggingResponse | null = null
|
|
28
|
-
|
|
29
|
-
static async open(
|
|
30
|
-
nova: NovaClient,
|
|
31
|
-
cell: string,
|
|
32
|
-
motionGroupId: string,
|
|
33
|
-
opts: JoggerConnectionOpts,
|
|
34
|
-
) {
|
|
35
|
-
const motionGroupState =
|
|
36
|
-
await nova.api.motionGroupInfos.getCurrentMotionGroupState(motionGroupId)
|
|
37
|
-
|
|
38
|
-
return new JoggerConnection(
|
|
39
|
-
nova,
|
|
40
|
-
cell,
|
|
41
|
-
motionGroupId,
|
|
42
|
-
motionGroupState,
|
|
43
|
-
opts,
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
constructor(
|
|
48
|
-
readonly nova: NovaClient,
|
|
49
|
-
readonly cell: string,
|
|
50
|
-
readonly motionGroupId: string,
|
|
51
|
-
readonly motionGroupState: MotionGroupState,
|
|
52
|
-
readonly opts: JoggerConnectionOpts,
|
|
53
|
-
) {
|
|
54
|
-
this.joggingWebsocket = nova.openReconnectingWebsocket(
|
|
55
|
-
`/cells/${cell}/execution/jogging`,
|
|
56
|
-
)
|
|
57
|
-
this.joggingWebsocket.addEventListener("message", (ev: MessageEvent) => {
|
|
58
|
-
const data = tryParseJson(ev.data) as JoggingResponse
|
|
59
|
-
if (data && "error" in data) {
|
|
60
|
-
if (this.opts.onError) {
|
|
61
|
-
this.opts.onError(ev.data)
|
|
62
|
-
} else {
|
|
63
|
-
throw new Error(ev.data)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
this.joggingWebsocket.addEventListener("message", (ev: MessageEvent) => {
|
|
69
|
-
const data = tryParseJson(ev.data)
|
|
70
|
-
if (data && "error" in data) {
|
|
71
|
-
if (this.opts.onError) {
|
|
72
|
-
this.opts.onError(ev.data)
|
|
73
|
-
} else {
|
|
74
|
-
throw new Error(ev.data)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
get jointCount() {
|
|
81
|
-
return this.motionGroupState.joint_current?.joints.length
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
get activeWebsocket() {
|
|
85
|
-
return this.joggingWebsocket
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async stop() {
|
|
89
|
-
// Why not call the stopJogging API endpoint?
|
|
90
|
-
// Because this results in the websocket closing and we
|
|
91
|
-
// would like to keep it open for now.
|
|
92
|
-
if (!this.joggingWebsocket) {
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (this.lastVelocityRequest?.message_type === "JointVelocityRequest") {
|
|
97
|
-
this.joggingWebsocket.sendJson({
|
|
98
|
-
message_type: "JointVelocityRequest",
|
|
99
|
-
velocity: {
|
|
100
|
-
joints: Array.from(new Array(this.jointCount).keys()).map(() => 0),
|
|
101
|
-
},
|
|
102
|
-
} as JointVelocityRequest)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (this.lastVelocityRequest?.message_type === "TcpVelocityRequest") {
|
|
106
|
-
this.joggingWebsocket.sendJson({
|
|
107
|
-
message_type: "TcpVelocityRequest",
|
|
108
|
-
rotation: [0, 0, 0],
|
|
109
|
-
translation: [0, 0, 0],
|
|
110
|
-
} as TcpVelocityRequest)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
dispose() {
|
|
115
|
-
if (this.joggingWebsocket) {
|
|
116
|
-
this.joggingWebsocket.dispose()
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Start rotation of a single robot joint at the specified velocity
|
|
122
|
-
*/
|
|
123
|
-
async startJointRotation({
|
|
124
|
-
joint,
|
|
125
|
-
velocityRadsPerSec,
|
|
126
|
-
}: {
|
|
127
|
-
/** Index of the joint to rotate */
|
|
128
|
-
joint: number
|
|
129
|
-
/** Speed of the rotation in radians per second */
|
|
130
|
-
velocityRadsPerSec: number
|
|
131
|
-
}) {
|
|
132
|
-
if (!this.joggingWebsocket) {
|
|
133
|
-
throw new Error(
|
|
134
|
-
"Joint jogging websocket not connected. Wait for reconnect or open new jogging connection",
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const jointVelocities = new Array(this.jointCount).fill(0)
|
|
139
|
-
jointVelocities[joint] = velocityRadsPerSec
|
|
140
|
-
|
|
141
|
-
this.joggingWebsocket.sendJson({
|
|
142
|
-
message_type: "JointVelocityRequest",
|
|
143
|
-
velocity: {
|
|
144
|
-
joints: jointVelocities,
|
|
145
|
-
},
|
|
146
|
-
} as JointVelocityRequest)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Start the TCP moving along a specified axis at a given velocity
|
|
151
|
-
*/
|
|
152
|
-
async startTCPTranslation({
|
|
153
|
-
axis,
|
|
154
|
-
velocityMmPerSec,
|
|
155
|
-
useToolCoordinateSystem,
|
|
156
|
-
}: {
|
|
157
|
-
axis: "x" | "y" | "z"
|
|
158
|
-
velocityMmPerSec: number
|
|
159
|
-
useToolCoordinateSystem: boolean
|
|
160
|
-
}) {
|
|
161
|
-
if (!this.joggingWebsocket) {
|
|
162
|
-
throw new Error(
|
|
163
|
-
"Cartesian jogging websocket not connected. Wait for reconnect or open new jogging connection",
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const joggingVector = [0, 0, 0]
|
|
168
|
-
joggingVector[axisToIndex(axis)] = velocityMmPerSec
|
|
169
|
-
|
|
170
|
-
this.joggingWebsocket.sendJson({
|
|
171
|
-
message_type: "TcpVelocityRequest",
|
|
172
|
-
|
|
173
|
-
translation: joggingVector,
|
|
174
|
-
rotation: [0, 0, 0],
|
|
175
|
-
use_tool_coordinate_system: useToolCoordinateSystem,
|
|
176
|
-
} as TcpVelocityRequest)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Start the TCP rotating around a specified axis at a given velocity
|
|
181
|
-
*/
|
|
182
|
-
async startTCPRotation({
|
|
183
|
-
axis,
|
|
184
|
-
velocityRadsPerSec,
|
|
185
|
-
useToolCoordinateSystem,
|
|
186
|
-
}: {
|
|
187
|
-
axis: "x" | "y" | "z"
|
|
188
|
-
velocityRadsPerSec: number
|
|
189
|
-
useToolCoordinateSystem: boolean
|
|
190
|
-
}) {
|
|
191
|
-
if (!this.joggingWebsocket) {
|
|
192
|
-
throw new Error(
|
|
193
|
-
"Cartesian jogging websocket not connected. Wait for reconnect or open new jogging connection",
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const joggingVector = [0, 0, 0]
|
|
198
|
-
joggingVector[axisToIndex(axis)] = velocityRadsPerSec
|
|
199
|
-
|
|
200
|
-
this.joggingWebsocket.sendJson({
|
|
201
|
-
message_type: "TcpVelocityRequest",
|
|
202
|
-
rotation: joggingVector,
|
|
203
|
-
translation: [0, 0, 0],
|
|
204
|
-
use_tool_coordinate_system: useToolCoordinateSystem,
|
|
205
|
-
} as TcpVelocityRequest)
|
|
206
|
-
}
|
|
207
|
-
}
|