@wandelbots/nova-js 3.5.1 → 3.5.2

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.
@@ -1,9 +1,14 @@
1
- /** biome-ignore-all lint/suspicious/noApproximativeNumericConstant: mock data contains approximative pi values from robot description */
2
- import type { MotionGroupState, RobotController } from "@wandelbots/nova-api/v2"
1
+ import type { MotionGroupState } from "@wandelbots/nova-api/v2"
3
2
  import type { AxiosResponse, InternalAxiosRequestConfig } from "axios"
4
3
  import { AxiosError } from "axios"
5
4
  import * as pathToRegexp from "path-to-regexp"
6
5
  import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
6
+ import { getCurrentRobotControllerState } from "./getCurrentRobotControllerState"
7
+ import { getMotionGroupDescription } from "./getMotionGroupDescription"
8
+ import { getMotionGroupKinematicModel } from "./getMotionGroupKinematicModel"
9
+ import { getRobotController } from "./getRobotController"
10
+ import { listCoordinateSystems } from "./listCoordinateSystems"
11
+ import { listRobotControllers } from "./listRobotControllers"
7
12
 
8
13
  /**
9
14
  * Ultra-simplified mock Nova server for testing stuff
@@ -15,419 +20,22 @@ export class MockNovaInstance {
15
20
  config: InternalAxiosRequestConfig,
16
21
  ): Promise<AxiosResponse> {
17
22
  const apiHandlers = [
18
- {
19
- method: "GET",
20
- path: "/cells/:cellId/controllers",
21
- handle() {
22
- return ["mock-ur5e"]
23
- },
24
- },
25
- {
26
- method: "GET",
27
- path: "/cells/:cellId/controllers/:controllerId",
28
- handle() {
29
- return {
30
- configuration: {
31
- initial_joint_position: "[0,-1.571,-1.571,-1.571,1.571,-1.571,0]",
32
- kind: "VirtualController",
33
- manufacturer: "universalrobots",
34
- type: "universalrobots-ur5e",
35
- },
36
- name: "mock-ur5",
37
- } satisfies RobotController
38
- },
39
- },
40
- {
41
- method: "GET",
42
- path: "/cells/:cellId/controllers/:controllerId/state",
43
- handle() {
44
- return {
45
- mode: "MODE_CONTROL",
46
- last_error: [],
47
- timestamp: "2025-10-16T09:19:26.634534092Z",
48
- sequence_number: 1054764,
49
- controller: "mock-ur5e",
50
- operation_mode: "OPERATION_MODE_AUTO",
51
- safety_state: "SAFETY_STATE_NORMAL",
52
- velocity_override: 100,
53
- motion_groups: [
54
- {
55
- timestamp: "2025-10-16T09:19:26.634534092Z",
56
- sequence_number: 1054764,
57
- motion_group: "0@mock-ur5e",
58
- controller: "mock-ur5e",
59
- joint_position: [
60
- 1.487959623336792, -1.8501918315887451, 1.8003005981445312,
61
- 6.034560203552246, 1.4921919107437134, 1.593459963798523,
62
- ],
63
- joint_limit_reached: {
64
- limit_reached: [false, false, false, false, false, false],
65
- },
66
- joint_torque: [],
67
- joint_current: [0, 0, 0, 0, 0, 0],
68
- flange_pose: {
69
- position: [
70
- 107.6452433732927, -409.0402987746852, 524.2402132330305,
71
- ],
72
- orientation: [
73
- 0.9874434028353319, -0.986571714997442, 1.3336589451098142,
74
- ],
75
- },
76
- tcp: "Flange",
77
- tcp_pose: {
78
- position: [
79
- 107.6452433732927, -409.0402987746852, 524.2402132330305,
80
- ],
81
- orientation: [
82
- 0.9874434028353319, -0.986571714997442, 1.3336589451098142,
83
- ],
84
- },
85
- payload: "",
86
- coordinate_system: "",
87
- standstill: true,
88
- },
89
- ],
90
- }
91
- },
92
- },
93
- {
94
- method: "GET",
95
- path: "/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description",
96
- handle() {
97
- return {
98
- motion_group_model: "UniversalRobots_UR5e",
99
- mounting: {
100
- position: [0, 0, 0],
101
- orientation: [0, 0, 0],
102
- },
103
- tcps: {
104
- Flange: {
105
- name: "Default-Flange",
106
- pose: {
107
- position: [0, 0, 0],
108
- orientation: [0, 0, 0],
109
- },
110
- },
111
- },
112
- payloads: {
113
- "FPay-0": {
114
- name: "FPay-0",
115
- payload: 0,
116
- center_of_mass: [0, 0, 0],
117
- moment_of_inertia: [0, 0, 0],
118
- },
119
- },
120
- cycle_time: 8,
121
- dh_parameters: [
122
- {
123
- alpha: 1.5707963267948966,
124
- d: 162.25,
125
- },
126
- {
127
- a: -425,
128
- },
129
- {
130
- a: -392.2,
131
- },
132
- {
133
- alpha: 1.5707963267948966,
134
- d: 133.3,
135
- },
136
- {
137
- alpha: -1.5707963267948966,
138
- d: 99.7,
139
- },
140
- {
141
- d: 99.6,
142
- },
143
- ],
144
- operation_limits: {
145
- auto_limits: {
146
- joints: [
147
- {
148
- position: {
149
- lower_limit: -6.283185307179586,
150
- upper_limit: 6.283185307179586,
151
- },
152
- velocity: 3.34159255027771,
153
- acceleration: 40,
154
- torque: 150,
155
- },
156
- {
157
- position: {
158
- lower_limit: -6.283185307179586,
159
- upper_limit: 6.283185307179586,
160
- },
161
- velocity: 3.34159255027771,
162
- acceleration: 40,
163
- torque: 150,
164
- },
165
- {
166
- position: {
167
- lower_limit: -6.283185307179586,
168
- upper_limit: 6.283185307179586,
169
- },
170
- velocity: 3.34159255027771,
171
- acceleration: 40,
172
- torque: 150,
173
- },
174
- {
175
- position: {
176
- lower_limit: -6.283185307179586,
177
- upper_limit: 6.283185307179586,
178
- },
179
- velocity: 3.34159255027771,
180
- acceleration: 40,
181
- torque: 28,
182
- },
183
- {
184
- position: {
185
- lower_limit: -6.283185307179586,
186
- upper_limit: 6.283185307179586,
187
- },
188
- velocity: 3.34159255027771,
189
- acceleration: 40,
190
- torque: 28,
191
- },
192
- {
193
- position: {
194
- lower_limit: -6.283185307179586,
195
- upper_limit: 6.283185307179586,
196
- },
197
- velocity: 3.34159255027771,
198
- acceleration: 40,
199
- torque: 28,
200
- },
201
- ],
202
- tcp: {
203
- velocity: 5000,
204
- },
205
- elbow: {
206
- velocity: 5000,
207
- },
208
- flange: {
209
- velocity: 5000,
210
- },
211
- },
212
- manual_limits: {
213
- joints: [
214
- {
215
- position: {
216
- lower_limit: -6.283185307179586,
217
- upper_limit: 6.283185307179586,
218
- },
219
- velocity: 3.34159255027771,
220
- acceleration: 40,
221
- torque: 150,
222
- },
223
- {
224
- position: {
225
- lower_limit: -6.283185307179586,
226
- upper_limit: 6.283185307179586,
227
- },
228
- velocity: 3.34159255027771,
229
- acceleration: 40,
230
- torque: 150,
231
- },
232
- {
233
- position: {
234
- lower_limit: -6.283185307179586,
235
- upper_limit: 6.283185307179586,
236
- },
237
- velocity: 3.34159255027771,
238
- acceleration: 40,
239
- torque: 150,
240
- },
241
- {
242
- position: {
243
- lower_limit: -6.283185307179586,
244
- upper_limit: 6.283185307179586,
245
- },
246
- velocity: 3.34159255027771,
247
- acceleration: 40,
248
- torque: 28,
249
- },
250
- {
251
- position: {
252
- lower_limit: -6.283185307179586,
253
- upper_limit: 6.283185307179586,
254
- },
255
- velocity: 3.34159255027771,
256
- acceleration: 40,
257
- torque: 28,
258
- },
259
- {
260
- position: {
261
- lower_limit: -6.283185307179586,
262
- upper_limit: 6.283185307179586,
263
- },
264
- velocity: 3.34159255027771,
265
- acceleration: 40,
266
- torque: 28,
267
- },
268
- ],
269
- tcp: {
270
- velocity: 5000,
271
- },
272
- },
273
- manual_t1_limits: {
274
- joints: [
275
- {
276
- position: {
277
- lower_limit: -6.283185307179586,
278
- upper_limit: 6.283185307179586,
279
- },
280
- velocity: 3.34159255027771,
281
- acceleration: 40,
282
- torque: 150,
283
- },
284
- {
285
- position: {
286
- lower_limit: -6.283185307179586,
287
- upper_limit: 6.283185307179586,
288
- },
289
- velocity: 3.34159255027771,
290
- acceleration: 40,
291
- torque: 150,
292
- },
293
- {
294
- position: {
295
- lower_limit: -6.283185307179586,
296
- upper_limit: 6.283185307179586,
297
- },
298
- velocity: 3.34159255027771,
299
- acceleration: 40,
300
- torque: 150,
301
- },
302
- {
303
- position: {
304
- lower_limit: -6.283185307179586,
305
- upper_limit: 6.283185307179586,
306
- },
307
- velocity: 3.34159255027771,
308
- acceleration: 40,
309
- torque: 28,
310
- },
311
- {
312
- position: {
313
- lower_limit: -6.283185307179586,
314
- upper_limit: 6.283185307179586,
315
- },
316
- velocity: 3.34159255027771,
317
- acceleration: 40,
318
- torque: 28,
319
- },
320
- {
321
- position: {
322
- lower_limit: -6.283185307179586,
323
- upper_limit: 6.283185307179586,
324
- },
325
- velocity: 3.34159255027771,
326
- acceleration: 40,
327
- torque: 28,
328
- },
329
- ],
330
- tcp: {
331
- velocity: 5000,
332
- },
333
- },
334
- manual_t2_limits: {
335
- joints: [
336
- {
337
- position: {
338
- lower_limit: -6.283185307179586,
339
- upper_limit: 6.283185307179586,
340
- },
341
- velocity: 3.34159255027771,
342
- acceleration: 40,
343
- torque: 150,
344
- },
345
- {
346
- position: {
347
- lower_limit: -6.283185307179586,
348
- upper_limit: 6.283185307179586,
349
- },
350
- velocity: 3.34159255027771,
351
- acceleration: 40,
352
- torque: 150,
353
- },
354
- {
355
- position: {
356
- lower_limit: -6.283185307179586,
357
- upper_limit: 6.283185307179586,
358
- },
359
- velocity: 3.34159255027771,
360
- acceleration: 40,
361
- torque: 150,
362
- },
363
- {
364
- position: {
365
- lower_limit: -6.283185307179586,
366
- upper_limit: 6.283185307179586,
367
- },
368
- velocity: 3.34159255027771,
369
- acceleration: 40,
370
- torque: 28,
371
- },
372
- {
373
- position: {
374
- lower_limit: -6.283185307179586,
375
- upper_limit: 6.283185307179586,
376
- },
377
- velocity: 3.34159255027771,
378
- acceleration: 40,
379
- torque: 28,
380
- },
381
- {
382
- position: {
383
- lower_limit: -6.283185307179586,
384
- upper_limit: 6.283185307179586,
385
- },
386
- velocity: 3.34159255027771,
387
- acceleration: 40,
388
- torque: 28,
389
- },
390
- ],
391
- tcp: {
392
- velocity: 5000,
393
- },
394
- },
395
- },
396
- serial_number: "WBVirtualRobot",
397
- }
398
- },
399
- },
400
- {
401
- method: "GET",
402
- path: "/cells/:cellId/controllers/:controllerId/coordinate-systems",
403
- handle() {
404
- return [
405
- {
406
- coordinate_system: "",
407
- name: "world",
408
- reference_coordinate_system: "",
409
- position: [0, 0, 0],
410
- orientation: [0, 0, 0],
411
- orientation_type: "ROTATION_VECTOR",
412
- },
413
- {
414
- coordinate_system: "CS-0",
415
- name: "Default-CS",
416
- reference_coordinate_system: "",
417
- position: [0, 0, 0],
418
- orientation: [0, 0, 0],
419
- orientation_type: "ROTATION_VECTOR",
420
- },
421
- ] //satisfies CoordinateSystems
422
- },
423
- },
23
+ listRobotControllers,
24
+ getRobotController,
25
+ getMotionGroupDescription,
26
+ getCurrentRobotControllerState,
27
+ listCoordinateSystems,
28
+ getMotionGroupKinematicModel,
424
29
  ]
425
30
 
426
31
  const method = config.method?.toUpperCase() || "GET"
427
- const path = `/cells${config.url?.split("/cells")[1]?.split("?")[0]}`
32
+ if (!config.url) {
33
+ throw new Error("No url sent with request")
34
+ }
35
+ const path = config.url
428
36
 
429
37
  for (const handler of apiHandlers) {
430
- const match = pathToRegexp.match(handler.path)(path || "")
38
+ const match = pathToRegexp.match(handler.path)(path)
431
39
  if (method === handler.method && match) {
432
40
  const json = handler.handle()
433
41
  return {
@@ -448,17 +56,6 @@ export class MockNovaInstance {
448
56
  "404",
449
57
  config,
450
58
  )
451
-
452
- // return {
453
- // status: 404,
454
- // statusText: "Not Found",
455
- // data: "",
456
- // headers: {},
457
- // config,
458
- // request: {
459
- // responseURL: config.url,
460
- // },
461
- // }
462
59
  }
463
60
 
464
61
  // Please note: Only very basic websocket mocking is done here, needs to be extended as needed
@@ -0,0 +1,53 @@
1
+ export const getCurrentRobotControllerState = {
2
+ method: "GET",
3
+ path: "/cells/:cellId/controllers/:controllerId/state",
4
+ handle() {
5
+ return {
6
+ mode: "MODE_CONTROL",
7
+ last_error: [],
8
+ timestamp: "2025-10-16T09:19:26.634534092Z",
9
+ sequence_number: 1054764,
10
+ controller: "mock-ur5e",
11
+ operation_mode: "OPERATION_MODE_AUTO",
12
+ safety_state: "SAFETY_STATE_NORMAL",
13
+ velocity_override: 100,
14
+ motion_groups: [
15
+ {
16
+ timestamp: "2025-10-16T09:19:26.634534092Z",
17
+ sequence_number: 1054764,
18
+ motion_group: "0@mock-ur5e",
19
+ controller: "mock-ur5e",
20
+ joint_position: [
21
+ 1.487959623336792, -1.8501918315887451, 1.8003005981445312,
22
+ 6.034560203552246, 1.4921919107437134, 1.593459963798523,
23
+ ],
24
+ joint_limit_reached: {
25
+ limit_reached: [false, false, false, false, false, false],
26
+ },
27
+ joint_torque: [],
28
+ joint_current: [0, 0, 0, 0, 0, 0],
29
+ flange_pose: {
30
+ position: [
31
+ 107.6452433732927, -409.0402987746852, 524.2402132330305,
32
+ ],
33
+ orientation: [
34
+ 0.9874434028353319, -0.986571714997442, 1.3336589451098142,
35
+ ],
36
+ },
37
+ tcp: "Flange",
38
+ tcp_pose: {
39
+ position: [
40
+ 107.6452433732927, -409.0402987746852, 524.2402132330305,
41
+ ],
42
+ orientation: [
43
+ 0.9874434028353319, -0.986571714997442, 1.3336589451098142,
44
+ ],
45
+ },
46
+ payload: "",
47
+ coordinate_system: "",
48
+ standstill: true,
49
+ },
50
+ ],
51
+ }
52
+ },
53
+ }