@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
@@ -5,7 +5,6 @@ import * as pathToRegexp from "path-to-regexp"
5
5
  import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
6
6
 
7
7
  /**
8
- * EXPERIMENTAL
9
8
  * Ultra-simplified mock Nova server for testing stuff
10
9
  */
11
10
  export class MockNovaInstance {
@@ -15,6 +14,417 @@ export class MockNovaInstance {
15
14
  config: InternalAxiosRequestConfig,
16
15
  ): Promise<AxiosResponse> {
17
16
  const apiHandlers = [
17
+ {
18
+ method: "GET",
19
+ path: "/cells/:cellId/controllers/:controllerId/state",
20
+ handle() {
21
+ return {
22
+ mode: "MODE_CONTROL",
23
+ last_error: [],
24
+ timestamp: "2025-10-16T09:19:26.634534092Z",
25
+ sequence_number: 1054764,
26
+ controller: "mock-ur5e",
27
+ operation_mode: "OPERATION_MODE_AUTO",
28
+ safety_state: "SAFETY_STATE_NORMAL",
29
+ velocity_override: 100,
30
+ motion_groups: [
31
+ {
32
+ timestamp: "2025-10-16T09:19:26.634534092Z",
33
+ sequence_number: 1054764,
34
+ motion_group: "0@mock-ur5e",
35
+ controller: "mock-ur5e",
36
+ joint_position: [
37
+ 1.487959623336792, -1.8501918315887451, 1.8003005981445312,
38
+ 6.034560203552246, 1.4921919107437134, 1.593459963798523,
39
+ ],
40
+ joint_limit_reached: {
41
+ limit_reached: [false, false, false, false, false, false],
42
+ },
43
+ joint_torque: [],
44
+ joint_current: [0, 0, 0, 0, 0, 0],
45
+ flange_pose: {
46
+ position: [
47
+ 107.6452433732927, -409.0402987746852, 524.2402132330305,
48
+ ],
49
+ orientation: [
50
+ 0.9874434028353319, -0.986571714997442, 1.3336589451098142,
51
+ ],
52
+ },
53
+ tcp: "Flange",
54
+ tcp_pose: {
55
+ position: [
56
+ 107.6452433732927, -409.0402987746852, 524.2402132330305,
57
+ ],
58
+ orientation: [
59
+ 0.9874434028353319, -0.986571714997442, 1.3336589451098142,
60
+ ],
61
+ },
62
+ payload: "",
63
+ coordinate_system: "",
64
+ standstill: true,
65
+ },
66
+ ],
67
+ }
68
+ },
69
+ },
70
+ {
71
+ method: "GET",
72
+ path: "/cells/:cellId/controllers/:controllerId/coordinate-systems",
73
+ handle() {
74
+ return [
75
+ {
76
+ coordinate_system: "",
77
+ name: "world",
78
+ reference_coordinate_system: "",
79
+ position: [0, 0, 0],
80
+ orientation: [0, 0, 0],
81
+ orientation_type: "ROTATION_VECTOR",
82
+ },
83
+ {
84
+ coordinate_system: "CS-0",
85
+ name: "Default-CS",
86
+ reference_coordinate_system: "",
87
+ position: [0, 0, 0],
88
+ orientation: [0, 0, 0],
89
+ orientation_type: "ROTATION_VECTOR",
90
+ },
91
+ ] //satisfies CoordinateSystems
92
+ },
93
+ },
94
+
95
+ // As you need, add more mock requests here...
96
+ // Below is mostly V1:
97
+ {
98
+ method: "GET",
99
+ path: "/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description",
100
+ handle() {
101
+ return {
102
+ motion_group_model: "UniversalRobots_UR5e",
103
+ mounting: {
104
+ position: [0, 0, 0],
105
+ orientation: [0, 0, 0],
106
+ },
107
+ tcps: {
108
+ Flange: {
109
+ name: "Default-Flange",
110
+ pose: {
111
+ position: [0, 0, 0],
112
+ orientation: [0, 0, 0],
113
+ },
114
+ },
115
+ "complex-tcp-position": {
116
+ name: "Complex TCP Position",
117
+ pose: {
118
+ position: [-200, 300, 150],
119
+ orientation: [
120
+ -0.12139440409113832, -0.06356210998212003,
121
+ -0.2023240068185639,
122
+ ],
123
+ },
124
+ },
125
+ "offset-150mm-xy": {
126
+ name: "-150mm XY Offset",
127
+ pose: {
128
+ position: [-150, -150, 0],
129
+ orientation: [0, 0, 0],
130
+ },
131
+ },
132
+ "rotated-90deg-z": {
133
+ name: "90° Z Axis Rotation",
134
+ pose: {
135
+ position: [0, 0, 0],
136
+ orientation: [0, 0, 1.5708],
137
+ },
138
+ },
139
+ },
140
+ payloads: {
141
+ "FPay-0": {
142
+ name: "FPay-0",
143
+ payload: 0,
144
+ center_of_mass: [0, 0, 0],
145
+ moment_of_inertia: [0, 0, 0],
146
+ },
147
+ },
148
+ cycle_time: 8,
149
+ dh_parameters: [
150
+ {
151
+ alpha: 1.5707963267948966,
152
+ d: 162.25,
153
+ },
154
+ {
155
+ a: -425,
156
+ },
157
+ {
158
+ a: -392.2,
159
+ },
160
+ {
161
+ alpha: 1.5707963267948966,
162
+ d: 133.3,
163
+ },
164
+ {
165
+ alpha: -1.5707963267948966,
166
+ d: 99.7,
167
+ },
168
+ {
169
+ d: 99.6,
170
+ },
171
+ ],
172
+ operation_limits: {
173
+ auto_limits: {
174
+ joints: [
175
+ {
176
+ position: {
177
+ lower_limit: -6.283185307179586,
178
+ upper_limit: 6.283185307179586,
179
+ },
180
+ velocity: 3.34159255027771,
181
+ acceleration: 40,
182
+ torque: 150,
183
+ },
184
+ {
185
+ position: {
186
+ lower_limit: -6.283185307179586,
187
+ upper_limit: 6.283185307179586,
188
+ },
189
+ velocity: 3.34159255027771,
190
+ acceleration: 40,
191
+ torque: 150,
192
+ },
193
+ {
194
+ position: {
195
+ lower_limit: -6.283185307179586,
196
+ upper_limit: 6.283185307179586,
197
+ },
198
+ velocity: 3.34159255027771,
199
+ acceleration: 40,
200
+ torque: 150,
201
+ },
202
+ {
203
+ position: {
204
+ lower_limit: -6.283185307179586,
205
+ upper_limit: 6.283185307179586,
206
+ },
207
+ velocity: 3.34159255027771,
208
+ acceleration: 40,
209
+ torque: 28,
210
+ },
211
+ {
212
+ position: {
213
+ lower_limit: -6.283185307179586,
214
+ upper_limit: 6.283185307179586,
215
+ },
216
+ velocity: 3.34159255027771,
217
+ acceleration: 40,
218
+ torque: 28,
219
+ },
220
+ {
221
+ position: {
222
+ lower_limit: -6.283185307179586,
223
+ upper_limit: 6.283185307179586,
224
+ },
225
+ velocity: 3.34159255027771,
226
+ acceleration: 40,
227
+ torque: 28,
228
+ },
229
+ ],
230
+ tcp: {
231
+ velocity: 5000,
232
+ },
233
+ elbow: {
234
+ velocity: 5000,
235
+ },
236
+ flange: {
237
+ velocity: 5000,
238
+ },
239
+ },
240
+ manual_limits: {
241
+ joints: [
242
+ {
243
+ position: {
244
+ lower_limit: -6.283185307179586,
245
+ upper_limit: 6.283185307179586,
246
+ },
247
+ velocity: 3.34159255027771,
248
+ acceleration: 40,
249
+ torque: 150,
250
+ },
251
+ {
252
+ position: {
253
+ lower_limit: -6.283185307179586,
254
+ upper_limit: 6.283185307179586,
255
+ },
256
+ velocity: 3.34159255027771,
257
+ acceleration: 40,
258
+ torque: 150,
259
+ },
260
+ {
261
+ position: {
262
+ lower_limit: -6.283185307179586,
263
+ upper_limit: 6.283185307179586,
264
+ },
265
+ velocity: 3.34159255027771,
266
+ acceleration: 40,
267
+ torque: 150,
268
+ },
269
+ {
270
+ position: {
271
+ lower_limit: -6.283185307179586,
272
+ upper_limit: 6.283185307179586,
273
+ },
274
+ velocity: 3.34159255027771,
275
+ acceleration: 40,
276
+ torque: 28,
277
+ },
278
+ {
279
+ position: {
280
+ lower_limit: -6.283185307179586,
281
+ upper_limit: 6.283185307179586,
282
+ },
283
+ velocity: 3.34159255027771,
284
+ acceleration: 40,
285
+ torque: 28,
286
+ },
287
+ {
288
+ position: {
289
+ lower_limit: -6.283185307179586,
290
+ upper_limit: 6.283185307179586,
291
+ },
292
+ velocity: 3.34159255027771,
293
+ acceleration: 40,
294
+ torque: 28,
295
+ },
296
+ ],
297
+ tcp: {
298
+ velocity: 5000,
299
+ },
300
+ },
301
+ manual_t1_limits: {
302
+ joints: [
303
+ {
304
+ position: {
305
+ lower_limit: -6.283185307179586,
306
+ upper_limit: 6.283185307179586,
307
+ },
308
+ velocity: 3.34159255027771,
309
+ acceleration: 40,
310
+ torque: 150,
311
+ },
312
+ {
313
+ position: {
314
+ lower_limit: -6.283185307179586,
315
+ upper_limit: 6.283185307179586,
316
+ },
317
+ velocity: 3.34159255027771,
318
+ acceleration: 40,
319
+ torque: 150,
320
+ },
321
+ {
322
+ position: {
323
+ lower_limit: -6.283185307179586,
324
+ upper_limit: 6.283185307179586,
325
+ },
326
+ velocity: 3.34159255027771,
327
+ acceleration: 40,
328
+ torque: 150,
329
+ },
330
+ {
331
+ position: {
332
+ lower_limit: -6.283185307179586,
333
+ upper_limit: 6.283185307179586,
334
+ },
335
+ velocity: 3.34159255027771,
336
+ acceleration: 40,
337
+ torque: 28,
338
+ },
339
+ {
340
+ position: {
341
+ lower_limit: -6.283185307179586,
342
+ upper_limit: 6.283185307179586,
343
+ },
344
+ velocity: 3.34159255027771,
345
+ acceleration: 40,
346
+ torque: 28,
347
+ },
348
+ {
349
+ position: {
350
+ lower_limit: -6.283185307179586,
351
+ upper_limit: 6.283185307179586,
352
+ },
353
+ velocity: 3.34159255027771,
354
+ acceleration: 40,
355
+ torque: 28,
356
+ },
357
+ ],
358
+ tcp: {
359
+ velocity: 5000,
360
+ },
361
+ },
362
+ manual_t2_limits: {
363
+ joints: [
364
+ {
365
+ position: {
366
+ lower_limit: -6.283185307179586,
367
+ upper_limit: 6.283185307179586,
368
+ },
369
+ velocity: 3.34159255027771,
370
+ acceleration: 40,
371
+ torque: 150,
372
+ },
373
+ {
374
+ position: {
375
+ lower_limit: -6.283185307179586,
376
+ upper_limit: 6.283185307179586,
377
+ },
378
+ velocity: 3.34159255027771,
379
+ acceleration: 40,
380
+ torque: 150,
381
+ },
382
+ {
383
+ position: {
384
+ lower_limit: -6.283185307179586,
385
+ upper_limit: 6.283185307179586,
386
+ },
387
+ velocity: 3.34159255027771,
388
+ acceleration: 40,
389
+ torque: 150,
390
+ },
391
+ {
392
+ position: {
393
+ lower_limit: -6.283185307179586,
394
+ upper_limit: 6.283185307179586,
395
+ },
396
+ velocity: 3.34159255027771,
397
+ acceleration: 40,
398
+ torque: 28,
399
+ },
400
+ {
401
+ position: {
402
+ lower_limit: -6.283185307179586,
403
+ upper_limit: 6.283185307179586,
404
+ },
405
+ velocity: 3.34159255027771,
406
+ acceleration: 40,
407
+ torque: 28,
408
+ },
409
+ {
410
+ position: {
411
+ lower_limit: -6.283185307179586,
412
+ upper_limit: 6.283185307179586,
413
+ },
414
+ velocity: 3.34159255027771,
415
+ acceleration: 40,
416
+ torque: 28,
417
+ },
418
+ ],
419
+ tcp: {
420
+ velocity: 5000,
421
+ },
422
+ },
423
+ },
424
+ serial_number: "WBVirtualRobot",
425
+ }
426
+ },
427
+ },
18
428
  {
19
429
  method: "GET",
20
430
  path: "/cells/:cellId/controllers",
@@ -605,26 +1015,6 @@ export class MockNovaInstance {
605
1015
  } // Mock safety setup
606
1016
  },
607
1017
  },
608
- {
609
- method: "GET",
610
- path: "/cells/:cellId/coordinate-systems",
611
- handle() {
612
- return {
613
- coordinatesystems: [
614
- {
615
- coordinate_system: "",
616
- name: "world",
617
- reference_uid: "",
618
- position: [0, 0, 0],
619
- rotation: {
620
- angles: [0, 0, 0],
621
- type: "ROTATION_VECTOR",
622
- },
623
- },
624
- ],
625
- } //satisfies CoordinateSystems
626
- },
627
- },
628
1018
  {
629
1019
  method: "GET",
630
1020
  path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
@@ -0,0 +1,27 @@
1
+ import type { Pose } from "@wandelbots/nova-api/v2"
2
+
3
+ /**
4
+ * Convert a Pose object representing a motion group position
5
+ * into a string which represents that pose in Wandelscript.
6
+ */
7
+ export function poseToWandelscriptString(
8
+ pose: Pick<Pose, "position" | "orientation">,
9
+ ) {
10
+ const position = [
11
+ pose.position?.[0] ?? 0,
12
+ pose.position?.[1] ?? 0,
13
+ pose.position?.[2] ?? 0,
14
+ ]
15
+
16
+ const orientation = [
17
+ pose.orientation?.[0] ?? 0,
18
+ pose.orientation?.[1] ?? 0,
19
+ pose.orientation?.[2] ?? 0,
20
+ ]
21
+
22
+ const positionValues = position.map((v) => v.toFixed(1))
23
+ // Rotation needs more precision since it's in radians
24
+ const rotationValues = orientation.map((v) => v.toFixed(4))
25
+
26
+ return `(${positionValues.concat(rotationValues).join(", ")})`
27
+ }
@@ -1,7 +0,0 @@
1
- /**
2
- * Initializes Auth0 login process using redirect if necessary and retrieves an access token.
3
- * Returns null when an access token should not be needed to authenticate (i.e. cookie auth
4
- * when deployed on the instance domain)
5
- */
6
- export declare const loginWithAuth0: (instanceUrl: string) => Promise<string | null>;
7
- //# sourceMappingURL=LoginWithAuth0.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoginWithAuth0.d.ts","sourceRoot":"","sources":["../src/LoginWithAuth0.ts"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,aAAa,MAAM,KAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAsDvB,CAAA"}
@@ -1,53 +0,0 @@
1
- // src/lib/converters.ts
2
- function tryParseJson(json) {
3
- try {
4
- return JSON.parse(json);
5
- } catch (e) {
6
- return void 0;
7
- }
8
- }
9
- function tryStringifyJson(json) {
10
- try {
11
- return JSON.stringify(json);
12
- } catch (e) {
13
- return void 0;
14
- }
15
- }
16
- function makeUrlQueryString(obj) {
17
- const str = new URLSearchParams(obj).toString();
18
- return str ? `?${str}` : "";
19
- }
20
- function radiansToDegrees(radians) {
21
- return radians * (180 / Math.PI);
22
- }
23
- function degreesToRadians(degrees) {
24
- return degrees * (Math.PI / 180);
25
- }
26
- function poseToWandelscriptString(pose) {
27
- var _a, _b, _c, _d, _e, _f;
28
- const position = [pose.position.x, pose.position.y, pose.position.z];
29
- const orientation = [
30
- (_b = (_a = pose.orientation) == null ? void 0 : _a.x) != null ? _b : 0,
31
- (_d = (_c = pose.orientation) == null ? void 0 : _c.y) != null ? _d : 0,
32
- (_f = (_e = pose.orientation) == null ? void 0 : _e.z) != null ? _f : 0
33
- ];
34
- const positionValues = position.map((v) => v.toFixed(1));
35
- const rotationValues = orientation.map((v) => v.toFixed(4));
36
- return `(${positionValues.concat(rotationValues).join(", ")})`;
37
- }
38
- function isSameCoordinateSystem(firstCoordSystem, secondCoordSystem) {
39
- if (!firstCoordSystem) firstCoordSystem = "world";
40
- if (!secondCoordSystem) secondCoordSystem = "world";
41
- return firstCoordSystem === secondCoordSystem;
42
- }
43
-
44
- export {
45
- tryParseJson,
46
- tryStringifyJson,
47
- makeUrlQueryString,
48
- radiansToDegrees,
49
- degreesToRadians,
50
- poseToWandelscriptString,
51
- isSameCoordinateSystem
52
- };
53
- //# sourceMappingURL=chunk-B2C22PTK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/converters.ts"],"sourcesContent":["import type { Pose } from \"@wandelbots/nova-api/v1\"\n\n/** Try to parse something as JSON; return undefined if we can't */\n// biome-ignore lint/suspicious/noExplicitAny: it's json\nexport function tryParseJson(json: unknown): any {\n try {\n return JSON.parse(json as string)\n } catch {\n return undefined\n }\n}\n\n/** Try to turn something into JSON; return undefined if we can't */\nexport function tryStringifyJson(json: unknown): string | undefined {\n try {\n return JSON.stringify(json)\n } catch {\n return undefined\n }\n}\n\n/**\n * Converts object parameters to query string.\n * e.g. { a: \"1\", b: \"2\" } => \"?a=1&b=2\"\n * {} => \"\"\n */\nexport function makeUrlQueryString(obj: Record<string, string>): string {\n const str = new URLSearchParams(obj).toString()\n return str ? `?${str}` : \"\"\n}\n\n/** Convert radians to degrees */\nexport function radiansToDegrees(radians: number): number {\n return radians * (180 / Math.PI)\n}\n\n/** Convert degrees to radians */\nexport function degreesToRadians(degrees: number): number {\n return degrees * (Math.PI / 180)\n}\n\n/**\n * Convert a Pose object representing a motion group position\n * into a string which represents that pose in Wandelscript.\n */\nexport function poseToWandelscriptString(\n pose: Pick<Pose, \"position\" | \"orientation\">,\n) {\n const position = [pose.position.x, pose.position.y, pose.position.z]\n const orientation = [\n pose.orientation?.x ?? 0,\n pose.orientation?.y ?? 0,\n pose.orientation?.z ?? 0,\n ]\n\n const positionValues = position.map((v) => v.toFixed(1))\n // Rotation needs more precision since it's in radians\n const rotationValues = orientation.map((v) => v.toFixed(4))\n\n return `(${positionValues.concat(rotationValues).join(\", \")})`\n}\n\n/**\n * Check for coordinate system id equivalence, accounting for the \"world\" default\n * on empty/undefined values.\n */\nexport function isSameCoordinateSystem(\n firstCoordSystem: string | undefined,\n secondCoordSystem: string | undefined,\n) {\n if (!firstCoordSystem) firstCoordSystem = \"world\"\n if (!secondCoordSystem) secondCoordSystem = \"world\"\n\n return firstCoordSystem === secondCoordSystem\n}\n"],"mappings":";AAIO,SAAS,aAAa,MAAoB;AAC/C,MAAI;AACF,WAAO,KAAK,MAAM,IAAc;AAAA,EAClC,SAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,iBAAiB,MAAmC;AAClE,MAAI;AACF,WAAO,KAAK,UAAU,IAAI;AAAA,EAC5B,SAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOO,SAAS,mBAAmB,KAAqC;AACtE,QAAM,MAAM,IAAI,gBAAgB,GAAG,EAAE,SAAS;AAC9C,SAAO,MAAM,IAAI,GAAG,KAAK;AAC3B;AAGO,SAAS,iBAAiB,SAAyB;AACxD,SAAO,WAAW,MAAM,KAAK;AAC/B;AAGO,SAAS,iBAAiB,SAAyB;AACxD,SAAO,WAAW,KAAK,KAAK;AAC9B;AAMO,SAAS,yBACd,MACA;AA/CF;AAgDE,QAAM,WAAW,CAAC,KAAK,SAAS,GAAG,KAAK,SAAS,GAAG,KAAK,SAAS,CAAC;AACnE,QAAM,cAAc;AAAA,KAClB,gBAAK,gBAAL,mBAAkB,MAAlB,YAAuB;AAAA,KACvB,gBAAK,gBAAL,mBAAkB,MAAlB,YAAuB;AAAA,KACvB,gBAAK,gBAAL,mBAAkB,MAAlB,YAAuB;AAAA,EACzB;AAEA,QAAM,iBAAiB,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEvD,QAAM,iBAAiB,YAAY,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE1D,SAAO,IAAI,eAAe,OAAO,cAAc,EAAE,KAAK,IAAI,CAAC;AAC7D;AAMO,SAAS,uBACd,kBACA,mBACA;AACA,MAAI,CAAC,iBAAkB,oBAAmB;AAC1C,MAAI,CAAC,kBAAmB,qBAAoB;AAE5C,SAAO,qBAAqB;AAC9B;","names":[]}