@wandelbots/nova-js 3.13.0 → 4.0.0-pr.309.02b99fd

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.
Files changed (72) hide show
  1. package/dist/{AutoReconnectingWebsocket-1K2J1NA4.d.cts → AutoReconnectingWebsocket-BSt-vnzX.d.mts} +4 -16
  2. package/dist/AutoReconnectingWebsocket-BSt-vnzX.d.mts.map +1 -0
  3. package/dist/{context-ffr5Q2dc.mjs → LoginWithAuth0-D92HnzHq.mjs} +3 -13
  4. package/dist/LoginWithAuth0-D92HnzHq.mjs.map +1 -0
  5. package/dist/{Nova--8gozkLR.d.mts → Nova-C8nDNSCa.d.mts} +2 -2
  6. package/dist/{Nova--8gozkLR.d.mts.map → Nova-C8nDNSCa.d.mts.map} +1 -1
  7. package/dist/experimental/nats/index.d.mts +1 -1
  8. package/dist/index.d.mts +2 -7
  9. package/dist/index.d.mts.map +1 -1
  10. package/dist/index.mjs +2 -3
  11. package/dist/v2/index.d.mts +2 -130
  12. package/dist/v2/index.mjs +4 -231
  13. package/dist/v2/index.mjs.map +1 -1
  14. package/package.json +13 -17
  15. package/src/index.ts +0 -2
  16. package/src/lib/AutoReconnectingWebsocket.ts +3 -4
  17. package/src/lib/LoginWithAuth0.ts +1 -1
  18. package/src/lib/context.ts +1 -1
  19. package/src/lib/errorHandling.ts +0 -7
  20. package/src/v2/index.ts +0 -3
  21. package/dist/AutoReconnectingWebsocket-1K2J1NA4.d.cts.map +0 -1
  22. package/dist/AutoReconnectingWebsocket-1K2J1NA4.d.mts +0 -69
  23. package/dist/AutoReconnectingWebsocket-1K2J1NA4.d.mts.map +0 -1
  24. package/dist/Nova-B1o5iTQ6.d.cts +0 -85
  25. package/dist/Nova-B1o5iTQ6.d.cts.map +0 -1
  26. package/dist/context-BZELA2eh.cjs +0 -348
  27. package/dist/context-BZELA2eh.cjs.map +0 -1
  28. package/dist/context-ffr5Q2dc.mjs.map +0 -1
  29. package/dist/converters-EYS27XJE.cjs +0 -146
  30. package/dist/converters-EYS27XJE.cjs.map +0 -1
  31. package/dist/experimental/nats/index.cjs +0 -158
  32. package/dist/experimental/nats/index.cjs.map +0 -1
  33. package/dist/experimental/nats/index.d.cts +0 -3235
  34. package/dist/experimental/nats/index.d.cts.map +0 -1
  35. package/dist/index.cjs +0 -24
  36. package/dist/index.d.cts +0 -110
  37. package/dist/index.d.cts.map +0 -1
  38. package/dist/v1/index.cjs +0 -201
  39. package/dist/v1/index.cjs.map +0 -1
  40. package/dist/v1/index.d.cts +0 -67
  41. package/dist/v1/index.d.cts.map +0 -1
  42. package/dist/v1/index.d.mts +0 -67
  43. package/dist/v1/index.d.mts.map +0 -1
  44. package/dist/v1/index.mjs +0 -184
  45. package/dist/v1/index.mjs.map +0 -1
  46. package/dist/v2/index.cjs +0 -1038
  47. package/dist/v2/index.cjs.map +0 -1
  48. package/dist/v2/index.d.cts +0 -131
  49. package/dist/v2/index.d.cts.map +0 -1
  50. package/dist/v2/index.d.mts.map +0 -1
  51. package/dist/wandelscriptUtils-CpUXdLVc.mjs +0 -2062
  52. package/dist/wandelscriptUtils-CpUXdLVc.mjs.map +0 -1
  53. package/dist/wandelscriptUtils-DY3WsiuB.d.cts +0 -356
  54. package/dist/wandelscriptUtils-DY3WsiuB.d.cts.map +0 -1
  55. package/dist/wandelscriptUtils-DcY1aLWu.cjs +0 -2099
  56. package/dist/wandelscriptUtils-DcY1aLWu.cjs.map +0 -1
  57. package/dist/wandelscriptUtils-YHTxn_p9.d.mts +0 -356
  58. package/dist/wandelscriptUtils-YHTxn_p9.d.mts.map +0 -1
  59. package/src/lib/deprecated/v1/ConnectedMotionGroup.ts +0 -449
  60. package/src/lib/deprecated/v1/JoggerConnection.ts +0 -491
  61. package/src/lib/deprecated/v1/MotionStreamConnection.ts +0 -215
  62. package/src/lib/deprecated/v1/NovaCellAPIClient.ts +0 -208
  63. package/src/lib/deprecated/v1/NovaClient.ts +0 -260
  64. package/src/lib/deprecated/v1/ProgramStateConnection.ts +0 -277
  65. package/src/lib/deprecated/v1/getLatestTrajectories.ts +0 -37
  66. package/src/lib/deprecated/v1/mock/MockNovaInstance.ts +0 -1303
  67. package/src/lib/deprecated/v1/motionStateUpdate.ts +0 -58
  68. package/src/lib/deprecated/v1/wandelscriptUtils.ts +0 -23
  69. package/src/lib/deprecated/v2/NovaCellAPIClient.ts +0 -215
  70. package/src/lib/deprecated/v2/NovaClient.ts +0 -218
  71. package/src/lib/deprecated/v2/wandelscriptUtils.ts +0 -28
  72. package/src/v1/index.ts +0 -14
@@ -1,2062 +0,0 @@
1
- import { i as loginWithAuth0, l as availableStorage, n as isLocalhostDev, o as guardedPageReload, t as isBrowser, u as AutoReconnectingWebsocket } from "./context-ffr5Q2dc.mjs";
2
- import { a as parseNovaInstanceUrl, c as tryParseJson, r as isSameCoordinateSystem } from "./converters-DnG1fX23.mjs";
3
- import axios, { AxiosError, isAxiosError } from "axios";
4
- import { makeAutoObservable, runInAction } from "mobx";
5
- import * as THREE from "three";
6
- import { Vector3 } from "three";
7
- import { Vector3 as Vector3$1 } from "three/src/math/Vector3.js";
8
- import { ApplicationApi, CellApi, ControllerApi, ControllerIOsApi, CoordinateSystemsApi, DeviceConfigurationApi, LibraryProgramApi, LibraryProgramMetadataApi, LibraryRecipeApi, LibraryRecipeMetadataApi, MotionApi, MotionGroupApi, MotionGroupInfosApi, MotionGroupJoggingApi, MotionGroupKinematicApi, ProgramApi, ProgramValuesApi, StoreCollisionComponentsApi, StoreCollisionScenesApi, StoreObjectApi, SystemApi, VirtualRobotApi, VirtualRobotBehaviorApi, VirtualRobotModeApi, VirtualRobotSetupApi } from "@wandelbots/nova-api/v1";
9
- import * as pathToRegexp from "path-to-regexp";
10
- //#region src/lib/deprecated/v1/motionStateUpdate.ts
11
- /** @deprecated */
12
- function jointValuesEqual(oldJointValues, newJointValues, changeDeltaThreshold) {
13
- if (newJointValues.length !== oldJointValues.length) return true;
14
- for (let jointIndex = 0; jointIndex < newJointValues.length; jointIndex++) if (Math.abs(newJointValues[jointIndex] - oldJointValues[jointIndex]) > changeDeltaThreshold) return false;
15
- return true;
16
- }
17
- /** @deprecated */
18
- function tcpPoseEqual(oldTcp, newTcp, changeDeltaThreshold) {
19
- if (oldTcp === void 0 && newTcp || oldTcp && newTcp === void 0) return false;
20
- if (oldTcp === void 0 || newTcp === void 0) return true;
21
- let changedDelta = 0;
22
- changedDelta += Math.abs(oldTcp.orientation.x - newTcp.orientation.x);
23
- changedDelta += Math.abs(oldTcp.orientation.y - newTcp.orientation.y);
24
- changedDelta += Math.abs(oldTcp.orientation.z - newTcp.orientation.z);
25
- changedDelta += Math.abs(oldTcp.position.x - newTcp.position.x);
26
- changedDelta += Math.abs(oldTcp.position.y - newTcp.position.y);
27
- changedDelta += Math.abs(oldTcp.position.z - newTcp.position.z);
28
- if (changedDelta > changeDeltaThreshold) return false;
29
- return oldTcp.coordinate_system === newTcp.coordinate_system && oldTcp.tcp === newTcp.tcp;
30
- }
31
- //#endregion
32
- //#region src/lib/deprecated/v1/ConnectedMotionGroup.ts
33
- const MOTION_DELTA_THRESHOLD$1 = 1e-4;
34
- /**
35
- * Store representing the current state of a connected motion group.
36
- * @deprecated
37
- */
38
- var ConnectedMotionGroup = class ConnectedMotionGroup {
39
- static async connect(nova, motionGroupId, controllers) {
40
- const [_motionGroupIndex, controllerId] = motionGroupId.split("@");
41
- const controller = controllers.find((c) => c.controller === controllerId);
42
- const motionGroup = controller?.physical_motion_groups.find((mg) => mg.motion_group === motionGroupId);
43
- if (!controller || !motionGroup) throw new Error(`Controller ${controllerId} or motion group ${motionGroupId} not found`);
44
- const motionStateSocket = nova.openReconnectingWebsocket(`/motion-groups/${motionGroupId}/state-stream`);
45
- const firstMessage = await motionStateSocket.firstMessage();
46
- const initialMotionState = tryParseJson(firstMessage.data)?.result;
47
- if (!initialMotionState) throw new Error(`Unable to parse initial motion state message ${firstMessage.data}`);
48
- console.log(`Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:\n `, initialMotionState);
49
- const isVirtual = (await nova.api.controller.getRobotController(controller.controller)).configuration.kind === "VirtualController";
50
- const mounting = await (async () => {
51
- try {
52
- return await nova.api.motionGroupInfos.getMounting(motionGroup.motion_group);
53
- } catch (err) {
54
- console.error(`Error fetching mounting for ${motionGroup.motion_group}`, err);
55
- return null;
56
- }
57
- })();
58
- const controllerStateSocket = nova.openReconnectingWebsocket(`/controllers/${controller.controller}/state-stream?response_rate=1000`);
59
- const firstControllerMessage = await controllerStateSocket.firstMessage();
60
- const initialControllerState = tryParseJson(firstControllerMessage.data)?.result;
61
- if (!initialControllerState) throw new Error(`Unable to parse initial controller state message ${firstControllerMessage.data}`);
62
- console.log(`Connected controller state websocket to controller ${controller.controller}. Initial state:\n `, initialControllerState);
63
- const { tcps } = await nova.api.motionGroupInfos.listTcps(motionGroupId);
64
- return new ConnectedMotionGroup(nova, controller, motionGroup, initialMotionState, motionStateSocket, isVirtual, tcps, await nova.api.motionGroupInfos.getMotionGroupSpecification(motionGroupId), await nova.api.motionGroupInfos.getSafetySetup(motionGroupId), mounting, initialControllerState, controllerStateSocket);
65
- }
66
- connectedJoggingCartesianSocket = null;
67
- connectedJoggingJointsSocket = null;
68
- planData;
69
- joggingVelocity = 10;
70
- rapidlyChangingMotionState;
71
- controllerState;
72
- /**
73
- * Reflects activation state of the motion group / robot servos. The
74
- * movement controls in the UI should only be enabled in the "active" state
75
- */
76
- activationState = "inactive";
77
- nova;
78
- controller;
79
- motionGroup;
80
- initialMotionState;
81
- motionStateSocket;
82
- isVirtual;
83
- tcps;
84
- motionGroupSpecification;
85
- safetySetup;
86
- mounting;
87
- initialControllerState;
88
- controllerStateSocket;
89
- constructor(nova, controller, motionGroup, initialMotionState, motionStateSocket, isVirtual, tcps, motionGroupSpecification, safetySetup, mounting, initialControllerState, controllerStateSocket) {
90
- this.nova = nova;
91
- this.controller = controller;
92
- this.motionGroup = motionGroup;
93
- this.initialMotionState = initialMotionState;
94
- this.motionStateSocket = motionStateSocket;
95
- this.isVirtual = isVirtual;
96
- this.tcps = tcps;
97
- this.motionGroupSpecification = motionGroupSpecification;
98
- this.safetySetup = safetySetup;
99
- this.mounting = mounting;
100
- this.initialControllerState = initialControllerState;
101
- this.controllerStateSocket = controllerStateSocket;
102
- this.rapidlyChangingMotionState = initialMotionState;
103
- this.controllerState = initialControllerState;
104
- controllerStateSocket.addEventListener("message", (event) => {
105
- const data = tryParseJson(event.data)?.result;
106
- if (!data) return;
107
- runInAction(() => {
108
- this.controllerState = data;
109
- });
110
- });
111
- motionStateSocket.addEventListener("message", (event) => {
112
- const motionStateResponse = tryParseJson(event.data)?.result;
113
- if (!motionStateResponse) throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${event.data}`);
114
- if (!jointValuesEqual(this.rapidlyChangingMotionState.state.joint_position.joints, motionStateResponse.state.joint_position.joints, MOTION_DELTA_THRESHOLD$1)) runInAction(() => {
115
- this.rapidlyChangingMotionState.state = motionStateResponse.state;
116
- });
117
- if (!tcpPoseEqual(this.rapidlyChangingMotionState.tcp_pose, motionStateResponse.tcp_pose, MOTION_DELTA_THRESHOLD$1)) runInAction(() => {
118
- this.rapidlyChangingMotionState.tcp_pose = motionStateResponse.tcp_pose;
119
- });
120
- });
121
- makeAutoObservable(this);
122
- }
123
- get motionGroupId() {
124
- return this.motionGroup.motion_group;
125
- }
126
- get controllerId() {
127
- return this.controller.controller;
128
- }
129
- get modelFromController() {
130
- return this.motionGroup.model_from_controller;
131
- }
132
- get wandelscriptIdentifier() {
133
- const num = this.motionGroupId.split("@")[0];
134
- return `${this.controllerId.replaceAll("-", "_")}_${num}`;
135
- }
136
- /** Jogging velocity in radians for rotation and joint movement */
137
- get joggingVelocityRads() {
138
- return this.joggingVelocity * Math.PI / 180;
139
- }
140
- get joints() {
141
- return this.initialMotionState.state.joint_position.joints.map((_, i) => {
142
- return { index: i };
143
- });
144
- }
145
- get dhParameters() {
146
- return this.motionGroupSpecification.dh_parameters;
147
- }
148
- get safetyZones() {
149
- return this.safetySetup.safety_zones;
150
- }
151
- /** Gets the robot mounting position offset in 3D viz coordinates */
152
- get mountingPosition() {
153
- if (!this.mounting) return [
154
- 0,
155
- 0,
156
- 0
157
- ];
158
- return [
159
- this.mounting.pose.position.x / 1e3,
160
- this.mounting.pose.position.y / 1e3,
161
- this.mounting.pose.position.z / 1e3
162
- ];
163
- }
164
- /** Gets the robot mounting position rotation in 3D viz coordinates */
165
- get mountingQuaternion() {
166
- const rotationVector = new THREE.Vector3(this.mounting?.pose.orientation?.x || 0, this.mounting?.pose.orientation?.y || 0, this.mounting?.pose.orientation?.z || 0);
167
- const magnitude = rotationVector.length();
168
- const axis = rotationVector.normalize();
169
- return new THREE.Quaternion().setFromAxisAngle(axis, magnitude);
170
- }
171
- /**
172
- * Whether the controller is currently in a safety state
173
- * corresponding to an emergency stop
174
- */
175
- get isEstopActive() {
176
- return ["SAFETY_STATE_ROBOT_EMERGENCY_STOP", "SAFETY_STATE_DEVICE_EMERGENCY_STOP"].includes(this.controllerState.safety_state);
177
- }
178
- /**
179
- * Whether the controller is in a safety state
180
- * that may be non-functional for robot pad purposes
181
- */
182
- get isMoveableSafetyState() {
183
- return ["SAFETY_STATE_NORMAL", "SAFETY_STATE_REDUCED"].includes(this.controllerState.safety_state);
184
- }
185
- /**
186
- * Whether the controller is in an operation mode that allows movement
187
- */
188
- get isMoveableOperationMode() {
189
- return [
190
- "OPERATION_MODE_AUTO",
191
- "OPERATION_MODE_MANUAL",
192
- "OPERATION_MODE_MANUAL_T1",
193
- "OPERATION_MODE_MANUAL_T2"
194
- ].includes(this.controllerState.operation_mode);
195
- }
196
- /**
197
- * Whether the robot is currently active and can be moved, based on the
198
- * safety state, operation mode and servo toggle activation state.
199
- */
200
- get canBeMoved() {
201
- return this.isMoveableSafetyState && this.isMoveableOperationMode && this.activationState === "active";
202
- }
203
- async deactivate() {
204
- if (this.activationState !== "active") {
205
- console.error("Tried to deactivate while already deactivating");
206
- return;
207
- }
208
- runInAction(() => {
209
- this.activationState = "deactivating";
210
- });
211
- try {
212
- await this.nova.api.controller.setDefaultMode(this.controllerId, "MODE_MONITOR");
213
- runInAction(() => {
214
- this.activationState = "inactive";
215
- });
216
- } catch (err) {
217
- runInAction(() => {
218
- this.activationState = "active";
219
- });
220
- throw err;
221
- }
222
- }
223
- async activate() {
224
- if (this.activationState !== "inactive") {
225
- console.error("Tried to activate while already activating");
226
- return;
227
- }
228
- runInAction(() => {
229
- this.activationState = "activating";
230
- });
231
- try {
232
- await this.nova.api.controller.setDefaultMode(this.controllerId, "MODE_CONTROL");
233
- runInAction(() => {
234
- this.activationState = "active";
235
- });
236
- } catch (err) {
237
- runInAction(() => {
238
- this.activationState = "inactive";
239
- });
240
- throw err;
241
- }
242
- }
243
- toggleActivation() {
244
- if (this.activationState === "inactive") this.activate();
245
- else if (this.activationState === "active") this.deactivate();
246
- }
247
- dispose() {
248
- this.motionStateSocket.close();
249
- if (this.connectedJoggingCartesianSocket) this.connectedJoggingCartesianSocket.close();
250
- if (this.connectedJoggingJointsSocket) this.connectedJoggingJointsSocket.close();
251
- }
252
- setJoggingVelocity(velocity) {
253
- this.joggingVelocity = velocity;
254
- }
255
- };
256
- //#endregion
257
- //#region src/lib/deprecated/v1/JoggerConnection.ts
258
- /** @deprecated */
259
- var JoggerConnection = class JoggerConnection {
260
- cartesianWebsocket = null;
261
- jointWebsocket = null;
262
- cartesianJoggingOpts = {};
263
- static async open(nova, motionGroupId, opts = {}) {
264
- return new JoggerConnection(await nova.connectMotionStream(motionGroupId), opts);
265
- }
266
- motionStream;
267
- opts;
268
- constructor(motionStream, opts = {}) {
269
- this.motionStream = motionStream;
270
- this.opts = opts;
271
- }
272
- get motionGroupId() {
273
- return this.motionStream.motionGroupId;
274
- }
275
- get nova() {
276
- return this.motionStream.nova;
277
- }
278
- get numJoints() {
279
- return this.motionStream.joints.length;
280
- }
281
- get activeJoggingMode() {
282
- if (this.cartesianWebsocket) return "cartesian";
283
- if (this.jointWebsocket) return "joint";
284
- return "increment";
285
- }
286
- get activeWebsocket() {
287
- return this.cartesianWebsocket || this.jointWebsocket;
288
- }
289
- async stop() {
290
- if (this.cartesianWebsocket) this.cartesianWebsocket.sendJson({
291
- motion_group: this.motionGroupId,
292
- position_direction: {
293
- x: 0,
294
- y: 0,
295
- z: 0
296
- },
297
- rotation_direction: {
298
- x: 0,
299
- y: 0,
300
- z: 0
301
- },
302
- position_velocity: 0,
303
- rotation_velocity: 0,
304
- tcp: this.cartesianJoggingOpts.tcpId,
305
- coordinate_system: this.cartesianJoggingOpts.coordSystemId
306
- });
307
- if (this.jointWebsocket) this.jointWebsocket.sendJson({
308
- motion_group: this.motionGroupId,
309
- joint_velocities: new Array(this.numJoints).fill(0)
310
- });
311
- }
312
- dispose() {
313
- if (this.cartesianWebsocket) this.cartesianWebsocket.dispose();
314
- if (this.jointWebsocket) this.jointWebsocket.dispose();
315
- }
316
- setJoggingMode(mode, cartesianJoggingOpts) {
317
- console.log("Setting jogging mode to", mode);
318
- if (cartesianJoggingOpts) {
319
- if (JSON.stringify(this.cartesianJoggingOpts) !== JSON.stringify(cartesianJoggingOpts)) {
320
- if (this.cartesianWebsocket) {
321
- this.cartesianWebsocket.dispose();
322
- this.cartesianWebsocket = null;
323
- }
324
- }
325
- this.cartesianJoggingOpts = cartesianJoggingOpts;
326
- }
327
- if (mode !== "cartesian" && this.cartesianWebsocket) {
328
- this.cartesianWebsocket.dispose();
329
- this.cartesianWebsocket = null;
330
- }
331
- if (mode !== "joint" && this.jointWebsocket) {
332
- this.jointWebsocket.dispose();
333
- this.jointWebsocket = null;
334
- }
335
- if (mode === "cartesian" && !this.cartesianWebsocket) {
336
- this.cartesianWebsocket = this.nova.openReconnectingWebsocket(`/motion-groups/move-tcp`);
337
- this.cartesianWebsocket.addEventListener("message", (ev) => {
338
- const data = tryParseJson(ev.data);
339
- if (data && "error" in data) if (this.opts.onError) this.opts.onError(ev.data);
340
- else throw new Error(ev.data);
341
- });
342
- }
343
- if (mode === "joint" && !this.jointWebsocket) {
344
- this.jointWebsocket = this.nova.openReconnectingWebsocket(`/motion-groups/move-joint`);
345
- this.jointWebsocket.addEventListener("message", (ev) => {
346
- const data = tryParseJson(ev.data);
347
- if (data && "error" in data) if (this.opts.onError) this.opts.onError(ev.data);
348
- else throw new Error(ev.data);
349
- });
350
- }
351
- }
352
- /**
353
- * Start rotation of a single robot joint at the specified velocity
354
- */
355
- async startJointRotation({ joint, direction, velocityRadsPerSec }) {
356
- if (!this.jointWebsocket) throw new Error("Joint jogging websocket not connected; call setJoggingMode first");
357
- const jointVelocities = new Array(this.numJoints).fill(0);
358
- jointVelocities[joint] = direction === "-" ? -velocityRadsPerSec : velocityRadsPerSec;
359
- this.jointWebsocket.sendJson({
360
- motion_group: this.motionGroupId,
361
- joint_velocities: jointVelocities
362
- });
363
- }
364
- /**
365
- * Start the TCP moving along a specified axis at a given velocity
366
- */
367
- async startTCPTranslation({ axis, direction, velocityMmPerSec }) {
368
- if (!this.cartesianWebsocket) throw new Error("Cartesian jogging websocket not connected; call setJoggingMode first");
369
- const zeroVector = {
370
- x: 0,
371
- y: 0,
372
- z: 0
373
- };
374
- const joggingVector = Object.assign({}, zeroVector);
375
- joggingVector[axis] = direction === "-" ? -1 : 1;
376
- this.cartesianWebsocket.sendJson({
377
- motion_group: this.motionGroupId,
378
- position_direction: joggingVector,
379
- rotation_direction: zeroVector,
380
- position_velocity: velocityMmPerSec,
381
- rotation_velocity: 0,
382
- tcp: this.cartesianJoggingOpts.tcpId,
383
- coordinate_system: this.cartesianJoggingOpts.coordSystemId
384
- });
385
- }
386
- /**
387
- * Start the TCP rotating around a specified axis at a given velocity
388
- */
389
- async startTCPRotation({ axis, direction, velocityRadsPerSec }) {
390
- if (!this.cartesianWebsocket) throw new Error("Cartesian jogging websocket not connected; call setJoggingMode first");
391
- const zeroVector = {
392
- x: 0,
393
- y: 0,
394
- z: 0
395
- };
396
- const joggingVector = Object.assign({}, zeroVector);
397
- joggingVector[axis] = direction === "-" ? -1 : 1;
398
- this.cartesianWebsocket.sendJson({
399
- motion_group: this.motionGroupId,
400
- position_direction: zeroVector,
401
- rotation_direction: joggingVector,
402
- position_velocity: 0,
403
- rotation_velocity: velocityRadsPerSec,
404
- tcp: this.cartesianJoggingOpts.tcpId,
405
- coordinate_system: this.cartesianJoggingOpts.coordSystemId
406
- });
407
- }
408
- /**
409
- * Move the robot by a fixed distance in a single cartesian
410
- * axis, either rotating or translating relative to the TCP.
411
- * Promise resolves only after the motion has completed.
412
- */
413
- async runIncrementalCartesianMotion({ currentTcpPose, currentJoints, coordSystemId, velocityInRelevantUnits, axis, direction, motion }) {
414
- const commands = [];
415
- if (!isSameCoordinateSystem(currentTcpPose.coordinate_system, coordSystemId)) throw new Error(`Current TCP pose coordinate system ${currentTcpPose.coordinate_system} does not match target coordinate system ${coordSystemId}`);
416
- if (motion.type === "translate") {
417
- const targetTcpPosition = Object.assign({}, currentTcpPose.position);
418
- targetTcpPosition[axis] += motion.distanceMm * (direction === "-" ? -1 : 1);
419
- commands.push({
420
- settings: { limits_override: { tcp_velocity_limit: velocityInRelevantUnits } },
421
- line: {
422
- position: targetTcpPosition,
423
- orientation: currentTcpPose.orientation,
424
- coordinate_system: coordSystemId
425
- }
426
- });
427
- } else if (motion.type === "rotate") {
428
- const currentRotationVector = new Vector3$1(currentTcpPose.orientation.x, currentTcpPose.orientation.y, currentTcpPose.orientation.z);
429
- const currentRotationRad = currentRotationVector.length();
430
- const currentRotationDirection = currentRotationVector.clone().normalize();
431
- const differenceRotationRad = motion.distanceRads * (direction === "-" ? -1 : 1);
432
- const differenceRotationDirection = new Vector3$1(0, 0, 0);
433
- differenceRotationDirection[axis] = 1;
434
- const f1 = Math.cos(.5 * differenceRotationRad) * Math.cos(.5 * currentRotationRad);
435
- const f2 = Math.sin(.5 * differenceRotationRad) * Math.sin(.5 * currentRotationRad);
436
- const f3 = Math.sin(.5 * differenceRotationRad) * Math.cos(.5 * currentRotationRad);
437
- const f4 = Math.cos(.5 * differenceRotationRad) * Math.sin(.5 * currentRotationRad);
438
- const dotProduct = differenceRotationDirection.dot(currentRotationDirection);
439
- const crossProduct = differenceRotationDirection.clone().cross(currentRotationDirection);
440
- const newRotationRad = 2 * Math.acos(f1 - f2 * dotProduct);
441
- const f5 = newRotationRad / Math.sin(.5 * newRotationRad);
442
- const targetTcpOrientation = new Vector3$1().addScaledVector(crossProduct, f2).addScaledVector(differenceRotationDirection, f3).addScaledVector(currentRotationDirection, f4).multiplyScalar(f5);
443
- commands.push({
444
- settings: { limits_override: { tcp_orientation_velocity_limit: velocityInRelevantUnits } },
445
- line: {
446
- position: currentTcpPose.position,
447
- orientation: targetTcpOrientation,
448
- coordinate_system: coordSystemId
449
- }
450
- });
451
- }
452
- const motionPlanRes = await this.nova.api.motion.planMotion({
453
- motion_group: this.motionGroupId,
454
- start_joint_position: currentJoints,
455
- tcp: this.cartesianJoggingOpts.tcpId,
456
- commands
457
- });
458
- const plannedMotion = motionPlanRes.plan_successful_response?.motion;
459
- if (!plannedMotion) throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(motionPlanRes)}`);
460
- await this.nova.api.motion.streamMoveForward(plannedMotion, 100, void 0, void 0, void 0, { timeout: 1e3 * 60 });
461
- }
462
- /**
463
- * Rotate a single robot joint by a fixed number of radians
464
- * Promise resolves only after the motion has completed.
465
- */
466
- async runIncrementalJointRotation({ joint, currentJoints, velocityRadsPerSec, direction, distanceRads }) {
467
- const targetJoints = [...currentJoints.joints];
468
- targetJoints[joint] += distanceRads * (direction === "-" ? -1 : 1);
469
- const jointVelocityLimits = new Array(currentJoints.joints.length).fill(velocityRadsPerSec);
470
- const motionPlanRes = await this.nova.api.motion.planMotion({
471
- motion_group: this.motionGroupId,
472
- start_joint_position: currentJoints,
473
- commands: [{
474
- settings: { limits_override: { joint_velocity_limits: { joints: jointVelocityLimits } } },
475
- joint_ptp: { joints: targetJoints }
476
- }]
477
- });
478
- const plannedMotion = motionPlanRes.plan_successful_response?.motion;
479
- if (!plannedMotion) {
480
- console.error("Failed to plan jogging increment motion", motionPlanRes);
481
- return;
482
- }
483
- await this.nova.api.motion.streamMoveForward(plannedMotion, 100, void 0, void 0, void 0, { timeout: 1e3 * 60 });
484
- }
485
- };
486
- //#endregion
487
- //#region src/lib/deprecated/v1/MotionStreamConnection.ts
488
- const MOTION_DELTA_THRESHOLD = 1e-4;
489
- function unwrapRotationVector(newRotationVectorApi, currentRotationVectorApi) {
490
- const currentRotationVector = new Vector3(currentRotationVectorApi.x, currentRotationVectorApi.y, currentRotationVectorApi.z);
491
- const newRotationVector = new Vector3(newRotationVectorApi.x, newRotationVectorApi.y, newRotationVectorApi.z);
492
- const currentAngle = currentRotationVector.length();
493
- const currentAxis = currentRotationVector.normalize();
494
- let newAngle = newRotationVector.length();
495
- let newAxis = newRotationVector.normalize();
496
- if (newAxis.dot(currentAxis) < 0) {
497
- newAngle = -newAngle;
498
- newAxis = newAxis.multiplyScalar(-1);
499
- }
500
- let angleDifference = newAngle - currentAngle;
501
- angleDifference -= 2 * Math.PI * Math.floor((angleDifference + Math.PI) / (2 * Math.PI));
502
- newAngle = currentAngle + angleDifference;
503
- return newAxis.multiplyScalar(newAngle);
504
- }
505
- /**
506
- * Store representing the current state of a connected motion group.
507
- * @deprecated
508
- */
509
- var MotionStreamConnection = class MotionStreamConnection {
510
- static async open(nova, motionGroupId) {
511
- const { instances: controllers } = await nova.api.controller.listControllers();
512
- const [_motionGroupIndex, controllerId] = motionGroupId.split("@");
513
- const controller = controllers.find((c) => c.controller === controllerId);
514
- const motionGroup = controller?.physical_motion_groups.find((mg) => mg.motion_group === motionGroupId);
515
- if (!controller || !motionGroup) throw new Error(`Controller ${controllerId} or motion group ${motionGroupId} not found`);
516
- const motionStateSocket = nova.openReconnectingWebsocket(`/motion-groups/${motionGroupId}/state-stream`);
517
- const firstMessage = await motionStateSocket.firstMessage();
518
- const initialMotionState = tryParseJson(firstMessage.data)?.result;
519
- if (!initialMotionState) throw new Error(`Unable to parse initial motion state message ${firstMessage.data}`);
520
- console.log(`Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:\n `, initialMotionState);
521
- return new MotionStreamConnection(nova, controller, motionGroup, initialMotionState, motionStateSocket);
522
- }
523
- rapidlyChangingMotionState;
524
- nova;
525
- controller;
526
- motionGroup;
527
- initialMotionState;
528
- motionStateSocket;
529
- constructor(nova, controller, motionGroup, initialMotionState, motionStateSocket) {
530
- this.nova = nova;
531
- this.controller = controller;
532
- this.motionGroup = motionGroup;
533
- this.initialMotionState = initialMotionState;
534
- this.motionStateSocket = motionStateSocket;
535
- this.rapidlyChangingMotionState = initialMotionState;
536
- motionStateSocket.addEventListener("message", (event) => {
537
- const motionStateResponse = tryParseJson(event.data)?.result;
538
- if (!motionStateResponse) throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${event.data}`);
539
- if (!jointValuesEqual(this.rapidlyChangingMotionState.state.joint_position.joints, motionStateResponse.state.joint_position.joints, MOTION_DELTA_THRESHOLD)) runInAction(() => {
540
- this.rapidlyChangingMotionState.state = motionStateResponse.state;
541
- });
542
- if (!tcpPoseEqual(this.rapidlyChangingMotionState.tcp_pose, motionStateResponse.tcp_pose, MOTION_DELTA_THRESHOLD)) runInAction(() => {
543
- if (this.rapidlyChangingMotionState.tcp_pose == null) this.rapidlyChangingMotionState.tcp_pose = motionStateResponse.tcp_pose;
544
- else this.rapidlyChangingMotionState.tcp_pose = {
545
- position: motionStateResponse.tcp_pose.position,
546
- orientation: unwrapRotationVector(motionStateResponse.tcp_pose.orientation, this.rapidlyChangingMotionState.tcp_pose.orientation),
547
- tcp: motionStateResponse.tcp_pose.tcp,
548
- coordinate_system: motionStateResponse.tcp_pose.coordinate_system
549
- };
550
- });
551
- });
552
- makeAutoObservable(this);
553
- }
554
- get motionGroupId() {
555
- return this.motionGroup.motion_group;
556
- }
557
- get controllerId() {
558
- return this.controller.controller;
559
- }
560
- get modelFromController() {
561
- return this.motionGroup.model_from_controller;
562
- }
563
- get wandelscriptIdentifier() {
564
- const num = this.motionGroupId.split("@")[0];
565
- return `${this.controllerId.replaceAll("-", "_")}_${num}`;
566
- }
567
- get joints() {
568
- return this.initialMotionState.state.joint_position.joints.map((_, i) => {
569
- return { index: i };
570
- });
571
- }
572
- dispose() {
573
- this.motionStateSocket.close();
574
- }
575
- };
576
- //#endregion
577
- //#region src/lib/deprecated/v1/NovaCellAPIClient.ts
578
- /**
579
- * API client providing type-safe access to all the Nova API REST endpoints
580
- * associated with a specific cell id.
581
- * @deprecated Use `NovaAPIClient` from `@wandelbots/nova-js/v2` instead.
582
- */
583
- var NovaCellAPIClient = class {
584
- system;
585
- cell;
586
- deviceConfig;
587
- motionGroup;
588
- motionGroupInfos;
589
- controller;
590
- program;
591
- programValues;
592
- controllerIOs;
593
- motionGroupKinematic;
594
- motion;
595
- coordinateSystems;
596
- application;
597
- applicationGlobal;
598
- motionGroupJogging;
599
- virtualRobot;
600
- virtualRobotSetup;
601
- virtualRobotMode;
602
- virtualRobotBehavior;
603
- libraryProgramMetadata;
604
- libraryProgram;
605
- libraryRecipeMetadata;
606
- libraryRecipe;
607
- storeObject;
608
- storeCollisionComponents;
609
- storeCollisionScenes;
610
- cellId;
611
- opts;
612
- constructor(cellId, opts) {
613
- this.cellId = cellId;
614
- this.opts = opts;
615
- this.system = this.withUnwrappedResponsesOnly(SystemApi);
616
- this.cell = this.withUnwrappedResponsesOnly(CellApi);
617
- this.deviceConfig = this.withCellId(DeviceConfigurationApi);
618
- this.motionGroup = this.withCellId(MotionGroupApi);
619
- this.motionGroupInfos = this.withCellId(MotionGroupInfosApi);
620
- this.controller = this.withCellId(ControllerApi);
621
- this.program = this.withCellId(ProgramApi);
622
- this.programValues = this.withCellId(ProgramValuesApi);
623
- this.controllerIOs = this.withCellId(ControllerIOsApi);
624
- this.motionGroupKinematic = this.withCellId(MotionGroupKinematicApi);
625
- this.motion = this.withCellId(MotionApi);
626
- this.coordinateSystems = this.withCellId(CoordinateSystemsApi);
627
- this.application = this.withCellId(ApplicationApi);
628
- this.applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi);
629
- this.motionGroupJogging = this.withCellId(MotionGroupJoggingApi);
630
- this.virtualRobot = this.withCellId(VirtualRobotApi);
631
- this.virtualRobotSetup = this.withCellId(VirtualRobotSetupApi);
632
- this.virtualRobotMode = this.withCellId(VirtualRobotModeApi);
633
- this.virtualRobotBehavior = this.withCellId(VirtualRobotBehaviorApi);
634
- this.libraryProgramMetadata = this.withCellId(LibraryProgramMetadataApi);
635
- this.libraryProgram = this.withCellId(LibraryProgramApi);
636
- this.libraryRecipeMetadata = this.withCellId(LibraryRecipeMetadataApi);
637
- this.libraryRecipe = this.withCellId(LibraryRecipeApi);
638
- this.storeObject = this.withCellId(StoreObjectApi);
639
- this.storeCollisionComponents = this.withCellId(StoreCollisionComponentsApi);
640
- this.storeCollisionScenes = this.withCellId(StoreCollisionScenesApi);
641
- }
642
- /**
643
- * Some TypeScript sorcery which alters the API class methods so you don't
644
- * have to pass the cell id to every single one, and de-encapsulates the
645
- * response data
646
- */
647
- withCellId(ApiConstructor) {
648
- const apiClient = new ApiConstructor({
649
- ...this.opts,
650
- isJsonMime: (mime) => {
651
- return mime === "application/json";
652
- }
653
- }, this.opts.basePath ?? "", this.opts.axiosInstance ?? axios.create());
654
- for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) if (key !== "constructor" && typeof apiClient[key] === "function") {
655
- const originalFunction = apiClient[key];
656
- apiClient[key] = (...args) => {
657
- return originalFunction.apply(apiClient, [this.cellId, ...args]).then((res) => res.data);
658
- };
659
- }
660
- return apiClient;
661
- }
662
- /**
663
- * As withCellId, but only does the response unwrapping
664
- */
665
- withUnwrappedResponsesOnly(ApiConstructor) {
666
- const apiClient = new ApiConstructor({
667
- ...this.opts,
668
- isJsonMime: (mime) => {
669
- return mime === "application/json";
670
- }
671
- }, this.opts.basePath ?? "", this.opts.axiosInstance ?? axios.create());
672
- for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) if (key !== "constructor" && typeof apiClient[key] === "function") {
673
- const originalFunction = apiClient[key];
674
- apiClient[key] = (...args) => {
675
- return originalFunction.apply(apiClient, args).then((res) => res.data);
676
- };
677
- }
678
- return apiClient;
679
- }
680
- };
681
- //#endregion
682
- //#region src/lib/deprecated/v1/mock/MockNovaInstance.ts
683
- /**
684
- * Ultra-simplified mock Nova server for testing stuff
685
- * @deprecated
686
- */
687
- var MockNovaInstance = class {
688
- connections = [];
689
- async handleAPIRequest(config) {
690
- const apiHandlers = [
691
- {
692
- method: "GET",
693
- path: "/cells/:cellId/controllers",
694
- handle() {
695
- return { instances: [{
696
- controller: "mock-ur5e",
697
- model_name: "UniversalRobots::Controller",
698
- host: "mock-ur5e",
699
- allow_software_install_on_controller: true,
700
- physical_motion_groups: [{
701
- motion_group: "0@mock-ur5e",
702
- name_from_controller: "UR5e",
703
- active: false,
704
- model_from_controller: "UniversalRobots_UR5e"
705
- }],
706
- has_error: false,
707
- error_details: ""
708
- }] };
709
- }
710
- },
711
- {
712
- method: "GET",
713
- path: "/cells/:cellId/controllers/:controllerId",
714
- handle() {
715
- return {
716
- configuration: {
717
- kind: "VirtualController",
718
- manufacturer: "universalrobots",
719
- position: "[0,-1.571,-1.571,-1.571,1.571,-1.571,0]",
720
- type: "universalrobots-ur5e"
721
- },
722
- name: "mock-ur5"
723
- };
724
- }
725
- },
726
- {
727
- method: "GET",
728
- path: "/cells/:cellId/motion-groups/:motionGroupId/specification",
729
- handle() {
730
- return {
731
- dh_parameters: [
732
- {
733
- alpha: 1.5707963267948966,
734
- theta: 0,
735
- a: 0,
736
- d: 162.25,
737
- reverse_rotation_direction: false
738
- },
739
- {
740
- alpha: 0,
741
- theta: 0,
742
- a: -425,
743
- d: 0,
744
- reverse_rotation_direction: false
745
- },
746
- {
747
- alpha: 0,
748
- theta: 0,
749
- a: -392.2,
750
- d: 0,
751
- reverse_rotation_direction: false
752
- },
753
- {
754
- alpha: 1.5707963267948966,
755
- theta: 0,
756
- a: 0,
757
- d: 133.3,
758
- reverse_rotation_direction: false
759
- },
760
- {
761
- alpha: -1.5707963267948966,
762
- theta: 0,
763
- a: 0,
764
- d: 99.7,
765
- reverse_rotation_direction: false
766
- },
767
- {
768
- alpha: 0,
769
- theta: 0,
770
- a: 0,
771
- d: 99.6,
772
- reverse_rotation_direction: false
773
- }
774
- ],
775
- mechanical_joint_limits: [
776
- {
777
- joint: "JOINTNAME_AXIS_1",
778
- lower_limit: -6.335545063018799,
779
- upper_limit: 6.335545063018799,
780
- unlimited: false
781
- },
782
- {
783
- joint: "JOINTNAME_AXIS_2",
784
- lower_limit: -6.335545063018799,
785
- upper_limit: 6.335545063018799,
786
- unlimited: false
787
- },
788
- {
789
- joint: "JOINTNAME_AXIS_3",
790
- lower_limit: -6.335545063018799,
791
- upper_limit: 6.335545063018799,
792
- unlimited: false
793
- },
794
- {
795
- joint: "JOINTNAME_AXIS_4",
796
- lower_limit: -6.335545063018799,
797
- upper_limit: 6.335545063018799,
798
- unlimited: false
799
- },
800
- {
801
- joint: "JOINTNAME_AXIS_5",
802
- lower_limit: -6.335545063018799,
803
- upper_limit: 6.335545063018799,
804
- unlimited: false
805
- },
806
- {
807
- joint: "JOINTNAME_AXIS_6",
808
- lower_limit: -6.335545063018799,
809
- upper_limit: 6.335545063018799,
810
- unlimited: false
811
- }
812
- ]
813
- };
814
- }
815
- },
816
- {
817
- method: "GET",
818
- path: "/cells/:cellId/motion-groups/:motionGroupId/safety-setup",
819
- handle() {
820
- return {
821
- safety_settings: [{
822
- safety_state: "SAFETY_NORMAL",
823
- settings: {
824
- joint_position_limits: [
825
- {
826
- joint: "JOINTNAME_AXIS_1",
827
- lower_limit: -2.96705961227417,
828
- upper_limit: 2.96705961227417,
829
- unlimited: false
830
- },
831
- {
832
- joint: "JOINTNAME_AXIS_2",
833
- lower_limit: -1.7453292608261108,
834
- upper_limit: 2.7925267219543457,
835
- unlimited: false
836
- },
837
- {
838
- joint: "JOINTNAME_AXIS_3",
839
- lower_limit: -3.3161256313323975,
840
- upper_limit: .40142571926116943,
841
- unlimited: false
842
- },
843
- {
844
- joint: "JOINTNAME_AXIS_4",
845
- lower_limit: -3.4906585216522217,
846
- upper_limit: 3.4906585216522217,
847
- unlimited: false
848
- },
849
- {
850
- joint: "JOINTNAME_AXIS_5",
851
- lower_limit: -2.4434609413146973,
852
- upper_limit: 2.4434609413146973,
853
- unlimited: false
854
- },
855
- {
856
- joint: "JOINTNAME_AXIS_6",
857
- lower_limit: -4.71238899230957,
858
- upper_limit: 4.71238899230957,
859
- unlimited: false
860
- }
861
- ],
862
- joint_velocity_limits: [
863
- {
864
- joint: "JOINTNAME_AXIS_1",
865
- limit: 3.1415927410125732
866
- },
867
- {
868
- joint: "JOINTNAME_AXIS_2",
869
- limit: 3.1415927410125732
870
- },
871
- {
872
- joint: "JOINTNAME_AXIS_3",
873
- limit: 3.4906585216522217
874
- },
875
- {
876
- joint: "JOINTNAME_AXIS_4",
877
- limit: 6.108652591705322
878
- },
879
- {
880
- joint: "JOINTNAME_AXIS_5",
881
- limit: 6.108652591705322
882
- },
883
- {
884
- joint: "JOINTNAME_AXIS_6",
885
- limit: 6.981317043304443
886
- }
887
- ],
888
- joint_acceleration_limits: [],
889
- joint_torque_limits: [],
890
- tcp_velocity_limit: 1800
891
- }
892
- }],
893
- safety_zones: [
894
- {
895
- id: 1,
896
- priority: 0,
897
- geometry: {
898
- compound: { child_geometries: [
899
- {
900
- convex_hull: { vertices: [
901
- {
902
- x: -800,
903
- y: -1330,
904
- z: -1820
905
- },
906
- {
907
- x: 1650,
908
- y: -1330,
909
- z: -1820
910
- },
911
- {
912
- x: 1650,
913
- y: 1330,
914
- z: -1820
915
- },
916
- {
917
- x: -800,
918
- y: 1330,
919
- z: -1820
920
- }
921
- ] },
922
- init_pose: {
923
- position: {
924
- x: 0,
925
- y: 0,
926
- z: 0
927
- },
928
- orientation: {
929
- x: 0,
930
- y: 0,
931
- z: 0,
932
- w: 1
933
- }
934
- },
935
- id: "box"
936
- },
937
- {
938
- convex_hull: { vertices: [
939
- {
940
- x: -800,
941
- y: -1330,
942
- z: -1820
943
- },
944
- {
945
- x: 1650,
946
- y: -1330,
947
- z: -1820
948
- },
949
- {
950
- x: 1650,
951
- y: -1330,
952
- z: 1500
953
- },
954
- {
955
- x: -800,
956
- y: -1330,
957
- z: 1500
958
- }
959
- ] },
960
- init_pose: {
961
- position: {
962
- x: 0,
963
- y: 0,
964
- z: 0
965
- },
966
- orientation: {
967
- x: 0,
968
- y: 0,
969
- z: 0,
970
- w: 1
971
- }
972
- },
973
- id: "box"
974
- },
975
- {
976
- convex_hull: { vertices: [
977
- {
978
- x: -800,
979
- y: -1330,
980
- z: -1820
981
- },
982
- {
983
- x: -800,
984
- y: 1330,
985
- z: -1820
986
- },
987
- {
988
- x: -800,
989
- y: 1330,
990
- z: 1500
991
- },
992
- {
993
- x: -800,
994
- y: -1330,
995
- z: 1500
996
- }
997
- ] },
998
- init_pose: {
999
- position: {
1000
- x: 0,
1001
- y: 0,
1002
- z: 0
1003
- },
1004
- orientation: {
1005
- x: 0,
1006
- y: 0,
1007
- z: 0,
1008
- w: 1
1009
- }
1010
- },
1011
- id: "box"
1012
- },
1013
- {
1014
- convex_hull: { vertices: [
1015
- {
1016
- x: 1650,
1017
- y: 1330,
1018
- z: 1500
1019
- },
1020
- {
1021
- x: -800,
1022
- y: 1330,
1023
- z: 1500
1024
- },
1025
- {
1026
- x: -800,
1027
- y: -1330,
1028
- z: 1500
1029
- },
1030
- {
1031
- x: 1650,
1032
- y: -1330,
1033
- z: 1500
1034
- }
1035
- ] },
1036
- init_pose: {
1037
- position: {
1038
- x: 0,
1039
- y: 0,
1040
- z: 0
1041
- },
1042
- orientation: {
1043
- x: 0,
1044
- y: 0,
1045
- z: 0,
1046
- w: 1
1047
- }
1048
- },
1049
- id: "box"
1050
- },
1051
- {
1052
- convex_hull: { vertices: [
1053
- {
1054
- x: 1650,
1055
- y: 1330,
1056
- z: 1500
1057
- },
1058
- {
1059
- x: -800,
1060
- y: 1330,
1061
- z: 1500
1062
- },
1063
- {
1064
- x: -800,
1065
- y: 1330,
1066
- z: -1820
1067
- },
1068
- {
1069
- x: 1650,
1070
- y: 1330,
1071
- z: -1820
1072
- }
1073
- ] },
1074
- init_pose: {
1075
- position: {
1076
- x: 0,
1077
- y: 0,
1078
- z: 0
1079
- },
1080
- orientation: {
1081
- x: 0,
1082
- y: 0,
1083
- z: 0,
1084
- w: 1
1085
- }
1086
- },
1087
- id: "box"
1088
- },
1089
- {
1090
- convex_hull: { vertices: [
1091
- {
1092
- x: 1650,
1093
- y: 1330,
1094
- z: 1500
1095
- },
1096
- {
1097
- x: 1650,
1098
- y: -1330,
1099
- z: 1500
1100
- },
1101
- {
1102
- x: 1650,
1103
- y: -1330,
1104
- z: -1820
1105
- },
1106
- {
1107
- x: 1650,
1108
- y: 1330,
1109
- z: -1820
1110
- }
1111
- ] },
1112
- init_pose: {
1113
- position: {
1114
- x: 0,
1115
- y: 0,
1116
- z: 0
1117
- },
1118
- orientation: {
1119
- x: 0,
1120
- y: 0,
1121
- z: 0,
1122
- w: 1
1123
- }
1124
- },
1125
- id: "box"
1126
- }
1127
- ] },
1128
- init_pose: {
1129
- position: {
1130
- x: 0,
1131
- y: 0,
1132
- z: 0
1133
- },
1134
- orientation: {
1135
- x: 0,
1136
- y: 0,
1137
- z: 0,
1138
- w: 1
1139
- }
1140
- },
1141
- id: "Cell workzone"
1142
- },
1143
- motion_group_uid: 1
1144
- },
1145
- {
1146
- id: 2,
1147
- priority: 0,
1148
- geometry: {
1149
- convex_hull: { vertices: [
1150
- {
1151
- x: 1650,
1152
- y: 1330,
1153
- z: -1850
1154
- },
1155
- {
1156
- x: 865,
1157
- y: 1330,
1158
- z: -1850
1159
- },
1160
- {
1161
- x: 865,
1162
- y: -720,
1163
- z: -1850
1164
- },
1165
- {
1166
- x: 1650,
1167
- y: -720,
1168
- z: -1850
1169
- },
1170
- {
1171
- x: 1650,
1172
- y: 1330,
1173
- z: -920
1174
- },
1175
- {
1176
- x: 865,
1177
- y: 1330,
1178
- z: -920
1179
- },
1180
- {
1181
- x: 865,
1182
- y: -720,
1183
- z: -920
1184
- },
1185
- {
1186
- x: 1650,
1187
- y: -720,
1188
- z: -920
1189
- }
1190
- ] },
1191
- init_pose: {
1192
- position: {
1193
- x: 0,
1194
- y: 0,
1195
- z: 0
1196
- },
1197
- orientation: {
1198
- x: 0,
1199
- y: 0,
1200
- z: 0,
1201
- w: 1
1202
- }
1203
- },
1204
- id: "Transport"
1205
- },
1206
- motion_group_uid: 1
1207
- },
1208
- {
1209
- id: 3,
1210
- priority: 0,
1211
- geometry: {
1212
- convex_hull: { vertices: [
1213
- {
1214
- x: 1650,
1215
- y: 1330,
1216
- z: -600
1217
- },
1218
- {
1219
- x: 865,
1220
- y: 1330,
1221
- z: -600
1222
- },
1223
- {
1224
- x: 865,
1225
- y: 430,
1226
- z: -600
1227
- },
1228
- {
1229
- x: 1650,
1230
- y: 430,
1231
- z: -600
1232
- },
1233
- {
1234
- x: 1650,
1235
- y: 1330,
1236
- z: -1250
1237
- },
1238
- {
1239
- x: 865,
1240
- y: 1330,
1241
- z: -1250
1242
- },
1243
- {
1244
- x: 865,
1245
- y: 430,
1246
- z: -1250
1247
- },
1248
- {
1249
- x: 1650,
1250
- y: 430,
1251
- z: -1250
1252
- }
1253
- ] },
1254
- init_pose: {
1255
- position: {
1256
- x: 0,
1257
- y: 0,
1258
- z: 0
1259
- },
1260
- orientation: {
1261
- x: 0,
1262
- y: 0,
1263
- z: 0,
1264
- w: 1
1265
- }
1266
- },
1267
- id: "Tunel"
1268
- },
1269
- motion_group_uid: 1
1270
- },
1271
- {
1272
- id: 4,
1273
- priority: 0,
1274
- geometry: {
1275
- convex_hull: { vertices: [
1276
- {
1277
- x: 1650,
1278
- y: -760,
1279
- z: -440
1280
- },
1281
- {
1282
- x: 900,
1283
- y: -760,
1284
- z: -440
1285
- },
1286
- {
1287
- x: 900,
1288
- y: -1330,
1289
- z: -440
1290
- },
1291
- {
1292
- x: 1650,
1293
- y: -1330,
1294
- z: -440
1295
- },
1296
- {
1297
- x: 1650,
1298
- y: -760,
1299
- z: -1800
1300
- },
1301
- {
1302
- x: 900,
1303
- y: -760,
1304
- z: -1800
1305
- },
1306
- {
1307
- x: 900,
1308
- y: -1330,
1309
- z: -1800
1310
- },
1311
- {
1312
- x: 1650,
1313
- y: -1330,
1314
- z: -1800
1315
- }
1316
- ] },
1317
- init_pose: {
1318
- position: {
1319
- x: 0,
1320
- y: 0,
1321
- z: 0
1322
- },
1323
- orientation: {
1324
- x: 0,
1325
- y: 0,
1326
- z: 0,
1327
- w: 1
1328
- }
1329
- },
1330
- id: "Fanuc controller"
1331
- },
1332
- motion_group_uid: 1
1333
- },
1334
- {
1335
- id: 6,
1336
- priority: 0,
1337
- geometry: {
1338
- convex_hull: { vertices: [
1339
- {
1340
- x: -200,
1341
- y: -200,
1342
- z: -1900
1343
- },
1344
- {
1345
- x: 200,
1346
- y: -200,
1347
- z: -1900
1348
- },
1349
- {
1350
- x: 200,
1351
- y: 200,
1352
- z: -1900
1353
- },
1354
- {
1355
- x: -200,
1356
- y: 200,
1357
- z: -1900
1358
- },
1359
- {
1360
- x: -200,
1361
- y: -200,
1362
- z: -350
1363
- },
1364
- {
1365
- x: 200,
1366
- y: -200,
1367
- z: -350
1368
- },
1369
- {
1370
- x: 200,
1371
- y: 200,
1372
- z: -350
1373
- },
1374
- {
1375
- x: -200,
1376
- y: 200,
1377
- z: -350
1378
- }
1379
- ] },
1380
- init_pose: {
1381
- position: {
1382
- x: 0,
1383
- y: 0,
1384
- z: 0
1385
- },
1386
- orientation: {
1387
- x: 0,
1388
- y: 0,
1389
- z: 0,
1390
- w: 1
1391
- }
1392
- },
1393
- id: "Robot base"
1394
- },
1395
- motion_group_uid: 1
1396
- }
1397
- ],
1398
- robot_model_geometries: [
1399
- {
1400
- link_index: 1,
1401
- geometry: {
1402
- sphere: { radius: 270 },
1403
- init_pose: {
1404
- position: {
1405
- x: -70,
1406
- y: -70,
1407
- z: -50
1408
- },
1409
- orientation: {
1410
- x: 0,
1411
- y: 0,
1412
- z: 0,
1413
- w: 1
1414
- }
1415
- },
1416
- id: "link1_sphere"
1417
- }
1418
- },
1419
- {
1420
- link_index: 2,
1421
- geometry: {
1422
- capsule: {
1423
- radius: 160,
1424
- cylinder_height: 800
1425
- },
1426
- init_pose: {
1427
- position: {
1428
- x: -450,
1429
- y: 40,
1430
- z: 170
1431
- },
1432
- orientation: {
1433
- x: 0,
1434
- y: -Math.SQRT1_2,
1435
- z: 0,
1436
- w: Math.SQRT1_2
1437
- }
1438
- },
1439
- id: "link2_capsule"
1440
- }
1441
- },
1442
- {
1443
- link_index: 3,
1444
- geometry: {
1445
- sphere: { radius: 270 },
1446
- init_pose: {
1447
- position: {
1448
- x: -110,
1449
- y: 10,
1450
- z: -100
1451
- },
1452
- orientation: {
1453
- x: 0,
1454
- y: 0,
1455
- z: 0,
1456
- w: 1
1457
- }
1458
- },
1459
- id: "link3_sphere"
1460
- }
1461
- },
1462
- {
1463
- link_index: 4,
1464
- geometry: {
1465
- capsule: {
1466
- radius: 110,
1467
- cylinder_height: 600
1468
- },
1469
- init_pose: {
1470
- position: {
1471
- x: 0,
1472
- y: 300,
1473
- z: 40
1474
- },
1475
- orientation: {
1476
- x: -Math.SQRT1_2,
1477
- y: 0,
1478
- z: 0,
1479
- w: Math.SQRT1_2
1480
- }
1481
- },
1482
- id: "link4_capsule"
1483
- }
1484
- },
1485
- {
1486
- link_index: 5,
1487
- geometry: {
1488
- sphere: { radius: 75 },
1489
- init_pose: {
1490
- position: {
1491
- x: 0,
1492
- y: 0,
1493
- z: -50
1494
- },
1495
- orientation: {
1496
- x: 0,
1497
- y: 0,
1498
- z: 0,
1499
- w: 1
1500
- }
1501
- },
1502
- id: "link5_sphere"
1503
- }
1504
- }
1505
- ],
1506
- tool_geometries: []
1507
- };
1508
- }
1509
- },
1510
- {
1511
- method: "GET",
1512
- path: "/cells/:cellId/coordinate-systems",
1513
- handle() {
1514
- return { coordinatesystems: [{
1515
- coordinate_system: "",
1516
- name: "world",
1517
- reference_uid: "",
1518
- position: {
1519
- x: 0,
1520
- y: 0,
1521
- z: 0
1522
- },
1523
- rotation: {
1524
- angles: [
1525
- 0,
1526
- 0,
1527
- 0
1528
- ],
1529
- type: "ROTATION_VECTOR"
1530
- }
1531
- }] };
1532
- }
1533
- },
1534
- {
1535
- method: "GET",
1536
- path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
1537
- handle() {
1538
- return { tcps: [{
1539
- id: "Flange",
1540
- readable_name: "Default-Flange",
1541
- position: {
1542
- x: 0,
1543
- y: 0,
1544
- z: 0
1545
- },
1546
- rotation: {
1547
- angles: [
1548
- 0,
1549
- 0,
1550
- 0,
1551
- 0
1552
- ],
1553
- type: "ROTATION_VECTOR"
1554
- }
1555
- }, {
1556
- id: "complex-tcp-position",
1557
- readable_name: "Complex TCP Position",
1558
- position: {
1559
- x: -200,
1560
- y: 300,
1561
- z: 150
1562
- },
1563
- rotation: {
1564
- angles: [
1565
- -.12139440409113832,
1566
- -.06356210998212003,
1567
- -.2023240068185639,
1568
- 0
1569
- ],
1570
- type: "ROTATION_VECTOR"
1571
- }
1572
- }] };
1573
- }
1574
- }
1575
- ];
1576
- const method = config.method?.toUpperCase() || "GET";
1577
- const path = `/cells${config.url?.split("/cells")[1]?.split("?")[0]}`;
1578
- for (const handler of apiHandlers) {
1579
- const match = pathToRegexp.match(handler.path)(path || "");
1580
- if (method === handler.method && match) {
1581
- const json = handler.handle();
1582
- return {
1583
- status: 200,
1584
- statusText: "Success",
1585
- data: JSON.stringify(json),
1586
- headers: {},
1587
- config,
1588
- request: { responseURL: config.url }
1589
- };
1590
- }
1591
- }
1592
- throw new AxiosError(`No mock handler matched this request: ${method} ${path}`, "404", config);
1593
- }
1594
- handleWebsocketConnection(socket) {
1595
- this.connections.push(socket);
1596
- setTimeout(() => {
1597
- socket.dispatchEvent(new Event("open"));
1598
- console.log("Websocket connection opened from", socket.url);
1599
- if (socket.url.includes("/state-stream")) socket.dispatchEvent(new MessageEvent("message", { data: JSON.stringify(defaultMotionState) }));
1600
- if (socket.url.includes("/move-joint")) socket.dispatchEvent(new MessageEvent("message", { data: JSON.stringify({ result: {
1601
- motion_group: "0@ur",
1602
- state: {
1603
- controller: "ur",
1604
- operation_mode: "OPERATION_MODE_AUTO",
1605
- safety_state: "SAFETY_STATE_NORMAL",
1606
- timestamp: "2024-09-18T12:48:26.096266444Z",
1607
- velocity_override: 100,
1608
- motion_groups: [{
1609
- motion_group: "0@ur",
1610
- controller: "ur",
1611
- joint_position: { joints: [
1612
- 1.3492152690887451,
1613
- -1.5659207105636597,
1614
- 1.6653711795806885,
1615
- -1.0991662740707397,
1616
- -1.829018235206604,
1617
- 1.264623761177063
1618
- ] },
1619
- joint_velocity: { joints: [
1620
- 0,
1621
- 0,
1622
- 0,
1623
- 0,
1624
- 0,
1625
- 0
1626
- ] },
1627
- flange_pose: {
1628
- position: {
1629
- x: 6.437331889439328,
1630
- y: -628.4123774830913,
1631
- z: 577.0569957147832
1632
- },
1633
- orientation: {
1634
- x: -1.683333649797158,
1635
- y: -1.9783363827298732,
1636
- z: -.4928031860165713
1637
- },
1638
- coordinate_system: ""
1639
- },
1640
- tcp_pose: {
1641
- position: {
1642
- x: 6.437331889439328,
1643
- y: -628.4123774830913,
1644
- z: 577.0569957147832
1645
- },
1646
- orientation: {
1647
- x: -1.683333649797158,
1648
- y: -1.9783363827298732,
1649
- z: -.4928031860165713
1650
- },
1651
- coordinate_system: "",
1652
- tcp: "Flange"
1653
- },
1654
- velocity: {
1655
- linear: {
1656
- x: 0,
1657
- y: 0,
1658
- z: 0
1659
- },
1660
- angular: {
1661
- x: -0,
1662
- y: 0,
1663
- z: 0
1664
- },
1665
- coordinate_system: ""
1666
- },
1667
- force: {
1668
- force: {
1669
- x: 0,
1670
- y: 0,
1671
- z: 0
1672
- },
1673
- moment: {
1674
- x: 0,
1675
- y: 0,
1676
- z: 0
1677
- },
1678
- coordinate_system: ""
1679
- },
1680
- joint_limit_reached: { limit_reached: [
1681
- false,
1682
- false,
1683
- false,
1684
- false,
1685
- false,
1686
- false
1687
- ] },
1688
- joint_current: { joints: [
1689
- 0,
1690
- 0,
1691
- 0,
1692
- 0,
1693
- 0,
1694
- 0
1695
- ] },
1696
- sequence_number: "671259"
1697
- }],
1698
- sequence_number: "671259"
1699
- },
1700
- movement_state: "MOVEMENT_STATE_MOVING"
1701
- } }) }));
1702
- if (socket.url.includes("/move-tcp")) socket.dispatchEvent(new MessageEvent("message", { data: JSON.stringify({ result: {
1703
- motion_group: "0@ur",
1704
- state: {
1705
- controller: "ur",
1706
- operation_mode: "OPERATION_MODE_AUTO",
1707
- safety_state: "SAFETY_STATE_NORMAL",
1708
- timestamp: "2024-09-18T12:43:12.188335774Z",
1709
- velocity_override: 100,
1710
- motion_groups: [{
1711
- motion_group: "0@ur",
1712
- controller: "ur",
1713
- joint_position: { joints: [
1714
- 1.3352527618408203,
1715
- -1.5659207105636597,
1716
- 1.6653711795806885,
1717
- -1.110615611076355,
1718
- -1.829018235206604,
1719
- 1.264623761177063
1720
- ] },
1721
- joint_velocity: { joints: [
1722
- 0,
1723
- 0,
1724
- 0,
1725
- 0,
1726
- 0,
1727
- 0
1728
- ] },
1729
- flange_pose: {
1730
- position: {
1731
- x: -2.763015284002938,
1732
- y: -630.2151479701106,
1733
- z: 577.524509114342
1734
- },
1735
- orientation: {
1736
- x: -1.704794877102097,
1737
- y: -1.9722372952861567,
1738
- z: -.4852079204210754
1739
- },
1740
- coordinate_system: ""
1741
- },
1742
- tcp_pose: {
1743
- position: {
1744
- x: -2.763015284002938,
1745
- y: -630.2151479701106,
1746
- z: 577.524509114342
1747
- },
1748
- orientation: {
1749
- x: -1.704794877102097,
1750
- y: -1.9722372952861567,
1751
- z: -.4852079204210754
1752
- },
1753
- coordinate_system: "",
1754
- tcp: "Flange"
1755
- },
1756
- velocity: {
1757
- linear: {
1758
- x: 0,
1759
- y: 0,
1760
- z: 0
1761
- },
1762
- angular: {
1763
- x: -0,
1764
- y: 0,
1765
- z: 0
1766
- },
1767
- coordinate_system: ""
1768
- },
1769
- force: {
1770
- force: {
1771
- x: 0,
1772
- y: 0,
1773
- z: 0
1774
- },
1775
- moment: {
1776
- x: 0,
1777
- y: 0,
1778
- z: 0
1779
- },
1780
- coordinate_system: ""
1781
- },
1782
- joint_limit_reached: { limit_reached: [
1783
- false,
1784
- false,
1785
- false,
1786
- false,
1787
- false,
1788
- false
1789
- ] },
1790
- joint_current: { joints: [
1791
- 0,
1792
- 0,
1793
- 0,
1794
- 0,
1795
- 0,
1796
- 0
1797
- ] },
1798
- sequence_number: "627897"
1799
- }],
1800
- sequence_number: "627897"
1801
- },
1802
- movement_state: "MOVEMENT_STATE_MOVING"
1803
- } }) }));
1804
- }, 10);
1805
- }
1806
- handleWebsocketMessage(socket, message) {
1807
- console.log(`Received message on ${socket.url}`, message);
1808
- }
1809
- };
1810
- const defaultMotionState = { result: {
1811
- state: {
1812
- motion_group: "0@universalrobots-ur5e",
1813
- controller: "universalrobots-ur5e",
1814
- joint_position: { joints: [
1815
- 1.1699999570846558,
1816
- -1.5700000524520874,
1817
- 1.3600000143051147,
1818
- 1.0299999713897705,
1819
- 1.2899999618530273,
1820
- 1.2799999713897705
1821
- ] },
1822
- joint_velocity: { joints: [
1823
- 0,
1824
- 0,
1825
- 0,
1826
- 0,
1827
- 0,
1828
- 0
1829
- ] },
1830
- flange_pose: {
1831
- position: {
1832
- x: 1.3300010259703043,
1833
- y: -409.2680714682808,
1834
- z: 531.0203477065281
1835
- },
1836
- orientation: {
1837
- x: 1.7564919306270736,
1838
- y: -1.7542521568325058,
1839
- z: .7326972590614671
1840
- },
1841
- coordinate_system: ""
1842
- },
1843
- tcp_pose: {
1844
- position: {
1845
- x: 1.3300010259703043,
1846
- y: -409.2680714682808,
1847
- z: 531.0203477065281
1848
- },
1849
- orientation: {
1850
- x: 1.7564919306270736,
1851
- y: -1.7542521568325058,
1852
- z: .7326972590614671
1853
- },
1854
- coordinate_system: "",
1855
- tcp: "Flange"
1856
- },
1857
- velocity: {
1858
- linear: {
1859
- x: 0,
1860
- y: 0,
1861
- z: 0
1862
- },
1863
- angular: {
1864
- x: 0,
1865
- y: 0,
1866
- z: 0
1867
- },
1868
- coordinate_system: ""
1869
- },
1870
- force: {
1871
- force: {
1872
- x: 0,
1873
- y: 0,
1874
- z: 0
1875
- },
1876
- moment: {
1877
- x: 0,
1878
- y: 0,
1879
- z: 0
1880
- },
1881
- coordinate_system: ""
1882
- },
1883
- joint_limit_reached: { limit_reached: [
1884
- false,
1885
- false,
1886
- false,
1887
- false,
1888
- false,
1889
- false
1890
- ] },
1891
- joint_current: { joints: [
1892
- 0,
1893
- 0,
1894
- 0,
1895
- 0,
1896
- 0,
1897
- 0
1898
- ] },
1899
- sequence_number: "1"
1900
- },
1901
- tcp_pose: {
1902
- position: {
1903
- x: 302.90748476115556,
1904
- y: -152.87065869452337,
1905
- z: 424.0454619321661
1906
- },
1907
- orientation: {
1908
- x: 2.3403056115045353,
1909
- y: -1.1706836379431356,
1910
- z: .9772511964246311
1911
- },
1912
- coordinate_system: "",
1913
- tcp: "Flange"
1914
- }
1915
- } };
1916
- //#endregion
1917
- //#region src/lib/deprecated/v1/NovaClient.ts
1918
- /**
1919
- * Client for connecting to a Nova instance and controlling robots.
1920
- * @deprecated The nova v1 client is deprecated. Please use the v2 client from `@wandelbots/nova-js/v2` instead.
1921
- */
1922
- var NovaClient = class {
1923
- api;
1924
- config;
1925
- mock;
1926
- instanceUrl;
1927
- authPromise = null;
1928
- accessToken = null;
1929
- constructor(config) {
1930
- const cellId = config.cellId ?? "cell";
1931
- this.config = {
1932
- cellId,
1933
- ...config
1934
- };
1935
- this.accessToken = config.accessToken || availableStorage.getString("wbjs.access_token") || null;
1936
- if (this.config.instanceUrl === "https://mock.example.com") this.mock = new MockNovaInstance();
1937
- this.instanceUrl = parseNovaInstanceUrl(this.config.instanceUrl);
1938
- const axiosInstance = axios.create({
1939
- baseURL: new URL("/api/v1", this.config.instanceUrl).href,
1940
- headers: isLocalhostDev ? {} : { "X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK" }
1941
- });
1942
- axiosInstance.interceptors.request.use(async (request) => {
1943
- if (!request.headers.Authorization) {
1944
- if (this.accessToken) request.headers.Authorization = `Bearer ${this.accessToken}`;
1945
- else if (this.config.username && this.config.password) request.headers.Authorization = `Basic ${btoa(`${config.username}:${config.password}`)}`;
1946
- }
1947
- return request;
1948
- });
1949
- if (isBrowser) axiosInstance.interceptors.response.use((r) => r, async (error) => {
1950
- if (isAxiosError(error)) {
1951
- if (error.response?.status === 401) try {
1952
- await this.renewAuthentication();
1953
- if (error.config) {
1954
- if (this.accessToken) error.config.headers.Authorization = `Bearer ${this.accessToken}`;
1955
- else delete error.config.headers.Authorization;
1956
- return axiosInstance.request(error.config);
1957
- }
1958
- } catch (err) {
1959
- return Promise.reject(err);
1960
- }
1961
- else if (error.response?.status === 503) {
1962
- if ((await fetch(window.location.href)).status === 503) return guardedPageReload("503_server_unavailable");
1963
- }
1964
- }
1965
- return Promise.reject(error);
1966
- });
1967
- this.api = new NovaCellAPIClient(cellId, {
1968
- ...config,
1969
- basePath: new URL("/api/v1", this.instanceUrl).href,
1970
- isJsonMime: (mime) => {
1971
- return mime === "application/json";
1972
- },
1973
- baseOptions: {
1974
- ...this.mock ? { adapter: (config) => {
1975
- return this.mock.handleAPIRequest(config);
1976
- } } : {},
1977
- ...config.baseOptions
1978
- },
1979
- axiosInstance
1980
- });
1981
- }
1982
- async renewAuthentication() {
1983
- if (this.authPromise) return;
1984
- const storedToken = availableStorage.getString("wbjs.access_token");
1985
- if (storedToken && this.accessToken !== storedToken) {
1986
- this.accessToken = storedToken;
1987
- return;
1988
- }
1989
- this.authPromise = loginWithAuth0(this.instanceUrl);
1990
- try {
1991
- this.accessToken = await this.authPromise;
1992
- if (this.accessToken) availableStorage.setString("wbjs.access_token", this.accessToken);
1993
- else availableStorage.delete("wbjs.access_token");
1994
- } finally {
1995
- this.authPromise = null;
1996
- }
1997
- }
1998
- makeWebsocketURL(path) {
1999
- const url = new URL(new URL(`/api/v1/cells/${this.config.cellId}/${path.replace(/^\/+/, "")}`, this.instanceUrl).href);
2000
- url.protocol = url.protocol.replace("http", "ws");
2001
- url.protocol = url.protocol.replace("https", "wss");
2002
- if (this.accessToken) url.searchParams.append("token", this.accessToken);
2003
- else if (this.config.username && this.config.password) {
2004
- url.username = this.config.username;
2005
- url.password = this.config.password;
2006
- }
2007
- return url.toString();
2008
- }
2009
- /**
2010
- * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.
2011
- * If you explicitly want to reconnect an existing websocket, call `reconnect`
2012
- * on the returned object.
2013
- */
2014
- openReconnectingWebsocket(path) {
2015
- return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), { mock: this.mock });
2016
- }
2017
- /**
2018
- * Connect to the motion state websocket(s) for a given motion group
2019
- */
2020
- async connectMotionStream(motionGroupId) {
2021
- return await MotionStreamConnection.open(this, motionGroupId);
2022
- }
2023
- /**
2024
- * Connect to the jogging websocket(s) for a given motion group
2025
- */
2026
- async connectJogger(motionGroupId) {
2027
- return await JoggerConnection.open(this, motionGroupId);
2028
- }
2029
- async connectMotionGroups(motionGroupIds) {
2030
- const { instances } = await this.api.controller.listControllers();
2031
- return Promise.all(motionGroupIds.map((motionGroupId) => ConnectedMotionGroup.connect(this, motionGroupId, instances)));
2032
- }
2033
- async connectMotionGroup(motionGroupId) {
2034
- return (await this.connectMotionGroups([motionGroupId]))[0];
2035
- }
2036
- };
2037
- //#endregion
2038
- //#region src/lib/deprecated/v1/wandelscriptUtils.ts
2039
- /**
2040
- * Convert a Pose object representing a motion group position
2041
- * into a string which represents that pose in Wandelscript.
2042
- * @deprecated
2043
- */
2044
- function poseToWandelscriptString(pose) {
2045
- const position = [
2046
- pose.position.x,
2047
- pose.position.y,
2048
- pose.position.z
2049
- ];
2050
- const orientation = [
2051
- pose.orientation?.x ?? 0,
2052
- pose.orientation?.y ?? 0,
2053
- pose.orientation?.z ?? 0
2054
- ];
2055
- const positionValues = position.map((v) => v.toFixed(1));
2056
- const rotationValues = orientation.map((v) => v.toFixed(4));
2057
- return `(${positionValues.concat(rotationValues).join(", ")})`;
2058
- }
2059
- //#endregion
2060
- export { JoggerConnection as a, MotionStreamConnection as i, NovaClient as n, ConnectedMotionGroup as o, NovaCellAPIClient as r, poseToWandelscriptString as t };
2061
-
2062
- //# sourceMappingURL=wandelscriptUtils-CpUXdLVc.mjs.map