@wandelbots/nova-js 1.17.1-pr.feat-added-v2-client.64.9ac2247

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 (95) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +202 -0
  3. package/dist/LoginWithAuth0.d.ts +7 -0
  4. package/dist/LoginWithAuth0.d.ts.map +1 -0
  5. package/dist/chunk-V3NJLR6P.js +336 -0
  6. package/dist/chunk-V3NJLR6P.js.map +1 -0
  7. package/dist/index.cjs +390 -0
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.ts +6 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +54 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/lib/AutoReconnectingWebsocket.d.ts +43 -0
  14. package/dist/lib/AutoReconnectingWebsocket.d.ts.map +1 -0
  15. package/dist/lib/availableStorage.d.ts +15 -0
  16. package/dist/lib/availableStorage.d.ts.map +1 -0
  17. package/dist/lib/converters.d.ts +26 -0
  18. package/dist/lib/converters.d.ts.map +1 -0
  19. package/dist/lib/errorHandling.d.ts +4 -0
  20. package/dist/lib/errorHandling.d.ts.map +1 -0
  21. package/dist/lib/v1/ConnectedMotionGroup.d.ts +77 -0
  22. package/dist/lib/v1/ConnectedMotionGroup.d.ts.map +1 -0
  23. package/dist/lib/v1/JoggerConnection.d.ts +94 -0
  24. package/dist/lib/v1/JoggerConnection.d.ts.map +1 -0
  25. package/dist/lib/v1/MotionStreamConnection.d.ts +25 -0
  26. package/dist/lib/v1/MotionStreamConnection.d.ts.map +1 -0
  27. package/dist/lib/v1/NovaCellAPIClient.d.ts +66 -0
  28. package/dist/lib/v1/NovaCellAPIClient.d.ts.map +1 -0
  29. package/dist/lib/v1/NovaClient.d.ts +67 -0
  30. package/dist/lib/v1/NovaClient.d.ts.map +1 -0
  31. package/dist/lib/v1/ProgramStateConnection.d.ts +53 -0
  32. package/dist/lib/v1/ProgramStateConnection.d.ts.map +1 -0
  33. package/dist/lib/v1/getLatestTrajectories.d.ts +4 -0
  34. package/dist/lib/v1/getLatestTrajectories.d.ts.map +1 -0
  35. package/dist/lib/v1/index.cjs +3957 -0
  36. package/dist/lib/v1/index.cjs.map +1 -0
  37. package/dist/lib/v1/index.d.ts +9 -0
  38. package/dist/lib/v1/index.d.ts.map +1 -0
  39. package/dist/lib/v1/index.js +3662 -0
  40. package/dist/lib/v1/index.js.map +1 -0
  41. package/dist/lib/v1/mock/MockNovaInstance.d.ts +13 -0
  42. package/dist/lib/v1/mock/MockNovaInstance.d.ts.map +1 -0
  43. package/dist/lib/v1/motionStateUpdate.d.ts +4 -0
  44. package/dist/lib/v1/motionStateUpdate.d.ts.map +1 -0
  45. package/dist/lib/v2/ConnectedMotionGroup.d.ts +41 -0
  46. package/dist/lib/v2/ConnectedMotionGroup.d.ts.map +1 -0
  47. package/dist/lib/v2/JoggerConnection.d.ts +53 -0
  48. package/dist/lib/v2/JoggerConnection.d.ts.map +1 -0
  49. package/dist/lib/v2/MotionStreamConnection.d.ts +25 -0
  50. package/dist/lib/v2/MotionStreamConnection.d.ts.map +1 -0
  51. package/dist/lib/v2/NovaCellAPIClient.d.ts +64 -0
  52. package/dist/lib/v2/NovaCellAPIClient.d.ts.map +1 -0
  53. package/dist/lib/v2/NovaClient.d.ts +67 -0
  54. package/dist/lib/v2/NovaClient.d.ts.map +1 -0
  55. package/dist/lib/v2/ProgramStateConnection.d.ts +53 -0
  56. package/dist/lib/v2/ProgramStateConnection.d.ts.map +1 -0
  57. package/dist/lib/v2/index.cjs +2239 -0
  58. package/dist/lib/v2/index.cjs.map +1 -0
  59. package/dist/lib/v2/index.d.ts +8 -0
  60. package/dist/lib/v2/index.d.ts.map +1 -0
  61. package/dist/lib/v2/index.js +1947 -0
  62. package/dist/lib/v2/index.js.map +1 -0
  63. package/dist/lib/v2/mock/MockNovaInstance.d.ts +13 -0
  64. package/dist/lib/v2/mock/MockNovaInstance.d.ts.map +1 -0
  65. package/dist/lib/v2/motionStateUpdate.d.ts +4 -0
  66. package/dist/lib/v2/motionStateUpdate.d.ts.map +1 -0
  67. package/dist/lib/v2/vectorUtils.d.ts +7 -0
  68. package/dist/lib/v2/vectorUtils.d.ts.map +1 -0
  69. package/package.json +67 -0
  70. package/src/LoginWithAuth0.ts +90 -0
  71. package/src/index.ts +5 -0
  72. package/src/lib/AutoReconnectingWebsocket.ts +163 -0
  73. package/src/lib/availableStorage.ts +46 -0
  74. package/src/lib/converters.ts +74 -0
  75. package/src/lib/errorHandling.ts +26 -0
  76. package/src/lib/v1/ConnectedMotionGroup.ts +419 -0
  77. package/src/lib/v1/JoggerConnection.ts +480 -0
  78. package/src/lib/v1/MotionStreamConnection.ts +202 -0
  79. package/src/lib/v1/NovaCellAPIClient.ts +180 -0
  80. package/src/lib/v1/NovaClient.ts +232 -0
  81. package/src/lib/v1/ProgramStateConnection.ts +267 -0
  82. package/src/lib/v1/getLatestTrajectories.ts +36 -0
  83. package/src/lib/v1/index.ts +8 -0
  84. package/src/lib/v1/mock/MockNovaInstance.ts +1302 -0
  85. package/src/lib/v1/motionStateUpdate.ts +55 -0
  86. package/src/lib/v2/ConnectedMotionGroup.ts +216 -0
  87. package/src/lib/v2/JoggerConnection.ts +207 -0
  88. package/src/lib/v2/MotionStreamConnection.ts +201 -0
  89. package/src/lib/v2/NovaCellAPIClient.ts +174 -0
  90. package/src/lib/v2/NovaClient.ts +230 -0
  91. package/src/lib/v2/ProgramStateConnection.ts +255 -0
  92. package/src/lib/v2/index.ts +7 -0
  93. package/src/lib/v2/mock/MockNovaInstance.ts +982 -0
  94. package/src/lib/v2/motionStateUpdate.ts +55 -0
  95. package/src/lib/v2/vectorUtils.ts +36 -0
@@ -0,0 +1,3662 @@
1
+ import {
2
+ AutoReconnectingWebsocket,
3
+ __async,
4
+ __spreadProps,
5
+ __spreadValues,
6
+ availableStorage,
7
+ isSameCoordinateSystem,
8
+ loginWithAuth0,
9
+ tryParseJson
10
+ } from "../../chunk-V3NJLR6P.js";
11
+
12
+ // src/lib/v1/index.ts
13
+ export * from "@wandelbots/nova-api/v1";
14
+
15
+ // src/lib/v1/ConnectedMotionGroup.ts
16
+ import { makeAutoObservable, runInAction } from "mobx";
17
+ import * as THREE from "three";
18
+
19
+ // src/lib/v1/motionStateUpdate.ts
20
+ function jointValuesEqual(oldJointValues, newJointValues, changeDeltaThreshold) {
21
+ if (newJointValues.length !== oldJointValues.length) {
22
+ return true;
23
+ }
24
+ for (let jointIndex = 0; jointIndex < newJointValues.length; jointIndex++) {
25
+ if (Math.abs(newJointValues[jointIndex] - oldJointValues[jointIndex]) > changeDeltaThreshold) {
26
+ return false;
27
+ }
28
+ }
29
+ return true;
30
+ }
31
+ function tcpPoseEqual(oldTcp, newTcp, changeDeltaThreshold) {
32
+ if (oldTcp === void 0 && newTcp || oldTcp && newTcp === void 0) {
33
+ return false;
34
+ }
35
+ if (oldTcp === void 0 || newTcp === void 0) {
36
+ return true;
37
+ }
38
+ let changedDelta = 0;
39
+ changedDelta += Math.abs(oldTcp.orientation.x - newTcp.orientation.x);
40
+ changedDelta += Math.abs(oldTcp.orientation.y - newTcp.orientation.y);
41
+ changedDelta += Math.abs(oldTcp.orientation.z - newTcp.orientation.z);
42
+ changedDelta += Math.abs(oldTcp.position.x - newTcp.position.x);
43
+ changedDelta += Math.abs(oldTcp.position.y - newTcp.position.y);
44
+ changedDelta += Math.abs(oldTcp.position.z - newTcp.position.z);
45
+ if (changedDelta > changeDeltaThreshold) {
46
+ return false;
47
+ }
48
+ return oldTcp.coordinate_system === newTcp.coordinate_system && oldTcp.tcp === newTcp.tcp;
49
+ }
50
+
51
+ // src/lib/v1/ConnectedMotionGroup.ts
52
+ var MOTION_DELTA_THRESHOLD = 1e-4;
53
+ var ConnectedMotionGroup = class _ConnectedMotionGroup {
54
+ constructor(nova, controller, motionGroup, initialMotionState, motionStateSocket, isVirtual, tcps, motionGroupSpecification, safetySetup, mounting, initialControllerState, controllerStateSocket) {
55
+ this.nova = nova;
56
+ this.controller = controller;
57
+ this.motionGroup = motionGroup;
58
+ this.initialMotionState = initialMotionState;
59
+ this.motionStateSocket = motionStateSocket;
60
+ this.isVirtual = isVirtual;
61
+ this.tcps = tcps;
62
+ this.motionGroupSpecification = motionGroupSpecification;
63
+ this.safetySetup = safetySetup;
64
+ this.mounting = mounting;
65
+ this.initialControllerState = initialControllerState;
66
+ this.controllerStateSocket = controllerStateSocket;
67
+ this.connectedJoggingCartesianSocket = null;
68
+ this.connectedJoggingJointsSocket = null;
69
+ // tmp
70
+ this.joggingVelocity = 10;
71
+ /**
72
+ * Reflects activation state of the motion group / robot servos. The
73
+ * movement controls in the UI should only be enabled in the "active" state
74
+ */
75
+ this.activationState = "inactive";
76
+ this.rapidlyChangingMotionState = initialMotionState;
77
+ this.controllerState = initialControllerState;
78
+ controllerStateSocket.addEventListener("message", (event) => {
79
+ var _a;
80
+ const data = (_a = tryParseJson(event.data)) == null ? void 0 : _a.result;
81
+ if (!data) {
82
+ return;
83
+ }
84
+ runInAction(() => {
85
+ this.controllerState = data;
86
+ });
87
+ });
88
+ motionStateSocket.addEventListener("message", (event) => {
89
+ var _a;
90
+ const motionStateResponse = (_a = tryParseJson(event.data)) == null ? void 0 : _a.result;
91
+ if (!motionStateResponse) {
92
+ throw new Error(
93
+ `Failed to get motion state for ${this.motionGroupId}: ${event.data}`
94
+ );
95
+ }
96
+ if (!jointValuesEqual(
97
+ this.rapidlyChangingMotionState.state.joint_position.joints,
98
+ motionStateResponse.state.joint_position.joints,
99
+ MOTION_DELTA_THRESHOLD
100
+ )) {
101
+ runInAction(() => {
102
+ this.rapidlyChangingMotionState.state = motionStateResponse.state;
103
+ });
104
+ }
105
+ if (!tcpPoseEqual(
106
+ this.rapidlyChangingMotionState.tcp_pose,
107
+ motionStateResponse.tcp_pose,
108
+ MOTION_DELTA_THRESHOLD
109
+ )) {
110
+ runInAction(() => {
111
+ this.rapidlyChangingMotionState.tcp_pose = motionStateResponse.tcp_pose;
112
+ });
113
+ }
114
+ });
115
+ makeAutoObservable(this);
116
+ }
117
+ static connect(nova, motionGroupId, controllers) {
118
+ return __async(this, null, function* () {
119
+ var _a, _b;
120
+ const [_motionGroupIndex, controllerId] = motionGroupId.split("@");
121
+ const controller = controllers.find((c) => c.controller === controllerId);
122
+ const motionGroup = controller == null ? void 0 : controller.physical_motion_groups.find(
123
+ (mg) => mg.motion_group === motionGroupId
124
+ );
125
+ if (!controller || !motionGroup) {
126
+ throw new Error(
127
+ `Controller ${controllerId} or motion group ${motionGroupId} not found`
128
+ );
129
+ }
130
+ const motionStateSocket = nova.openReconnectingWebsocket(
131
+ `/motion-groups/${motionGroupId}/state-stream`
132
+ );
133
+ const firstMessage = yield motionStateSocket.firstMessage();
134
+ const initialMotionState = (_a = tryParseJson(firstMessage.data)) == null ? void 0 : _a.result;
135
+ if (!initialMotionState) {
136
+ throw new Error(
137
+ `Unable to parse initial motion state message ${firstMessage.data}`
138
+ );
139
+ }
140
+ console.log(
141
+ `Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:
142
+ `,
143
+ initialMotionState
144
+ );
145
+ const config = yield nova.api.controller.getRobotController(
146
+ controller.controller
147
+ );
148
+ const isVirtual = config.configuration.kind === "VirtualController";
149
+ const mounting = yield (() => __async(this, null, function* () {
150
+ try {
151
+ const mounting2 = yield nova.api.motionGroupInfos.getMounting(
152
+ motionGroup.motion_group
153
+ );
154
+ return mounting2;
155
+ } catch (err) {
156
+ console.error(
157
+ `Error fetching mounting for ${motionGroup.motion_group}`,
158
+ err
159
+ );
160
+ return null;
161
+ }
162
+ }))();
163
+ const controllerStateSocket = nova.openReconnectingWebsocket(
164
+ `/controllers/${controller.controller}/state-stream?response_rate=1000`
165
+ );
166
+ const firstControllerMessage = yield controllerStateSocket.firstMessage();
167
+ const initialControllerState = (_b = tryParseJson(firstControllerMessage.data)) == null ? void 0 : _b.result;
168
+ if (!initialControllerState) {
169
+ throw new Error(
170
+ `Unable to parse initial controller state message ${firstControllerMessage.data}`
171
+ );
172
+ }
173
+ console.log(
174
+ `Connected controller state websocket to controller ${controller.controller}. Initial state:
175
+ `,
176
+ initialControllerState
177
+ );
178
+ const { tcps } = yield nova.api.motionGroupInfos.listTcps(motionGroupId);
179
+ const motionGroupSpecification = yield nova.api.motionGroupInfos.getMotionGroupSpecification(motionGroupId);
180
+ const safetySetup = yield nova.api.motionGroupInfos.getSafetySetup(motionGroupId);
181
+ return new _ConnectedMotionGroup(
182
+ nova,
183
+ controller,
184
+ motionGroup,
185
+ initialMotionState,
186
+ motionStateSocket,
187
+ isVirtual,
188
+ tcps,
189
+ motionGroupSpecification,
190
+ safetySetup,
191
+ mounting,
192
+ initialControllerState,
193
+ controllerStateSocket
194
+ );
195
+ });
196
+ }
197
+ get motionGroupId() {
198
+ return this.motionGroup.motion_group;
199
+ }
200
+ get controllerId() {
201
+ return this.controller.controller;
202
+ }
203
+ get modelFromController() {
204
+ return this.motionGroup.model_from_controller;
205
+ }
206
+ get wandelscriptIdentifier() {
207
+ const num = this.motionGroupId.split("@")[0];
208
+ return `${this.controllerId.replaceAll("-", "_")}_${num}`;
209
+ }
210
+ /** Jogging velocity in radians for rotation and joint movement */
211
+ get joggingVelocityRads() {
212
+ return this.joggingVelocity * Math.PI / 180;
213
+ }
214
+ get joints() {
215
+ return this.initialMotionState.state.joint_position.joints.map((_, i) => {
216
+ return {
217
+ index: i
218
+ };
219
+ });
220
+ }
221
+ get dhParameters() {
222
+ return this.motionGroupSpecification.dh_parameters;
223
+ }
224
+ get safetyZones() {
225
+ return this.safetySetup.safety_zones;
226
+ }
227
+ /** Gets the robot mounting position offset in 3D viz coordinates */
228
+ get mountingPosition() {
229
+ if (!this.mounting) {
230
+ return [0, 0, 0];
231
+ }
232
+ return [
233
+ this.mounting.pose.position.x / 1e3,
234
+ this.mounting.pose.position.y / 1e3,
235
+ this.mounting.pose.position.z / 1e3
236
+ ];
237
+ }
238
+ /** Gets the robot mounting position rotation in 3D viz coordinates */
239
+ get mountingQuaternion() {
240
+ var _a, _b, _c, _d, _e, _f;
241
+ const rotationVector = new THREE.Vector3(
242
+ ((_b = (_a = this.mounting) == null ? void 0 : _a.pose.orientation) == null ? void 0 : _b.x) || 0,
243
+ ((_d = (_c = this.mounting) == null ? void 0 : _c.pose.orientation) == null ? void 0 : _d.y) || 0,
244
+ ((_f = (_e = this.mounting) == null ? void 0 : _e.pose.orientation) == null ? void 0 : _f.z) || 0
245
+ );
246
+ const magnitude = rotationVector.length();
247
+ const axis = rotationVector.normalize();
248
+ return new THREE.Quaternion().setFromAxisAngle(axis, magnitude);
249
+ }
250
+ /**
251
+ * Whether the controller is currently in a safety state
252
+ * corresponding to an emergency stop
253
+ */
254
+ get isEstopActive() {
255
+ const estopStates = [
256
+ "SAFETY_STATE_ROBOT_EMERGENCY_STOP",
257
+ "SAFETY_STATE_DEVICE_EMERGENCY_STOP"
258
+ ];
259
+ return estopStates.includes(this.controllerState.safety_state);
260
+ }
261
+ /**
262
+ * Whether the controller is in a safety state
263
+ * that may be non-functional for robot pad purposes
264
+ */
265
+ get isMoveableSafetyState() {
266
+ const goodSafetyStates = [
267
+ "SAFETY_STATE_NORMAL",
268
+ "SAFETY_STATE_REDUCED"
269
+ ];
270
+ return goodSafetyStates.includes(this.controllerState.safety_state);
271
+ }
272
+ /**
273
+ * Whether the controller is in an operation mode that allows movement
274
+ */
275
+ get isMoveableOperationMode() {
276
+ const goodOperationModes = [
277
+ "OPERATION_MODE_AUTO",
278
+ "OPERATION_MODE_MANUAL",
279
+ "OPERATION_MODE_MANUAL_T1",
280
+ "OPERATION_MODE_MANUAL_T2"
281
+ ];
282
+ return goodOperationModes.includes(this.controllerState.operation_mode);
283
+ }
284
+ /**
285
+ * Whether the robot is currently active and can be moved, based on the
286
+ * safety state, operation mode and servo toggle activation state.
287
+ */
288
+ get canBeMoved() {
289
+ return this.isMoveableSafetyState && this.isMoveableOperationMode && this.activationState === "active";
290
+ }
291
+ deactivate() {
292
+ return __async(this, null, function* () {
293
+ if (this.activationState !== "active") {
294
+ console.error("Tried to deactivate while already deactivating");
295
+ return;
296
+ }
297
+ runInAction(() => {
298
+ this.activationState = "deactivating";
299
+ });
300
+ try {
301
+ yield this.nova.api.controller.setDefaultMode(
302
+ this.controllerId,
303
+ "MODE_MONITOR"
304
+ );
305
+ runInAction(() => {
306
+ this.activationState = "inactive";
307
+ });
308
+ } catch (err) {
309
+ runInAction(() => {
310
+ this.activationState = "active";
311
+ });
312
+ throw err;
313
+ }
314
+ });
315
+ }
316
+ activate() {
317
+ return __async(this, null, function* () {
318
+ if (this.activationState !== "inactive") {
319
+ console.error("Tried to activate while already activating");
320
+ return;
321
+ }
322
+ runInAction(() => {
323
+ this.activationState = "activating";
324
+ });
325
+ try {
326
+ yield this.nova.api.controller.setDefaultMode(
327
+ this.controllerId,
328
+ "MODE_CONTROL"
329
+ );
330
+ runInAction(() => {
331
+ this.activationState = "active";
332
+ });
333
+ } catch (err) {
334
+ runInAction(() => {
335
+ this.activationState = "inactive";
336
+ });
337
+ throw err;
338
+ }
339
+ });
340
+ }
341
+ toggleActivation() {
342
+ if (this.activationState === "inactive") {
343
+ this.activate();
344
+ } else if (this.activationState === "active") {
345
+ this.deactivate();
346
+ }
347
+ }
348
+ dispose() {
349
+ this.motionStateSocket.close();
350
+ if (this.connectedJoggingCartesianSocket)
351
+ this.connectedJoggingCartesianSocket.close();
352
+ if (this.connectedJoggingJointsSocket)
353
+ this.connectedJoggingJointsSocket.close();
354
+ }
355
+ setJoggingVelocity(velocity) {
356
+ this.joggingVelocity = velocity;
357
+ }
358
+ };
359
+
360
+ // src/lib/v1/getLatestTrajectories.ts
361
+ var lastMotionIds = /* @__PURE__ */ new Set();
362
+ function getLatestTrajectories(apiClient, sampleTime = 50, responsesCoordinateSystem) {
363
+ return __async(this, null, function* () {
364
+ const newTrajectories = [];
365
+ try {
366
+ const motions = yield apiClient.motion.listMotions();
367
+ const currentMotionIds = new Set(motions.motions);
368
+ const newMotionIds = Array.from(currentMotionIds).filter(
369
+ (id) => !lastMotionIds.has(id)
370
+ );
371
+ for (const motionId of newMotionIds) {
372
+ const trajectory = yield apiClient.motion.getMotionTrajectory(
373
+ motionId,
374
+ sampleTime,
375
+ responsesCoordinateSystem
376
+ );
377
+ newTrajectories.push(trajectory);
378
+ }
379
+ lastMotionIds = currentMotionIds;
380
+ } catch (error) {
381
+ console.error("Failed to get latest trajectories:", error);
382
+ }
383
+ return newTrajectories;
384
+ });
385
+ }
386
+
387
+ // node_modules/lodash-es/_listCacheClear.js
388
+ function listCacheClear() {
389
+ this.__data__ = [];
390
+ this.size = 0;
391
+ }
392
+ var listCacheClear_default = listCacheClear;
393
+
394
+ // node_modules/lodash-es/eq.js
395
+ function eq(value, other) {
396
+ return value === other || value !== value && other !== other;
397
+ }
398
+ var eq_default = eq;
399
+
400
+ // node_modules/lodash-es/_assocIndexOf.js
401
+ function assocIndexOf(array, key) {
402
+ var length = array.length;
403
+ while (length--) {
404
+ if (eq_default(array[length][0], key)) {
405
+ return length;
406
+ }
407
+ }
408
+ return -1;
409
+ }
410
+ var assocIndexOf_default = assocIndexOf;
411
+
412
+ // node_modules/lodash-es/_listCacheDelete.js
413
+ var arrayProto = Array.prototype;
414
+ var splice = arrayProto.splice;
415
+ function listCacheDelete(key) {
416
+ var data = this.__data__, index = assocIndexOf_default(data, key);
417
+ if (index < 0) {
418
+ return false;
419
+ }
420
+ var lastIndex = data.length - 1;
421
+ if (index == lastIndex) {
422
+ data.pop();
423
+ } else {
424
+ splice.call(data, index, 1);
425
+ }
426
+ --this.size;
427
+ return true;
428
+ }
429
+ var listCacheDelete_default = listCacheDelete;
430
+
431
+ // node_modules/lodash-es/_listCacheGet.js
432
+ function listCacheGet(key) {
433
+ var data = this.__data__, index = assocIndexOf_default(data, key);
434
+ return index < 0 ? void 0 : data[index][1];
435
+ }
436
+ var listCacheGet_default = listCacheGet;
437
+
438
+ // node_modules/lodash-es/_listCacheHas.js
439
+ function listCacheHas(key) {
440
+ return assocIndexOf_default(this.__data__, key) > -1;
441
+ }
442
+ var listCacheHas_default = listCacheHas;
443
+
444
+ // node_modules/lodash-es/_listCacheSet.js
445
+ function listCacheSet(key, value) {
446
+ var data = this.__data__, index = assocIndexOf_default(data, key);
447
+ if (index < 0) {
448
+ ++this.size;
449
+ data.push([key, value]);
450
+ } else {
451
+ data[index][1] = value;
452
+ }
453
+ return this;
454
+ }
455
+ var listCacheSet_default = listCacheSet;
456
+
457
+ // node_modules/lodash-es/_ListCache.js
458
+ function ListCache(entries) {
459
+ var index = -1, length = entries == null ? 0 : entries.length;
460
+ this.clear();
461
+ while (++index < length) {
462
+ var entry = entries[index];
463
+ this.set(entry[0], entry[1]);
464
+ }
465
+ }
466
+ ListCache.prototype.clear = listCacheClear_default;
467
+ ListCache.prototype["delete"] = listCacheDelete_default;
468
+ ListCache.prototype.get = listCacheGet_default;
469
+ ListCache.prototype.has = listCacheHas_default;
470
+ ListCache.prototype.set = listCacheSet_default;
471
+ var ListCache_default = ListCache;
472
+
473
+ // node_modules/lodash-es/_stackClear.js
474
+ function stackClear() {
475
+ this.__data__ = new ListCache_default();
476
+ this.size = 0;
477
+ }
478
+ var stackClear_default = stackClear;
479
+
480
+ // node_modules/lodash-es/_stackDelete.js
481
+ function stackDelete(key) {
482
+ var data = this.__data__, result = data["delete"](key);
483
+ this.size = data.size;
484
+ return result;
485
+ }
486
+ var stackDelete_default = stackDelete;
487
+
488
+ // node_modules/lodash-es/_stackGet.js
489
+ function stackGet(key) {
490
+ return this.__data__.get(key);
491
+ }
492
+ var stackGet_default = stackGet;
493
+
494
+ // node_modules/lodash-es/_stackHas.js
495
+ function stackHas(key) {
496
+ return this.__data__.has(key);
497
+ }
498
+ var stackHas_default = stackHas;
499
+
500
+ // node_modules/lodash-es/_freeGlobal.js
501
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
502
+ var freeGlobal_default = freeGlobal;
503
+
504
+ // node_modules/lodash-es/_root.js
505
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
506
+ var root = freeGlobal_default || freeSelf || Function("return this")();
507
+ var root_default = root;
508
+
509
+ // node_modules/lodash-es/_Symbol.js
510
+ var Symbol = root_default.Symbol;
511
+ var Symbol_default = Symbol;
512
+
513
+ // node_modules/lodash-es/_getRawTag.js
514
+ var objectProto = Object.prototype;
515
+ var hasOwnProperty = objectProto.hasOwnProperty;
516
+ var nativeObjectToString = objectProto.toString;
517
+ var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
518
+ function getRawTag(value) {
519
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
520
+ try {
521
+ value[symToStringTag] = void 0;
522
+ var unmasked = true;
523
+ } catch (e) {
524
+ }
525
+ var result = nativeObjectToString.call(value);
526
+ if (unmasked) {
527
+ if (isOwn) {
528
+ value[symToStringTag] = tag;
529
+ } else {
530
+ delete value[symToStringTag];
531
+ }
532
+ }
533
+ return result;
534
+ }
535
+ var getRawTag_default = getRawTag;
536
+
537
+ // node_modules/lodash-es/_objectToString.js
538
+ var objectProto2 = Object.prototype;
539
+ var nativeObjectToString2 = objectProto2.toString;
540
+ function objectToString(value) {
541
+ return nativeObjectToString2.call(value);
542
+ }
543
+ var objectToString_default = objectToString;
544
+
545
+ // node_modules/lodash-es/_baseGetTag.js
546
+ var nullTag = "[object Null]";
547
+ var undefinedTag = "[object Undefined]";
548
+ var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
549
+ function baseGetTag(value) {
550
+ if (value == null) {
551
+ return value === void 0 ? undefinedTag : nullTag;
552
+ }
553
+ return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
554
+ }
555
+ var baseGetTag_default = baseGetTag;
556
+
557
+ // node_modules/lodash-es/isObject.js
558
+ function isObject(value) {
559
+ var type = typeof value;
560
+ return value != null && (type == "object" || type == "function");
561
+ }
562
+ var isObject_default = isObject;
563
+
564
+ // node_modules/lodash-es/isFunction.js
565
+ var asyncTag = "[object AsyncFunction]";
566
+ var funcTag = "[object Function]";
567
+ var genTag = "[object GeneratorFunction]";
568
+ var proxyTag = "[object Proxy]";
569
+ function isFunction(value) {
570
+ if (!isObject_default(value)) {
571
+ return false;
572
+ }
573
+ var tag = baseGetTag_default(value);
574
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
575
+ }
576
+ var isFunction_default = isFunction;
577
+
578
+ // node_modules/lodash-es/_coreJsData.js
579
+ var coreJsData = root_default["__core-js_shared__"];
580
+ var coreJsData_default = coreJsData;
581
+
582
+ // node_modules/lodash-es/_isMasked.js
583
+ var maskSrcKey = function() {
584
+ var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
585
+ return uid ? "Symbol(src)_1." + uid : "";
586
+ }();
587
+ function isMasked(func) {
588
+ return !!maskSrcKey && maskSrcKey in func;
589
+ }
590
+ var isMasked_default = isMasked;
591
+
592
+ // node_modules/lodash-es/_toSource.js
593
+ var funcProto = Function.prototype;
594
+ var funcToString = funcProto.toString;
595
+ function toSource(func) {
596
+ if (func != null) {
597
+ try {
598
+ return funcToString.call(func);
599
+ } catch (e) {
600
+ }
601
+ try {
602
+ return func + "";
603
+ } catch (e) {
604
+ }
605
+ }
606
+ return "";
607
+ }
608
+ var toSource_default = toSource;
609
+
610
+ // node_modules/lodash-es/_baseIsNative.js
611
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
612
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
613
+ var funcProto2 = Function.prototype;
614
+ var objectProto3 = Object.prototype;
615
+ var funcToString2 = funcProto2.toString;
616
+ var hasOwnProperty2 = objectProto3.hasOwnProperty;
617
+ var reIsNative = RegExp(
618
+ "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
619
+ );
620
+ function baseIsNative(value) {
621
+ if (!isObject_default(value) || isMasked_default(value)) {
622
+ return false;
623
+ }
624
+ var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
625
+ return pattern.test(toSource_default(value));
626
+ }
627
+ var baseIsNative_default = baseIsNative;
628
+
629
+ // node_modules/lodash-es/_getValue.js
630
+ function getValue(object, key) {
631
+ return object == null ? void 0 : object[key];
632
+ }
633
+ var getValue_default = getValue;
634
+
635
+ // node_modules/lodash-es/_getNative.js
636
+ function getNative(object, key) {
637
+ var value = getValue_default(object, key);
638
+ return baseIsNative_default(value) ? value : void 0;
639
+ }
640
+ var getNative_default = getNative;
641
+
642
+ // node_modules/lodash-es/_Map.js
643
+ var Map = getNative_default(root_default, "Map");
644
+ var Map_default = Map;
645
+
646
+ // node_modules/lodash-es/_nativeCreate.js
647
+ var nativeCreate = getNative_default(Object, "create");
648
+ var nativeCreate_default = nativeCreate;
649
+
650
+ // node_modules/lodash-es/_hashClear.js
651
+ function hashClear() {
652
+ this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
653
+ this.size = 0;
654
+ }
655
+ var hashClear_default = hashClear;
656
+
657
+ // node_modules/lodash-es/_hashDelete.js
658
+ function hashDelete(key) {
659
+ var result = this.has(key) && delete this.__data__[key];
660
+ this.size -= result ? 1 : 0;
661
+ return result;
662
+ }
663
+ var hashDelete_default = hashDelete;
664
+
665
+ // node_modules/lodash-es/_hashGet.js
666
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
667
+ var objectProto4 = Object.prototype;
668
+ var hasOwnProperty3 = objectProto4.hasOwnProperty;
669
+ function hashGet(key) {
670
+ var data = this.__data__;
671
+ if (nativeCreate_default) {
672
+ var result = data[key];
673
+ return result === HASH_UNDEFINED ? void 0 : result;
674
+ }
675
+ return hasOwnProperty3.call(data, key) ? data[key] : void 0;
676
+ }
677
+ var hashGet_default = hashGet;
678
+
679
+ // node_modules/lodash-es/_hashHas.js
680
+ var objectProto5 = Object.prototype;
681
+ var hasOwnProperty4 = objectProto5.hasOwnProperty;
682
+ function hashHas(key) {
683
+ var data = this.__data__;
684
+ return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty4.call(data, key);
685
+ }
686
+ var hashHas_default = hashHas;
687
+
688
+ // node_modules/lodash-es/_hashSet.js
689
+ var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
690
+ function hashSet(key, value) {
691
+ var data = this.__data__;
692
+ this.size += this.has(key) ? 0 : 1;
693
+ data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
694
+ return this;
695
+ }
696
+ var hashSet_default = hashSet;
697
+
698
+ // node_modules/lodash-es/_Hash.js
699
+ function Hash(entries) {
700
+ var index = -1, length = entries == null ? 0 : entries.length;
701
+ this.clear();
702
+ while (++index < length) {
703
+ var entry = entries[index];
704
+ this.set(entry[0], entry[1]);
705
+ }
706
+ }
707
+ Hash.prototype.clear = hashClear_default;
708
+ Hash.prototype["delete"] = hashDelete_default;
709
+ Hash.prototype.get = hashGet_default;
710
+ Hash.prototype.has = hashHas_default;
711
+ Hash.prototype.set = hashSet_default;
712
+ var Hash_default = Hash;
713
+
714
+ // node_modules/lodash-es/_mapCacheClear.js
715
+ function mapCacheClear() {
716
+ this.size = 0;
717
+ this.__data__ = {
718
+ "hash": new Hash_default(),
719
+ "map": new (Map_default || ListCache_default)(),
720
+ "string": new Hash_default()
721
+ };
722
+ }
723
+ var mapCacheClear_default = mapCacheClear;
724
+
725
+ // node_modules/lodash-es/_isKeyable.js
726
+ function isKeyable(value) {
727
+ var type = typeof value;
728
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
729
+ }
730
+ var isKeyable_default = isKeyable;
731
+
732
+ // node_modules/lodash-es/_getMapData.js
733
+ function getMapData(map, key) {
734
+ var data = map.__data__;
735
+ return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
736
+ }
737
+ var getMapData_default = getMapData;
738
+
739
+ // node_modules/lodash-es/_mapCacheDelete.js
740
+ function mapCacheDelete(key) {
741
+ var result = getMapData_default(this, key)["delete"](key);
742
+ this.size -= result ? 1 : 0;
743
+ return result;
744
+ }
745
+ var mapCacheDelete_default = mapCacheDelete;
746
+
747
+ // node_modules/lodash-es/_mapCacheGet.js
748
+ function mapCacheGet(key) {
749
+ return getMapData_default(this, key).get(key);
750
+ }
751
+ var mapCacheGet_default = mapCacheGet;
752
+
753
+ // node_modules/lodash-es/_mapCacheHas.js
754
+ function mapCacheHas(key) {
755
+ return getMapData_default(this, key).has(key);
756
+ }
757
+ var mapCacheHas_default = mapCacheHas;
758
+
759
+ // node_modules/lodash-es/_mapCacheSet.js
760
+ function mapCacheSet(key, value) {
761
+ var data = getMapData_default(this, key), size = data.size;
762
+ data.set(key, value);
763
+ this.size += data.size == size ? 0 : 1;
764
+ return this;
765
+ }
766
+ var mapCacheSet_default = mapCacheSet;
767
+
768
+ // node_modules/lodash-es/_MapCache.js
769
+ function MapCache(entries) {
770
+ var index = -1, length = entries == null ? 0 : entries.length;
771
+ this.clear();
772
+ while (++index < length) {
773
+ var entry = entries[index];
774
+ this.set(entry[0], entry[1]);
775
+ }
776
+ }
777
+ MapCache.prototype.clear = mapCacheClear_default;
778
+ MapCache.prototype["delete"] = mapCacheDelete_default;
779
+ MapCache.prototype.get = mapCacheGet_default;
780
+ MapCache.prototype.has = mapCacheHas_default;
781
+ MapCache.prototype.set = mapCacheSet_default;
782
+ var MapCache_default = MapCache;
783
+
784
+ // node_modules/lodash-es/_stackSet.js
785
+ var LARGE_ARRAY_SIZE = 200;
786
+ function stackSet(key, value) {
787
+ var data = this.__data__;
788
+ if (data instanceof ListCache_default) {
789
+ var pairs = data.__data__;
790
+ if (!Map_default || pairs.length < LARGE_ARRAY_SIZE - 1) {
791
+ pairs.push([key, value]);
792
+ this.size = ++data.size;
793
+ return this;
794
+ }
795
+ data = this.__data__ = new MapCache_default(pairs);
796
+ }
797
+ data.set(key, value);
798
+ this.size = data.size;
799
+ return this;
800
+ }
801
+ var stackSet_default = stackSet;
802
+
803
+ // node_modules/lodash-es/_Stack.js
804
+ function Stack(entries) {
805
+ var data = this.__data__ = new ListCache_default(entries);
806
+ this.size = data.size;
807
+ }
808
+ Stack.prototype.clear = stackClear_default;
809
+ Stack.prototype["delete"] = stackDelete_default;
810
+ Stack.prototype.get = stackGet_default;
811
+ Stack.prototype.has = stackHas_default;
812
+ Stack.prototype.set = stackSet_default;
813
+ var Stack_default = Stack;
814
+
815
+ // node_modules/lodash-es/_setCacheAdd.js
816
+ var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
817
+ function setCacheAdd(value) {
818
+ this.__data__.set(value, HASH_UNDEFINED3);
819
+ return this;
820
+ }
821
+ var setCacheAdd_default = setCacheAdd;
822
+
823
+ // node_modules/lodash-es/_setCacheHas.js
824
+ function setCacheHas(value) {
825
+ return this.__data__.has(value);
826
+ }
827
+ var setCacheHas_default = setCacheHas;
828
+
829
+ // node_modules/lodash-es/_SetCache.js
830
+ function SetCache(values) {
831
+ var index = -1, length = values == null ? 0 : values.length;
832
+ this.__data__ = new MapCache_default();
833
+ while (++index < length) {
834
+ this.add(values[index]);
835
+ }
836
+ }
837
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd_default;
838
+ SetCache.prototype.has = setCacheHas_default;
839
+ var SetCache_default = SetCache;
840
+
841
+ // node_modules/lodash-es/_arraySome.js
842
+ function arraySome(array, predicate) {
843
+ var index = -1, length = array == null ? 0 : array.length;
844
+ while (++index < length) {
845
+ if (predicate(array[index], index, array)) {
846
+ return true;
847
+ }
848
+ }
849
+ return false;
850
+ }
851
+ var arraySome_default = arraySome;
852
+
853
+ // node_modules/lodash-es/_cacheHas.js
854
+ function cacheHas(cache, key) {
855
+ return cache.has(key);
856
+ }
857
+ var cacheHas_default = cacheHas;
858
+
859
+ // node_modules/lodash-es/_equalArrays.js
860
+ var COMPARE_PARTIAL_FLAG = 1;
861
+ var COMPARE_UNORDERED_FLAG = 2;
862
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
863
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
864
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
865
+ return false;
866
+ }
867
+ var arrStacked = stack.get(array);
868
+ var othStacked = stack.get(other);
869
+ if (arrStacked && othStacked) {
870
+ return arrStacked == other && othStacked == array;
871
+ }
872
+ var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
873
+ stack.set(array, other);
874
+ stack.set(other, array);
875
+ while (++index < arrLength) {
876
+ var arrValue = array[index], othValue = other[index];
877
+ if (customizer) {
878
+ var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
879
+ }
880
+ if (compared !== void 0) {
881
+ if (compared) {
882
+ continue;
883
+ }
884
+ result = false;
885
+ break;
886
+ }
887
+ if (seen) {
888
+ if (!arraySome_default(other, function(othValue2, othIndex) {
889
+ if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
890
+ return seen.push(othIndex);
891
+ }
892
+ })) {
893
+ result = false;
894
+ break;
895
+ }
896
+ } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
897
+ result = false;
898
+ break;
899
+ }
900
+ }
901
+ stack["delete"](array);
902
+ stack["delete"](other);
903
+ return result;
904
+ }
905
+ var equalArrays_default = equalArrays;
906
+
907
+ // node_modules/lodash-es/_Uint8Array.js
908
+ var Uint8Array = root_default.Uint8Array;
909
+ var Uint8Array_default = Uint8Array;
910
+
911
+ // node_modules/lodash-es/_mapToArray.js
912
+ function mapToArray(map) {
913
+ var index = -1, result = Array(map.size);
914
+ map.forEach(function(value, key) {
915
+ result[++index] = [key, value];
916
+ });
917
+ return result;
918
+ }
919
+ var mapToArray_default = mapToArray;
920
+
921
+ // node_modules/lodash-es/_setToArray.js
922
+ function setToArray(set) {
923
+ var index = -1, result = Array(set.size);
924
+ set.forEach(function(value) {
925
+ result[++index] = value;
926
+ });
927
+ return result;
928
+ }
929
+ var setToArray_default = setToArray;
930
+
931
+ // node_modules/lodash-es/_equalByTag.js
932
+ var COMPARE_PARTIAL_FLAG2 = 1;
933
+ var COMPARE_UNORDERED_FLAG2 = 2;
934
+ var boolTag = "[object Boolean]";
935
+ var dateTag = "[object Date]";
936
+ var errorTag = "[object Error]";
937
+ var mapTag = "[object Map]";
938
+ var numberTag = "[object Number]";
939
+ var regexpTag = "[object RegExp]";
940
+ var setTag = "[object Set]";
941
+ var stringTag = "[object String]";
942
+ var symbolTag = "[object Symbol]";
943
+ var arrayBufferTag = "[object ArrayBuffer]";
944
+ var dataViewTag = "[object DataView]";
945
+ var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
946
+ var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
947
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
948
+ switch (tag) {
949
+ case dataViewTag:
950
+ if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
951
+ return false;
952
+ }
953
+ object = object.buffer;
954
+ other = other.buffer;
955
+ case arrayBufferTag:
956
+ if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
957
+ return false;
958
+ }
959
+ return true;
960
+ case boolTag:
961
+ case dateTag:
962
+ case numberTag:
963
+ return eq_default(+object, +other);
964
+ case errorTag:
965
+ return object.name == other.name && object.message == other.message;
966
+ case regexpTag:
967
+ case stringTag:
968
+ return object == other + "";
969
+ case mapTag:
970
+ var convert = mapToArray_default;
971
+ case setTag:
972
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
973
+ convert || (convert = setToArray_default);
974
+ if (object.size != other.size && !isPartial) {
975
+ return false;
976
+ }
977
+ var stacked = stack.get(object);
978
+ if (stacked) {
979
+ return stacked == other;
980
+ }
981
+ bitmask |= COMPARE_UNORDERED_FLAG2;
982
+ stack.set(object, other);
983
+ var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
984
+ stack["delete"](object);
985
+ return result;
986
+ case symbolTag:
987
+ if (symbolValueOf) {
988
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
989
+ }
990
+ }
991
+ return false;
992
+ }
993
+ var equalByTag_default = equalByTag;
994
+
995
+ // node_modules/lodash-es/_arrayPush.js
996
+ function arrayPush(array, values) {
997
+ var index = -1, length = values.length, offset = array.length;
998
+ while (++index < length) {
999
+ array[offset + index] = values[index];
1000
+ }
1001
+ return array;
1002
+ }
1003
+ var arrayPush_default = arrayPush;
1004
+
1005
+ // node_modules/lodash-es/isArray.js
1006
+ var isArray = Array.isArray;
1007
+ var isArray_default = isArray;
1008
+
1009
+ // node_modules/lodash-es/_baseGetAllKeys.js
1010
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1011
+ var result = keysFunc(object);
1012
+ return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
1013
+ }
1014
+ var baseGetAllKeys_default = baseGetAllKeys;
1015
+
1016
+ // node_modules/lodash-es/_arrayFilter.js
1017
+ function arrayFilter(array, predicate) {
1018
+ var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
1019
+ while (++index < length) {
1020
+ var value = array[index];
1021
+ if (predicate(value, index, array)) {
1022
+ result[resIndex++] = value;
1023
+ }
1024
+ }
1025
+ return result;
1026
+ }
1027
+ var arrayFilter_default = arrayFilter;
1028
+
1029
+ // node_modules/lodash-es/stubArray.js
1030
+ function stubArray() {
1031
+ return [];
1032
+ }
1033
+ var stubArray_default = stubArray;
1034
+
1035
+ // node_modules/lodash-es/_getSymbols.js
1036
+ var objectProto6 = Object.prototype;
1037
+ var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
1038
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
1039
+ var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
1040
+ if (object == null) {
1041
+ return [];
1042
+ }
1043
+ object = Object(object);
1044
+ return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
1045
+ return propertyIsEnumerable.call(object, symbol);
1046
+ });
1047
+ };
1048
+ var getSymbols_default = getSymbols;
1049
+
1050
+ // node_modules/lodash-es/_baseTimes.js
1051
+ function baseTimes(n, iteratee) {
1052
+ var index = -1, result = Array(n);
1053
+ while (++index < n) {
1054
+ result[index] = iteratee(index);
1055
+ }
1056
+ return result;
1057
+ }
1058
+ var baseTimes_default = baseTimes;
1059
+
1060
+ // node_modules/lodash-es/isObjectLike.js
1061
+ function isObjectLike(value) {
1062
+ return value != null && typeof value == "object";
1063
+ }
1064
+ var isObjectLike_default = isObjectLike;
1065
+
1066
+ // node_modules/lodash-es/_baseIsArguments.js
1067
+ var argsTag = "[object Arguments]";
1068
+ function baseIsArguments(value) {
1069
+ return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
1070
+ }
1071
+ var baseIsArguments_default = baseIsArguments;
1072
+
1073
+ // node_modules/lodash-es/isArguments.js
1074
+ var objectProto7 = Object.prototype;
1075
+ var hasOwnProperty5 = objectProto7.hasOwnProperty;
1076
+ var propertyIsEnumerable2 = objectProto7.propertyIsEnumerable;
1077
+ var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
1078
+ return arguments;
1079
+ }()) ? baseIsArguments_default : function(value) {
1080
+ return isObjectLike_default(value) && hasOwnProperty5.call(value, "callee") && !propertyIsEnumerable2.call(value, "callee");
1081
+ };
1082
+ var isArguments_default = isArguments;
1083
+
1084
+ // node_modules/lodash-es/stubFalse.js
1085
+ function stubFalse() {
1086
+ return false;
1087
+ }
1088
+ var stubFalse_default = stubFalse;
1089
+
1090
+ // node_modules/lodash-es/isBuffer.js
1091
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
1092
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
1093
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1094
+ var Buffer = moduleExports ? root_default.Buffer : void 0;
1095
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
1096
+ var isBuffer = nativeIsBuffer || stubFalse_default;
1097
+ var isBuffer_default = isBuffer;
1098
+
1099
+ // node_modules/lodash-es/_isIndex.js
1100
+ var MAX_SAFE_INTEGER = 9007199254740991;
1101
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
1102
+ function isIndex(value, length) {
1103
+ var type = typeof value;
1104
+ length = length == null ? MAX_SAFE_INTEGER : length;
1105
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
1106
+ }
1107
+ var isIndex_default = isIndex;
1108
+
1109
+ // node_modules/lodash-es/isLength.js
1110
+ var MAX_SAFE_INTEGER2 = 9007199254740991;
1111
+ function isLength(value) {
1112
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
1113
+ }
1114
+ var isLength_default = isLength;
1115
+
1116
+ // node_modules/lodash-es/_baseIsTypedArray.js
1117
+ var argsTag2 = "[object Arguments]";
1118
+ var arrayTag = "[object Array]";
1119
+ var boolTag2 = "[object Boolean]";
1120
+ var dateTag2 = "[object Date]";
1121
+ var errorTag2 = "[object Error]";
1122
+ var funcTag2 = "[object Function]";
1123
+ var mapTag2 = "[object Map]";
1124
+ var numberTag2 = "[object Number]";
1125
+ var objectTag = "[object Object]";
1126
+ var regexpTag2 = "[object RegExp]";
1127
+ var setTag2 = "[object Set]";
1128
+ var stringTag2 = "[object String]";
1129
+ var weakMapTag = "[object WeakMap]";
1130
+ var arrayBufferTag2 = "[object ArrayBuffer]";
1131
+ var dataViewTag2 = "[object DataView]";
1132
+ var float32Tag = "[object Float32Array]";
1133
+ var float64Tag = "[object Float64Array]";
1134
+ var int8Tag = "[object Int8Array]";
1135
+ var int16Tag = "[object Int16Array]";
1136
+ var int32Tag = "[object Int32Array]";
1137
+ var uint8Tag = "[object Uint8Array]";
1138
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
1139
+ var uint16Tag = "[object Uint16Array]";
1140
+ var uint32Tag = "[object Uint32Array]";
1141
+ var typedArrayTags = {};
1142
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
1143
+ typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag2] = typedArrayTags[boolTag2] = typedArrayTags[dataViewTag2] = typedArrayTags[dateTag2] = typedArrayTags[errorTag2] = typedArrayTags[funcTag2] = typedArrayTags[mapTag2] = typedArrayTags[numberTag2] = typedArrayTags[objectTag] = typedArrayTags[regexpTag2] = typedArrayTags[setTag2] = typedArrayTags[stringTag2] = typedArrayTags[weakMapTag] = false;
1144
+ function baseIsTypedArray(value) {
1145
+ return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
1146
+ }
1147
+ var baseIsTypedArray_default = baseIsTypedArray;
1148
+
1149
+ // node_modules/lodash-es/_baseUnary.js
1150
+ function baseUnary(func) {
1151
+ return function(value) {
1152
+ return func(value);
1153
+ };
1154
+ }
1155
+ var baseUnary_default = baseUnary;
1156
+
1157
+ // node_modules/lodash-es/_nodeUtil.js
1158
+ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
1159
+ var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
1160
+ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
1161
+ var freeProcess = moduleExports2 && freeGlobal_default.process;
1162
+ var nodeUtil = function() {
1163
+ try {
1164
+ var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
1165
+ if (types) {
1166
+ return types;
1167
+ }
1168
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
1169
+ } catch (e) {
1170
+ }
1171
+ }();
1172
+ var nodeUtil_default = nodeUtil;
1173
+
1174
+ // node_modules/lodash-es/isTypedArray.js
1175
+ var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
1176
+ var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
1177
+ var isTypedArray_default = isTypedArray;
1178
+
1179
+ // node_modules/lodash-es/_arrayLikeKeys.js
1180
+ var objectProto8 = Object.prototype;
1181
+ var hasOwnProperty6 = objectProto8.hasOwnProperty;
1182
+ function arrayLikeKeys(value, inherited) {
1183
+ var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
1184
+ for (var key in value) {
1185
+ if ((inherited || hasOwnProperty6.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
1186
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
1187
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
1188
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
1189
+ isIndex_default(key, length)))) {
1190
+ result.push(key);
1191
+ }
1192
+ }
1193
+ return result;
1194
+ }
1195
+ var arrayLikeKeys_default = arrayLikeKeys;
1196
+
1197
+ // node_modules/lodash-es/_isPrototype.js
1198
+ var objectProto9 = Object.prototype;
1199
+ function isPrototype(value) {
1200
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto9;
1201
+ return value === proto;
1202
+ }
1203
+ var isPrototype_default = isPrototype;
1204
+
1205
+ // node_modules/lodash-es/_overArg.js
1206
+ function overArg(func, transform) {
1207
+ return function(arg) {
1208
+ return func(transform(arg));
1209
+ };
1210
+ }
1211
+ var overArg_default = overArg;
1212
+
1213
+ // node_modules/lodash-es/_nativeKeys.js
1214
+ var nativeKeys = overArg_default(Object.keys, Object);
1215
+ var nativeKeys_default = nativeKeys;
1216
+
1217
+ // node_modules/lodash-es/_baseKeys.js
1218
+ var objectProto10 = Object.prototype;
1219
+ var hasOwnProperty7 = objectProto10.hasOwnProperty;
1220
+ function baseKeys(object) {
1221
+ if (!isPrototype_default(object)) {
1222
+ return nativeKeys_default(object);
1223
+ }
1224
+ var result = [];
1225
+ for (var key in Object(object)) {
1226
+ if (hasOwnProperty7.call(object, key) && key != "constructor") {
1227
+ result.push(key);
1228
+ }
1229
+ }
1230
+ return result;
1231
+ }
1232
+ var baseKeys_default = baseKeys;
1233
+
1234
+ // node_modules/lodash-es/isArrayLike.js
1235
+ function isArrayLike(value) {
1236
+ return value != null && isLength_default(value.length) && !isFunction_default(value);
1237
+ }
1238
+ var isArrayLike_default = isArrayLike;
1239
+
1240
+ // node_modules/lodash-es/keys.js
1241
+ function keys(object) {
1242
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
1243
+ }
1244
+ var keys_default = keys;
1245
+
1246
+ // node_modules/lodash-es/_getAllKeys.js
1247
+ function getAllKeys(object) {
1248
+ return baseGetAllKeys_default(object, keys_default, getSymbols_default);
1249
+ }
1250
+ var getAllKeys_default = getAllKeys;
1251
+
1252
+ // node_modules/lodash-es/_equalObjects.js
1253
+ var COMPARE_PARTIAL_FLAG3 = 1;
1254
+ var objectProto11 = Object.prototype;
1255
+ var hasOwnProperty8 = objectProto11.hasOwnProperty;
1256
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1257
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
1258
+ if (objLength != othLength && !isPartial) {
1259
+ return false;
1260
+ }
1261
+ var index = objLength;
1262
+ while (index--) {
1263
+ var key = objProps[index];
1264
+ if (!(isPartial ? key in other : hasOwnProperty8.call(other, key))) {
1265
+ return false;
1266
+ }
1267
+ }
1268
+ var objStacked = stack.get(object);
1269
+ var othStacked = stack.get(other);
1270
+ if (objStacked && othStacked) {
1271
+ return objStacked == other && othStacked == object;
1272
+ }
1273
+ var result = true;
1274
+ stack.set(object, other);
1275
+ stack.set(other, object);
1276
+ var skipCtor = isPartial;
1277
+ while (++index < objLength) {
1278
+ key = objProps[index];
1279
+ var objValue = object[key], othValue = other[key];
1280
+ if (customizer) {
1281
+ var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
1282
+ }
1283
+ if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
1284
+ result = false;
1285
+ break;
1286
+ }
1287
+ skipCtor || (skipCtor = key == "constructor");
1288
+ }
1289
+ if (result && !skipCtor) {
1290
+ var objCtor = object.constructor, othCtor = other.constructor;
1291
+ if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
1292
+ result = false;
1293
+ }
1294
+ }
1295
+ stack["delete"](object);
1296
+ stack["delete"](other);
1297
+ return result;
1298
+ }
1299
+ var equalObjects_default = equalObjects;
1300
+
1301
+ // node_modules/lodash-es/_DataView.js
1302
+ var DataView = getNative_default(root_default, "DataView");
1303
+ var DataView_default = DataView;
1304
+
1305
+ // node_modules/lodash-es/_Promise.js
1306
+ var Promise2 = getNative_default(root_default, "Promise");
1307
+ var Promise_default = Promise2;
1308
+
1309
+ // node_modules/lodash-es/_Set.js
1310
+ var Set2 = getNative_default(root_default, "Set");
1311
+ var Set_default = Set2;
1312
+
1313
+ // node_modules/lodash-es/_WeakMap.js
1314
+ var WeakMap = getNative_default(root_default, "WeakMap");
1315
+ var WeakMap_default = WeakMap;
1316
+
1317
+ // node_modules/lodash-es/_getTag.js
1318
+ var mapTag3 = "[object Map]";
1319
+ var objectTag2 = "[object Object]";
1320
+ var promiseTag = "[object Promise]";
1321
+ var setTag3 = "[object Set]";
1322
+ var weakMapTag2 = "[object WeakMap]";
1323
+ var dataViewTag3 = "[object DataView]";
1324
+ var dataViewCtorString = toSource_default(DataView_default);
1325
+ var mapCtorString = toSource_default(Map_default);
1326
+ var promiseCtorString = toSource_default(Promise_default);
1327
+ var setCtorString = toSource_default(Set_default);
1328
+ var weakMapCtorString = toSource_default(WeakMap_default);
1329
+ var getTag = baseGetTag_default;
1330
+ if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag3 || Map_default && getTag(new Map_default()) != mapTag3 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag3 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
1331
+ getTag = function(value) {
1332
+ var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
1333
+ if (ctorString) {
1334
+ switch (ctorString) {
1335
+ case dataViewCtorString:
1336
+ return dataViewTag3;
1337
+ case mapCtorString:
1338
+ return mapTag3;
1339
+ case promiseCtorString:
1340
+ return promiseTag;
1341
+ case setCtorString:
1342
+ return setTag3;
1343
+ case weakMapCtorString:
1344
+ return weakMapTag2;
1345
+ }
1346
+ }
1347
+ return result;
1348
+ };
1349
+ }
1350
+ var getTag_default = getTag;
1351
+
1352
+ // node_modules/lodash-es/_baseIsEqualDeep.js
1353
+ var COMPARE_PARTIAL_FLAG4 = 1;
1354
+ var argsTag3 = "[object Arguments]";
1355
+ var arrayTag2 = "[object Array]";
1356
+ var objectTag3 = "[object Object]";
1357
+ var objectProto12 = Object.prototype;
1358
+ var hasOwnProperty9 = objectProto12.hasOwnProperty;
1359
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
1360
+ var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
1361
+ objTag = objTag == argsTag3 ? objectTag3 : objTag;
1362
+ othTag = othTag == argsTag3 ? objectTag3 : othTag;
1363
+ var objIsObj = objTag == objectTag3, othIsObj = othTag == objectTag3, isSameTag = objTag == othTag;
1364
+ if (isSameTag && isBuffer_default(object)) {
1365
+ if (!isBuffer_default(other)) {
1366
+ return false;
1367
+ }
1368
+ objIsArr = true;
1369
+ objIsObj = false;
1370
+ }
1371
+ if (isSameTag && !objIsObj) {
1372
+ stack || (stack = new Stack_default());
1373
+ return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
1374
+ }
1375
+ if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
1376
+ var objIsWrapped = objIsObj && hasOwnProperty9.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty9.call(other, "__wrapped__");
1377
+ if (objIsWrapped || othIsWrapped) {
1378
+ var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
1379
+ stack || (stack = new Stack_default());
1380
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1381
+ }
1382
+ }
1383
+ if (!isSameTag) {
1384
+ return false;
1385
+ }
1386
+ stack || (stack = new Stack_default());
1387
+ return equalObjects_default(object, other, bitmask, customizer, equalFunc, stack);
1388
+ }
1389
+ var baseIsEqualDeep_default = baseIsEqualDeep;
1390
+
1391
+ // node_modules/lodash-es/_baseIsEqual.js
1392
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
1393
+ if (value === other) {
1394
+ return true;
1395
+ }
1396
+ if (value == null || other == null || !isObjectLike_default(value) && !isObjectLike_default(other)) {
1397
+ return value !== value && other !== other;
1398
+ }
1399
+ return baseIsEqualDeep_default(value, other, bitmask, customizer, baseIsEqual, stack);
1400
+ }
1401
+ var baseIsEqual_default = baseIsEqual;
1402
+
1403
+ // node_modules/lodash-es/isEqual.js
1404
+ function isEqual(value, other) {
1405
+ return baseIsEqual_default(value, other);
1406
+ }
1407
+ var isEqual_default = isEqual;
1408
+
1409
+ // src/lib/v1/JoggerConnection.ts
1410
+ import { Vector3 as Vector32 } from "three/src/math/Vector3.js";
1411
+ var JoggerConnection = class _JoggerConnection {
1412
+ constructor(motionStream, opts = {}) {
1413
+ this.motionStream = motionStream;
1414
+ this.opts = opts;
1415
+ // Currently a separate websocket is needed for each mode, pester API people
1416
+ // to merge these for simplicity
1417
+ this.cartesianWebsocket = null;
1418
+ this.jointWebsocket = null;
1419
+ this.cartesianJoggingOpts = {};
1420
+ }
1421
+ static open(_0, _1) {
1422
+ return __async(this, arguments, function* (nova, motionGroupId, opts = {}) {
1423
+ const motionStream = yield nova.connectMotionStream(motionGroupId);
1424
+ return new _JoggerConnection(motionStream, opts);
1425
+ });
1426
+ }
1427
+ get motionGroupId() {
1428
+ return this.motionStream.motionGroupId;
1429
+ }
1430
+ get nova() {
1431
+ return this.motionStream.nova;
1432
+ }
1433
+ get numJoints() {
1434
+ return this.motionStream.joints.length;
1435
+ }
1436
+ get activeJoggingMode() {
1437
+ if (this.cartesianWebsocket) return "cartesian";
1438
+ if (this.jointWebsocket) return "joint";
1439
+ return "increment";
1440
+ }
1441
+ get activeWebsocket() {
1442
+ return this.cartesianWebsocket || this.jointWebsocket;
1443
+ }
1444
+ stop() {
1445
+ return __async(this, null, function* () {
1446
+ if (this.cartesianWebsocket) {
1447
+ this.cartesianWebsocket.sendJson({
1448
+ motion_group: this.motionGroupId,
1449
+ position_direction: { x: 0, y: 0, z: 0 },
1450
+ rotation_direction: { x: 0, y: 0, z: 0 },
1451
+ position_velocity: 0,
1452
+ rotation_velocity: 0,
1453
+ tcp: this.cartesianJoggingOpts.tcpId,
1454
+ coordinate_system: this.cartesianJoggingOpts.coordSystemId
1455
+ });
1456
+ }
1457
+ if (this.jointWebsocket) {
1458
+ this.jointWebsocket.sendJson({
1459
+ motion_group: this.motionGroupId,
1460
+ joint_velocities: new Array(this.numJoints).fill(0)
1461
+ });
1462
+ }
1463
+ });
1464
+ }
1465
+ dispose() {
1466
+ if (this.cartesianWebsocket) {
1467
+ this.cartesianWebsocket.dispose();
1468
+ }
1469
+ if (this.jointWebsocket) {
1470
+ this.jointWebsocket.dispose();
1471
+ }
1472
+ }
1473
+ setJoggingMode(mode, cartesianJoggingOpts) {
1474
+ console.log("Setting jogging mode to", mode);
1475
+ if (cartesianJoggingOpts) {
1476
+ if (!isEqual_default(this.cartesianJoggingOpts, cartesianJoggingOpts)) {
1477
+ if (this.cartesianWebsocket) {
1478
+ this.cartesianWebsocket.dispose();
1479
+ this.cartesianWebsocket = null;
1480
+ }
1481
+ }
1482
+ this.cartesianJoggingOpts = cartesianJoggingOpts;
1483
+ }
1484
+ if (mode !== "cartesian" && this.cartesianWebsocket) {
1485
+ this.cartesianWebsocket.dispose();
1486
+ this.cartesianWebsocket = null;
1487
+ }
1488
+ if (mode !== "joint" && this.jointWebsocket) {
1489
+ this.jointWebsocket.dispose();
1490
+ this.jointWebsocket = null;
1491
+ }
1492
+ if (mode === "cartesian" && !this.cartesianWebsocket) {
1493
+ this.cartesianWebsocket = this.nova.openReconnectingWebsocket(
1494
+ `/motion-groups/move-tcp`
1495
+ );
1496
+ this.cartesianWebsocket.addEventListener(
1497
+ "message",
1498
+ (ev) => {
1499
+ const data = tryParseJson(ev.data);
1500
+ if (data && "error" in data) {
1501
+ if (this.opts.onError) {
1502
+ this.opts.onError(ev.data);
1503
+ } else {
1504
+ throw new Error(ev.data);
1505
+ }
1506
+ }
1507
+ }
1508
+ );
1509
+ }
1510
+ if (mode === "joint" && !this.jointWebsocket) {
1511
+ this.jointWebsocket = this.nova.openReconnectingWebsocket(
1512
+ `/motion-groups/move-joint`
1513
+ );
1514
+ this.jointWebsocket.addEventListener("message", (ev) => {
1515
+ const data = tryParseJson(ev.data);
1516
+ if (data && "error" in data) {
1517
+ if (this.opts.onError) {
1518
+ this.opts.onError(ev.data);
1519
+ } else {
1520
+ throw new Error(ev.data);
1521
+ }
1522
+ }
1523
+ });
1524
+ }
1525
+ }
1526
+ /**
1527
+ * Start rotation of a single robot joint at the specified velocity
1528
+ */
1529
+ startJointRotation(_0) {
1530
+ return __async(this, arguments, function* ({
1531
+ joint,
1532
+ direction,
1533
+ velocityRadsPerSec
1534
+ }) {
1535
+ if (!this.jointWebsocket) {
1536
+ throw new Error(
1537
+ "Joint jogging websocket not connected; call setJoggingMode first"
1538
+ );
1539
+ }
1540
+ const jointVelocities = new Array(this.numJoints).fill(0);
1541
+ jointVelocities[joint] = direction === "-" ? -velocityRadsPerSec : velocityRadsPerSec;
1542
+ this.jointWebsocket.sendJson({
1543
+ motion_group: this.motionGroupId,
1544
+ joint_velocities: jointVelocities
1545
+ });
1546
+ });
1547
+ }
1548
+ /**
1549
+ * Start the TCP moving along a specified axis at a given velocity
1550
+ */
1551
+ startTCPTranslation(_0) {
1552
+ return __async(this, arguments, function* ({
1553
+ axis,
1554
+ direction,
1555
+ velocityMmPerSec
1556
+ }) {
1557
+ if (!this.cartesianWebsocket) {
1558
+ throw new Error(
1559
+ "Cartesian jogging websocket not connected; call setJoggingMode first"
1560
+ );
1561
+ }
1562
+ const zeroVector = { x: 0, y: 0, z: 0 };
1563
+ const joggingVector = Object.assign({}, zeroVector);
1564
+ joggingVector[axis] = direction === "-" ? -1 : 1;
1565
+ this.cartesianWebsocket.sendJson({
1566
+ motion_group: this.motionGroupId,
1567
+ position_direction: joggingVector,
1568
+ rotation_direction: zeroVector,
1569
+ position_velocity: velocityMmPerSec,
1570
+ rotation_velocity: 0,
1571
+ tcp: this.cartesianJoggingOpts.tcpId,
1572
+ coordinate_system: this.cartesianJoggingOpts.coordSystemId
1573
+ });
1574
+ });
1575
+ }
1576
+ /**
1577
+ * Start the TCP rotating around a specified axis at a given velocity
1578
+ */
1579
+ startTCPRotation(_0) {
1580
+ return __async(this, arguments, function* ({
1581
+ axis,
1582
+ direction,
1583
+ velocityRadsPerSec
1584
+ }) {
1585
+ if (!this.cartesianWebsocket) {
1586
+ throw new Error(
1587
+ "Cartesian jogging websocket not connected; call setJoggingMode first"
1588
+ );
1589
+ }
1590
+ const zeroVector = { x: 0, y: 0, z: 0 };
1591
+ const joggingVector = Object.assign({}, zeroVector);
1592
+ joggingVector[axis] = direction === "-" ? -1 : 1;
1593
+ this.cartesianWebsocket.sendJson({
1594
+ motion_group: this.motionGroupId,
1595
+ position_direction: zeroVector,
1596
+ rotation_direction: joggingVector,
1597
+ position_velocity: 0,
1598
+ rotation_velocity: velocityRadsPerSec,
1599
+ tcp: this.cartesianJoggingOpts.tcpId,
1600
+ coordinate_system: this.cartesianJoggingOpts.coordSystemId
1601
+ });
1602
+ });
1603
+ }
1604
+ /**
1605
+ * Move the robot by a fixed distance in a single cartesian
1606
+ * axis, either rotating or translating relative to the TCP.
1607
+ * Promise resolves only after the motion has completed.
1608
+ */
1609
+ runIncrementalCartesianMotion(_0) {
1610
+ return __async(this, arguments, function* ({
1611
+ currentTcpPose,
1612
+ currentJoints,
1613
+ coordSystemId,
1614
+ velocityInRelevantUnits,
1615
+ axis,
1616
+ direction,
1617
+ motion
1618
+ }) {
1619
+ var _a;
1620
+ const commands = [];
1621
+ if (!isSameCoordinateSystem(currentTcpPose.coordinate_system, coordSystemId)) {
1622
+ throw new Error(
1623
+ `Current TCP pose coordinate system ${currentTcpPose.coordinate_system} does not match target coordinate system ${coordSystemId}`
1624
+ );
1625
+ }
1626
+ if (motion.type === "translate") {
1627
+ const targetTcpPosition = Object.assign({}, currentTcpPose.position);
1628
+ targetTcpPosition[axis] += motion.distanceMm * (direction === "-" ? -1 : 1);
1629
+ commands.push({
1630
+ settings: {
1631
+ limits_override: {
1632
+ tcp_velocity_limit: velocityInRelevantUnits
1633
+ }
1634
+ },
1635
+ line: {
1636
+ position: targetTcpPosition,
1637
+ orientation: currentTcpPose.orientation,
1638
+ coordinate_system: coordSystemId
1639
+ }
1640
+ });
1641
+ } else if (motion.type === "rotate") {
1642
+ const currentRotationVector = new Vector32(
1643
+ currentTcpPose.orientation["x"],
1644
+ currentTcpPose.orientation["y"],
1645
+ currentTcpPose.orientation["z"]
1646
+ );
1647
+ const currentRotationRad = currentRotationVector.length();
1648
+ const currentRotationDirection = currentRotationVector.clone().normalize();
1649
+ const differenceRotationRad = motion.distanceRads * (direction === "-" ? -1 : 1);
1650
+ const differenceRotationDirection = new Vector32(0, 0, 0);
1651
+ differenceRotationDirection[axis] = 1;
1652
+ const f1 = Math.cos(0.5 * differenceRotationRad) * Math.cos(0.5 * currentRotationRad);
1653
+ const f2 = Math.sin(0.5 * differenceRotationRad) * Math.sin(0.5 * currentRotationRad);
1654
+ const f3 = Math.sin(0.5 * differenceRotationRad) * Math.cos(0.5 * currentRotationRad);
1655
+ const f4 = Math.cos(0.5 * differenceRotationRad) * Math.sin(0.5 * currentRotationRad);
1656
+ const dotProduct = differenceRotationDirection.dot(
1657
+ currentRotationDirection
1658
+ );
1659
+ const crossProduct = differenceRotationDirection.clone().cross(currentRotationDirection);
1660
+ const newRotationRad = 2 * Math.acos(f1 - f2 * dotProduct);
1661
+ const f5 = newRotationRad / Math.sin(0.5 * newRotationRad);
1662
+ const targetTcpOrientation = new Vector32().addScaledVector(crossProduct, f2).addScaledVector(differenceRotationDirection, f3).addScaledVector(currentRotationDirection, f4).multiplyScalar(f5);
1663
+ commands.push({
1664
+ settings: {
1665
+ limits_override: {
1666
+ tcp_orientation_velocity_limit: velocityInRelevantUnits
1667
+ }
1668
+ },
1669
+ line: {
1670
+ position: currentTcpPose.position,
1671
+ orientation: targetTcpOrientation,
1672
+ coordinate_system: coordSystemId
1673
+ }
1674
+ });
1675
+ }
1676
+ const motionPlanRes = yield this.nova.api.motion.planMotion({
1677
+ motion_group: this.motionGroupId,
1678
+ start_joint_position: currentJoints,
1679
+ tcp: this.cartesianJoggingOpts.tcpId,
1680
+ commands
1681
+ });
1682
+ const plannedMotion = (_a = motionPlanRes.plan_successful_response) == null ? void 0 : _a.motion;
1683
+ if (!plannedMotion) {
1684
+ throw new Error(
1685
+ `Failed to plan jogging increment motion ${JSON.stringify(motionPlanRes)}`
1686
+ );
1687
+ }
1688
+ yield this.nova.api.motion.streamMoveForward(
1689
+ plannedMotion,
1690
+ 100,
1691
+ void 0,
1692
+ void 0,
1693
+ void 0,
1694
+ {
1695
+ // Might take a while at low velocity
1696
+ timeout: 1e3 * 60
1697
+ }
1698
+ );
1699
+ });
1700
+ }
1701
+ /**
1702
+ * Rotate a single robot joint by a fixed number of radians
1703
+ * Promise resolves only after the motion has completed.
1704
+ */
1705
+ runIncrementalJointRotation(_0) {
1706
+ return __async(this, arguments, function* ({
1707
+ joint,
1708
+ currentJoints,
1709
+ velocityRadsPerSec,
1710
+ direction,
1711
+ distanceRads
1712
+ }) {
1713
+ var _a;
1714
+ const targetJoints = [...currentJoints.joints];
1715
+ targetJoints[joint] += distanceRads * (direction === "-" ? -1 : 1);
1716
+ const jointVelocityLimits = new Array(
1717
+ currentJoints.joints.length
1718
+ ).fill(velocityRadsPerSec);
1719
+ const motionPlanRes = yield this.nova.api.motion.planMotion({
1720
+ motion_group: this.motionGroupId,
1721
+ start_joint_position: currentJoints,
1722
+ commands: [
1723
+ {
1724
+ settings: {
1725
+ limits_override: {
1726
+ joint_velocity_limits: {
1727
+ joints: jointVelocityLimits
1728
+ }
1729
+ }
1730
+ },
1731
+ joint_ptp: {
1732
+ joints: targetJoints
1733
+ }
1734
+ }
1735
+ ]
1736
+ });
1737
+ const plannedMotion = (_a = motionPlanRes.plan_successful_response) == null ? void 0 : _a.motion;
1738
+ if (!plannedMotion) {
1739
+ console.error("Failed to plan jogging increment motion", motionPlanRes);
1740
+ return;
1741
+ }
1742
+ yield this.nova.api.motion.streamMoveForward(
1743
+ plannedMotion,
1744
+ 100,
1745
+ void 0,
1746
+ void 0,
1747
+ void 0,
1748
+ {
1749
+ // Might take a while at low velocity
1750
+ timeout: 1e3 * 60
1751
+ }
1752
+ );
1753
+ });
1754
+ }
1755
+ };
1756
+
1757
+ // src/lib/v1/MotionStreamConnection.ts
1758
+ import { makeAutoObservable as makeAutoObservable2, runInAction as runInAction2 } from "mobx";
1759
+ import { Vector3 as Vector33 } from "three";
1760
+ var MOTION_DELTA_THRESHOLD2 = 1e-4;
1761
+ function unwrapRotationVector(newRotationVectorApi, currentRotationVectorApi) {
1762
+ const currentRotationVector = new Vector33(
1763
+ currentRotationVectorApi.x,
1764
+ currentRotationVectorApi.y,
1765
+ currentRotationVectorApi.z
1766
+ );
1767
+ const newRotationVector = new Vector33(
1768
+ newRotationVectorApi.x,
1769
+ newRotationVectorApi.y,
1770
+ newRotationVectorApi.z
1771
+ );
1772
+ const currentAngle = currentRotationVector.length();
1773
+ const currentAxis = currentRotationVector.normalize();
1774
+ let newAngle = newRotationVector.length();
1775
+ let newAxis = newRotationVector.normalize();
1776
+ if (newAxis.dot(currentAxis) < 0) {
1777
+ newAngle = -newAngle;
1778
+ newAxis = newAxis.multiplyScalar(-1);
1779
+ }
1780
+ let angleDifference = newAngle - currentAngle;
1781
+ angleDifference -= 2 * Math.PI * Math.floor((angleDifference + Math.PI) / (2 * Math.PI));
1782
+ newAngle = currentAngle + angleDifference;
1783
+ return newAxis.multiplyScalar(newAngle);
1784
+ }
1785
+ var MotionStreamConnection = class _MotionStreamConnection {
1786
+ constructor(nova, controller, motionGroup, initialMotionState, motionStateSocket) {
1787
+ this.nova = nova;
1788
+ this.controller = controller;
1789
+ this.motionGroup = motionGroup;
1790
+ this.initialMotionState = initialMotionState;
1791
+ this.motionStateSocket = motionStateSocket;
1792
+ this.rapidlyChangingMotionState = initialMotionState;
1793
+ motionStateSocket.addEventListener("message", (event) => {
1794
+ var _a;
1795
+ const motionStateResponse = (_a = tryParseJson(event.data)) == null ? void 0 : _a.result;
1796
+ if (!motionStateResponse) {
1797
+ throw new Error(
1798
+ `Failed to get motion state for ${this.motionGroupId}: ${event.data}`
1799
+ );
1800
+ }
1801
+ if (!jointValuesEqual(
1802
+ this.rapidlyChangingMotionState.state.joint_position.joints,
1803
+ motionStateResponse.state.joint_position.joints,
1804
+ MOTION_DELTA_THRESHOLD2
1805
+ )) {
1806
+ runInAction2(() => {
1807
+ this.rapidlyChangingMotionState.state = motionStateResponse.state;
1808
+ });
1809
+ }
1810
+ if (!tcpPoseEqual(
1811
+ this.rapidlyChangingMotionState.tcp_pose,
1812
+ motionStateResponse.tcp_pose,
1813
+ MOTION_DELTA_THRESHOLD2
1814
+ )) {
1815
+ runInAction2(() => {
1816
+ if (this.rapidlyChangingMotionState.tcp_pose == void 0) {
1817
+ this.rapidlyChangingMotionState.tcp_pose = motionStateResponse.tcp_pose;
1818
+ } else {
1819
+ this.rapidlyChangingMotionState.tcp_pose = {
1820
+ position: motionStateResponse.tcp_pose.position,
1821
+ orientation: unwrapRotationVector(
1822
+ motionStateResponse.tcp_pose.orientation,
1823
+ this.rapidlyChangingMotionState.tcp_pose.orientation
1824
+ ),
1825
+ tcp: motionStateResponse.tcp_pose.tcp,
1826
+ coordinate_system: motionStateResponse.tcp_pose.coordinate_system
1827
+ };
1828
+ }
1829
+ });
1830
+ }
1831
+ });
1832
+ makeAutoObservable2(this);
1833
+ }
1834
+ static open(nova, motionGroupId) {
1835
+ return __async(this, null, function* () {
1836
+ var _a;
1837
+ const { instances: controllers } = yield nova.api.controller.listControllers();
1838
+ const [_motionGroupIndex, controllerId] = motionGroupId.split("@");
1839
+ const controller = controllers.find((c) => c.controller === controllerId);
1840
+ const motionGroup = controller == null ? void 0 : controller.physical_motion_groups.find(
1841
+ (mg) => mg.motion_group === motionGroupId
1842
+ );
1843
+ if (!controller || !motionGroup) {
1844
+ throw new Error(
1845
+ `Controller ${controllerId} or motion group ${motionGroupId} not found`
1846
+ );
1847
+ }
1848
+ const motionStateSocket = nova.openReconnectingWebsocket(
1849
+ `/motion-groups/${motionGroupId}/state-stream`
1850
+ );
1851
+ const firstMessage = yield motionStateSocket.firstMessage();
1852
+ console.log("got first message", firstMessage);
1853
+ const initialMotionState = (_a = tryParseJson(firstMessage.data)) == null ? void 0 : _a.result;
1854
+ if (!initialMotionState) {
1855
+ throw new Error(
1856
+ `Unable to parse initial motion state message ${firstMessage.data}`
1857
+ );
1858
+ }
1859
+ console.log(
1860
+ `Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:
1861
+ `,
1862
+ initialMotionState
1863
+ );
1864
+ return new _MotionStreamConnection(
1865
+ nova,
1866
+ controller,
1867
+ motionGroup,
1868
+ initialMotionState,
1869
+ motionStateSocket
1870
+ );
1871
+ });
1872
+ }
1873
+ get motionGroupId() {
1874
+ return this.motionGroup.motion_group;
1875
+ }
1876
+ get controllerId() {
1877
+ return this.controller.controller;
1878
+ }
1879
+ get modelFromController() {
1880
+ return this.motionGroup.model_from_controller;
1881
+ }
1882
+ get wandelscriptIdentifier() {
1883
+ const num = this.motionGroupId.split("@")[0];
1884
+ return `${this.controllerId.replaceAll("-", "_")}_${num}`;
1885
+ }
1886
+ get joints() {
1887
+ return this.initialMotionState.state.joint_position.joints.map((_, i) => {
1888
+ return {
1889
+ index: i
1890
+ };
1891
+ });
1892
+ }
1893
+ dispose() {
1894
+ this.motionStateSocket.close();
1895
+ }
1896
+ };
1897
+
1898
+ // src/lib/v1/NovaCellAPIClient.ts
1899
+ import {
1900
+ ApplicationApi,
1901
+ CellApi,
1902
+ ControllerApi,
1903
+ ControllerIOsApi,
1904
+ CoordinateSystemsApi,
1905
+ DeviceConfigurationApi,
1906
+ LibraryProgramApi,
1907
+ LibraryProgramMetadataApi,
1908
+ LibraryRecipeApi,
1909
+ LibraryRecipeMetadataApi,
1910
+ MotionApi,
1911
+ MotionGroupApi,
1912
+ MotionGroupInfosApi,
1913
+ MotionGroupJoggingApi,
1914
+ MotionGroupKinematicApi,
1915
+ ProgramApi,
1916
+ ProgramValuesApi,
1917
+ StoreCollisionComponentsApi,
1918
+ StoreCollisionScenesApi,
1919
+ StoreObjectApi,
1920
+ SystemApi,
1921
+ VirtualRobotApi,
1922
+ VirtualRobotBehaviorApi,
1923
+ VirtualRobotModeApi,
1924
+ VirtualRobotSetupApi
1925
+ } from "@wandelbots/nova-api/v1";
1926
+ import axios from "axios";
1927
+ var NovaCellAPIClient = class {
1928
+ constructor(cellId, opts) {
1929
+ this.cellId = cellId;
1930
+ this.opts = opts;
1931
+ this.system = this.withUnwrappedResponsesOnly(SystemApi);
1932
+ this.cell = this.withUnwrappedResponsesOnly(CellApi);
1933
+ this.deviceConfig = this.withCellId(DeviceConfigurationApi);
1934
+ this.motionGroup = this.withCellId(MotionGroupApi);
1935
+ this.motionGroupInfos = this.withCellId(MotionGroupInfosApi);
1936
+ this.controller = this.withCellId(ControllerApi);
1937
+ this.program = this.withCellId(ProgramApi);
1938
+ this.programValues = this.withCellId(ProgramValuesApi);
1939
+ this.controllerIOs = this.withCellId(ControllerIOsApi);
1940
+ this.motionGroupKinematic = this.withCellId(MotionGroupKinematicApi);
1941
+ this.motion = this.withCellId(MotionApi);
1942
+ this.coordinateSystems = this.withCellId(CoordinateSystemsApi);
1943
+ this.application = this.withCellId(ApplicationApi);
1944
+ this.applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi);
1945
+ this.motionGroupJogging = this.withCellId(MotionGroupJoggingApi);
1946
+ this.virtualRobot = this.withCellId(VirtualRobotApi);
1947
+ this.virtualRobotSetup = this.withCellId(VirtualRobotSetupApi);
1948
+ this.virtualRobotMode = this.withCellId(VirtualRobotModeApi);
1949
+ this.virtualRobotBehavior = this.withCellId(VirtualRobotBehaviorApi);
1950
+ this.libraryProgramMetadata = this.withCellId(LibraryProgramMetadataApi);
1951
+ this.libraryProgram = this.withCellId(LibraryProgramApi);
1952
+ this.libraryRecipeMetadata = this.withCellId(LibraryRecipeMetadataApi);
1953
+ this.libraryRecipe = this.withCellId(LibraryRecipeApi);
1954
+ this.storeObject = this.withCellId(StoreObjectApi);
1955
+ this.storeCollisionComponents = this.withCellId(
1956
+ StoreCollisionComponentsApi
1957
+ );
1958
+ this.storeCollisionScenes = this.withCellId(StoreCollisionScenesApi);
1959
+ }
1960
+ /**
1961
+ * Some TypeScript sorcery which alters the API class methods so you don't
1962
+ * have to pass the cell id to every single one, and de-encapsulates the
1963
+ * response data
1964
+ */
1965
+ withCellId(ApiConstructor) {
1966
+ var _a, _b;
1967
+ const apiClient = new ApiConstructor(
1968
+ __spreadProps(__spreadValues({}, this.opts), {
1969
+ isJsonMime: (mime) => {
1970
+ return mime === "application/json";
1971
+ }
1972
+ }),
1973
+ (_a = this.opts.basePath) != null ? _a : "",
1974
+ (_b = this.opts.axiosInstance) != null ? _b : axios.create()
1975
+ );
1976
+ for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) {
1977
+ if (key !== "constructor" && typeof apiClient[key] === "function") {
1978
+ const originalFunction = apiClient[key];
1979
+ apiClient[key] = (...args) => {
1980
+ return originalFunction.apply(apiClient, [this.cellId, ...args]).then((res) => res.data);
1981
+ };
1982
+ }
1983
+ }
1984
+ return apiClient;
1985
+ }
1986
+ /**
1987
+ * As withCellId, but only does the response unwrapping
1988
+ */
1989
+ withUnwrappedResponsesOnly(ApiConstructor) {
1990
+ var _a, _b;
1991
+ const apiClient = new ApiConstructor(
1992
+ __spreadProps(__spreadValues({}, this.opts), {
1993
+ isJsonMime: (mime) => {
1994
+ return mime === "application/json";
1995
+ }
1996
+ }),
1997
+ (_a = this.opts.basePath) != null ? _a : "",
1998
+ (_b = this.opts.axiosInstance) != null ? _b : axios.create()
1999
+ );
2000
+ for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) {
2001
+ if (key !== "constructor" && typeof apiClient[key] === "function") {
2002
+ const originalFunction = apiClient[key];
2003
+ apiClient[key] = (...args) => {
2004
+ return originalFunction.apply(apiClient, args).then((res) => res.data);
2005
+ };
2006
+ }
2007
+ }
2008
+ return apiClient;
2009
+ }
2010
+ };
2011
+
2012
+ // src/lib/v1/NovaClient.ts
2013
+ import axios2, { isAxiosError } from "axios";
2014
+ import urlJoin from "url-join";
2015
+
2016
+ // src/lib/v1/mock/MockNovaInstance.ts
2017
+ import { AxiosError } from "axios";
2018
+ import * as pathToRegexp from "path-to-regexp";
2019
+ var MockNovaInstance = class {
2020
+ constructor() {
2021
+ this.connections = [];
2022
+ }
2023
+ handleAPIRequest(config) {
2024
+ return __async(this, null, function* () {
2025
+ var _a, _b, _c;
2026
+ const apiHandlers = [
2027
+ {
2028
+ method: "GET",
2029
+ path: "/cells/:cellId/controllers",
2030
+ handle() {
2031
+ return {
2032
+ instances: [
2033
+ {
2034
+ controller: "mock-ur5e",
2035
+ model_name: "UniversalRobots::Controller",
2036
+ host: "mock-ur5e",
2037
+ allow_software_install_on_controller: true,
2038
+ physical_motion_groups: [
2039
+ {
2040
+ motion_group: "0@mock-ur5e",
2041
+ name_from_controller: "UR5e",
2042
+ active: false,
2043
+ model_from_controller: "UniversalRobots_UR5e"
2044
+ }
2045
+ ],
2046
+ has_error: false,
2047
+ error_details: ""
2048
+ }
2049
+ ]
2050
+ };
2051
+ }
2052
+ },
2053
+ {
2054
+ method: "GET",
2055
+ path: "/cells/:cellId/controllers/:controllerId",
2056
+ handle() {
2057
+ return {
2058
+ configuration: {
2059
+ kind: "VirtualController",
2060
+ manufacturer: "universalrobots",
2061
+ position: "[0,-1.571,-1.571,-1.571,1.571,-1.571,0]",
2062
+ type: "universalrobots-ur5e"
2063
+ },
2064
+ name: "mock-ur5"
2065
+ };
2066
+ }
2067
+ },
2068
+ {
2069
+ method: "GET",
2070
+ path: "/cells/:cellId/motion-groups/:motionGroupId/specification",
2071
+ handle() {
2072
+ return {
2073
+ dh_parameters: [
2074
+ {
2075
+ alpha: 1.5707963267948966,
2076
+ theta: 0,
2077
+ a: 0,
2078
+ d: 162.25,
2079
+ reverse_rotation_direction: false
2080
+ },
2081
+ {
2082
+ alpha: 0,
2083
+ theta: 0,
2084
+ a: -425,
2085
+ d: 0,
2086
+ reverse_rotation_direction: false
2087
+ },
2088
+ {
2089
+ alpha: 0,
2090
+ theta: 0,
2091
+ a: -392.2,
2092
+ d: 0,
2093
+ reverse_rotation_direction: false
2094
+ },
2095
+ {
2096
+ alpha: 1.5707963267948966,
2097
+ theta: 0,
2098
+ a: 0,
2099
+ d: 133.3,
2100
+ reverse_rotation_direction: false
2101
+ },
2102
+ {
2103
+ alpha: -1.5707963267948966,
2104
+ theta: 0,
2105
+ a: 0,
2106
+ d: 99.7,
2107
+ reverse_rotation_direction: false
2108
+ },
2109
+ {
2110
+ alpha: 0,
2111
+ theta: 0,
2112
+ a: 0,
2113
+ d: 99.6,
2114
+ reverse_rotation_direction: false
2115
+ }
2116
+ ],
2117
+ mechanical_joint_limits: [
2118
+ {
2119
+ joint: "JOINTNAME_AXIS_1",
2120
+ lower_limit: -6.335545063018799,
2121
+ upper_limit: 6.335545063018799,
2122
+ unlimited: false
2123
+ },
2124
+ {
2125
+ joint: "JOINTNAME_AXIS_2",
2126
+ lower_limit: -6.335545063018799,
2127
+ upper_limit: 6.335545063018799,
2128
+ unlimited: false
2129
+ },
2130
+ {
2131
+ joint: "JOINTNAME_AXIS_3",
2132
+ lower_limit: -6.335545063018799,
2133
+ upper_limit: 6.335545063018799,
2134
+ unlimited: false
2135
+ },
2136
+ {
2137
+ joint: "JOINTNAME_AXIS_4",
2138
+ lower_limit: -6.335545063018799,
2139
+ upper_limit: 6.335545063018799,
2140
+ unlimited: false
2141
+ },
2142
+ {
2143
+ joint: "JOINTNAME_AXIS_5",
2144
+ lower_limit: -6.335545063018799,
2145
+ upper_limit: 6.335545063018799,
2146
+ unlimited: false
2147
+ },
2148
+ {
2149
+ joint: "JOINTNAME_AXIS_6",
2150
+ lower_limit: -6.335545063018799,
2151
+ upper_limit: 6.335545063018799,
2152
+ unlimited: false
2153
+ }
2154
+ ]
2155
+ };
2156
+ }
2157
+ },
2158
+ {
2159
+ method: "GET",
2160
+ path: "/cells/:cellId/motion-groups/:motionGroupId/safety-setup",
2161
+ handle() {
2162
+ return {
2163
+ safety_settings: [
2164
+ {
2165
+ safety_state: "SAFETY_NORMAL",
2166
+ settings: {
2167
+ joint_position_limits: [
2168
+ {
2169
+ joint: "JOINTNAME_AXIS_1",
2170
+ lower_limit: -2.96705961227417,
2171
+ upper_limit: 2.96705961227417,
2172
+ unlimited: false
2173
+ },
2174
+ {
2175
+ joint: "JOINTNAME_AXIS_2",
2176
+ lower_limit: -1.7453292608261108,
2177
+ upper_limit: 2.7925267219543457,
2178
+ unlimited: false
2179
+ },
2180
+ {
2181
+ joint: "JOINTNAME_AXIS_3",
2182
+ lower_limit: -3.3161256313323975,
2183
+ upper_limit: 0.40142571926116943,
2184
+ unlimited: false
2185
+ },
2186
+ {
2187
+ joint: "JOINTNAME_AXIS_4",
2188
+ lower_limit: -3.4906585216522217,
2189
+ upper_limit: 3.4906585216522217,
2190
+ unlimited: false
2191
+ },
2192
+ {
2193
+ joint: "JOINTNAME_AXIS_5",
2194
+ lower_limit: -2.4434609413146973,
2195
+ upper_limit: 2.4434609413146973,
2196
+ unlimited: false
2197
+ },
2198
+ {
2199
+ joint: "JOINTNAME_AXIS_6",
2200
+ lower_limit: -4.71238899230957,
2201
+ upper_limit: 4.71238899230957,
2202
+ unlimited: false
2203
+ }
2204
+ ],
2205
+ joint_velocity_limits: [
2206
+ {
2207
+ joint: "JOINTNAME_AXIS_1",
2208
+ limit: 3.1415927410125732
2209
+ },
2210
+ {
2211
+ joint: "JOINTNAME_AXIS_2",
2212
+ limit: 3.1415927410125732
2213
+ },
2214
+ {
2215
+ joint: "JOINTNAME_AXIS_3",
2216
+ limit: 3.4906585216522217
2217
+ },
2218
+ {
2219
+ joint: "JOINTNAME_AXIS_4",
2220
+ limit: 6.108652591705322
2221
+ },
2222
+ {
2223
+ joint: "JOINTNAME_AXIS_5",
2224
+ limit: 6.108652591705322
2225
+ },
2226
+ {
2227
+ joint: "JOINTNAME_AXIS_6",
2228
+ limit: 6.981317043304443
2229
+ }
2230
+ ],
2231
+ joint_acceleration_limits: [],
2232
+ joint_torque_limits: [],
2233
+ tcp_velocity_limit: 1800
2234
+ }
2235
+ }
2236
+ ],
2237
+ safety_zones: [
2238
+ {
2239
+ id: 1,
2240
+ priority: 0,
2241
+ geometry: {
2242
+ compound: {
2243
+ child_geometries: [
2244
+ {
2245
+ convex_hull: {
2246
+ vertices: [
2247
+ {
2248
+ x: -800,
2249
+ y: -1330,
2250
+ z: -1820
2251
+ },
2252
+ {
2253
+ x: 1650,
2254
+ y: -1330,
2255
+ z: -1820
2256
+ },
2257
+ {
2258
+ x: 1650,
2259
+ y: 1330,
2260
+ z: -1820
2261
+ },
2262
+ {
2263
+ x: -800,
2264
+ y: 1330,
2265
+ z: -1820
2266
+ }
2267
+ ]
2268
+ },
2269
+ init_pose: {
2270
+ position: {
2271
+ x: 0,
2272
+ y: 0,
2273
+ z: 0
2274
+ },
2275
+ orientation: {
2276
+ x: 0,
2277
+ y: 0,
2278
+ z: 0,
2279
+ w: 1
2280
+ }
2281
+ },
2282
+ id: "box"
2283
+ },
2284
+ {
2285
+ convex_hull: {
2286
+ vertices: [
2287
+ {
2288
+ x: -800,
2289
+ y: -1330,
2290
+ z: -1820
2291
+ },
2292
+ {
2293
+ x: 1650,
2294
+ y: -1330,
2295
+ z: -1820
2296
+ },
2297
+ {
2298
+ x: 1650,
2299
+ y: -1330,
2300
+ z: 1500
2301
+ },
2302
+ {
2303
+ x: -800,
2304
+ y: -1330,
2305
+ z: 1500
2306
+ }
2307
+ ]
2308
+ },
2309
+ init_pose: {
2310
+ position: {
2311
+ x: 0,
2312
+ y: 0,
2313
+ z: 0
2314
+ },
2315
+ orientation: {
2316
+ x: 0,
2317
+ y: 0,
2318
+ z: 0,
2319
+ w: 1
2320
+ }
2321
+ },
2322
+ id: "box"
2323
+ },
2324
+ {
2325
+ convex_hull: {
2326
+ vertices: [
2327
+ {
2328
+ x: -800,
2329
+ y: -1330,
2330
+ z: -1820
2331
+ },
2332
+ {
2333
+ x: -800,
2334
+ y: 1330,
2335
+ z: -1820
2336
+ },
2337
+ {
2338
+ x: -800,
2339
+ y: 1330,
2340
+ z: 1500
2341
+ },
2342
+ {
2343
+ x: -800,
2344
+ y: -1330,
2345
+ z: 1500
2346
+ }
2347
+ ]
2348
+ },
2349
+ init_pose: {
2350
+ position: {
2351
+ x: 0,
2352
+ y: 0,
2353
+ z: 0
2354
+ },
2355
+ orientation: {
2356
+ x: 0,
2357
+ y: 0,
2358
+ z: 0,
2359
+ w: 1
2360
+ }
2361
+ },
2362
+ id: "box"
2363
+ },
2364
+ {
2365
+ convex_hull: {
2366
+ vertices: [
2367
+ {
2368
+ x: 1650,
2369
+ y: 1330,
2370
+ z: 1500
2371
+ },
2372
+ {
2373
+ x: -800,
2374
+ y: 1330,
2375
+ z: 1500
2376
+ },
2377
+ {
2378
+ x: -800,
2379
+ y: -1330,
2380
+ z: 1500
2381
+ },
2382
+ {
2383
+ x: 1650,
2384
+ y: -1330,
2385
+ z: 1500
2386
+ }
2387
+ ]
2388
+ },
2389
+ init_pose: {
2390
+ position: {
2391
+ x: 0,
2392
+ y: 0,
2393
+ z: 0
2394
+ },
2395
+ orientation: {
2396
+ x: 0,
2397
+ y: 0,
2398
+ z: 0,
2399
+ w: 1
2400
+ }
2401
+ },
2402
+ id: "box"
2403
+ },
2404
+ {
2405
+ convex_hull: {
2406
+ vertices: [
2407
+ {
2408
+ x: 1650,
2409
+ y: 1330,
2410
+ z: 1500
2411
+ },
2412
+ {
2413
+ x: -800,
2414
+ y: 1330,
2415
+ z: 1500
2416
+ },
2417
+ {
2418
+ x: -800,
2419
+ y: 1330,
2420
+ z: -1820
2421
+ },
2422
+ {
2423
+ x: 1650,
2424
+ y: 1330,
2425
+ z: -1820
2426
+ }
2427
+ ]
2428
+ },
2429
+ init_pose: {
2430
+ position: {
2431
+ x: 0,
2432
+ y: 0,
2433
+ z: 0
2434
+ },
2435
+ orientation: {
2436
+ x: 0,
2437
+ y: 0,
2438
+ z: 0,
2439
+ w: 1
2440
+ }
2441
+ },
2442
+ id: "box"
2443
+ },
2444
+ {
2445
+ convex_hull: {
2446
+ vertices: [
2447
+ {
2448
+ x: 1650,
2449
+ y: 1330,
2450
+ z: 1500
2451
+ },
2452
+ {
2453
+ x: 1650,
2454
+ y: -1330,
2455
+ z: 1500
2456
+ },
2457
+ {
2458
+ x: 1650,
2459
+ y: -1330,
2460
+ z: -1820
2461
+ },
2462
+ {
2463
+ x: 1650,
2464
+ y: 1330,
2465
+ z: -1820
2466
+ }
2467
+ ]
2468
+ },
2469
+ init_pose: {
2470
+ position: {
2471
+ x: 0,
2472
+ y: 0,
2473
+ z: 0
2474
+ },
2475
+ orientation: {
2476
+ x: 0,
2477
+ y: 0,
2478
+ z: 0,
2479
+ w: 1
2480
+ }
2481
+ },
2482
+ id: "box"
2483
+ }
2484
+ ]
2485
+ },
2486
+ init_pose: {
2487
+ position: {
2488
+ x: 0,
2489
+ y: 0,
2490
+ z: 0
2491
+ },
2492
+ orientation: {
2493
+ x: 0,
2494
+ y: 0,
2495
+ z: 0,
2496
+ w: 1
2497
+ }
2498
+ },
2499
+ id: "Cell workzone"
2500
+ },
2501
+ motion_group_uid: 1
2502
+ },
2503
+ {
2504
+ id: 2,
2505
+ priority: 0,
2506
+ geometry: {
2507
+ convex_hull: {
2508
+ vertices: [
2509
+ {
2510
+ x: 1650,
2511
+ y: 1330,
2512
+ z: -1850
2513
+ },
2514
+ {
2515
+ x: 865,
2516
+ y: 1330,
2517
+ z: -1850
2518
+ },
2519
+ {
2520
+ x: 865,
2521
+ y: -720,
2522
+ z: -1850
2523
+ },
2524
+ {
2525
+ x: 1650,
2526
+ y: -720,
2527
+ z: -1850
2528
+ },
2529
+ {
2530
+ x: 1650,
2531
+ y: 1330,
2532
+ z: -920
2533
+ },
2534
+ {
2535
+ x: 865,
2536
+ y: 1330,
2537
+ z: -920
2538
+ },
2539
+ {
2540
+ x: 865,
2541
+ y: -720,
2542
+ z: -920
2543
+ },
2544
+ {
2545
+ x: 1650,
2546
+ y: -720,
2547
+ z: -920
2548
+ }
2549
+ ]
2550
+ },
2551
+ init_pose: {
2552
+ position: {
2553
+ x: 0,
2554
+ y: 0,
2555
+ z: 0
2556
+ },
2557
+ orientation: {
2558
+ x: 0,
2559
+ y: 0,
2560
+ z: 0,
2561
+ w: 1
2562
+ }
2563
+ },
2564
+ id: "Transport"
2565
+ },
2566
+ motion_group_uid: 1
2567
+ },
2568
+ {
2569
+ id: 3,
2570
+ priority: 0,
2571
+ geometry: {
2572
+ convex_hull: {
2573
+ vertices: [
2574
+ {
2575
+ x: 1650,
2576
+ y: 1330,
2577
+ z: -600
2578
+ },
2579
+ {
2580
+ x: 865,
2581
+ y: 1330,
2582
+ z: -600
2583
+ },
2584
+ {
2585
+ x: 865,
2586
+ y: 430,
2587
+ z: -600
2588
+ },
2589
+ {
2590
+ x: 1650,
2591
+ y: 430,
2592
+ z: -600
2593
+ },
2594
+ {
2595
+ x: 1650,
2596
+ y: 1330,
2597
+ z: -1250
2598
+ },
2599
+ {
2600
+ x: 865,
2601
+ y: 1330,
2602
+ z: -1250
2603
+ },
2604
+ {
2605
+ x: 865,
2606
+ y: 430,
2607
+ z: -1250
2608
+ },
2609
+ {
2610
+ x: 1650,
2611
+ y: 430,
2612
+ z: -1250
2613
+ }
2614
+ ]
2615
+ },
2616
+ init_pose: {
2617
+ position: {
2618
+ x: 0,
2619
+ y: 0,
2620
+ z: 0
2621
+ },
2622
+ orientation: {
2623
+ x: 0,
2624
+ y: 0,
2625
+ z: 0,
2626
+ w: 1
2627
+ }
2628
+ },
2629
+ id: "Tunel"
2630
+ },
2631
+ motion_group_uid: 1
2632
+ },
2633
+ {
2634
+ id: 4,
2635
+ priority: 0,
2636
+ geometry: {
2637
+ convex_hull: {
2638
+ vertices: [
2639
+ {
2640
+ x: 1650,
2641
+ y: -760,
2642
+ z: -440
2643
+ },
2644
+ {
2645
+ x: 900,
2646
+ y: -760,
2647
+ z: -440
2648
+ },
2649
+ {
2650
+ x: 900,
2651
+ y: -1330,
2652
+ z: -440
2653
+ },
2654
+ {
2655
+ x: 1650,
2656
+ y: -1330,
2657
+ z: -440
2658
+ },
2659
+ {
2660
+ x: 1650,
2661
+ y: -760,
2662
+ z: -1800
2663
+ },
2664
+ {
2665
+ x: 900,
2666
+ y: -760,
2667
+ z: -1800
2668
+ },
2669
+ {
2670
+ x: 900,
2671
+ y: -1330,
2672
+ z: -1800
2673
+ },
2674
+ {
2675
+ x: 1650,
2676
+ y: -1330,
2677
+ z: -1800
2678
+ }
2679
+ ]
2680
+ },
2681
+ init_pose: {
2682
+ position: {
2683
+ x: 0,
2684
+ y: 0,
2685
+ z: 0
2686
+ },
2687
+ orientation: {
2688
+ x: 0,
2689
+ y: 0,
2690
+ z: 0,
2691
+ w: 1
2692
+ }
2693
+ },
2694
+ id: "Fanuc controller"
2695
+ },
2696
+ motion_group_uid: 1
2697
+ },
2698
+ {
2699
+ id: 6,
2700
+ priority: 0,
2701
+ geometry: {
2702
+ convex_hull: {
2703
+ vertices: [
2704
+ {
2705
+ x: -200,
2706
+ y: -200,
2707
+ z: -1900
2708
+ },
2709
+ {
2710
+ x: 200,
2711
+ y: -200,
2712
+ z: -1900
2713
+ },
2714
+ {
2715
+ x: 200,
2716
+ y: 200,
2717
+ z: -1900
2718
+ },
2719
+ {
2720
+ x: -200,
2721
+ y: 200,
2722
+ z: -1900
2723
+ },
2724
+ {
2725
+ x: -200,
2726
+ y: -200,
2727
+ z: -350
2728
+ },
2729
+ {
2730
+ x: 200,
2731
+ y: -200,
2732
+ z: -350
2733
+ },
2734
+ {
2735
+ x: 200,
2736
+ y: 200,
2737
+ z: -350
2738
+ },
2739
+ {
2740
+ x: -200,
2741
+ y: 200,
2742
+ z: -350
2743
+ }
2744
+ ]
2745
+ },
2746
+ init_pose: {
2747
+ position: {
2748
+ x: 0,
2749
+ y: 0,
2750
+ z: 0
2751
+ },
2752
+ orientation: {
2753
+ x: 0,
2754
+ y: 0,
2755
+ z: 0,
2756
+ w: 1
2757
+ }
2758
+ },
2759
+ id: "Robot base"
2760
+ },
2761
+ motion_group_uid: 1
2762
+ }
2763
+ ],
2764
+ robot_model_geometries: [
2765
+ {
2766
+ link_index: 1,
2767
+ geometry: {
2768
+ sphere: {
2769
+ radius: 270
2770
+ },
2771
+ init_pose: {
2772
+ position: {
2773
+ x: -70,
2774
+ y: -70,
2775
+ z: -50
2776
+ },
2777
+ orientation: {
2778
+ x: 0,
2779
+ y: 0,
2780
+ z: 0,
2781
+ w: 1
2782
+ }
2783
+ },
2784
+ id: "link1_sphere"
2785
+ }
2786
+ },
2787
+ {
2788
+ link_index: 2,
2789
+ geometry: {
2790
+ capsule: {
2791
+ radius: 160,
2792
+ cylinder_height: 800
2793
+ },
2794
+ init_pose: {
2795
+ position: {
2796
+ x: -450,
2797
+ y: 40,
2798
+ z: 170
2799
+ },
2800
+ orientation: {
2801
+ x: 0,
2802
+ y: -0.7071067811865475,
2803
+ z: 0,
2804
+ w: 0.7071067811865476
2805
+ }
2806
+ },
2807
+ id: "link2_capsule"
2808
+ }
2809
+ },
2810
+ {
2811
+ link_index: 3,
2812
+ geometry: {
2813
+ sphere: {
2814
+ radius: 270
2815
+ },
2816
+ init_pose: {
2817
+ position: {
2818
+ x: -110,
2819
+ y: 10,
2820
+ z: -100
2821
+ },
2822
+ orientation: {
2823
+ x: 0,
2824
+ y: 0,
2825
+ z: 0,
2826
+ w: 1
2827
+ }
2828
+ },
2829
+ id: "link3_sphere"
2830
+ }
2831
+ },
2832
+ {
2833
+ link_index: 4,
2834
+ geometry: {
2835
+ capsule: {
2836
+ radius: 110,
2837
+ cylinder_height: 600
2838
+ },
2839
+ init_pose: {
2840
+ position: {
2841
+ x: 0,
2842
+ y: 300,
2843
+ z: 40
2844
+ },
2845
+ orientation: {
2846
+ x: -0.7071067811865475,
2847
+ y: 0,
2848
+ z: 0,
2849
+ w: 0.7071067811865476
2850
+ }
2851
+ },
2852
+ id: "link4_capsule"
2853
+ }
2854
+ },
2855
+ {
2856
+ link_index: 5,
2857
+ geometry: {
2858
+ sphere: {
2859
+ radius: 75
2860
+ },
2861
+ init_pose: {
2862
+ position: {
2863
+ x: 0,
2864
+ y: 0,
2865
+ z: -50
2866
+ },
2867
+ orientation: {
2868
+ x: 0,
2869
+ y: 0,
2870
+ z: 0,
2871
+ w: 1
2872
+ }
2873
+ },
2874
+ id: "link5_sphere"
2875
+ }
2876
+ }
2877
+ ],
2878
+ tool_geometries: []
2879
+ };
2880
+ }
2881
+ },
2882
+ {
2883
+ method: "GET",
2884
+ path: "/cells/:cellId/coordinate-systems",
2885
+ handle() {
2886
+ return {
2887
+ coordinatesystems: [
2888
+ {
2889
+ coordinate_system: "",
2890
+ name: "world",
2891
+ reference_uid: "",
2892
+ position: {
2893
+ x: 0,
2894
+ y: 0,
2895
+ z: 0
2896
+ },
2897
+ rotation: {
2898
+ angles: [0, 0, 0],
2899
+ type: "ROTATION_VECTOR"
2900
+ }
2901
+ }
2902
+ ]
2903
+ };
2904
+ }
2905
+ },
2906
+ {
2907
+ method: "GET",
2908
+ path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
2909
+ handle() {
2910
+ return {
2911
+ tcps: [
2912
+ {
2913
+ id: "Flange",
2914
+ readable_name: "Default-Flange",
2915
+ position: {
2916
+ x: 0,
2917
+ y: 0,
2918
+ z: 0
2919
+ },
2920
+ rotation: {
2921
+ angles: [0, 0, 0, 0],
2922
+ type: "ROTATION_VECTOR"
2923
+ }
2924
+ },
2925
+ {
2926
+ id: "complex-tcp-position",
2927
+ readable_name: "Complex TCP Position",
2928
+ position: {
2929
+ x: -200,
2930
+ y: 300,
2931
+ z: 150
2932
+ },
2933
+ rotation: {
2934
+ angles: [
2935
+ -0.12139440409113832,
2936
+ -0.06356210998212003,
2937
+ -0.2023240068185639,
2938
+ 0
2939
+ ],
2940
+ type: "ROTATION_VECTOR"
2941
+ }
2942
+ }
2943
+ ]
2944
+ };
2945
+ }
2946
+ }
2947
+ ];
2948
+ const method = ((_a = config.method) == null ? void 0 : _a.toUpperCase()) || "GET";
2949
+ const path = "/cells" + ((_c = (_b = config.url) == null ? void 0 : _b.split("/cells")[1]) == null ? void 0 : _c.split("?")[0]);
2950
+ for (const handler of apiHandlers) {
2951
+ const match2 = pathToRegexp.match(handler.path)(path || "");
2952
+ if (method === handler.method && match2) {
2953
+ const json = handler.handle();
2954
+ return {
2955
+ status: 200,
2956
+ statusText: "Success",
2957
+ data: JSON.stringify(json),
2958
+ headers: {},
2959
+ config,
2960
+ request: {
2961
+ responseURL: config.url
2962
+ }
2963
+ };
2964
+ }
2965
+ }
2966
+ throw new AxiosError(
2967
+ `No mock handler matched this request: ${method} ${path}`,
2968
+ "404",
2969
+ config
2970
+ );
2971
+ });
2972
+ }
2973
+ handleWebsocketConnection(socket) {
2974
+ this.connections.push(socket);
2975
+ setTimeout(() => {
2976
+ socket.dispatchEvent(new Event("open"));
2977
+ console.log("Websocket connection opened from", socket.url);
2978
+ if (socket.url.includes("/state-stream")) {
2979
+ socket.dispatchEvent(
2980
+ new MessageEvent("message", {
2981
+ data: JSON.stringify(defaultMotionState)
2982
+ })
2983
+ );
2984
+ }
2985
+ if (socket.url.includes("/move-joint")) {
2986
+ socket.dispatchEvent(
2987
+ new MessageEvent("message", {
2988
+ data: JSON.stringify({
2989
+ result: {
2990
+ motion_group: "0@ur",
2991
+ state: {
2992
+ controller: "ur",
2993
+ operation_mode: "OPERATION_MODE_AUTO",
2994
+ safety_state: "SAFETY_STATE_NORMAL",
2995
+ timestamp: "2024-09-18T12:48:26.096266444Z",
2996
+ velocity_override: 100,
2997
+ motion_groups: [
2998
+ {
2999
+ motion_group: "0@ur",
3000
+ controller: "ur",
3001
+ joint_position: {
3002
+ joints: [
3003
+ 1.3492152690887451,
3004
+ -1.5659207105636597,
3005
+ 1.6653711795806885,
3006
+ -1.0991662740707397,
3007
+ -1.829018235206604,
3008
+ 1.264623761177063
3009
+ ]
3010
+ },
3011
+ joint_velocity: {
3012
+ joints: [0, 0, 0, 0, 0, 0]
3013
+ },
3014
+ flange_pose: {
3015
+ position: {
3016
+ x: 6.437331889439328,
3017
+ y: -628.4123774830913,
3018
+ z: 577.0569957147832
3019
+ },
3020
+ orientation: {
3021
+ x: -1.683333649797158,
3022
+ y: -1.9783363827298732,
3023
+ z: -0.4928031860165713
3024
+ },
3025
+ coordinate_system: ""
3026
+ },
3027
+ tcp_pose: {
3028
+ position: {
3029
+ x: 6.437331889439328,
3030
+ y: -628.4123774830913,
3031
+ z: 577.0569957147832
3032
+ },
3033
+ orientation: {
3034
+ x: -1.683333649797158,
3035
+ y: -1.9783363827298732,
3036
+ z: -0.4928031860165713
3037
+ },
3038
+ coordinate_system: "",
3039
+ tcp: "Flange"
3040
+ },
3041
+ velocity: {
3042
+ linear: {
3043
+ x: 0,
3044
+ y: 0,
3045
+ z: 0
3046
+ },
3047
+ angular: {
3048
+ x: -0,
3049
+ y: 0,
3050
+ z: 0
3051
+ },
3052
+ coordinate_system: ""
3053
+ },
3054
+ force: {
3055
+ force: {
3056
+ x: 0,
3057
+ y: 0,
3058
+ z: 0
3059
+ },
3060
+ moment: {
3061
+ x: 0,
3062
+ y: 0,
3063
+ z: 0
3064
+ },
3065
+ coordinate_system: ""
3066
+ },
3067
+ joint_limit_reached: {
3068
+ limit_reached: [
3069
+ false,
3070
+ false,
3071
+ false,
3072
+ false,
3073
+ false,
3074
+ false
3075
+ ]
3076
+ },
3077
+ joint_current: {
3078
+ joints: [0, 0, 0, 0, 0, 0]
3079
+ },
3080
+ sequence_number: "671259"
3081
+ }
3082
+ ],
3083
+ sequence_number: "671259"
3084
+ },
3085
+ movement_state: "MOVEMENT_STATE_MOVING"
3086
+ }
3087
+ })
3088
+ })
3089
+ );
3090
+ }
3091
+ if (socket.url.includes("/move-tcp")) {
3092
+ socket.dispatchEvent(
3093
+ new MessageEvent("message", {
3094
+ data: JSON.stringify({
3095
+ result: {
3096
+ motion_group: "0@ur",
3097
+ state: {
3098
+ controller: "ur",
3099
+ operation_mode: "OPERATION_MODE_AUTO",
3100
+ safety_state: "SAFETY_STATE_NORMAL",
3101
+ timestamp: "2024-09-18T12:43:12.188335774Z",
3102
+ velocity_override: 100,
3103
+ motion_groups: [
3104
+ {
3105
+ motion_group: "0@ur",
3106
+ controller: "ur",
3107
+ joint_position: {
3108
+ joints: [
3109
+ 1.3352527618408203,
3110
+ -1.5659207105636597,
3111
+ 1.6653711795806885,
3112
+ -1.110615611076355,
3113
+ -1.829018235206604,
3114
+ 1.264623761177063
3115
+ ]
3116
+ },
3117
+ joint_velocity: {
3118
+ joints: [0, 0, 0, 0, 0, 0]
3119
+ },
3120
+ flange_pose: {
3121
+ position: {
3122
+ x: -2.763015284002938,
3123
+ y: -630.2151479701106,
3124
+ z: 577.524509114342
3125
+ },
3126
+ orientation: {
3127
+ x: -1.704794877102097,
3128
+ y: -1.9722372952861567,
3129
+ z: -0.4852079204210754
3130
+ },
3131
+ coordinate_system: ""
3132
+ },
3133
+ tcp_pose: {
3134
+ position: {
3135
+ x: -2.763015284002938,
3136
+ y: -630.2151479701106,
3137
+ z: 577.524509114342
3138
+ },
3139
+ orientation: {
3140
+ x: -1.704794877102097,
3141
+ y: -1.9722372952861567,
3142
+ z: -0.4852079204210754
3143
+ },
3144
+ coordinate_system: "",
3145
+ tcp: "Flange"
3146
+ },
3147
+ velocity: {
3148
+ linear: {
3149
+ x: 0,
3150
+ y: 0,
3151
+ z: 0
3152
+ },
3153
+ angular: {
3154
+ x: -0,
3155
+ y: 0,
3156
+ z: 0
3157
+ },
3158
+ coordinate_system: ""
3159
+ },
3160
+ force: {
3161
+ force: {
3162
+ x: 0,
3163
+ y: 0,
3164
+ z: 0
3165
+ },
3166
+ moment: {
3167
+ x: 0,
3168
+ y: 0,
3169
+ z: 0
3170
+ },
3171
+ coordinate_system: ""
3172
+ },
3173
+ joint_limit_reached: {
3174
+ limit_reached: [
3175
+ false,
3176
+ false,
3177
+ false,
3178
+ false,
3179
+ false,
3180
+ false
3181
+ ]
3182
+ },
3183
+ joint_current: {
3184
+ joints: [0, 0, 0, 0, 0, 0]
3185
+ },
3186
+ sequence_number: "627897"
3187
+ }
3188
+ ],
3189
+ sequence_number: "627897"
3190
+ },
3191
+ movement_state: "MOVEMENT_STATE_MOVING"
3192
+ }
3193
+ })
3194
+ })
3195
+ );
3196
+ }
3197
+ }, 10);
3198
+ }
3199
+ handleWebsocketMessage(socket, message) {
3200
+ console.log(`Received message on ${socket.url}`, message);
3201
+ }
3202
+ };
3203
+ var defaultMotionState = {
3204
+ result: {
3205
+ state: {
3206
+ motion_group: "0@universalrobots-ur5e",
3207
+ controller: "universalrobots-ur5e",
3208
+ joint_position: {
3209
+ joints: [
3210
+ 1.1699999570846558,
3211
+ -1.5700000524520874,
3212
+ 1.3600000143051147,
3213
+ 1.0299999713897705,
3214
+ 1.2899999618530273,
3215
+ 1.2799999713897705
3216
+ ]
3217
+ },
3218
+ joint_velocity: {
3219
+ joints: [0, 0, 0, 0, 0, 0]
3220
+ },
3221
+ flange_pose: {
3222
+ position: {
3223
+ x: 1.3300010259703043,
3224
+ y: -409.2680714682808,
3225
+ z: 531.0203477065281
3226
+ },
3227
+ orientation: {
3228
+ x: 1.7564919306270736,
3229
+ y: -1.7542521568325058,
3230
+ z: 0.7326972590614671
3231
+ },
3232
+ coordinate_system: ""
3233
+ },
3234
+ tcp_pose: {
3235
+ position: {
3236
+ x: 1.3300010259703043,
3237
+ y: -409.2680714682808,
3238
+ z: 531.0203477065281
3239
+ },
3240
+ orientation: {
3241
+ x: 1.7564919306270736,
3242
+ y: -1.7542521568325058,
3243
+ z: 0.7326972590614671
3244
+ },
3245
+ coordinate_system: "",
3246
+ tcp: "Flange"
3247
+ },
3248
+ velocity: {
3249
+ linear: {
3250
+ x: 0,
3251
+ y: 0,
3252
+ z: 0
3253
+ },
3254
+ angular: {
3255
+ x: 0,
3256
+ y: 0,
3257
+ z: 0
3258
+ },
3259
+ coordinate_system: ""
3260
+ },
3261
+ force: {
3262
+ force: {
3263
+ x: 0,
3264
+ y: 0,
3265
+ z: 0
3266
+ },
3267
+ moment: {
3268
+ x: 0,
3269
+ y: 0,
3270
+ z: 0
3271
+ },
3272
+ coordinate_system: ""
3273
+ },
3274
+ joint_limit_reached: {
3275
+ limit_reached: [false, false, false, false, false, false]
3276
+ },
3277
+ joint_current: {
3278
+ joints: [0, 0, 0, 0, 0, 0]
3279
+ }
3280
+ },
3281
+ tcp_pose: {
3282
+ position: {
3283
+ x: 302.90748476115556,
3284
+ y: -152.87065869452337,
3285
+ z: 424.0454619321661
3286
+ },
3287
+ orientation: {
3288
+ x: 2.3403056115045353,
3289
+ y: -1.1706836379431356,
3290
+ z: 0.9772511964246311
3291
+ },
3292
+ coordinate_system: "",
3293
+ tcp: "Flange"
3294
+ }
3295
+ }
3296
+ };
3297
+
3298
+ // src/lib/v1/NovaClient.ts
3299
+ var NovaClient = class {
3300
+ constructor(config) {
3301
+ this.authPromise = null;
3302
+ this.accessToken = null;
3303
+ var _a;
3304
+ const cellId = (_a = config.cellId) != null ? _a : "cell";
3305
+ this.config = __spreadValues({
3306
+ cellId
3307
+ }, config);
3308
+ this.accessToken = config.accessToken || availableStorage.getString("wbjs.access_token") || null;
3309
+ if (this.config.instanceUrl === "https://mock.example.com") {
3310
+ this.mock = new MockNovaInstance();
3311
+ }
3312
+ const axiosInstance = axios2.create({
3313
+ baseURL: urlJoin(this.config.instanceUrl, "/api/v1")
3314
+ });
3315
+ axiosInstance.interceptors.request.use((request) => __async(this, null, function* () {
3316
+ if (!request.headers.Authorization) {
3317
+ if (this.accessToken) {
3318
+ request.headers.Authorization = `Bearer ${this.accessToken}`;
3319
+ } else if (this.config.username && this.config.password) {
3320
+ request.headers.Authorization = `Basic ${btoa(config.username + ":" + config.password)}`;
3321
+ }
3322
+ }
3323
+ return request;
3324
+ }));
3325
+ if (typeof window !== "undefined") {
3326
+ axiosInstance.interceptors.response.use(
3327
+ (r) => r,
3328
+ (error) => __async(this, null, function* () {
3329
+ var _a2, _b;
3330
+ if (isAxiosError(error)) {
3331
+ if (((_a2 = error.response) == null ? void 0 : _a2.status) === 401) {
3332
+ try {
3333
+ yield this.renewAuthentication();
3334
+ if (error.config) {
3335
+ if (this.accessToken) {
3336
+ error.config.headers.Authorization = `Bearer ${this.accessToken}`;
3337
+ } else {
3338
+ delete error.config.headers.Authorization;
3339
+ }
3340
+ return axiosInstance.request(error.config);
3341
+ }
3342
+ } catch (err) {
3343
+ return Promise.reject(err);
3344
+ }
3345
+ } else if (((_b = error.response) == null ? void 0 : _b.status) === 503) {
3346
+ const res = yield fetch(window.location.href);
3347
+ if (res.status === 503) {
3348
+ window.location.reload();
3349
+ }
3350
+ }
3351
+ }
3352
+ return Promise.reject(error);
3353
+ })
3354
+ );
3355
+ }
3356
+ this.api = new NovaCellAPIClient(cellId, __spreadProps(__spreadValues({}, config), {
3357
+ basePath: urlJoin(this.config.instanceUrl, "/api/v1"),
3358
+ isJsonMime: (mime) => {
3359
+ return mime === "application/json";
3360
+ },
3361
+ baseOptions: __spreadValues(__spreadValues({}, this.mock ? {
3362
+ adapter: (config2) => {
3363
+ return this.mock.handleAPIRequest(config2);
3364
+ }
3365
+ } : {}), config.baseOptions),
3366
+ axiosInstance
3367
+ }));
3368
+ }
3369
+ renewAuthentication() {
3370
+ return __async(this, null, function* () {
3371
+ if (this.authPromise) {
3372
+ return;
3373
+ }
3374
+ this.authPromise = loginWithAuth0(this.config.instanceUrl);
3375
+ try {
3376
+ this.accessToken = yield this.authPromise;
3377
+ if (this.accessToken) {
3378
+ availableStorage.setString("wbjs.access_token", this.accessToken);
3379
+ } else {
3380
+ availableStorage.delete("wbjs.access_token");
3381
+ }
3382
+ } finally {
3383
+ this.authPromise = null;
3384
+ }
3385
+ });
3386
+ }
3387
+ makeWebsocketURL(path) {
3388
+ const url = new URL(
3389
+ urlJoin(
3390
+ this.config.instanceUrl,
3391
+ `/api/v1/cells/${this.config.cellId}`,
3392
+ path
3393
+ )
3394
+ );
3395
+ url.protocol = url.protocol.replace("http", "ws");
3396
+ url.protocol = url.protocol.replace("https", "wss");
3397
+ if (this.accessToken) {
3398
+ url.searchParams.append("token", this.accessToken);
3399
+ } else if (this.config.username && this.config.password) {
3400
+ url.username = this.config.username;
3401
+ url.password = this.config.password;
3402
+ }
3403
+ return url.toString();
3404
+ }
3405
+ /**
3406
+ * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.
3407
+ * If you explicitly want to reconnect an existing websocket, call `reconnect`
3408
+ * on the returned object.
3409
+ */
3410
+ openReconnectingWebsocket(path) {
3411
+ return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {
3412
+ mock: this.mock
3413
+ });
3414
+ }
3415
+ /**
3416
+ * Connect to the motion state websocket(s) for a given motion group
3417
+ */
3418
+ connectMotionStream(motionGroupId) {
3419
+ return __async(this, null, function* () {
3420
+ return yield MotionStreamConnection.open(this, motionGroupId);
3421
+ });
3422
+ }
3423
+ /**
3424
+ * Connect to the jogging websocket(s) for a given motion group
3425
+ */
3426
+ connectJogger(motionGroupId) {
3427
+ return __async(this, null, function* () {
3428
+ return yield JoggerConnection.open(this, motionGroupId);
3429
+ });
3430
+ }
3431
+ connectMotionGroups(motionGroupIds) {
3432
+ return __async(this, null, function* () {
3433
+ const { instances } = yield this.api.controller.listControllers();
3434
+ return Promise.all(
3435
+ motionGroupIds.map(
3436
+ (motionGroupId) => ConnectedMotionGroup.connect(this, motionGroupId, instances)
3437
+ )
3438
+ );
3439
+ });
3440
+ }
3441
+ connectMotionGroup(motionGroupId) {
3442
+ return __async(this, null, function* () {
3443
+ const motionGroups = yield this.connectMotionGroups([motionGroupId]);
3444
+ return motionGroups[0];
3445
+ });
3446
+ }
3447
+ };
3448
+
3449
+ // src/lib/v1/ProgramStateConnection.ts
3450
+ import { AxiosError as AxiosError2 } from "axios";
3451
+ import { makeAutoObservable as makeAutoObservable3, runInAction as runInAction3 } from "mobx";
3452
+ var ProgramState = /* @__PURE__ */ ((ProgramState2) => {
3453
+ ProgramState2["NotStarted"] = "not started";
3454
+ ProgramState2["Running"] = "running";
3455
+ ProgramState2["Stopped"] = "stopped";
3456
+ ProgramState2["Failed"] = "failed";
3457
+ ProgramState2["Completed"] = "completed";
3458
+ return ProgramState2;
3459
+ })(ProgramState || {});
3460
+ var ProgramStateConnection = class {
3461
+ constructor(nova) {
3462
+ this.nova = nova;
3463
+ this.currentProgram = {};
3464
+ this.logs = [];
3465
+ this.executionState = "idle";
3466
+ this.currentlyExecutingProgramRunnerId = null;
3467
+ makeAutoObservable3(this, {}, { autoBind: true });
3468
+ this.programStateSocket = nova.openReconnectingWebsocket(`/programs/state`);
3469
+ this.programStateSocket.addEventListener("message", (ev) => {
3470
+ const msg = tryParseJson(ev.data);
3471
+ if (!msg) {
3472
+ console.error("Failed to parse program state message", ev.data);
3473
+ return;
3474
+ }
3475
+ if (msg.type === "update") {
3476
+ this.handleProgramStateMessage(msg);
3477
+ }
3478
+ });
3479
+ }
3480
+ /** Handle a program state update from the backend */
3481
+ handleProgramStateMessage(msg) {
3482
+ return __async(this, null, function* () {
3483
+ var _a;
3484
+ const { runner } = msg;
3485
+ if (runner.id !== this.currentlyExecutingProgramRunnerId) return;
3486
+ if (runner.state === "failed" /* Failed */) {
3487
+ try {
3488
+ const runnerState = yield this.nova.api.program.getProgramRunner(
3489
+ runner.id
3490
+ );
3491
+ const stdout = runnerState.stdout;
3492
+ if (stdout) {
3493
+ this.log(stdout);
3494
+ }
3495
+ this.logError(
3496
+ `Program runner ${runner.id} failed with error: ${runnerState.error}
3497
+ ${runnerState.traceback}`
3498
+ );
3499
+ } catch (err) {
3500
+ this.logError(
3501
+ `Failed to retrieve results for program ${runner.id}: ${err}`
3502
+ );
3503
+ }
3504
+ this.currentProgram.state = "failed" /* Failed */;
3505
+ this.gotoIdleState();
3506
+ } else if (runner.state === "stopped" /* Stopped */) {
3507
+ try {
3508
+ const runnerState = yield this.nova.api.program.getProgramRunner(
3509
+ runner.id
3510
+ );
3511
+ const stdout = runnerState.stdout;
3512
+ if (stdout) {
3513
+ this.log(stdout);
3514
+ }
3515
+ this.currentProgram.state = "stopped" /* Stopped */;
3516
+ this.log(`Program runner ${runner.id} stopped`);
3517
+ } catch (err) {
3518
+ this.logError(
3519
+ `Failed to retrieve results for program ${runner.id}: ${err}`
3520
+ );
3521
+ }
3522
+ this.gotoIdleState();
3523
+ } else if (runner.state === "completed" /* Completed */) {
3524
+ try {
3525
+ const runnerState = yield this.nova.api.program.getProgramRunner(
3526
+ runner.id
3527
+ );
3528
+ const stdout = runnerState.stdout;
3529
+ if (stdout) {
3530
+ this.log(stdout);
3531
+ }
3532
+ this.log(
3533
+ `Program runner ${runner.id} finished successfully in ${(_a = runner.execution_time) == null ? void 0 : _a.toFixed(2)} seconds`
3534
+ );
3535
+ this.currentProgram.state = "completed" /* Completed */;
3536
+ } catch (err) {
3537
+ this.logError(
3538
+ `Failed to retrieve results for program ${runner.id}: ${err}`
3539
+ );
3540
+ }
3541
+ this.gotoIdleState();
3542
+ } else if (runner.state === "running" /* Running */) {
3543
+ this.currentProgram.state = "running" /* Running */;
3544
+ this.log(`Program runner ${runner.id} now running`);
3545
+ } else if (runner.state !== "not started" /* NotStarted */) {
3546
+ console.error(runner);
3547
+ this.logError(
3548
+ `Program runner ${runner.id} entered unexpected state: ${runner.state}`
3549
+ );
3550
+ this.currentProgram.state = "not started" /* NotStarted */;
3551
+ this.gotoIdleState();
3552
+ }
3553
+ });
3554
+ }
3555
+ /** Call when a program is no longer executing */
3556
+ gotoIdleState() {
3557
+ runInAction3(() => {
3558
+ this.executionState = "idle";
3559
+ });
3560
+ this.currentlyExecutingProgramRunnerId = null;
3561
+ }
3562
+ executeProgram(wandelscript, initial_state, activeRobot) {
3563
+ return __async(this, null, function* () {
3564
+ this.currentProgram = {
3565
+ wandelscript,
3566
+ state: "not started" /* NotStarted */
3567
+ };
3568
+ const { currentProgram: openProgram } = this;
3569
+ if (!openProgram) return;
3570
+ runInAction3(() => {
3571
+ this.executionState = "starting";
3572
+ });
3573
+ if (activeRobot) {
3574
+ try {
3575
+ yield this.nova.api.motionGroupJogging.stopJogging(
3576
+ activeRobot.motionGroupId
3577
+ );
3578
+ } catch (err) {
3579
+ console.error(err);
3580
+ }
3581
+ }
3582
+ const trimmedCode = openProgram.wandelscript.replaceAll(/^\s*$/gm, "");
3583
+ try {
3584
+ const programRunnerRef = yield this.nova.api.program.createProgramRunner(
3585
+ {
3586
+ code: trimmedCode,
3587
+ initial_state,
3588
+ default_robot: activeRobot == null ? void 0 : activeRobot.wandelscriptIdentifier
3589
+ },
3590
+ {
3591
+ headers: {
3592
+ "Content-Type": "application/json"
3593
+ }
3594
+ }
3595
+ );
3596
+ this.log(`Created program runner ${programRunnerRef.id}"`);
3597
+ runInAction3(() => {
3598
+ this.executionState = "executing";
3599
+ });
3600
+ this.currentlyExecutingProgramRunnerId = programRunnerRef.id;
3601
+ } catch (error) {
3602
+ if (error instanceof AxiosError2 && error.response && error.request) {
3603
+ this.logError(
3604
+ `${error.response.status} ${error.response.statusText} from ${error.response.config.url} ${JSON.stringify(error.response.data)}`
3605
+ );
3606
+ } else {
3607
+ this.logError(JSON.stringify(error));
3608
+ }
3609
+ runInAction3(() => {
3610
+ this.executionState = "idle";
3611
+ });
3612
+ }
3613
+ });
3614
+ }
3615
+ stopProgram() {
3616
+ return __async(this, null, function* () {
3617
+ if (!this.currentlyExecutingProgramRunnerId) return;
3618
+ runInAction3(() => {
3619
+ this.executionState = "stopping";
3620
+ });
3621
+ try {
3622
+ yield this.nova.api.program.stopProgramRunner(
3623
+ this.currentlyExecutingProgramRunnerId
3624
+ );
3625
+ } catch (err) {
3626
+ runInAction3(() => {
3627
+ this.executionState = "executing";
3628
+ });
3629
+ throw err;
3630
+ }
3631
+ });
3632
+ }
3633
+ reset() {
3634
+ this.currentProgram = {};
3635
+ }
3636
+ log(message) {
3637
+ console.log(message);
3638
+ this.logs.push({
3639
+ timestamp: Date.now(),
3640
+ message
3641
+ });
3642
+ }
3643
+ logError(message) {
3644
+ console.log(message);
3645
+ this.logs.push({
3646
+ timestamp: Date.now(),
3647
+ message,
3648
+ level: "error"
3649
+ });
3650
+ }
3651
+ };
3652
+ export {
3653
+ ConnectedMotionGroup,
3654
+ JoggerConnection,
3655
+ MotionStreamConnection,
3656
+ NovaCellAPIClient,
3657
+ NovaClient,
3658
+ ProgramState,
3659
+ ProgramStateConnection,
3660
+ getLatestTrajectories
3661
+ };
3662
+ //# sourceMappingURL=index.js.map