@wandelbots/nova-js 3.2.0 → 3.3.0

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 (104) hide show
  1. package/README.md +32 -136
  2. package/dist/AutoReconnectingWebsocket-Qcrbm3Kb.d.cts +69 -0
  3. package/dist/AutoReconnectingWebsocket-Qcrbm3Kb.d.cts.map +1 -0
  4. package/dist/AutoReconnectingWebsocket-dHe-kceU.d.mts +69 -0
  5. package/dist/AutoReconnectingWebsocket-dHe-kceU.d.mts.map +1 -0
  6. package/dist/LoginWithAuth0-CBD9BXXz.cjs +264 -0
  7. package/dist/LoginWithAuth0-CBD9BXXz.cjs.map +1 -0
  8. package/dist/LoginWithAuth0-wQB-Sol1.mjs +217 -0
  9. package/dist/LoginWithAuth0-wQB-Sol1.mjs.map +1 -0
  10. package/dist/NovaClient-B8XM3OPO.mjs +2057 -0
  11. package/dist/NovaClient-B8XM3OPO.mjs.map +1 -0
  12. package/dist/NovaClient-CV7ooIkD.d.cts +349 -0
  13. package/dist/NovaClient-CV7ooIkD.d.cts.map +1 -0
  14. package/dist/NovaClient-D2EItmiH.cjs +2137 -0
  15. package/dist/NovaClient-D2EItmiH.cjs.map +1 -0
  16. package/dist/NovaClient-qJnHcx2s.d.mts +349 -0
  17. package/dist/NovaClient-qJnHcx2s.d.mts.map +1 -0
  18. package/dist/index.cjs +42 -386
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +73 -0
  21. package/dist/index.d.cts.map +1 -0
  22. package/dist/index.d.mts +73 -0
  23. package/dist/index.d.mts.map +1 -0
  24. package/dist/index.mjs +36 -0
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/lib/v1/index.cjs +190 -2940
  27. package/dist/lib/v1/index.cjs.map +1 -1
  28. package/dist/lib/v1/index.d.cts +62 -0
  29. package/dist/lib/v1/index.d.cts.map +1 -0
  30. package/dist/lib/v1/index.d.mts +62 -0
  31. package/dist/lib/v1/index.d.mts.map +1 -0
  32. package/dist/lib/v1/index.mjs +182 -0
  33. package/dist/lib/v1/index.mjs.map +1 -0
  34. package/dist/lib/v2/index.cjs +1821 -1468
  35. package/dist/lib/v2/index.cjs.map +1 -1
  36. package/dist/lib/v2/index.d.cts +118 -0
  37. package/dist/lib/v2/index.d.cts.map +1 -0
  38. package/dist/lib/v2/index.d.mts +118 -0
  39. package/dist/lib/v2/index.d.mts.map +1 -0
  40. package/dist/lib/v2/index.mjs +1822 -0
  41. package/dist/lib/v2/index.mjs.map +1 -0
  42. package/package.json +21 -19
  43. package/src/LoginWithAuth0.ts +12 -12
  44. package/src/index.ts +2 -0
  45. package/src/lib/converters.ts +5 -23
  46. package/src/lib/v1/MotionStreamConnection.ts +0 -1
  47. package/src/lib/v1/NovaClient.ts +18 -0
  48. package/src/lib/v1/index.ts +6 -0
  49. package/src/lib/v1/mock/MockNovaInstance.ts +0 -1
  50. package/src/lib/v1/wandelscriptUtils.ts +22 -0
  51. package/src/lib/v2/NovaClient.ts +14 -7
  52. package/src/lib/v2/index.ts +1 -0
  53. package/src/lib/v2/mock/MockNovaInstance.ts +411 -21
  54. package/src/lib/v2/wandelscriptUtils.ts +27 -0
  55. package/dist/LoginWithAuth0.d.ts +0 -7
  56. package/dist/LoginWithAuth0.d.ts.map +0 -1
  57. package/dist/chunk-B2C22PTK.js +0 -53
  58. package/dist/chunk-B2C22PTK.js.map +0 -1
  59. package/dist/chunk-I3PUV6ZD.js +0 -286
  60. package/dist/chunk-I3PUV6ZD.js.map +0 -1
  61. package/dist/index.d.ts +0 -6
  62. package/dist/index.d.ts.map +0 -1
  63. package/dist/index.js +0 -60
  64. package/dist/index.js.map +0 -1
  65. package/dist/lib/AutoReconnectingWebsocket.d.ts +0 -43
  66. package/dist/lib/AutoReconnectingWebsocket.d.ts.map +0 -1
  67. package/dist/lib/availableStorage.d.ts +0 -15
  68. package/dist/lib/availableStorage.d.ts.map +0 -1
  69. package/dist/lib/converters.d.ts +0 -26
  70. package/dist/lib/converters.d.ts.map +0 -1
  71. package/dist/lib/errorHandling.d.ts +0 -15
  72. package/dist/lib/errorHandling.d.ts.map +0 -1
  73. package/dist/lib/v1/ConnectedMotionGroup.d.ts +0 -77
  74. package/dist/lib/v1/ConnectedMotionGroup.d.ts.map +0 -1
  75. package/dist/lib/v1/JoggerConnection.d.ts +0 -94
  76. package/dist/lib/v1/JoggerConnection.d.ts.map +0 -1
  77. package/dist/lib/v1/MotionStreamConnection.d.ts +0 -26
  78. package/dist/lib/v1/MotionStreamConnection.d.ts.map +0 -1
  79. package/dist/lib/v1/NovaCellAPIClient.d.ts +0 -68
  80. package/dist/lib/v1/NovaCellAPIClient.d.ts.map +0 -1
  81. package/dist/lib/v1/NovaClient.d.ts +0 -67
  82. package/dist/lib/v1/NovaClient.d.ts.map +0 -1
  83. package/dist/lib/v1/ProgramStateConnection.d.ts +0 -57
  84. package/dist/lib/v1/ProgramStateConnection.d.ts.map +0 -1
  85. package/dist/lib/v1/getLatestTrajectories.d.ts +0 -4
  86. package/dist/lib/v1/getLatestTrajectories.d.ts.map +0 -1
  87. package/dist/lib/v1/index.d.ts +0 -9
  88. package/dist/lib/v1/index.d.ts.map +0 -1
  89. package/dist/lib/v1/index.js +0 -2653
  90. package/dist/lib/v1/index.js.map +0 -1
  91. package/dist/lib/v1/mock/MockNovaInstance.d.ts +0 -13
  92. package/dist/lib/v1/mock/MockNovaInstance.d.ts.map +0 -1
  93. package/dist/lib/v1/motionStateUpdate.d.ts +0 -4
  94. package/dist/lib/v1/motionStateUpdate.d.ts.map +0 -1
  95. package/dist/lib/v2/NovaCellAPIClient.d.ts +0 -62
  96. package/dist/lib/v2/NovaCellAPIClient.d.ts.map +0 -1
  97. package/dist/lib/v2/NovaClient.d.ts +0 -60
  98. package/dist/lib/v2/NovaClient.d.ts.map +0 -1
  99. package/dist/lib/v2/index.d.ts +0 -4
  100. package/dist/lib/v2/index.d.ts.map +0 -1
  101. package/dist/lib/v2/index.js +0 -1196
  102. package/dist/lib/v2/index.js.map +0 -1
  103. package/dist/lib/v2/mock/MockNovaInstance.d.ts +0 -13
  104. package/dist/lib/v2/mock/MockNovaInstance.d.ts.map +0 -1
@@ -1,1196 +0,0 @@
1
- import {
2
- AutoReconnectingWebsocket,
3
- __async,
4
- __spreadProps,
5
- __spreadValues,
6
- availableStorage,
7
- loginWithAuth0
8
- } from "../../chunk-I3PUV6ZD.js";
9
-
10
- // src/lib/v2/index.ts
11
- export * from "@wandelbots/nova-api/v2";
12
-
13
- // src/lib/v2/NovaCellAPIClient.ts
14
- import {
15
- ApplicationApi,
16
- BUSInputsOutputsApi,
17
- CellApi,
18
- ControllerApi,
19
- ControllerInputsOutputsApi,
20
- JoggingApi,
21
- KinematicsApi,
22
- MotionGroupApi,
23
- MotionGroupModelsApi,
24
- StoreCollisionComponentsApi,
25
- StoreCollisionSetupsApi,
26
- StoreObjectApi,
27
- SystemApi,
28
- TrajectoryCachingApi,
29
- TrajectoryExecutionApi,
30
- TrajectoryPlanningApi,
31
- VirtualControllerApi,
32
- VirtualControllerBehaviorApi,
33
- VirtualControllerInputsOutputsApi
34
- } from "@wandelbots/nova-api/v2";
35
- import axios from "axios";
36
- var NovaCellAPIClient = class {
37
- constructor(cellId, opts) {
38
- this.cellId = cellId;
39
- this.opts = opts;
40
- this.system = this.withUnwrappedResponsesOnly(SystemApi);
41
- this.cell = this.withUnwrappedResponsesOnly(CellApi);
42
- this.motionGroup = this.withCellId(MotionGroupApi);
43
- this.motionGroupModels = this.withCellId(MotionGroupModelsApi);
44
- this.controller = this.withCellId(ControllerApi);
45
- this.controllerIOs = this.withCellId(ControllerInputsOutputsApi);
46
- this.trajectoryPlanning = this.withCellId(TrajectoryPlanningApi);
47
- this.trajectoryExecution = this.withCellId(TrajectoryExecutionApi);
48
- this.trajectoryCaching = this.withCellId(TrajectoryCachingApi);
49
- this.application = this.withCellId(ApplicationApi);
50
- this.applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi);
51
- this.jogging = this.withCellId(JoggingApi);
52
- this.kinematics = this.withCellId(KinematicsApi);
53
- this.busInputsOutputs = this.withCellId(BUSInputsOutputsApi);
54
- this.virtualController = this.withCellId(VirtualControllerApi);
55
- this.virtualControllerBehavior = this.withCellId(
56
- VirtualControllerBehaviorApi
57
- );
58
- this.virtualControllerIOs = this.withCellId(
59
- VirtualControllerInputsOutputsApi
60
- );
61
- this.storeObject = this.withCellId(StoreObjectApi);
62
- this.storeCollisionComponents = this.withCellId(
63
- StoreCollisionComponentsApi
64
- );
65
- this.storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi);
66
- }
67
- /**
68
- * Some TypeScript sorcery which alters the API class methods so you don't
69
- * have to pass the cell id to every single one, and de-encapsulates the
70
- * response data
71
- */
72
- withCellId(ApiConstructor) {
73
- var _a, _b;
74
- const apiClient = new ApiConstructor(
75
- __spreadProps(__spreadValues({}, this.opts), {
76
- isJsonMime: (mime) => {
77
- return mime === "application/json";
78
- }
79
- }),
80
- (_a = this.opts.basePath) != null ? _a : "",
81
- (_b = this.opts.axiosInstance) != null ? _b : axios.create()
82
- );
83
- for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) {
84
- if (key !== "constructor" && typeof apiClient[key] === "function") {
85
- const originalFunction = apiClient[key];
86
- apiClient[key] = (...args) => {
87
- return originalFunction.apply(apiClient, [this.cellId, ...args]).then((res) => res.data);
88
- };
89
- }
90
- }
91
- return apiClient;
92
- }
93
- /**
94
- * As withCellId, but only does the response unwrapping
95
- */
96
- withUnwrappedResponsesOnly(ApiConstructor) {
97
- var _a, _b;
98
- const apiClient = new ApiConstructor(
99
- __spreadProps(__spreadValues({}, this.opts), {
100
- isJsonMime: (mime) => {
101
- return mime === "application/json";
102
- }
103
- }),
104
- (_a = this.opts.basePath) != null ? _a : "",
105
- (_b = this.opts.axiosInstance) != null ? _b : axios.create()
106
- );
107
- for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) {
108
- if (key !== "constructor" && typeof apiClient[key] === "function") {
109
- const originalFunction = apiClient[key];
110
- apiClient[key] = (...args) => {
111
- return originalFunction.apply(apiClient, args).then((res) => res.data);
112
- };
113
- }
114
- }
115
- return apiClient;
116
- }
117
- };
118
-
119
- // src/lib/v2/NovaClient.ts
120
- import axios2, { isAxiosError } from "axios";
121
- import urlJoin from "url-join";
122
-
123
- // src/lib/v2/mock/MockNovaInstance.ts
124
- import { AxiosError } from "axios";
125
- import * as pathToRegexp from "path-to-regexp";
126
- var MockNovaInstance = class {
127
- constructor() {
128
- this.connections = [];
129
- }
130
- handleAPIRequest(config) {
131
- return __async(this, null, function* () {
132
- var _a, _b, _c;
133
- const apiHandlers = [
134
- {
135
- method: "GET",
136
- path: "/cells/:cellId/controllers",
137
- handle() {
138
- return {
139
- controllers: [
140
- {
141
- controller: "mock-ur5e",
142
- model_name: "UniversalRobots::Controller",
143
- host: "mock-ur5e",
144
- allow_software_install_on_controller: true,
145
- motion_groups: [
146
- {
147
- motion_group: "0@mock-ur5e",
148
- name_from_controller: "UR5e",
149
- active: false,
150
- model_from_controller: "UniversalRobots_UR5e"
151
- }
152
- ],
153
- has_error: false,
154
- error_details: ""
155
- }
156
- ]
157
- };
158
- }
159
- },
160
- {
161
- method: "GET",
162
- path: "/cells/:cellId/controllers/:controllerId",
163
- handle() {
164
- return {
165
- configuration: {
166
- kind: "VirtualController",
167
- manufacturer: "universalrobots",
168
- type: "universalrobots-ur5e"
169
- },
170
- name: "mock-ur5"
171
- };
172
- }
173
- },
174
- {
175
- method: "GET",
176
- path: "/cells/:cellId/motion-groups/:motionGroupId/specification",
177
- handle() {
178
- return {
179
- dh_parameters: [
180
- {
181
- alpha: 1.5707963267948966,
182
- theta: 0,
183
- a: 0,
184
- d: 162.25,
185
- reverse_rotation_direction: false
186
- },
187
- {
188
- alpha: 0,
189
- theta: 0,
190
- a: -425,
191
- d: 0,
192
- reverse_rotation_direction: false
193
- },
194
- {
195
- alpha: 0,
196
- theta: 0,
197
- a: -392.2,
198
- d: 0,
199
- reverse_rotation_direction: false
200
- },
201
- {
202
- alpha: 1.5707963267948966,
203
- theta: 0,
204
- a: 0,
205
- d: 133.3,
206
- reverse_rotation_direction: false
207
- },
208
- {
209
- alpha: -1.5707963267948966,
210
- theta: 0,
211
- a: 0,
212
- d: 99.7,
213
- reverse_rotation_direction: false
214
- },
215
- {
216
- alpha: 0,
217
- theta: 0,
218
- a: 0,
219
- d: 99.6,
220
- reverse_rotation_direction: false
221
- }
222
- ],
223
- mechanical_joint_limits: [
224
- {
225
- joint: "JOINTNAME_AXIS_1",
226
- lower_limit: -6.335545063018799,
227
- upper_limit: 6.335545063018799,
228
- unlimited: false
229
- },
230
- {
231
- joint: "JOINTNAME_AXIS_2",
232
- lower_limit: -6.335545063018799,
233
- upper_limit: 6.335545063018799,
234
- unlimited: false
235
- },
236
- {
237
- joint: "JOINTNAME_AXIS_3",
238
- lower_limit: -6.335545063018799,
239
- upper_limit: 6.335545063018799,
240
- unlimited: false
241
- },
242
- {
243
- joint: "JOINTNAME_AXIS_4",
244
- lower_limit: -6.335545063018799,
245
- upper_limit: 6.335545063018799,
246
- unlimited: false
247
- },
248
- {
249
- joint: "JOINTNAME_AXIS_5",
250
- lower_limit: -6.335545063018799,
251
- upper_limit: 6.335545063018799,
252
- unlimited: false
253
- },
254
- {
255
- joint: "JOINTNAME_AXIS_6",
256
- lower_limit: -6.335545063018799,
257
- upper_limit: 6.335545063018799,
258
- unlimited: false
259
- }
260
- ]
261
- };
262
- }
263
- },
264
- {
265
- method: "GET",
266
- path: "/cells/:cellId/motion-groups/:motionGroupId/safety-setup",
267
- handle() {
268
- return {
269
- safety_settings: [
270
- {
271
- safety_state: "SAFETY_NORMAL",
272
- settings: {
273
- joint_position_limits: [
274
- {
275
- joint: "JOINTNAME_AXIS_1",
276
- lower_limit: -2.96705961227417,
277
- upper_limit: 2.96705961227417,
278
- unlimited: false
279
- },
280
- {
281
- joint: "JOINTNAME_AXIS_2",
282
- lower_limit: -1.7453292608261108,
283
- upper_limit: 2.7925267219543457,
284
- unlimited: false
285
- },
286
- {
287
- joint: "JOINTNAME_AXIS_3",
288
- lower_limit: -3.3161256313323975,
289
- upper_limit: 0.40142571926116943,
290
- unlimited: false
291
- },
292
- {
293
- joint: "JOINTNAME_AXIS_4",
294
- lower_limit: -3.4906585216522217,
295
- upper_limit: 3.4906585216522217,
296
- unlimited: false
297
- },
298
- {
299
- joint: "JOINTNAME_AXIS_5",
300
- lower_limit: -2.4434609413146973,
301
- upper_limit: 2.4434609413146973,
302
- unlimited: false
303
- },
304
- {
305
- joint: "JOINTNAME_AXIS_6",
306
- lower_limit: -4.71238899230957,
307
- upper_limit: 4.71238899230957,
308
- unlimited: false
309
- }
310
- ],
311
- joint_velocity_limits: [
312
- {
313
- joint: "JOINTNAME_AXIS_1",
314
- limit: 3.1415927410125732
315
- },
316
- {
317
- joint: "JOINTNAME_AXIS_2",
318
- limit: 3.1415927410125732
319
- },
320
- {
321
- joint: "JOINTNAME_AXIS_3",
322
- limit: 3.4906585216522217
323
- },
324
- {
325
- joint: "JOINTNAME_AXIS_4",
326
- limit: 6.108652591705322
327
- },
328
- {
329
- joint: "JOINTNAME_AXIS_5",
330
- limit: 6.108652591705322
331
- },
332
- {
333
- joint: "JOINTNAME_AXIS_6",
334
- limit: 6.981317043304443
335
- }
336
- ],
337
- joint_acceleration_limits: [],
338
- joint_torque_limits: [],
339
- tcp_velocity_limit: 1800
340
- }
341
- }
342
- ],
343
- safety_zones: [
344
- {
345
- id: 1,
346
- priority: 0,
347
- geometry: {
348
- compound: {
349
- child_geometries: [
350
- {
351
- convex_hull: {
352
- vertices: [
353
- { vertex: [-800, -1330, -1820] },
354
- { vertex: [1650, -1330, -1820] },
355
- { vertex: [1650, 1330, -1820] },
356
- { vertex: [-800, 1330, -1820] }
357
- ]
358
- },
359
- init_pose: {
360
- position: [0, 0, 0],
361
- orientation: [0, 0, 0, 1]
362
- },
363
- id: "box"
364
- },
365
- {
366
- convex_hull: {
367
- vertices: [
368
- {
369
- vertex: [-800, -1330, -1820]
370
- },
371
- {
372
- vertex: [1650, -1330, -1820]
373
- },
374
- {
375
- vertex: [1650, -1330, 1500]
376
- },
377
- {
378
- vertex: [-800, -1330, 1500]
379
- }
380
- ]
381
- },
382
- init_pose: {
383
- position: [0, 0, 0],
384
- orientation: [0, 0, 0, 1]
385
- },
386
- id: "box"
387
- },
388
- {
389
- convex_hull: {
390
- vertices: [
391
- {
392
- vertex: [-800, -1330, -1820]
393
- },
394
- {
395
- vertex: [-800, 1330, -1820]
396
- },
397
- {
398
- vertex: [-800, 1330, 1500]
399
- },
400
- {
401
- vertex: [-800, -1330, 1500]
402
- }
403
- ]
404
- },
405
- init_pose: {
406
- position: [0, 0, 0],
407
- orientation: [0, 0, 0, 1]
408
- },
409
- id: "box"
410
- },
411
- {
412
- convex_hull: {
413
- vertices: [
414
- {
415
- vertex: [1650, 1330, 1500]
416
- },
417
- {
418
- vertex: [-800, 1330, 1500]
419
- },
420
- {
421
- vertex: [-800, -1330, 1500]
422
- },
423
- {
424
- vertex: [1650, -1330, 1500]
425
- }
426
- ]
427
- },
428
- init_pose: {
429
- position: [0, 0, 0],
430
- orientation: [0, 0, 0, 1]
431
- },
432
- id: "box"
433
- },
434
- {
435
- convex_hull: {
436
- vertices: [
437
- {
438
- vertex: [1650, 1330, 1500]
439
- },
440
- {
441
- vertex: [-800, 1330, 1500]
442
- },
443
- {
444
- vertex: [-800, 1330, -1820]
445
- },
446
- {
447
- vertex: [1650, 1330, -1820]
448
- }
449
- ]
450
- },
451
- init_pose: {
452
- position: [0, 0, 0],
453
- orientation: [0, 0, 0, 1]
454
- },
455
- id: "box"
456
- },
457
- {
458
- convex_hull: {
459
- vertices: [
460
- {
461
- vertex: [1650, 1330, 1500]
462
- },
463
- {
464
- vertex: [1650, -1330, 1500]
465
- },
466
- {
467
- vertex: [1650, -1330, -1820]
468
- },
469
- {
470
- vertex: [1650, 1330, -1820]
471
- }
472
- ]
473
- },
474
- init_pose: {
475
- position: [0, 0, 0],
476
- orientation: [0, 0, 0, 1]
477
- },
478
- id: "box"
479
- }
480
- ]
481
- },
482
- init_pose: {
483
- position: [0, 0, 0],
484
- orientation: [0, 0, 0, 1]
485
- },
486
- id: "Cell workzone"
487
- },
488
- motion_group_uid: 1
489
- },
490
- {
491
- id: 2,
492
- priority: 0,
493
- geometry: {
494
- convex_hull: {
495
- vertices: [
496
- {
497
- vertex: [1650, 1330, -1850]
498
- },
499
- {
500
- vertex: [865, 1330, -1850]
501
- },
502
- {
503
- vertex: [865, -720, -1850]
504
- },
505
- {
506
- vertex: [1650, -720, -1850]
507
- },
508
- {
509
- vertex: [1650, 1330, -920]
510
- },
511
- {
512
- vertex: [865, 1330, -920]
513
- },
514
- {
515
- vertex: [865, -720, -920]
516
- },
517
- {
518
- vertex: [1650, -720, -920]
519
- }
520
- ]
521
- },
522
- init_pose: {
523
- position: [0, 0, 0],
524
- orientation: [0, 0, 0, 1]
525
- },
526
- id: "Transport"
527
- },
528
- motion_group_uid: 1
529
- },
530
- {
531
- id: 3,
532
- priority: 0,
533
- geometry: {
534
- convex_hull: {
535
- vertices: [
536
- {
537
- vertex: [1650, 1330, -600]
538
- },
539
- {
540
- vertex: [865, 1330, -600]
541
- },
542
- {
543
- vertex: [865, 430, -600]
544
- },
545
- {
546
- vertex: [1650, 430, -600]
547
- },
548
- {
549
- vertex: [1650, 1330, -1250]
550
- },
551
- {
552
- vertex: [865, 1330, -1250]
553
- },
554
- {
555
- vertex: [865, 430, -1250]
556
- },
557
- {
558
- vertex: [1650, 430, -1250]
559
- }
560
- ]
561
- },
562
- init_pose: {
563
- position: [0, 0, 0],
564
- orientation: [0, 0, 0, 1]
565
- },
566
- id: "Tunel"
567
- },
568
- motion_group_uid: 1
569
- },
570
- {
571
- id: 4,
572
- priority: 0,
573
- geometry: {
574
- convex_hull: {
575
- vertices: [
576
- {
577
- vertex: [1650, -760, -440]
578
- },
579
- {
580
- vertex: [900, -760, -440]
581
- },
582
- {
583
- vertex: [900, -1330, -440]
584
- },
585
- {
586
- vertex: [1650, -1330, -440]
587
- },
588
- {
589
- vertex: [1650, -760, -1800]
590
- },
591
- {
592
- vertex: [900, -760, -1800]
593
- },
594
- {
595
- vertex: [900, -1330, -1800]
596
- },
597
- {
598
- vertex: [1650, -1330, -1800]
599
- }
600
- ]
601
- },
602
- init_pose: {
603
- position: [0, 0, 0],
604
- orientation: [0, 0, 0, 1]
605
- },
606
- id: "Fanuc controller"
607
- },
608
- motion_group_uid: 1
609
- },
610
- {
611
- id: 6,
612
- priority: 0,
613
- geometry: {
614
- convex_hull: {
615
- vertices: [
616
- {
617
- vertex: [-200, -200, -1900]
618
- },
619
- {
620
- vertex: [200, -200, -1900]
621
- },
622
- {
623
- vertex: [200, 200, -1900]
624
- },
625
- {
626
- vertex: [-200, 200, -1900]
627
- },
628
- {
629
- vertex: [-200, -200, -350]
630
- },
631
- {
632
- vertex: [200, -200, -350]
633
- },
634
- {
635
- vertex: [200, 200, -350]
636
- },
637
- {
638
- vertex: [-200, 200, -350]
639
- }
640
- ]
641
- },
642
- init_pose: {
643
- position: [0, 0, 0],
644
- orientation: [0, 0, 0, 1]
645
- },
646
- id: "Robot base"
647
- },
648
- motion_group_uid: 1
649
- }
650
- ],
651
- robot_model_geometries: [
652
- {
653
- link_index: 1,
654
- geometry: {
655
- sphere: {
656
- radius: 270
657
- },
658
- init_pose: {
659
- position: [-70, -70, -50],
660
- orientation: [0, 0, 0, 1]
661
- },
662
- id: "link1_sphere"
663
- }
664
- },
665
- {
666
- link_index: 2,
667
- geometry: {
668
- capsule: {
669
- radius: 160,
670
- cylinder_height: 800
671
- },
672
- init_pose: {
673
- position: [-450, 40, 170],
674
- orientation: [0, -Math.SQRT1_2, 0, Math.SQRT1_2]
675
- },
676
- id: "link2_capsule"
677
- }
678
- },
679
- {
680
- link_index: 3,
681
- geometry: {
682
- sphere: {
683
- radius: 270
684
- },
685
- init_pose: {
686
- position: [-110, 10, -100],
687
- orientation: [0, 0, 0, 1]
688
- },
689
- id: "link3_sphere"
690
- }
691
- },
692
- {
693
- link_index: 4,
694
- geometry: {
695
- capsule: {
696
- radius: 110,
697
- cylinder_height: 600
698
- },
699
- init_pose: {
700
- position: [0, 300, 40],
701
- orientation: [-Math.SQRT1_2, 0, 0, Math.SQRT1_2]
702
- },
703
- id: "link4_capsule"
704
- }
705
- },
706
- {
707
- link_index: 5,
708
- geometry: {
709
- sphere: {
710
- radius: 75
711
- },
712
- init_pose: {
713
- position: [0, 0, -50],
714
- orientation: [0, 0, 0, 1]
715
- },
716
- id: "link5_sphere"
717
- }
718
- }
719
- ],
720
- tool_geometries: []
721
- };
722
- }
723
- },
724
- {
725
- method: "GET",
726
- path: "/cells/:cellId/coordinate-systems",
727
- handle() {
728
- return {
729
- coordinatesystems: [
730
- {
731
- coordinate_system: "",
732
- name: "world",
733
- reference_uid: "",
734
- position: [0, 0, 0],
735
- rotation: {
736
- angles: [0, 0, 0],
737
- type: "ROTATION_VECTOR"
738
- }
739
- }
740
- ]
741
- };
742
- }
743
- },
744
- {
745
- method: "GET",
746
- path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
747
- handle() {
748
- return {
749
- tcps: [
750
- {
751
- id: "Flange",
752
- readable_name: "Default-Flange",
753
- position: [0, 0, 0],
754
- rotation: {
755
- angles: [0, 0, 0, 0],
756
- type: "ROTATION_VECTOR"
757
- }
758
- },
759
- {
760
- id: "complex-tcp-position",
761
- readable_name: "Complex TCP Position",
762
- position: [-200, 300, 150],
763
- rotation: {
764
- angles: [
765
- -0.12139440409113832,
766
- -0.06356210998212003,
767
- -0.2023240068185639,
768
- 0
769
- ],
770
- type: "ROTATION_VECTOR"
771
- }
772
- }
773
- ]
774
- };
775
- }
776
- }
777
- ];
778
- const method = ((_a = config.method) == null ? void 0 : _a.toUpperCase()) || "GET";
779
- const path = `/cells${(_c = (_b = config.url) == null ? void 0 : _b.split("/cells")[1]) == null ? void 0 : _c.split("?")[0]}`;
780
- for (const handler of apiHandlers) {
781
- const match2 = pathToRegexp.match(handler.path)(path || "");
782
- if (method === handler.method && match2) {
783
- const json = handler.handle();
784
- return {
785
- status: 200,
786
- statusText: "Success",
787
- data: JSON.stringify(json),
788
- headers: {},
789
- config,
790
- request: {
791
- responseURL: config.url
792
- }
793
- };
794
- }
795
- }
796
- throw new AxiosError(
797
- `No mock handler matched this request: ${method} ${path}`,
798
- "404",
799
- config
800
- );
801
- });
802
- }
803
- handleWebsocketConnection(socket) {
804
- this.connections.push(socket);
805
- setTimeout(() => {
806
- socket.dispatchEvent(new Event("open"));
807
- console.log("Websocket connection opened from", socket.url);
808
- if (socket.url.includes("/state-stream")) {
809
- socket.dispatchEvent(
810
- new MessageEvent("message", {
811
- data: JSON.stringify(defaultMotionState)
812
- })
813
- );
814
- }
815
- if (socket.url.includes("/move-joint")) {
816
- socket.dispatchEvent(
817
- new MessageEvent("message", {
818
- data: JSON.stringify({
819
- result: {
820
- motion_group: "0@ur",
821
- state: {
822
- controller: "ur",
823
- operation_mode: "OPERATION_MODE_AUTO",
824
- safety_state: "SAFETY_STATE_NORMAL",
825
- timestamp: "2024-09-18T12:48:26.096266444Z",
826
- velocity_override: 100,
827
- motion_groups: [
828
- {
829
- motion_group: "0@ur",
830
- controller: "ur",
831
- joint_position: [
832
- 1.3492152690887451,
833
- -1.5659207105636597,
834
- 1.6653711795806885,
835
- -1.0991662740707397,
836
- -1.829018235206604,
837
- 1.264623761177063
838
- ],
839
- joint_velocity: {
840
- joints: [0, 0, 0, 0, 0, 0]
841
- },
842
- flange_pose: {
843
- position: [
844
- 6.437331889439328,
845
- -628.4123774830913,
846
- 577.0569957147832
847
- ],
848
- orientation: {
849
- x: -1.683333649797158,
850
- y: -1.9783363827298732,
851
- z: -0.4928031860165713
852
- },
853
- coordinate_system: ""
854
- },
855
- tcp_pose: {
856
- position: [
857
- 6.437331889439328,
858
- -628.4123774830913,
859
- 577.0569957147832
860
- ],
861
- orientation: {
862
- x: -1.683333649797158,
863
- y: -1.9783363827298732,
864
- z: -0.4928031860165713
865
- },
866
- coordinate_system: "",
867
- tcp: "Flange"
868
- },
869
- velocity: {
870
- linear: {
871
- x: 0,
872
- y: 0,
873
- z: 0
874
- },
875
- angular: {
876
- x: -0,
877
- y: 0,
878
- z: 0
879
- },
880
- coordinate_system: ""
881
- },
882
- force: {
883
- force: {
884
- x: 0,
885
- y: 0,
886
- z: 0
887
- },
888
- moment: {
889
- x: 0,
890
- y: 0,
891
- z: 0
892
- },
893
- coordinate_system: ""
894
- },
895
- joint_limit_reached: {
896
- limit_reached: [
897
- false,
898
- false,
899
- false,
900
- false,
901
- false,
902
- false
903
- ]
904
- },
905
- joint_current: {
906
- joints: [0, 0, 0, 0, 0, 0]
907
- },
908
- sequence_number: "671259"
909
- }
910
- ],
911
- sequence_number: "671259"
912
- },
913
- movement_state: "MOVEMENT_STATE_MOVING"
914
- }
915
- })
916
- })
917
- );
918
- }
919
- if (socket.url.includes("/move-tcp")) {
920
- socket.dispatchEvent(
921
- new MessageEvent("message", {
922
- data: JSON.stringify({
923
- result: {
924
- motion_group: "0@ur",
925
- state: {
926
- controller: "ur",
927
- operation_mode: "OPERATION_MODE_AUTO",
928
- safety_state: "SAFETY_STATE_NORMAL",
929
- timestamp: "2024-09-18T12:43:12.188335774Z",
930
- velocity_override: 100,
931
- motion_groups: [
932
- {
933
- motion_group: "0@ur",
934
- controller: "ur",
935
- joint_position: {
936
- joints: [
937
- 1.3352527618408203,
938
- -1.5659207105636597,
939
- 1.6653711795806885,
940
- -1.110615611076355,
941
- -1.829018235206604,
942
- 1.264623761177063
943
- ]
944
- },
945
- joint_velocity: {
946
- joints: [0, 0, 0, 0, 0, 0]
947
- },
948
- flange_pose: {
949
- position: [
950
- -2.763015284002938,
951
- -630.2151479701106,
952
- 577.524509114342
953
- ],
954
- orientation: {
955
- x: -1.704794877102097,
956
- y: -1.9722372952861567,
957
- z: -0.4852079204210754
958
- },
959
- coordinate_system: ""
960
- },
961
- tcp_pose: {
962
- position: [
963
- -2.763015284002938,
964
- -630.2151479701106,
965
- 577.524509114342
966
- ],
967
- orientation: {
968
- x: -1.704794877102097,
969
- y: -1.9722372952861567,
970
- z: -0.4852079204210754
971
- },
972
- coordinate_system: "",
973
- tcp: "Flange"
974
- },
975
- velocity: {
976
- linear: {
977
- x: 0,
978
- y: 0,
979
- z: 0
980
- },
981
- angular: {
982
- x: -0,
983
- y: 0,
984
- z: 0
985
- },
986
- coordinate_system: ""
987
- },
988
- force: {
989
- force: {
990
- x: 0,
991
- y: 0,
992
- z: 0
993
- },
994
- moment: {
995
- x: 0,
996
- y: 0,
997
- z: 0
998
- },
999
- coordinate_system: ""
1000
- },
1001
- joint_limit_reached: {
1002
- limit_reached: [
1003
- false,
1004
- false,
1005
- false,
1006
- false,
1007
- false,
1008
- false
1009
- ]
1010
- },
1011
- joint_current: {
1012
- joints: [0, 0, 0, 0, 0, 0]
1013
- },
1014
- sequence_number: "627897"
1015
- }
1016
- ],
1017
- sequence_number: "627897"
1018
- },
1019
- movement_state: "MOVEMENT_STATE_MOVING"
1020
- }
1021
- })
1022
- })
1023
- );
1024
- }
1025
- }, 10);
1026
- }
1027
- handleWebsocketMessage(socket, message) {
1028
- console.log(`Received message on ${socket.url}`, message);
1029
- }
1030
- };
1031
- var defaultMotionState = {
1032
- result: {
1033
- motion_group: "0@universalrobots-ur5e",
1034
- controller: "universalrobots-ur5e",
1035
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1036
- sequence_number: 1,
1037
- joint_position: [
1038
- 1.1699999570846558,
1039
- -1.5700000524520874,
1040
- 1.3600000143051147,
1041
- 1.0299999713897705,
1042
- 1.2899999618530273,
1043
- 1.2799999713897705
1044
- ],
1045
- joint_limit_reached: {
1046
- limit_reached: [false, false, false, false, false, false]
1047
- },
1048
- standstill: false,
1049
- flange_pose: {
1050
- position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],
1051
- orientation: [
1052
- 1.7564919306270736,
1053
- -1.7542521568325058,
1054
- 0.7326972590614671
1055
- ]
1056
- },
1057
- tcp_pose: {
1058
- position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],
1059
- orientation: [
1060
- 1.7564919306270736,
1061
- -1.7542521568325058,
1062
- 0.7326972590614671
1063
- ]
1064
- }
1065
- }
1066
- };
1067
-
1068
- // src/lib/v2/NovaClient.ts
1069
- var NovaClient = class {
1070
- constructor(config) {
1071
- this.authPromise = null;
1072
- this.accessToken = null;
1073
- var _a;
1074
- console.warn("Using experimental NOVA v2 client");
1075
- const cellId = (_a = config.cellId) != null ? _a : "cell";
1076
- this.config = __spreadValues({
1077
- cellId
1078
- }, config);
1079
- this.accessToken = config.accessToken || availableStorage.getString("wbjs.access_token") || null;
1080
- if (this.config.instanceUrl === "https://mock.example.com") {
1081
- this.mock = new MockNovaInstance();
1082
- }
1083
- const axiosInstance = axios2.create({
1084
- baseURL: urlJoin(this.config.instanceUrl, "/api/v2"),
1085
- // TODO - backend needs to set proper CORS headers for this
1086
- headers: typeof window !== "undefined" && window.location.origin.includes("localhost") ? {} : {
1087
- // Identify the client to the backend for logging purposes
1088
- "X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK"
1089
- }
1090
- });
1091
- axiosInstance.interceptors.request.use((request) => __async(this, null, function* () {
1092
- if (!request.headers.Authorization) {
1093
- if (this.accessToken) {
1094
- request.headers.Authorization = `Bearer ${this.accessToken}`;
1095
- } else if (this.config.username && this.config.password) {
1096
- request.headers.Authorization = `Basic ${btoa(`${config.username}:${config.password}`)}`;
1097
- }
1098
- }
1099
- return request;
1100
- }));
1101
- if (typeof window !== "undefined") {
1102
- axiosInstance.interceptors.response.use(
1103
- (r) => r,
1104
- (error) => __async(this, null, function* () {
1105
- var _a2, _b;
1106
- if (isAxiosError(error)) {
1107
- if (((_a2 = error.response) == null ? void 0 : _a2.status) === 401) {
1108
- try {
1109
- yield this.renewAuthentication();
1110
- if (error.config) {
1111
- if (this.accessToken) {
1112
- error.config.headers.Authorization = `Bearer ${this.accessToken}`;
1113
- } else {
1114
- delete error.config.headers.Authorization;
1115
- }
1116
- return axiosInstance.request(error.config);
1117
- }
1118
- } catch (err) {
1119
- return Promise.reject(err);
1120
- }
1121
- } else if (((_b = error.response) == null ? void 0 : _b.status) === 503) {
1122
- const res = yield fetch(window.location.href);
1123
- if (res.status === 503) {
1124
- window.location.reload();
1125
- }
1126
- }
1127
- }
1128
- return Promise.reject(error);
1129
- })
1130
- );
1131
- }
1132
- this.api = new NovaCellAPIClient(cellId, __spreadProps(__spreadValues({}, config), {
1133
- basePath: urlJoin(this.config.instanceUrl, "/api/v1"),
1134
- isJsonMime: (mime) => {
1135
- return mime === "application/json";
1136
- },
1137
- baseOptions: __spreadValues(__spreadValues({}, this.mock ? {
1138
- adapter: (config2) => {
1139
- return this.mock.handleAPIRequest(config2);
1140
- }
1141
- } : {}), config.baseOptions),
1142
- axiosInstance
1143
- }));
1144
- }
1145
- renewAuthentication() {
1146
- return __async(this, null, function* () {
1147
- if (this.authPromise) {
1148
- return;
1149
- }
1150
- this.authPromise = loginWithAuth0(this.config.instanceUrl);
1151
- try {
1152
- this.accessToken = yield this.authPromise;
1153
- if (this.accessToken) {
1154
- availableStorage.setString("wbjs.access_token", this.accessToken);
1155
- } else {
1156
- availableStorage.delete("wbjs.access_token");
1157
- }
1158
- } finally {
1159
- this.authPromise = null;
1160
- }
1161
- });
1162
- }
1163
- makeWebsocketURL(path) {
1164
- const url = new URL(
1165
- urlJoin(
1166
- this.config.instanceUrl,
1167
- `/api/v1/cells/${this.config.cellId}`,
1168
- path
1169
- )
1170
- );
1171
- url.protocol = url.protocol.replace("http", "ws");
1172
- url.protocol = url.protocol.replace("https", "wss");
1173
- if (this.accessToken) {
1174
- url.searchParams.append("token", this.accessToken);
1175
- } else if (this.config.username && this.config.password) {
1176
- url.username = this.config.username;
1177
- url.password = this.config.password;
1178
- }
1179
- return url.toString();
1180
- }
1181
- /**
1182
- * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.
1183
- * If you explicitly want to reconnect an existing websocket, call `reconnect`
1184
- * on the returned object.
1185
- */
1186
- openReconnectingWebsocket(path) {
1187
- return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {
1188
- mock: this.mock
1189
- });
1190
- }
1191
- };
1192
- export {
1193
- NovaCellAPIClient,
1194
- NovaClient
1195
- };
1196
- //# sourceMappingURL=index.js.map