@wandelbots/wandelbots-js-react-components 5.4.0 → 5.4.1

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.
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Real motion state data captured from websocket connections
3
+ * to actual robot controllers, converted to MotionGroupState format.
4
+ */
5
+ import { JointTypeEnum } from "@wandelbots/nova-js/v2"
6
+ import type {
7
+ MotionGroupState,
8
+ MotionGroupDescription,
9
+ DHParameter,
10
+ } from "@wandelbots/nova-js/v2"
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // UR5e – 6 revolute joints
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export const ur5eMotionGroupState: MotionGroupState = {
17
+ motion_group: "0@ur5emock",
18
+ controller: "ur5emock",
19
+ joint_position: [
20
+ 0, -1.5709999799728394, -1.5709999799728394, -1.5709999799728394,
21
+ 1.5709999799728394, -1.5709999799728394,
22
+ ],
23
+ joint_limit_reached: {
24
+ limit_reached: [false, false, false, false, false, false],
25
+ },
26
+ tcp_pose: {
27
+ position: [491.9256498952305, -133.27971614361718, 487.42935363090754],
28
+ orientation: [
29
+ -3.1413887753705083, -0.0003197791888075772, 0.000959598168759525,
30
+ ],
31
+ },
32
+ tcp: "Flange",
33
+ flange_pose: {
34
+ position: [491.9256498952305, -133.27971614361718, 487.42935363090754],
35
+ orientation: [
36
+ -3.1413887753705083, -0.0003197791888075772, 0.000959598168759525,
37
+ ],
38
+ },
39
+ coordinate_system: "",
40
+ standstill: true,
41
+ sequence_number: 38283,
42
+ timestamp: "2026-04-24T08:23:04.230859905Z",
43
+ description_revision: 0,
44
+ }
45
+
46
+ export const ur5eDhParameters: DHParameter[] = Array.from(
47
+ { length: 6 },
48
+ () => ({ type: JointTypeEnum.RevoluteJoint }) as DHParameter,
49
+ )
50
+
51
+ export const ur5eDescription: MotionGroupDescription = {
52
+ motion_group_model: "ur5e",
53
+ cycle_time: 0.004,
54
+ mounting: {},
55
+ operation_limits: { auto_limits: { joints: [] } },
56
+ dh_parameters: ur5eDhParameters,
57
+ } as unknown as MotionGroupDescription
58
+
59
+ // ---------------------------------------------------------------------------
60
+ // Turn mock – 2 revolute joints
61
+ // ---------------------------------------------------------------------------
62
+
63
+ export const turnMockMotionGroupState: MotionGroupState = {
64
+ motion_group: "0@turnmock",
65
+ controller: "turnmock",
66
+ joint_position: [0, 0],
67
+ joint_limit_reached: {
68
+ limit_reached: [false, false],
69
+ },
70
+ tcp_pose: {
71
+ position: [0, 0, 0],
72
+ orientation: [0, 0, 0],
73
+ },
74
+ tcp: "",
75
+ flange_pose: {
76
+ position: [0, 0, 0],
77
+ orientation: [0, 0, 0],
78
+ },
79
+ coordinate_system: "",
80
+ standstill: true,
81
+ sequence_number: 31111,
82
+ timestamp: "2026-04-24T08:26:21.729120996Z",
83
+ description_revision: 0,
84
+ }
85
+
86
+ export const turnMockDhParameters: DHParameter[] = Array.from(
87
+ { length: 2 },
88
+ () => ({ type: JointTypeEnum.RevoluteJoint }) as DHParameter,
89
+ )
90
+
91
+ export const turnMockDescription: MotionGroupDescription = {
92
+ motion_group_model: "turnmock",
93
+ cycle_time: 0.004,
94
+ mounting: {},
95
+ operation_limits: { auto_limits: { joints: [] } },
96
+ dh_parameters: turnMockDhParameters,
97
+ } as unknown as MotionGroupDescription
98
+
99
+ // ---------------------------------------------------------------------------
100
+ // Linear axis mock – 1 prismatic joint
101
+ // ---------------------------------------------------------------------------
102
+
103
+ export const linearAxisMotionGroupState: MotionGroupState = {
104
+ motion_group: "0@linearaxismock",
105
+ controller: "linearaxismock",
106
+ joint_position: [0],
107
+ joint_limit_reached: {
108
+ limit_reached: [false],
109
+ },
110
+ tcp_pose: {
111
+ position: [0, 0, 0],
112
+ orientation: [0, 0, 0],
113
+ },
114
+ tcp: "Flange",
115
+ flange_pose: {
116
+ position: [0, 0, 0],
117
+ orientation: [0, 1.5707963267948966, 0],
118
+ },
119
+ coordinate_system: "",
120
+ standstill: true,
121
+ sequence_number: 40497,
122
+ timestamp: "2026-04-24T08:27:41.630099378Z",
123
+ description_revision: 0,
124
+ }
125
+
126
+ export const linearAxisDhParameters: DHParameter[] = [
127
+ { type: JointTypeEnum.PrismaticJoint } as DHParameter,
128
+ ]
129
+
130
+ export const linearAxisDescription: MotionGroupDescription = {
131
+ motion_group_model: "linearaxismock",
132
+ cycle_time: 0.004,
133
+ mounting: {},
134
+ operation_limits: { auto_limits: { joints: [] } },
135
+ dh_parameters: linearAxisDhParameters,
136
+ } as unknown as MotionGroupDescription
137
+
@@ -3,12 +3,13 @@ import {
3
3
  tryParseJson,
4
4
  XYZ_TO_VECTOR,
5
5
  } from "@wandelbots/nova-js"
6
- import type {
7
- InitializeMovementResponse,
8
- MotionCommand,
9
- NovaClient,
10
- Pose,
11
- StartMovementResponse,
6
+ import {
7
+ JointTypeEnum,
8
+ type InitializeMovementResponse,
9
+ type MotionCommand,
10
+ type NovaClient,
11
+ type Pose,
12
+ type StartMovementResponse,
12
13
  } from "@wandelbots/nova-js/v2"
13
14
  import { when } from "mobx"
14
15
  import { Vector3 } from "three/src/math/Vector3.js"
@@ -55,7 +56,8 @@ export class JoggerConnection {
55
56
  ENDPOINT_JOGGING = "/execution/jogging"
56
57
  ENDPOINT_TRAJECTORY = "/execution/trajectory"
57
58
  DEFAULT_MODE = "off" as JoggerMode
58
- DEFAULT_TCP = "Flange"
59
+ DEFAULT_TCP: string | undefined = "Flange"
60
+ NO_TCP: string | undefined = undefined;
59
61
  // DEFAULT_COORDINATE_SYSTEM = "world"
60
62
  DEFAULT_INIT_TIMEOUT = 5000
61
63
  DEFAULT_ORIENTATION = "coordsys" as JoggerOrientation
@@ -64,7 +66,7 @@ export class JoggerConnection {
64
66
  joggingSocket: AutoReconnectingWebsocket | null = null
65
67
  trajectorySocket: AutoReconnectingWebsocket | null = null
66
68
  timeout: number = this.DEFAULT_INIT_TIMEOUT
67
- tcp: string
69
+ tcp: string | undefined
68
70
  // coordinateSystem?: string
69
71
  orientation: JoggerOrientation
70
72
  onError?: (err: unknown) => void
@@ -95,6 +97,7 @@ export class JoggerConnection {
95
97
  // Get matching motion stream
96
98
  const motionStream = await MotionStreamConnection.open(nova, motionGroupId)
97
99
 
100
+
98
101
  // Initialize jogger with options
99
102
  const jogger = new JoggerConnection(motionStream, options)
100
103
 
@@ -109,7 +112,7 @@ export class JoggerConnection {
109
112
  readonly motionStream: MotionStreamConnection,
110
113
  readonly options: JoggerConnectionOptions | undefined = {},
111
114
  ) {
112
- this.tcp = options?.tcp || motionStream.motionGroup.tcp || this.DEFAULT_TCP
115
+ this.tcp = options?.tcp || motionStream.motionGroup.tcp || this.getDefaultTcp(motionStream)
113
116
  // this.coordinateSystem = options?.coordinateSystem || this.DEFAULT_COORDINATE_SYSTEM
114
117
  this.orientation = options?.orientation || this.DEFAULT_ORIENTATION
115
118
  this.timeout = options?.timeout || this.DEFAULT_INIT_TIMEOUT
@@ -117,6 +120,17 @@ export class JoggerConnection {
117
120
  this.onError = options?.onError
118
121
  }
119
122
 
123
+ getDefaultTcp(motionStream: MotionStreamConnection){
124
+ const firstJointType = motionStream.description.dh_parameters?.[0]?.type
125
+ if(
126
+ motionStream.joints.length < 6 &&
127
+ (firstJointType === JointTypeEnum.RevoluteJoint || firstJointType === JointTypeEnum.PrismaticJoint)
128
+ ){
129
+ return this.NO_TCP;
130
+ }
131
+ return this.DEFAULT_TCP;
132
+ }
133
+
120
134
  // Set a new tcp or other options. If current mode is jogging, will reinitialize the jogging websocket
121
135
  async setOptions(options: Partial<JoggerConnectionOptions>) {
122
136
  if (options.tcp) {
@@ -271,7 +285,7 @@ export class JoggerConnection {
271
285
  this.joggingSocket.sendJson({
272
286
  message_type: "InitializeJoggingRequest",
273
287
  motion_group: this.motionGroupId,
274
- tcp: this.tcp,
288
+ ...(this.tcp ? { tcp: this.tcp } : {}),
275
289
  })
276
290
  })
277
291
  }