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