@wandelbots/wandelbots-js-react-components 5.2.0 → 5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandelbots/wandelbots-js-react-components",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -3,8 +3,9 @@ import { observer } from "mobx-react-lite"
3
3
  import type { ReactNode } from "react"
4
4
  import { JoggingJointLimitDetector } from "./JoggingJointLimitDetector"
5
5
  import { JoggingJointValueControl } from "./JoggingJointValueControl"
6
- import { type JoggingStore, JointCategory } from "./JoggingStore"
6
+ import { type JoggingStore } from "./JoggingStore"
7
7
  import { JoggingVelocitySlider } from "./JoggingVelocitySlider"
8
+ import { JointTypeEnum } from "@wandelbots/nova-js/v2"
8
9
 
9
10
  export const JoggingJointTab = observer(
10
11
  ({ store, children }: { store: JoggingStore; children: ReactNode }) => {
@@ -19,11 +20,11 @@ export const JoggingJointTab = observer(
19
20
  joint: opts.joint,
20
21
  direction: opts.direction,
21
22
  velocityUnit:
22
- store.jointCategory === JointCategory.PRISMATIC
23
+ store.jointType === JointTypeEnum.PrismaticJoint
23
24
  ? "mm/s"
24
25
  : "rad/s",
25
26
  velocityValue:
26
- store.jointCategory === JointCategory.PRISMATIC
27
+ store.jointType === JointTypeEnum.PrismaticJoint
27
28
  ? store.translationVelocityMmPerSec
28
29
  : store.rotationVelocityRadsPerSec,
29
30
 
@@ -46,7 +47,7 @@ export const JoggingJointTab = observer(
46
47
  <JoggingVelocitySlider
47
48
  store={store}
48
49
  useDegree={
49
- store.jointCategory === JointCategory.REVOLUTE
50
+ store.jointType === JointTypeEnum.RevoluteJoint
50
51
  }
51
52
  />
52
53
 
@@ -96,7 +97,7 @@ export const JoggingJointTab = observer(
96
97
  lowerLimit={jointLimits?.lower_limit}
97
98
  upperLimit={jointLimits?.upper_limit}
98
99
  useDegree={
99
- store.jointCategory === JointCategory.REVOLUTE
100
+ store.jointType === JointTypeEnum.RevoluteJoint
100
101
  }
101
102
 
102
103
  getValue={() => {
@@ -1,8 +1,11 @@
1
1
  import { tryParseJson } from "@wandelbots/nova-js"
2
- import type {
3
- CoordinateSystem,
4
- MotionGroupDescription,
5
- RobotTcp,
2
+ import {
3
+ type CoordinateSystem,
4
+ type DHParameter,
5
+ type MotionGroupDescription,
6
+ type RobotTcp,
7
+ type KinematicModel,
8
+ JointTypeEnum,
6
9
  } from "@wandelbots/nova-js/v2"
7
10
  import { countBy } from "lodash-es"
8
11
  import keyBy from "lodash-es/keyBy"
@@ -40,30 +43,12 @@ export type IncrementJogInProgress = {
40
43
  axis: JoggingAxis
41
44
  }
42
45
 
43
- export enum JointCategory {
44
- REVOLUTE = "REVOLUTE",
45
- PRISMATIC = "PRISMATIC",
46
- }
47
-
48
46
  type TabType = "cartesian" | "joint" | "debug";
49
47
  export type CartesianMotionType = "translate" | "rotate"
50
48
 
51
49
  export class JoggingStore {
52
50
  selectedTabId: TabType = "cartesian";
53
51
 
54
- /**
55
- * State of the jogging panel. Starts as "inactive"
56
- */
57
- activationState: "inactive" | "loading" | "active" = "inactive"
58
-
59
- /**
60
- * If an error occurred connecting to the jogging websocket
61
- */
62
- activationError: unknown | null = null
63
-
64
- /** To avoid activation race conditions */
65
- activationCounter: number = 0
66
-
67
52
  /** Locks to prevent UI interactions during certain operations */
68
53
  locks = new Set<string>()
69
54
 
@@ -145,6 +130,17 @@ export class JoggingStore {
145
130
 
146
131
  disposers: IReactionDisposer[] = []
147
132
 
133
+ /**
134
+ * Inverse solver from the kinematic model of the motion group to determine, which tabs should be rendered
135
+ */
136
+ inverseSolver: string | null | undefined = undefined
137
+
138
+ /**
139
+ * Joint type to determine, whether the active robot should be displayed as Robot or Linear Axis and what tabs
140
+ * should be rendered by the JoggingPanel component.
141
+ */
142
+ jointType: JointTypeEnum = JointTypeEnum.RevoluteJoint
143
+
148
144
  /**
149
145
  * Load a jogging store with the relevant data it needs
150
146
  * from the backend
@@ -167,6 +163,10 @@ export class JoggingStore {
167
163
  ),
168
164
  ])
169
165
 
166
+ const kinematicModel: KinematicModel = await nova.api.motionGroupModels.getMotionGroupKinematicModel(
167
+ description.motion_group_model,
168
+ )
169
+
170
170
  const tcps = Object.entries(description.tcps || {}).map(([id, tcp]) => ({
171
171
  id,
172
172
  readable_name: tcp.name,
@@ -174,7 +174,7 @@ export class JoggingStore {
174
174
  orientation: tcp.pose.orientation as Vector3Simple,
175
175
  }))
176
176
 
177
- return new JoggingStore(jogger, coordinatesystems || [], description, tcps)
177
+ return new JoggingStore(jogger, coordinatesystems || [], description, tcps, kinematicModel.inverse_solver)
178
178
  }
179
179
 
180
180
  constructor(
@@ -182,6 +182,7 @@ export class JoggingStore {
182
182
  readonly coordSystems: CoordinateSystem[],
183
183
  readonly motionGroupDescription: MotionGroupDescription,
184
184
  readonly tcps: RobotTcp[],
185
+ readonly inverseSolverValue: string | null | undefined,
185
186
  ) {
186
187
  // TODO workaround for default coord system on backend having a canonical id
187
188
  // of empty string. Can remove when fixed on API side
@@ -193,6 +194,10 @@ export class JoggingStore {
193
194
  }
194
195
  this.selectedCoordSystemId = coordSystems[0]?.coordinate_system || "world"
195
196
  this.selectedTcpId = tcps[0]?.id || ""
197
+ this.inverseSolver = inverseSolverValue
198
+ this.jointType =
199
+ motionGroupDescription?.dh_parameters?.[0]?.type ??
200
+ JointTypeEnum.RevoluteJoint
196
201
 
197
202
  // Make all properties observable and actions auto-bound
198
203
  makeAutoObservable(this, {}, { autoBind: true })
@@ -306,17 +311,22 @@ export class JoggingStore {
306
311
  }
307
312
 
308
313
  get tabs() {
309
- const tempTabs : {id: TabType, label: string}[] = [{
310
- id: "joint",
311
- label: "Joints",
312
- }] ;
313
- if(this.isTcpCartesianMoveable){
314
+ const tempTabs: { id: TabType; label: string }[] = [
315
+ {
316
+ id: "joint",
317
+ label: "Joints",
318
+ },
319
+ ]
320
+ // show the cartesian tab only : 1. when there is a solver or 2. when no solver could be loaded ( as a default )
321
+ // do not show the cartesian tab when the solver is null this means, it cannot get jogged cartesian
322
+ if (this.inverseSolver !== null) {
314
323
  tempTabs.unshift({
315
324
  id: "cartesian",
316
325
  label: "Cartesian",
317
- })}
326
+ })
327
+ }
318
328
 
319
- return tempTabs;
329
+ return tempTabs
320
330
  }
321
331
 
322
332
 
@@ -348,10 +358,6 @@ export class JoggingStore {
348
358
  return keyBy(this.coordSystems, (cs) => cs.coordinate_system)
349
359
  }
350
360
 
351
- get selectedCoordSystem() {
352
- return this.coordSystemsById[this.selectedCoordSystemId]
353
- }
354
-
355
361
  /**
356
362
  * The id of the coordinate system to use for jogging.
357
363
  * If in tool orientation, this is set to "tool", not the
@@ -401,24 +407,6 @@ export class JoggingStore {
401
407
  : this.maxTranslationVelocityMmPerSec
402
408
  }
403
409
 
404
-
405
- /*
406
- * ToDo replace Hardcoded Models with an api request that delivers the type (will become part of DH-Parameters)
407
- * Ticket already created
408
- * */
409
- get jointCategory(): JointCategory {
410
- return this.motionGroupDescription.motion_group_model === "ABB_IRT710"
411
- ? JointCategory.PRISMATIC
412
- : JointCategory.REVOLUTE
413
- }
414
-
415
- get isTcpCartesianMoveable(): boolean{
416
- if(this.motionGroupDescription.motion_group_model === "ABB_IRT710"){
417
- return false;
418
- }
419
- return true;
420
- }
421
-
422
410
  onTabChange(_event: React.SyntheticEvent, newValue: number) {
423
411
  const tab = this.tabs[newValue] || this.tabs[0]!
424
412
  this.selectedTabId = tab.id
@@ -444,7 +432,7 @@ export class JoggingStore {
444
432
  this.incrementJogInProgress = incrementJog
445
433
  }
446
434
 
447
- setVelocityFromSlider(velocity: number,useDegree : boolean ) {
435
+ setVelocityFromSlider(velocity: number, useDegree: boolean) {
448
436
  if (useDegree) {
449
437
  this.rotationVelocityDegPerSec = velocity
450
438
  } else {
@@ -25,10 +25,6 @@ export const MotionGroupVisualizer: React.FC<MotionGroupVisualizerProps> = exter
25
25
 
26
26
  /**
27
27
  * Sets the joint type according to delivered dh parameter type
28
- *
29
- * TODO as soon as V2 api migration is done, the setting of the default RevoluteJoint value should be
30
- * deleted, cause the type property is expected to be always delivered. It is not the case in the V1 at the
31
- * moment.
32
28
  */
33
29
  useEffect(() => {
34
30
  if (dhParameters.length) {