@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,982 @@
1
+ import type {
2
+ ControllersList,
3
+ MotionGroupSpecification,
4
+ MotionGroupState,
5
+ RobotController,
6
+ SafetySetup,
7
+ } from "@wandelbots/nova-api/v2"
8
+ import type { AxiosResponse, InternalAxiosRequestConfig } from "axios"
9
+ import { AxiosError } from "axios"
10
+ import * as pathToRegexp from "path-to-regexp"
11
+ import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
12
+
13
+ /**
14
+ * EXPERIMENTAL
15
+ * Ultra-simplified mock Nova server for testing stuff
16
+ */
17
+ export class MockNovaInstance {
18
+ readonly connections: AutoReconnectingWebsocket[] = []
19
+
20
+ async handleAPIRequest(
21
+ config: InternalAxiosRequestConfig,
22
+ ): Promise<AxiosResponse> {
23
+ const apiHandlers = [
24
+ {
25
+ method: "GET",
26
+ path: "/cells/:cellId/controllers",
27
+ handle() {
28
+ return {
29
+ controllers: [
30
+ {
31
+ controller: "mock-ur5e",
32
+ model_name: "UniversalRobots::Controller",
33
+ host: "mock-ur5e",
34
+ allow_software_install_on_controller: true,
35
+ motion_groups: [
36
+ {
37
+ motion_group: "0@mock-ur5e",
38
+ name_from_controller: "UR5e",
39
+ active: false,
40
+ model_from_controller: "UniversalRobots_UR5e",
41
+ },
42
+ ],
43
+ has_error: false,
44
+ error_details: "",
45
+ },
46
+ ],
47
+ } satisfies ControllersList
48
+ },
49
+ },
50
+ {
51
+ method: "GET",
52
+ path: "/cells/:cellId/controllers/:controllerId",
53
+ handle() {
54
+ return {
55
+ configuration: {
56
+ kind: "VirtualController",
57
+ manufacturer: "universalrobots",
58
+ position: "[0,-1.571,-1.571,-1.571,1.571,-1.571,0]",
59
+ type: "universalrobots-ur5e",
60
+ },
61
+ name: "mock-ur5",
62
+ } satisfies RobotController
63
+ },
64
+ },
65
+ {
66
+ method: "GET",
67
+ path: "/cells/:cellId/motion-groups/:motionGroupId/specification",
68
+ handle() {
69
+ return {
70
+ dh_parameters: [
71
+ {
72
+ alpha: 1.5707963267948966,
73
+ theta: 0,
74
+ a: 0,
75
+ d: 162.25,
76
+ reverse_rotation_direction: false,
77
+ },
78
+ {
79
+ alpha: 0,
80
+ theta: 0,
81
+ a: -425,
82
+ d: 0,
83
+ reverse_rotation_direction: false,
84
+ },
85
+ {
86
+ alpha: 0,
87
+ theta: 0,
88
+ a: -392.2,
89
+ d: 0,
90
+ reverse_rotation_direction: false,
91
+ },
92
+ {
93
+ alpha: 1.5707963267948966,
94
+ theta: 0,
95
+ a: 0,
96
+ d: 133.3,
97
+ reverse_rotation_direction: false,
98
+ },
99
+ {
100
+ alpha: -1.5707963267948966,
101
+ theta: 0,
102
+ a: 0,
103
+ d: 99.7,
104
+ reverse_rotation_direction: false,
105
+ },
106
+ {
107
+ alpha: 0,
108
+ theta: 0,
109
+ a: 0,
110
+ d: 99.6,
111
+ reverse_rotation_direction: false,
112
+ },
113
+ ],
114
+ mechanical_joint_limits: [
115
+ {
116
+ joint: "JOINTNAME_AXIS_1",
117
+ lower_limit: -6.335545063018799,
118
+ upper_limit: 6.335545063018799,
119
+ unlimited: false,
120
+ },
121
+ {
122
+ joint: "JOINTNAME_AXIS_2",
123
+ lower_limit: -6.335545063018799,
124
+ upper_limit: 6.335545063018799,
125
+ unlimited: false,
126
+ },
127
+ {
128
+ joint: "JOINTNAME_AXIS_3",
129
+ lower_limit: -6.335545063018799,
130
+ upper_limit: 6.335545063018799,
131
+ unlimited: false,
132
+ },
133
+ {
134
+ joint: "JOINTNAME_AXIS_4",
135
+ lower_limit: -6.335545063018799,
136
+ upper_limit: 6.335545063018799,
137
+ unlimited: false,
138
+ },
139
+ {
140
+ joint: "JOINTNAME_AXIS_5",
141
+ lower_limit: -6.335545063018799,
142
+ upper_limit: 6.335545063018799,
143
+ unlimited: false,
144
+ },
145
+ {
146
+ joint: "JOINTNAME_AXIS_6",
147
+ lower_limit: -6.335545063018799,
148
+ upper_limit: 6.335545063018799,
149
+ unlimited: false,
150
+ },
151
+ ],
152
+ } satisfies MotionGroupSpecification
153
+ },
154
+ },
155
+ {
156
+ method: "GET",
157
+ path: "/cells/:cellId/motion-groups/:motionGroupId/safety-setup",
158
+ handle() {
159
+ return {
160
+ safety_settings: [
161
+ {
162
+ safety_state: "SAFETY_NORMAL",
163
+ settings: {
164
+ joint_position_limits: [
165
+ {
166
+ joint: "JOINTNAME_AXIS_1",
167
+ lower_limit: -2.96705961227417,
168
+ upper_limit: 2.96705961227417,
169
+ unlimited: false,
170
+ },
171
+ {
172
+ joint: "JOINTNAME_AXIS_2",
173
+ lower_limit: -1.7453292608261108,
174
+ upper_limit: 2.7925267219543457,
175
+ unlimited: false,
176
+ },
177
+ {
178
+ joint: "JOINTNAME_AXIS_3",
179
+ lower_limit: -3.3161256313323975,
180
+ upper_limit: 0.40142571926116943,
181
+ unlimited: false,
182
+ },
183
+ {
184
+ joint: "JOINTNAME_AXIS_4",
185
+ lower_limit: -3.4906585216522217,
186
+ upper_limit: 3.4906585216522217,
187
+ unlimited: false,
188
+ },
189
+ {
190
+ joint: "JOINTNAME_AXIS_5",
191
+ lower_limit: -2.4434609413146973,
192
+ upper_limit: 2.4434609413146973,
193
+ unlimited: false,
194
+ },
195
+ {
196
+ joint: "JOINTNAME_AXIS_6",
197
+ lower_limit: -4.71238899230957,
198
+ upper_limit: 4.71238899230957,
199
+ unlimited: false,
200
+ },
201
+ ],
202
+ joint_velocity_limits: [
203
+ {
204
+ joint: "JOINTNAME_AXIS_1",
205
+ limit: 3.1415927410125732,
206
+ },
207
+ {
208
+ joint: "JOINTNAME_AXIS_2",
209
+ limit: 3.1415927410125732,
210
+ },
211
+ {
212
+ joint: "JOINTNAME_AXIS_3",
213
+ limit: 3.4906585216522217,
214
+ },
215
+ {
216
+ joint: "JOINTNAME_AXIS_4",
217
+ limit: 6.108652591705322,
218
+ },
219
+ {
220
+ joint: "JOINTNAME_AXIS_5",
221
+ limit: 6.108652591705322,
222
+ },
223
+ {
224
+ joint: "JOINTNAME_AXIS_6",
225
+ limit: 6.981317043304443,
226
+ },
227
+ ],
228
+ joint_acceleration_limits: [],
229
+ joint_torque_limits: [],
230
+ tcp_velocity_limit: 1800,
231
+ },
232
+ },
233
+ ],
234
+ safety_zones: [
235
+ {
236
+ id: 1,
237
+ priority: 0,
238
+ geometry: {
239
+ compound: {
240
+ child_geometries: [
241
+ {
242
+ convex_hull: {
243
+ vertices: [
244
+ { vertex: [-800, -1330, -1820] },
245
+ { vertex: [1650, -1330, -1820] },
246
+ { vertex: [1650, 1330, -1820] },
247
+ { vertex: [-800, 1330, -1820] },
248
+ ],
249
+ },
250
+ init_pose: {
251
+ position: [0, 0, 0],
252
+ orientation: [0, 0, 0, 1],
253
+ },
254
+ id: "box",
255
+ },
256
+ {
257
+ convex_hull: {
258
+ vertices: [
259
+ {
260
+ vertex: [-800, -1330, -1820],
261
+ },
262
+ {
263
+ vertex: [1650, -1330, -1820],
264
+ },
265
+ {
266
+ vertex: [1650, -1330, 1500],
267
+ },
268
+ {
269
+ vertex: [-800, -1330, 1500],
270
+ },
271
+ ],
272
+ },
273
+ init_pose: {
274
+ position: [0, 0, 0],
275
+ orientation: [0, 0, 0, 1],
276
+ },
277
+ id: "box",
278
+ },
279
+ {
280
+ convex_hull: {
281
+ vertices: [
282
+ {
283
+ vertex: [-800, -1330, -1820],
284
+ },
285
+ {
286
+ vertex: [-800, 1330, -1820],
287
+ },
288
+ {
289
+ vertex: [-800, 1330, 1500],
290
+ },
291
+ {
292
+ vertex: [-800, -1330, 1500],
293
+ },
294
+ ],
295
+ },
296
+ init_pose: {
297
+ position: [0, 0, 0],
298
+ orientation: [0, 0, 0, 1],
299
+ },
300
+ id: "box",
301
+ },
302
+ {
303
+ convex_hull: {
304
+ vertices: [
305
+ {
306
+ vertex: [1650, 1330, 1500],
307
+ },
308
+ {
309
+ vertex: [-800, 1330, 1500],
310
+ },
311
+ {
312
+ vertex: [-800, -1330, 1500],
313
+ },
314
+ {
315
+ vertex: [1650, -1330, 1500],
316
+ },
317
+ ],
318
+ },
319
+ init_pose: {
320
+ position: [0, 0, 0],
321
+ orientation: [0, 0, 0, 1],
322
+ },
323
+ id: "box",
324
+ },
325
+ {
326
+ convex_hull: {
327
+ vertices: [
328
+ {
329
+ vertex: [1650, 1330, 1500],
330
+ },
331
+ {
332
+ vertex: [-800, 1330, 1500],
333
+ },
334
+ {
335
+ vertex: [-800, 1330, -1820],
336
+ },
337
+ {
338
+ vertex: [1650, 1330, -1820],
339
+ },
340
+ ],
341
+ },
342
+ init_pose: {
343
+ position: [0, 0, 0],
344
+ orientation: [0, 0, 0, 1],
345
+ },
346
+ id: "box",
347
+ },
348
+ {
349
+ convex_hull: {
350
+ vertices: [
351
+ {
352
+ vertex: [1650, 1330, 1500],
353
+ },
354
+ {
355
+ vertex: [1650, -1330, 1500],
356
+ },
357
+ {
358
+ vertex: [1650, -1330, -1820],
359
+ },
360
+ {
361
+ vertex: [1650, 1330, -1820],
362
+ },
363
+ ],
364
+ },
365
+ init_pose: {
366
+ position: [0, 0, 0],
367
+ orientation: [0, 0, 0, 1],
368
+ },
369
+ id: "box",
370
+ },
371
+ ],
372
+ },
373
+ init_pose: {
374
+ position: [0, 0, 0],
375
+ orientation: [0, 0, 0, 1],
376
+ },
377
+ id: "Cell workzone",
378
+ },
379
+ motion_group_uid: 1,
380
+ },
381
+ {
382
+ id: 2,
383
+ priority: 0,
384
+ geometry: {
385
+ convex_hull: {
386
+ vertices: [
387
+ {
388
+ vertex: [1650, 1330, -1850],
389
+ },
390
+ {
391
+ vertex: [865, 1330, -1850],
392
+ },
393
+ {
394
+ vertex: [865, -720, -1850],
395
+ },
396
+ {
397
+ vertex: [1650, -720, -1850],
398
+ },
399
+ {
400
+ vertex: [1650, 1330, -920],
401
+ },
402
+ {
403
+ vertex: [865, 1330, -920],
404
+ },
405
+ {
406
+ vertex: [865, -720, -920],
407
+ },
408
+ {
409
+ vertex: [1650, -720, -920],
410
+ },
411
+ ],
412
+ },
413
+ init_pose: {
414
+ position: [0, 0, 0],
415
+ orientation: [0, 0, 0, 1],
416
+ },
417
+ id: "Transport",
418
+ },
419
+ motion_group_uid: 1,
420
+ },
421
+ {
422
+ id: 3,
423
+ priority: 0,
424
+ geometry: {
425
+ convex_hull: {
426
+ vertices: [
427
+ {
428
+ vertex: [1650, 1330, -600],
429
+ },
430
+ {
431
+ vertex: [865, 1330, -600],
432
+ },
433
+ {
434
+ vertex: [865, 430, -600],
435
+ },
436
+ {
437
+ vertex: [1650, 430, -600],
438
+ },
439
+ {
440
+ vertex: [1650, 1330, -1250],
441
+ },
442
+ {
443
+ vertex: [865, 1330, -1250],
444
+ },
445
+ {
446
+ vertex: [865, 430, -1250],
447
+ },
448
+ {
449
+ vertex: [1650, 430, -1250],
450
+ },
451
+ ],
452
+ },
453
+ init_pose: {
454
+ position: [0, 0, 0],
455
+ orientation: [0, 0, 0, 1],
456
+ },
457
+ id: "Tunel",
458
+ },
459
+ motion_group_uid: 1,
460
+ },
461
+ {
462
+ id: 4,
463
+ priority: 0,
464
+ geometry: {
465
+ convex_hull: {
466
+ vertices: [
467
+ {
468
+ vertex: [1650, -760, -440],
469
+ },
470
+ {
471
+ vertex: [900, -760, -440],
472
+ },
473
+ {
474
+ vertex: [900, -1330, -440],
475
+ },
476
+ {
477
+ vertex: [1650, -1330, -440],
478
+ },
479
+ {
480
+ vertex: [1650, -760, -1800],
481
+ },
482
+ {
483
+ vertex: [900, -760, -1800],
484
+ },
485
+ {
486
+ vertex: [900, -1330, -1800],
487
+ },
488
+ {
489
+ vertex: [1650, -1330, -1800],
490
+ },
491
+ ],
492
+ },
493
+ init_pose: {
494
+ position: [0, 0, 0],
495
+ orientation: [0, 0, 0, 1],
496
+ },
497
+ id: "Fanuc controller",
498
+ },
499
+ motion_group_uid: 1,
500
+ },
501
+ {
502
+ id: 6,
503
+ priority: 0,
504
+ geometry: {
505
+ convex_hull: {
506
+ vertices: [
507
+ {
508
+ vertex: [-200, -200, -1900],
509
+ },
510
+ {
511
+ vertex: [200, -200, -1900],
512
+ },
513
+ {
514
+ vertex: [200, 200, -1900],
515
+ },
516
+ {
517
+ vertex: [-200, 200, -1900],
518
+ },
519
+ {
520
+ vertex: [-200, -200, -350],
521
+ },
522
+ {
523
+ vertex: [200, -200, -350],
524
+ },
525
+ {
526
+ vertex: [200, 200, -350],
527
+ },
528
+ {
529
+ vertex: [-200, 200, -350],
530
+ },
531
+ ],
532
+ },
533
+ init_pose: {
534
+ position: [0, 0, 0],
535
+ orientation: [0, 0, 0, 1],
536
+ },
537
+ id: "Robot base",
538
+ },
539
+ motion_group_uid: 1,
540
+ },
541
+ ],
542
+ robot_model_geometries: [
543
+ {
544
+ link_index: 1,
545
+ geometry: {
546
+ sphere: {
547
+ radius: 270,
548
+ },
549
+ init_pose: {
550
+ position: [-70, -70, -50],
551
+ orientation: [0, 0, 0, 1],
552
+ },
553
+ id: "link1_sphere",
554
+ },
555
+ },
556
+ {
557
+ link_index: 2,
558
+ geometry: {
559
+ capsule: {
560
+ radius: 160,
561
+ cylinder_height: 800,
562
+ },
563
+ init_pose: {
564
+ position: [-450, 40, 170],
565
+ orientation: [
566
+ 0, -0.7071067811865475, 0, 0.7071067811865476,
567
+ ],
568
+ },
569
+ id: "link2_capsule",
570
+ },
571
+ },
572
+ {
573
+ link_index: 3,
574
+ geometry: {
575
+ sphere: {
576
+ radius: 270,
577
+ },
578
+ init_pose: {
579
+ position: [-110, 10, -100],
580
+ orientation: [0, 0, 0, 1],
581
+ },
582
+ id: "link3_sphere",
583
+ },
584
+ },
585
+ {
586
+ link_index: 4,
587
+ geometry: {
588
+ capsule: {
589
+ radius: 110,
590
+ cylinder_height: 600,
591
+ },
592
+ init_pose: {
593
+ position: [0, 300, 40],
594
+ orientation: [
595
+ -0.7071067811865475, 0, 0, 0.7071067811865476,
596
+ ],
597
+ },
598
+ id: "link4_capsule",
599
+ },
600
+ },
601
+ {
602
+ link_index: 5,
603
+ geometry: {
604
+ sphere: {
605
+ radius: 75,
606
+ },
607
+ init_pose: {
608
+ position: [0, 0, -50],
609
+ orientation: [0, 0, 0, 1],
610
+ },
611
+ id: "link5_sphere",
612
+ },
613
+ },
614
+ ],
615
+ tool_geometries: [],
616
+ } satisfies SafetySetup
617
+ },
618
+ },
619
+ {
620
+ method: "GET",
621
+ path: "/cells/:cellId/coordinate-systems",
622
+ handle() {
623
+ return {
624
+ coordinatesystems: [
625
+ {
626
+ coordinate_system: "",
627
+ name: "world",
628
+ reference_uid: "",
629
+ position: [0, 0, 0],
630
+ rotation: {
631
+ angles: [0, 0, 0],
632
+ type: "ROTATION_VECTOR",
633
+ },
634
+ },
635
+ ],
636
+ } //satisfies CoordinateSystems
637
+ },
638
+ },
639
+ {
640
+ method: "GET",
641
+ path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
642
+ handle() {
643
+ return {
644
+ tcps: [
645
+ {
646
+ id: "Flange",
647
+ readable_name: "Default-Flange",
648
+ position: [0, 0, 0],
649
+ rotation: {
650
+ angles: [0, 0, 0, 0],
651
+ type: "ROTATION_VECTOR",
652
+ },
653
+ },
654
+ {
655
+ id: "complex-tcp-position",
656
+ readable_name: "Complex TCP Position",
657
+ position: [-200, 300, 150],
658
+ rotation: {
659
+ angles: [
660
+ -0.12139440409113832, -0.06356210998212003,
661
+ -0.2023240068185639, 0,
662
+ ],
663
+ type: "ROTATION_VECTOR",
664
+ },
665
+ },
666
+ ],
667
+ }
668
+ },
669
+ },
670
+ ]
671
+
672
+ const method = config.method?.toUpperCase() || "GET"
673
+ const path = "/cells" + config.url?.split("/cells")[1]?.split("?")[0]
674
+
675
+ for (const handler of apiHandlers) {
676
+ const match = pathToRegexp.match(handler.path)(path || "")
677
+ if (method === handler.method && match) {
678
+ const json = handler.handle()
679
+ return {
680
+ status: 200,
681
+ statusText: "Success",
682
+ data: JSON.stringify(json),
683
+ headers: {},
684
+ config,
685
+ request: {
686
+ responseURL: config.url,
687
+ },
688
+ }
689
+ }
690
+ }
691
+
692
+ throw new AxiosError(
693
+ `No mock handler matched this request: ${method} ${path}`,
694
+ "404",
695
+ config,
696
+ )
697
+
698
+ // return {
699
+ // status: 404,
700
+ // statusText: "Not Found",
701
+ // data: "",
702
+ // headers: {},
703
+ // config,
704
+ // request: {
705
+ // responseURL: config.url,
706
+ // },
707
+ // }
708
+ }
709
+
710
+ handleWebsocketConnection(socket: AutoReconnectingWebsocket) {
711
+ this.connections.push(socket)
712
+
713
+ setTimeout(() => {
714
+ socket.dispatchEvent(new Event("open"))
715
+
716
+ console.log("Websocket connection opened from", socket.url)
717
+
718
+ if (socket.url.includes("/state-stream")) {
719
+ socket.dispatchEvent(
720
+ new MessageEvent("message", {
721
+ data: JSON.stringify(defaultMotionState),
722
+ }),
723
+ )
724
+ }
725
+
726
+ if (socket.url.includes("/move-joint")) {
727
+ socket.dispatchEvent(
728
+ new MessageEvent("message", {
729
+ data: JSON.stringify({
730
+ result: {
731
+ motion_group: "0@ur",
732
+ state: {
733
+ controller: "ur",
734
+ operation_mode: "OPERATION_MODE_AUTO",
735
+ safety_state: "SAFETY_STATE_NORMAL",
736
+ timestamp: "2024-09-18T12:48:26.096266444Z",
737
+ velocity_override: 100,
738
+ motion_groups: [
739
+ {
740
+ motion_group: "0@ur",
741
+ controller: "ur",
742
+ joint_position: {
743
+ joints: [
744
+ 1.3492152690887451, -1.5659207105636597,
745
+ 1.6653711795806885, -1.0991662740707397,
746
+ -1.829018235206604, 1.264623761177063,
747
+ ],
748
+ },
749
+ joint_velocity: {
750
+ joints: [0, 0, 0, 0, 0, 0],
751
+ },
752
+ flange_pose: {
753
+ position: [
754
+ 6.437331889439328, -628.4123774830913,
755
+ 577.0569957147832,
756
+ ],
757
+ orientation: {
758
+ x: -1.683333649797158,
759
+ y: -1.9783363827298732,
760
+ z: -0.4928031860165713,
761
+ },
762
+ coordinate_system: "",
763
+ },
764
+ tcp_pose: {
765
+ position: [
766
+ 6.437331889439328, -628.4123774830913,
767
+ 577.0569957147832,
768
+ ],
769
+ orientation: {
770
+ x: -1.683333649797158,
771
+ y: -1.9783363827298732,
772
+ z: -0.4928031860165713,
773
+ },
774
+ coordinate_system: "",
775
+ tcp: "Flange",
776
+ },
777
+ velocity: {
778
+ linear: {
779
+ x: 0,
780
+ y: 0,
781
+ z: 0,
782
+ },
783
+ angular: {
784
+ x: -0,
785
+ y: 0,
786
+ z: 0,
787
+ },
788
+ coordinate_system: "",
789
+ },
790
+ force: {
791
+ force: {
792
+ x: 0,
793
+ y: 0,
794
+ z: 0,
795
+ },
796
+ moment: {
797
+ x: 0,
798
+ y: 0,
799
+ z: 0,
800
+ },
801
+ coordinate_system: "",
802
+ },
803
+ joint_limit_reached: {
804
+ limit_reached: [
805
+ false,
806
+ false,
807
+ false,
808
+ false,
809
+ false,
810
+ false,
811
+ ],
812
+ },
813
+ joint_current: {
814
+ joints: [0, 0, 0, 0, 0, 0],
815
+ },
816
+ sequence_number: "671259",
817
+ },
818
+ ],
819
+ sequence_number: "671259",
820
+ },
821
+ movement_state: "MOVEMENT_STATE_MOVING",
822
+ },
823
+ }),
824
+ }),
825
+ )
826
+ }
827
+
828
+ if (socket.url.includes("/move-tcp")) {
829
+ socket.dispatchEvent(
830
+ new MessageEvent("message", {
831
+ data: JSON.stringify({
832
+ result: {
833
+ motion_group: "0@ur",
834
+ state: {
835
+ controller: "ur",
836
+ operation_mode: "OPERATION_MODE_AUTO",
837
+ safety_state: "SAFETY_STATE_NORMAL",
838
+ timestamp: "2024-09-18T12:43:12.188335774Z",
839
+ velocity_override: 100,
840
+ motion_groups: [
841
+ {
842
+ motion_group: "0@ur",
843
+ controller: "ur",
844
+ joint_position: {
845
+ joints: [
846
+ 1.3352527618408203, -1.5659207105636597,
847
+ 1.6653711795806885, -1.110615611076355,
848
+ -1.829018235206604, 1.264623761177063,
849
+ ],
850
+ },
851
+ joint_velocity: {
852
+ joints: [0, 0, 0, 0, 0, 0],
853
+ },
854
+ flange_pose: {
855
+ position: [
856
+ -2.763015284002938, -630.2151479701106,
857
+ 577.524509114342,
858
+ ],
859
+ orientation: {
860
+ x: -1.704794877102097,
861
+ y: -1.9722372952861567,
862
+ z: -0.4852079204210754,
863
+ },
864
+ coordinate_system: "",
865
+ },
866
+ tcp_pose: {
867
+ position: [
868
+ -2.763015284002938, -630.2151479701106,
869
+ 577.524509114342,
870
+ ],
871
+ orientation: {
872
+ x: -1.704794877102097,
873
+ y: -1.9722372952861567,
874
+ z: -0.4852079204210754,
875
+ },
876
+ coordinate_system: "",
877
+ tcp: "Flange",
878
+ },
879
+ velocity: {
880
+ linear: {
881
+ x: 0,
882
+ y: 0,
883
+ z: 0,
884
+ },
885
+ angular: {
886
+ x: -0,
887
+ y: 0,
888
+ z: 0,
889
+ },
890
+ coordinate_system: "",
891
+ },
892
+ force: {
893
+ force: {
894
+ x: 0,
895
+ y: 0,
896
+ z: 0,
897
+ },
898
+ moment: {
899
+ x: 0,
900
+ y: 0,
901
+ z: 0,
902
+ },
903
+ coordinate_system: "",
904
+ },
905
+ joint_limit_reached: {
906
+ limit_reached: [
907
+ false,
908
+ false,
909
+ false,
910
+ false,
911
+ false,
912
+ false,
913
+ ],
914
+ },
915
+ joint_current: {
916
+ joints: [0, 0, 0, 0, 0, 0],
917
+ },
918
+ sequence_number: "627897",
919
+ },
920
+ ],
921
+ sequence_number: "627897",
922
+ },
923
+ movement_state: "MOVEMENT_STATE_MOVING",
924
+ },
925
+ }),
926
+ }),
927
+ )
928
+ }
929
+ }, 10)
930
+ }
931
+
932
+ handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string) {
933
+ console.log(`Received message on ${socket.url}`, message)
934
+ }
935
+ }
936
+
937
+ const defaultMotionState = {
938
+ result: {
939
+ motion_group: "0@universalrobots-ur5e",
940
+ controller: "universalrobots-ur5e",
941
+ joint_position: {
942
+ joints: [
943
+ 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,
944
+ 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,
945
+ ],
946
+ },
947
+ joint_velocity: {
948
+ joints: [0, 0, 0, 0, 0, 0],
949
+ },
950
+ flange_pose: {
951
+ position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],
952
+ orientation: [
953
+ 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,
954
+ ],
955
+ coordinate_system: "",
956
+ },
957
+ tcp_pose: {
958
+ position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],
959
+ orientation: [
960
+ 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,
961
+ ],
962
+ coordinate_system: "",
963
+ tcp: "Flange",
964
+ },
965
+ velocity: {
966
+ linear: [0, 0, 0],
967
+ angular: [0, 0, 0],
968
+ coordinate_system: "",
969
+ },
970
+ force: {
971
+ force: [0, 0, 0],
972
+ moment: [0, 0, 0],
973
+ coordinate_system: "",
974
+ },
975
+ joint_limit_reached: {
976
+ limit_reached: [false, false, false, false, false, false],
977
+ },
978
+ joint_current: {
979
+ joints: [0, 0, 0, 0, 0, 0],
980
+ },
981
+ } satisfies MotionGroupState,
982
+ }