@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,1302 @@
1
+ import type {
2
+ ControllerInstanceList,
3
+ MotionGroupSpecification,
4
+ MotionGroupStateResponse,
5
+ RobotController,
6
+ SafetySetup,
7
+ } from "@wandelbots/nova-api/v1"
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
+ instances: [
30
+ {
31
+ controller: "mock-ur5e",
32
+ model_name: "UniversalRobots::Controller",
33
+ host: "mock-ur5e",
34
+ allow_software_install_on_controller: true,
35
+ physical_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 ControllerInstanceList
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
+ {
245
+ x: -800,
246
+ y: -1330,
247
+ z: -1820,
248
+ },
249
+ {
250
+ x: 1650,
251
+ y: -1330,
252
+ z: -1820,
253
+ },
254
+ {
255
+ x: 1650,
256
+ y: 1330,
257
+ z: -1820,
258
+ },
259
+ {
260
+ x: -800,
261
+ y: 1330,
262
+ z: -1820,
263
+ },
264
+ ],
265
+ },
266
+ init_pose: {
267
+ position: {
268
+ x: 0,
269
+ y: 0,
270
+ z: 0,
271
+ },
272
+ orientation: {
273
+ x: 0,
274
+ y: 0,
275
+ z: 0,
276
+ w: 1,
277
+ },
278
+ },
279
+ id: "box",
280
+ },
281
+ {
282
+ convex_hull: {
283
+ vertices: [
284
+ {
285
+ x: -800,
286
+ y: -1330,
287
+ z: -1820,
288
+ },
289
+ {
290
+ x: 1650,
291
+ y: -1330,
292
+ z: -1820,
293
+ },
294
+ {
295
+ x: 1650,
296
+ y: -1330,
297
+ z: 1500,
298
+ },
299
+ {
300
+ x: -800,
301
+ y: -1330,
302
+ z: 1500,
303
+ },
304
+ ],
305
+ },
306
+ init_pose: {
307
+ position: {
308
+ x: 0,
309
+ y: 0,
310
+ z: 0,
311
+ },
312
+ orientation: {
313
+ x: 0,
314
+ y: 0,
315
+ z: 0,
316
+ w: 1,
317
+ },
318
+ },
319
+ id: "box",
320
+ },
321
+ {
322
+ convex_hull: {
323
+ vertices: [
324
+ {
325
+ x: -800,
326
+ y: -1330,
327
+ z: -1820,
328
+ },
329
+ {
330
+ x: -800,
331
+ y: 1330,
332
+ z: -1820,
333
+ },
334
+ {
335
+ x: -800,
336
+ y: 1330,
337
+ z: 1500,
338
+ },
339
+ {
340
+ x: -800,
341
+ y: -1330,
342
+ z: 1500,
343
+ },
344
+ ],
345
+ },
346
+ init_pose: {
347
+ position: {
348
+ x: 0,
349
+ y: 0,
350
+ z: 0,
351
+ },
352
+ orientation: {
353
+ x: 0,
354
+ y: 0,
355
+ z: 0,
356
+ w: 1,
357
+ },
358
+ },
359
+ id: "box",
360
+ },
361
+ {
362
+ convex_hull: {
363
+ vertices: [
364
+ {
365
+ x: 1650,
366
+ y: 1330,
367
+ z: 1500,
368
+ },
369
+ {
370
+ x: -800,
371
+ y: 1330,
372
+ z: 1500,
373
+ },
374
+ {
375
+ x: -800,
376
+ y: -1330,
377
+ z: 1500,
378
+ },
379
+ {
380
+ x: 1650,
381
+ y: -1330,
382
+ z: 1500,
383
+ },
384
+ ],
385
+ },
386
+ init_pose: {
387
+ position: {
388
+ x: 0,
389
+ y: 0,
390
+ z: 0,
391
+ },
392
+ orientation: {
393
+ x: 0,
394
+ y: 0,
395
+ z: 0,
396
+ w: 1,
397
+ },
398
+ },
399
+ id: "box",
400
+ },
401
+ {
402
+ convex_hull: {
403
+ vertices: [
404
+ {
405
+ x: 1650,
406
+ y: 1330,
407
+ z: 1500,
408
+ },
409
+ {
410
+ x: -800,
411
+ y: 1330,
412
+ z: 1500,
413
+ },
414
+ {
415
+ x: -800,
416
+ y: 1330,
417
+ z: -1820,
418
+ },
419
+ {
420
+ x: 1650,
421
+ y: 1330,
422
+ z: -1820,
423
+ },
424
+ ],
425
+ },
426
+ init_pose: {
427
+ position: {
428
+ x: 0,
429
+ y: 0,
430
+ z: 0,
431
+ },
432
+ orientation: {
433
+ x: 0,
434
+ y: 0,
435
+ z: 0,
436
+ w: 1,
437
+ },
438
+ },
439
+ id: "box",
440
+ },
441
+ {
442
+ convex_hull: {
443
+ vertices: [
444
+ {
445
+ x: 1650,
446
+ y: 1330,
447
+ z: 1500,
448
+ },
449
+ {
450
+ x: 1650,
451
+ y: -1330,
452
+ z: 1500,
453
+ },
454
+ {
455
+ x: 1650,
456
+ y: -1330,
457
+ z: -1820,
458
+ },
459
+ {
460
+ x: 1650,
461
+ y: 1330,
462
+ z: -1820,
463
+ },
464
+ ],
465
+ },
466
+ init_pose: {
467
+ position: {
468
+ x: 0,
469
+ y: 0,
470
+ z: 0,
471
+ },
472
+ orientation: {
473
+ x: 0,
474
+ y: 0,
475
+ z: 0,
476
+ w: 1,
477
+ },
478
+ },
479
+ id: "box",
480
+ },
481
+ ],
482
+ },
483
+ init_pose: {
484
+ position: {
485
+ x: 0,
486
+ y: 0,
487
+ z: 0,
488
+ },
489
+ orientation: {
490
+ x: 0,
491
+ y: 0,
492
+ z: 0,
493
+ w: 1,
494
+ },
495
+ },
496
+ id: "Cell workzone",
497
+ },
498
+ motion_group_uid: 1,
499
+ },
500
+ {
501
+ id: 2,
502
+ priority: 0,
503
+ geometry: {
504
+ convex_hull: {
505
+ vertices: [
506
+ {
507
+ x: 1650,
508
+ y: 1330,
509
+ z: -1850,
510
+ },
511
+ {
512
+ x: 865,
513
+ y: 1330,
514
+ z: -1850,
515
+ },
516
+ {
517
+ x: 865,
518
+ y: -720,
519
+ z: -1850,
520
+ },
521
+ {
522
+ x: 1650,
523
+ y: -720,
524
+ z: -1850,
525
+ },
526
+ {
527
+ x: 1650,
528
+ y: 1330,
529
+ z: -920,
530
+ },
531
+ {
532
+ x: 865,
533
+ y: 1330,
534
+ z: -920,
535
+ },
536
+ {
537
+ x: 865,
538
+ y: -720,
539
+ z: -920,
540
+ },
541
+ {
542
+ x: 1650,
543
+ y: -720,
544
+ z: -920,
545
+ },
546
+ ],
547
+ },
548
+ init_pose: {
549
+ position: {
550
+ x: 0,
551
+ y: 0,
552
+ z: 0,
553
+ },
554
+ orientation: {
555
+ x: 0,
556
+ y: 0,
557
+ z: 0,
558
+ w: 1,
559
+ },
560
+ },
561
+ id: "Transport",
562
+ },
563
+ motion_group_uid: 1,
564
+ },
565
+ {
566
+ id: 3,
567
+ priority: 0,
568
+ geometry: {
569
+ convex_hull: {
570
+ vertices: [
571
+ {
572
+ x: 1650,
573
+ y: 1330,
574
+ z: -600,
575
+ },
576
+ {
577
+ x: 865,
578
+ y: 1330,
579
+ z: -600,
580
+ },
581
+ {
582
+ x: 865,
583
+ y: 430,
584
+ z: -600,
585
+ },
586
+ {
587
+ x: 1650,
588
+ y: 430,
589
+ z: -600,
590
+ },
591
+ {
592
+ x: 1650,
593
+ y: 1330,
594
+ z: -1250,
595
+ },
596
+ {
597
+ x: 865,
598
+ y: 1330,
599
+ z: -1250,
600
+ },
601
+ {
602
+ x: 865,
603
+ y: 430,
604
+ z: -1250,
605
+ },
606
+ {
607
+ x: 1650,
608
+ y: 430,
609
+ z: -1250,
610
+ },
611
+ ],
612
+ },
613
+ init_pose: {
614
+ position: {
615
+ x: 0,
616
+ y: 0,
617
+ z: 0,
618
+ },
619
+ orientation: {
620
+ x: 0,
621
+ y: 0,
622
+ z: 0,
623
+ w: 1,
624
+ },
625
+ },
626
+ id: "Tunel",
627
+ },
628
+ motion_group_uid: 1,
629
+ },
630
+ {
631
+ id: 4,
632
+ priority: 0,
633
+ geometry: {
634
+ convex_hull: {
635
+ vertices: [
636
+ {
637
+ x: 1650,
638
+ y: -760,
639
+ z: -440,
640
+ },
641
+ {
642
+ x: 900,
643
+ y: -760,
644
+ z: -440,
645
+ },
646
+ {
647
+ x: 900,
648
+ y: -1330,
649
+ z: -440,
650
+ },
651
+ {
652
+ x: 1650,
653
+ y: -1330,
654
+ z: -440,
655
+ },
656
+ {
657
+ x: 1650,
658
+ y: -760,
659
+ z: -1800,
660
+ },
661
+ {
662
+ x: 900,
663
+ y: -760,
664
+ z: -1800,
665
+ },
666
+ {
667
+ x: 900,
668
+ y: -1330,
669
+ z: -1800,
670
+ },
671
+ {
672
+ x: 1650,
673
+ y: -1330,
674
+ z: -1800,
675
+ },
676
+ ],
677
+ },
678
+ init_pose: {
679
+ position: {
680
+ x: 0,
681
+ y: 0,
682
+ z: 0,
683
+ },
684
+ orientation: {
685
+ x: 0,
686
+ y: 0,
687
+ z: 0,
688
+ w: 1,
689
+ },
690
+ },
691
+ id: "Fanuc controller",
692
+ },
693
+ motion_group_uid: 1,
694
+ },
695
+ {
696
+ id: 6,
697
+ priority: 0,
698
+ geometry: {
699
+ convex_hull: {
700
+ vertices: [
701
+ {
702
+ x: -200,
703
+ y: -200,
704
+ z: -1900,
705
+ },
706
+ {
707
+ x: 200,
708
+ y: -200,
709
+ z: -1900,
710
+ },
711
+ {
712
+ x: 200,
713
+ y: 200,
714
+ z: -1900,
715
+ },
716
+ {
717
+ x: -200,
718
+ y: 200,
719
+ z: -1900,
720
+ },
721
+ {
722
+ x: -200,
723
+ y: -200,
724
+ z: -350,
725
+ },
726
+ {
727
+ x: 200,
728
+ y: -200,
729
+ z: -350,
730
+ },
731
+ {
732
+ x: 200,
733
+ y: 200,
734
+ z: -350,
735
+ },
736
+ {
737
+ x: -200,
738
+ y: 200,
739
+ z: -350,
740
+ },
741
+ ],
742
+ },
743
+ init_pose: {
744
+ position: {
745
+ x: 0,
746
+ y: 0,
747
+ z: 0,
748
+ },
749
+ orientation: {
750
+ x: 0,
751
+ y: 0,
752
+ z: 0,
753
+ w: 1,
754
+ },
755
+ },
756
+ id: "Robot base",
757
+ },
758
+ motion_group_uid: 1,
759
+ },
760
+ ],
761
+ robot_model_geometries: [
762
+ {
763
+ link_index: 1,
764
+ geometry: {
765
+ sphere: {
766
+ radius: 270,
767
+ },
768
+ init_pose: {
769
+ position: {
770
+ x: -70,
771
+ y: -70,
772
+ z: -50,
773
+ },
774
+ orientation: {
775
+ x: 0,
776
+ y: 0,
777
+ z: 0,
778
+ w: 1,
779
+ },
780
+ },
781
+ id: "link1_sphere",
782
+ },
783
+ },
784
+ {
785
+ link_index: 2,
786
+ geometry: {
787
+ capsule: {
788
+ radius: 160,
789
+ cylinder_height: 800,
790
+ },
791
+ init_pose: {
792
+ position: {
793
+ x: -450,
794
+ y: 40,
795
+ z: 170,
796
+ },
797
+ orientation: {
798
+ x: 0,
799
+ y: -0.7071067811865475,
800
+ z: 0,
801
+ w: 0.7071067811865476,
802
+ },
803
+ },
804
+ id: "link2_capsule",
805
+ },
806
+ },
807
+ {
808
+ link_index: 3,
809
+ geometry: {
810
+ sphere: {
811
+ radius: 270,
812
+ },
813
+ init_pose: {
814
+ position: {
815
+ x: -110,
816
+ y: 10,
817
+ z: -100,
818
+ },
819
+ orientation: {
820
+ x: 0,
821
+ y: 0,
822
+ z: 0,
823
+ w: 1,
824
+ },
825
+ },
826
+ id: "link3_sphere",
827
+ },
828
+ },
829
+ {
830
+ link_index: 4,
831
+ geometry: {
832
+ capsule: {
833
+ radius: 110,
834
+ cylinder_height: 600,
835
+ },
836
+ init_pose: {
837
+ position: {
838
+ x: 0,
839
+ y: 300,
840
+ z: 40,
841
+ },
842
+ orientation: {
843
+ x: -0.7071067811865475,
844
+ y: 0,
845
+ z: 0,
846
+ w: 0.7071067811865476,
847
+ },
848
+ },
849
+ id: "link4_capsule",
850
+ },
851
+ },
852
+ {
853
+ link_index: 5,
854
+ geometry: {
855
+ sphere: {
856
+ radius: 75,
857
+ },
858
+ init_pose: {
859
+ position: {
860
+ x: 0,
861
+ y: 0,
862
+ z: -50,
863
+ },
864
+ orientation: {
865
+ x: 0,
866
+ y: 0,
867
+ z: 0,
868
+ w: 1,
869
+ },
870
+ },
871
+ id: "link5_sphere",
872
+ },
873
+ },
874
+ ],
875
+ tool_geometries: [],
876
+ } satisfies SafetySetup
877
+ },
878
+ },
879
+ {
880
+ method: "GET",
881
+ path: "/cells/:cellId/coordinate-systems",
882
+ handle() {
883
+ return {
884
+ coordinatesystems: [
885
+ {
886
+ coordinate_system: "",
887
+ name: "world",
888
+ reference_uid: "",
889
+ position: {
890
+ x: 0,
891
+ y: 0,
892
+ z: 0,
893
+ },
894
+ rotation: {
895
+ angles: [0, 0, 0],
896
+ type: "ROTATION_VECTOR",
897
+ },
898
+ },
899
+ ],
900
+ } //satisfies CoordinateSystems
901
+ },
902
+ },
903
+ {
904
+ method: "GET",
905
+ path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
906
+ handle() {
907
+ return {
908
+ tcps: [
909
+ {
910
+ id: "Flange",
911
+ readable_name: "Default-Flange",
912
+ position: {
913
+ x: 0,
914
+ y: 0,
915
+ z: 0,
916
+ },
917
+ rotation: {
918
+ angles: [0, 0, 0, 0],
919
+ type: "ROTATION_VECTOR",
920
+ },
921
+ },
922
+ {
923
+ id: "complex-tcp-position",
924
+ readable_name: "Complex TCP Position",
925
+ position: {
926
+ x: -200,
927
+ y: 300,
928
+ z: 150,
929
+ },
930
+ rotation: {
931
+ angles: [
932
+ -0.12139440409113832, -0.06356210998212003,
933
+ -0.2023240068185639, 0,
934
+ ],
935
+ type: "ROTATION_VECTOR",
936
+ },
937
+ },
938
+ ],
939
+ }
940
+ },
941
+ },
942
+ ]
943
+
944
+ const method = config.method?.toUpperCase() || "GET"
945
+ const path = "/cells" + config.url?.split("/cells")[1]?.split("?")[0]
946
+
947
+ for (const handler of apiHandlers) {
948
+ const match = pathToRegexp.match(handler.path)(path || "")
949
+ if (method === handler.method && match) {
950
+ const json = handler.handle()
951
+ return {
952
+ status: 200,
953
+ statusText: "Success",
954
+ data: JSON.stringify(json),
955
+ headers: {},
956
+ config,
957
+ request: {
958
+ responseURL: config.url,
959
+ },
960
+ }
961
+ }
962
+ }
963
+
964
+ throw new AxiosError(
965
+ `No mock handler matched this request: ${method} ${path}`,
966
+ "404",
967
+ config,
968
+ )
969
+
970
+ // return {
971
+ // status: 404,
972
+ // statusText: "Not Found",
973
+ // data: "",
974
+ // headers: {},
975
+ // config,
976
+ // request: {
977
+ // responseURL: config.url,
978
+ // },
979
+ // }
980
+ }
981
+
982
+ handleWebsocketConnection(socket: AutoReconnectingWebsocket) {
983
+ this.connections.push(socket)
984
+
985
+ setTimeout(() => {
986
+ socket.dispatchEvent(new Event("open"))
987
+
988
+ console.log("Websocket connection opened from", socket.url)
989
+
990
+ if (socket.url.includes("/state-stream")) {
991
+ socket.dispatchEvent(
992
+ new MessageEvent("message", {
993
+ data: JSON.stringify(defaultMotionState),
994
+ }),
995
+ )
996
+ }
997
+
998
+ if (socket.url.includes("/move-joint")) {
999
+ socket.dispatchEvent(
1000
+ new MessageEvent("message", {
1001
+ data: JSON.stringify({
1002
+ result: {
1003
+ motion_group: "0@ur",
1004
+ state: {
1005
+ controller: "ur",
1006
+ operation_mode: "OPERATION_MODE_AUTO",
1007
+ safety_state: "SAFETY_STATE_NORMAL",
1008
+ timestamp: "2024-09-18T12:48:26.096266444Z",
1009
+ velocity_override: 100,
1010
+ motion_groups: [
1011
+ {
1012
+ motion_group: "0@ur",
1013
+ controller: "ur",
1014
+ joint_position: {
1015
+ joints: [
1016
+ 1.3492152690887451, -1.5659207105636597,
1017
+ 1.6653711795806885, -1.0991662740707397,
1018
+ -1.829018235206604, 1.264623761177063,
1019
+ ],
1020
+ },
1021
+ joint_velocity: {
1022
+ joints: [0, 0, 0, 0, 0, 0],
1023
+ },
1024
+ flange_pose: {
1025
+ position: {
1026
+ x: 6.437331889439328,
1027
+ y: -628.4123774830913,
1028
+ z: 577.0569957147832,
1029
+ },
1030
+ orientation: {
1031
+ x: -1.683333649797158,
1032
+ y: -1.9783363827298732,
1033
+ z: -0.4928031860165713,
1034
+ },
1035
+ coordinate_system: "",
1036
+ },
1037
+ tcp_pose: {
1038
+ position: {
1039
+ x: 6.437331889439328,
1040
+ y: -628.4123774830913,
1041
+ z: 577.0569957147832,
1042
+ },
1043
+ orientation: {
1044
+ x: -1.683333649797158,
1045
+ y: -1.9783363827298732,
1046
+ z: -0.4928031860165713,
1047
+ },
1048
+ coordinate_system: "",
1049
+ tcp: "Flange",
1050
+ },
1051
+ velocity: {
1052
+ linear: {
1053
+ x: 0,
1054
+ y: 0,
1055
+ z: 0,
1056
+ },
1057
+ angular: {
1058
+ x: -0,
1059
+ y: 0,
1060
+ z: 0,
1061
+ },
1062
+ coordinate_system: "",
1063
+ },
1064
+ force: {
1065
+ force: {
1066
+ x: 0,
1067
+ y: 0,
1068
+ z: 0,
1069
+ },
1070
+ moment: {
1071
+ x: 0,
1072
+ y: 0,
1073
+ z: 0,
1074
+ },
1075
+ coordinate_system: "",
1076
+ },
1077
+ joint_limit_reached: {
1078
+ limit_reached: [
1079
+ false,
1080
+ false,
1081
+ false,
1082
+ false,
1083
+ false,
1084
+ false,
1085
+ ],
1086
+ },
1087
+ joint_current: {
1088
+ joints: [0, 0, 0, 0, 0, 0],
1089
+ },
1090
+ sequence_number: "671259",
1091
+ },
1092
+ ],
1093
+ sequence_number: "671259",
1094
+ },
1095
+ movement_state: "MOVEMENT_STATE_MOVING",
1096
+ },
1097
+ }),
1098
+ }),
1099
+ )
1100
+ }
1101
+
1102
+ if (socket.url.includes("/move-tcp")) {
1103
+ socket.dispatchEvent(
1104
+ new MessageEvent("message", {
1105
+ data: JSON.stringify({
1106
+ result: {
1107
+ motion_group: "0@ur",
1108
+ state: {
1109
+ controller: "ur",
1110
+ operation_mode: "OPERATION_MODE_AUTO",
1111
+ safety_state: "SAFETY_STATE_NORMAL",
1112
+ timestamp: "2024-09-18T12:43:12.188335774Z",
1113
+ velocity_override: 100,
1114
+ motion_groups: [
1115
+ {
1116
+ motion_group: "0@ur",
1117
+ controller: "ur",
1118
+ joint_position: {
1119
+ joints: [
1120
+ 1.3352527618408203, -1.5659207105636597,
1121
+ 1.6653711795806885, -1.110615611076355,
1122
+ -1.829018235206604, 1.264623761177063,
1123
+ ],
1124
+ },
1125
+ joint_velocity: {
1126
+ joints: [0, 0, 0, 0, 0, 0],
1127
+ },
1128
+ flange_pose: {
1129
+ position: {
1130
+ x: -2.763015284002938,
1131
+ y: -630.2151479701106,
1132
+ z: 577.524509114342,
1133
+ },
1134
+ orientation: {
1135
+ x: -1.704794877102097,
1136
+ y: -1.9722372952861567,
1137
+ z: -0.4852079204210754,
1138
+ },
1139
+ coordinate_system: "",
1140
+ },
1141
+ tcp_pose: {
1142
+ position: {
1143
+ x: -2.763015284002938,
1144
+ y: -630.2151479701106,
1145
+ z: 577.524509114342,
1146
+ },
1147
+ orientation: {
1148
+ x: -1.704794877102097,
1149
+ y: -1.9722372952861567,
1150
+ z: -0.4852079204210754,
1151
+ },
1152
+ coordinate_system: "",
1153
+ tcp: "Flange",
1154
+ },
1155
+ velocity: {
1156
+ linear: {
1157
+ x: 0,
1158
+ y: 0,
1159
+ z: 0,
1160
+ },
1161
+ angular: {
1162
+ x: -0,
1163
+ y: 0,
1164
+ z: 0,
1165
+ },
1166
+ coordinate_system: "",
1167
+ },
1168
+ force: {
1169
+ force: {
1170
+ x: 0,
1171
+ y: 0,
1172
+ z: 0,
1173
+ },
1174
+ moment: {
1175
+ x: 0,
1176
+ y: 0,
1177
+ z: 0,
1178
+ },
1179
+ coordinate_system: "",
1180
+ },
1181
+ joint_limit_reached: {
1182
+ limit_reached: [
1183
+ false,
1184
+ false,
1185
+ false,
1186
+ false,
1187
+ false,
1188
+ false,
1189
+ ],
1190
+ },
1191
+ joint_current: {
1192
+ joints: [0, 0, 0, 0, 0, 0],
1193
+ },
1194
+ sequence_number: "627897",
1195
+ },
1196
+ ],
1197
+ sequence_number: "627897",
1198
+ },
1199
+ movement_state: "MOVEMENT_STATE_MOVING",
1200
+ },
1201
+ }),
1202
+ }),
1203
+ )
1204
+ }
1205
+ }, 10)
1206
+ }
1207
+
1208
+ handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string) {
1209
+ console.log(`Received message on ${socket.url}`, message)
1210
+ }
1211
+ }
1212
+
1213
+ const defaultMotionState = {
1214
+ result: {
1215
+ state: {
1216
+ motion_group: "0@universalrobots-ur5e",
1217
+ controller: "universalrobots-ur5e",
1218
+ joint_position: {
1219
+ joints: [
1220
+ 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,
1221
+ 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,
1222
+ ],
1223
+ },
1224
+ joint_velocity: {
1225
+ joints: [0, 0, 0, 0, 0, 0],
1226
+ },
1227
+ flange_pose: {
1228
+ position: {
1229
+ x: 1.3300010259703043,
1230
+ y: -409.2680714682808,
1231
+ z: 531.0203477065281,
1232
+ },
1233
+ orientation: {
1234
+ x: 1.7564919306270736,
1235
+ y: -1.7542521568325058,
1236
+ z: 0.7326972590614671,
1237
+ },
1238
+ coordinate_system: "",
1239
+ },
1240
+ tcp_pose: {
1241
+ position: {
1242
+ x: 1.3300010259703043,
1243
+ y: -409.2680714682808,
1244
+ z: 531.0203477065281,
1245
+ },
1246
+ orientation: {
1247
+ x: 1.7564919306270736,
1248
+ y: -1.7542521568325058,
1249
+ z: 0.7326972590614671,
1250
+ },
1251
+ coordinate_system: "",
1252
+ tcp: "Flange",
1253
+ },
1254
+ velocity: {
1255
+ linear: {
1256
+ x: 0,
1257
+ y: 0,
1258
+ z: 0,
1259
+ },
1260
+ angular: {
1261
+ x: 0,
1262
+ y: 0,
1263
+ z: 0,
1264
+ },
1265
+ coordinate_system: "",
1266
+ },
1267
+ force: {
1268
+ force: {
1269
+ x: 0,
1270
+ y: 0,
1271
+ z: 0,
1272
+ },
1273
+ moment: {
1274
+ x: 0,
1275
+ y: 0,
1276
+ z: 0,
1277
+ },
1278
+ coordinate_system: "",
1279
+ },
1280
+ joint_limit_reached: {
1281
+ limit_reached: [false, false, false, false, false, false],
1282
+ },
1283
+ joint_current: {
1284
+ joints: [0, 0, 0, 0, 0, 0],
1285
+ },
1286
+ },
1287
+ tcp_pose: {
1288
+ position: {
1289
+ x: 302.90748476115556,
1290
+ y: -152.87065869452337,
1291
+ z: 424.0454619321661,
1292
+ },
1293
+ orientation: {
1294
+ x: 2.3403056115045353,
1295
+ y: -1.1706836379431356,
1296
+ z: 0.9772511964246311,
1297
+ },
1298
+ coordinate_system: "",
1299
+ tcp: "Flange",
1300
+ },
1301
+ } satisfies MotionGroupStateResponse,
1302
+ }