@wandelbots/wandelbots-js-react-components 4.3.0 → 4.4.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 (34) hide show
  1. package/dist/3d.cjs.js +1 -1
  2. package/dist/3d.es.js +1 -1
  3. package/dist/{MotionGroupVisualizer-BgvrTXeT.js → MotionGroupVisualizer-Catdk92m.js} +339 -376
  4. package/dist/{MotionGroupVisualizer-BgvrTXeT.js.map → MotionGroupVisualizer-Catdk92m.js.map} +1 -1
  5. package/dist/MotionGroupVisualizer-DePl371W.cjs +2 -0
  6. package/dist/{MotionGroupVisualizer-C_fyiA-X.cjs.map → MotionGroupVisualizer-DePl371W.cjs.map} +1 -1
  7. package/dist/{auth0-spa-js.production.esm-mvPojIrB.js → auth0-spa-js.production.esm-DNao6_S5.js} +1478 -1457
  8. package/dist/auth0-spa-js.production.esm-DNao6_S5.js.map +1 -0
  9. package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs +5 -0
  10. package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs.map +1 -0
  11. package/dist/components/robots/MotionGroupVisualizer.d.ts.map +1 -1
  12. package/dist/core.cjs.js +1 -1
  13. package/dist/core.es.js +2 -2
  14. package/dist/index.cjs.js +1 -1
  15. package/dist/index.es.js +3 -3
  16. package/dist/{interpolation-6ZZN4S_x.js → interpolation-Chyc6Hfo.js} +3054 -2868
  17. package/dist/interpolation-Chyc6Hfo.js.map +1 -0
  18. package/dist/interpolation-CiEw5jkz.cjs +20 -0
  19. package/dist/interpolation-CiEw5jkz.cjs.map +1 -0
  20. package/dist/lib/ConnectedMotionGroup.d.ts +1 -0
  21. package/dist/lib/ConnectedMotionGroup.d.ts.map +1 -1
  22. package/dist/{theming-gUgI75AD.js → theming-CZbXnFej.js} +2 -2
  23. package/dist/{theming-gUgI75AD.js.map → theming-CZbXnFej.js.map} +1 -1
  24. package/dist/{theming-Cqo-msxF.cjs → theming-b98f6nXs.cjs} +2 -2
  25. package/dist/{theming-Cqo-msxF.cjs.map → theming-b98f6nXs.cjs.map} +1 -1
  26. package/package.json +2 -3
  27. package/src/components/robots/MotionGroupVisualizer.tsx +33 -75
  28. package/dist/MotionGroupVisualizer-C_fyiA-X.cjs +0 -2
  29. package/dist/auth0-spa-js.production.esm-D_IhPirK.cjs +0 -5
  30. package/dist/auth0-spa-js.production.esm-D_IhPirK.cjs.map +0 -1
  31. package/dist/auth0-spa-js.production.esm-mvPojIrB.js.map +0 -1
  32. package/dist/interpolation-6ZZN4S_x.js.map +0 -1
  33. package/dist/interpolation-CyO6DaVa.cjs +0 -20
  34. package/dist/interpolation-CyO6DaVa.cjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandelbots/wandelbots-js-react-components",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -93,7 +93,6 @@
93
93
  "@types/react": "^19.1.8",
94
94
  "@types/three": "^0.182.0",
95
95
  "@vitejs/plugin-react": "^4.3.4",
96
- "@wandelbots/nova-js": "^3.5.3",
97
96
  "add": "^2.0.6",
98
97
  "eslint-plugin-storybook": "^10.1.10",
99
98
  "glob": "^13.0.0",
@@ -176,7 +175,7 @@
176
175
  "dependencies": {
177
176
  "@mui/x-charts": "^8.27.0",
178
177
  "@mui/x-data-grid": "^8.27.0",
179
- "@wandelbots/nova-js": "^3.5.2",
178
+ "@wandelbots/nova-js": "^3.5.4",
180
179
  "axios": "^1.13.2",
181
180
  "dotenv": "^17.2.3",
182
181
  "i18next-browser-languagedetector": "^8.2.0",
@@ -1,6 +1,5 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from "react"
2
- import { NovaClient } from "@wandelbots/nova-js/v2"
3
- import type { KinematicModel } from "@wandelbots/nova-api/v2"
1
+ import React, { useEffect, useMemo, useState } from "react"
2
+ import { JointTypeEnum } from "@wandelbots/nova-js/v2"
4
3
 
5
4
  import { externalizeComponent } from "../../externalizeComponent"
6
5
  import { SupportedRobot, type SupportedRobotProps } from "./SupportedRobot"
@@ -13,101 +12,60 @@ export type MotionGroupVisualizerProps = {
13
12
 
14
13
  export const MotionGroupVisualizer: React.FC<MotionGroupVisualizerProps> = externalizeComponent((props: MotionGroupVisualizerProps) => {
15
14
  const {
16
- instanceUrl,
17
- inverseSolver: inverseSolverProp,
18
- modelFromController,
15
+ inverseSolver,
16
+ dhParameters,
19
17
  ...rest
20
18
  } = props
21
19
 
22
- const [inverseSolver, setInverseSolver] = useState<string | null | undefined>(
23
- inverseSolverProp,
24
- )
25
- const [, forceThreeRerender] = useState<boolean>(false)
26
-
27
20
  /**
28
- * Fetches the kinematic model from the API and saved the inverse_solver property, which defined
29
- * whether the motion group should be displayed as a robot or linear axis
21
+ * Joint type to find out - in combination with inverseSolver - whether the
22
+ * active robot is a turn table
30
23
  */
31
- const fetchKinematicModel = useCallback(async () => {
32
- const nova = new NovaClient({ instanceUrl })
33
-
34
- try {
35
- const kinematicModel: KinematicModel =
36
- await nova.api.motionGroupModels.getMotionGroupKinematicModel(
37
- modelFromController,
38
- )
39
-
40
- setInverseSolver(kinematicModel.inverse_solver)
41
- } catch (err) {
42
- console.warn(
43
- `Failed to fetch kinematic model from API for ${modelFromController}, falling back to local config`,
44
- )
45
- } finally {
46
- /**
47
- * The following is a workaround to force a rerender of the Three.js scene, due
48
- * to a race condition (if the component gets re-initialized, the robot
49
- * is rendered with the initial joint position). The forceThreeRerender tells
50
- * the Three.JS to re-render with the right joint position
51
- *
52
- * TODO remove the three rerender function and get rid of the
53
- * stale state condition
54
- * https://wandelbots.atlassian.net/browse/RB-3134
55
- */
56
- setTimeout(() => forceThreeRerender(true), 0)
57
- }
58
- }, [modelFromController, instanceUrl])
24
+ const [jointType, setJointType] = useState<JointTypeEnum>(JointTypeEnum.RevoluteJoint)
59
25
 
60
26
  /**
61
- * Checks the delivered inverseSolver property from the consumer
62
- * Defined, Null - carry on with the delivered value - the inverseSolver was fetched via consumer app
63
- * Undefined - carry out a request to fetch the inverseSolver value
27
+ * Sets the joint type according to delivered dh parameter type
64
28
  */
65
29
  useEffect(() => {
66
- const shouldKinematicBeFetched =
67
- inverseSolverProp === undefined && !!modelFromController && !!instanceUrl
68
-
69
- if (shouldKinematicBeFetched) {
70
- fetchKinematicModel()
30
+ if (dhParameters.length) {
31
+ setJointType(dhParameters[0].type ?? JointTypeEnum.RevoluteJoint)
71
32
  }
72
- }, [inverseSolverProp, modelFromController, fetchKinematicModel, instanceUrl])
33
+ }, [dhParameters])
73
34
 
74
35
  /**
75
36
  * The turntable models return inverseSolver = null - however these models
76
37
  * should be rendered with SupportedRobot instead of SupportedLinearAxis
77
- *
78
- * TODO
79
- * In the future - this hard coded check would be replaced with a new "type" property
80
- * from dh parameters
81
38
  */
82
39
  const isTurnTable = useMemo(() => {
83
- return [
84
- "KUKA_DKP250",
85
- "KUKA_DKP500_2",
86
- "Yaskawa_TURN1",
87
- "Yaskawa_TURN2",
88
- "Yaskawa_TURN3",
89
- ].some(model => model.toLowerCase() === modelFromController.toLowerCase())
90
- }, [modelFromController])
40
+ return inverseSolver === null && jointType === JointTypeEnum.RevoluteJoint
41
+ }, [inverseSolver, jointType])
42
+
43
+ /**
44
+ * Linear axis check
45
+ */
46
+ const isLinearAxis = useMemo(() => {
47
+ return inverseSolver === null && jointType === JointTypeEnum.PrismaticJoint
48
+ }, [inverseSolver, jointType])
49
+
50
+ /**
51
+ * Robot differentiation for readability reasons
52
+ */
53
+ const isRobot = useMemo(() => {
54
+ return !!inverseSolver
55
+ }, [inverseSolver])
56
+
91
57
 
92
- if (inverseSolver || isTurnTable) {
58
+ if (isRobot || isTurnTable) {
93
59
  return (
94
- <SupportedRobot
95
- instanceUrl={instanceUrl}
96
- modelFromController={modelFromController}
97
- {...rest}
98
- />
60
+ <SupportedRobot dhParameters={dhParameters} {...rest} />
99
61
  )
100
62
  }
101
63
 
102
- if (inverseSolver === null) {
64
+ if(isLinearAxis) {
103
65
  return (
104
- <SupportedLinearAxis
105
- instanceUrl={instanceUrl}
106
- modelFromController={modelFromController}
107
- {...rest}
108
- />
66
+ <SupportedLinearAxis dhParameters={dhParameters} {...rest} />
109
67
  )
110
68
  }
111
69
 
112
- return null
70
+ return <></>
113
71
  })
@@ -1,2 +0,0 @@
1
- "use strict";const t=require("./externalizeComponent-CkVWk2F_.cjs"),g=require("three"),W=require("three-stdlib"),_=require("@react-three/fiber"),M=require("@react-three/drei"),y=require("@mui/material"),ae=require("mobx-react-lite"),f=require("react"),ue=require("react-i18next"),E=require("./interpolation-CyO6DaVa.cjs"),$=require("react-error-boundary");function ce(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const j=ce(g);function le(e){switch(e.shape_type){case"convex_hull":return new W.ConvexGeometry(e.vertices.map(r=>new j.Vector3(r[0]/1e3,r[1]/1e3,r[2]/1e3)));case"box":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new j.SphereGeometry(e.radius/1e3);case"capsule":return new j.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new j.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new j.BufferGeometry}}function xe({name:e,collider:n,children:r}){var l,a;const s=((l=n.pose)==null?void 0:l.position)??[0,0,0],o=((a=n.pose)==null?void 0:a.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),t.jsxRuntimeExports.jsx("mesh",{name:e,position:new j.Vector3(s[0],s[1],s[2]).divideScalar(1e3),rotation:new j.Euler(o[0],o[1],o[2],"XYZ"),geometry:le(n.shape),children:r})}function me({name:e,colliders:n,meshChildrenProvider:r,...s}){return t.jsxRuntimeExports.jsx("group",{name:e,...s,children:Object.entries(n).map(([o,l])=>t.jsxRuntimeExports.jsx(xe,{name:o,collider:l,children:r(o,l)},o))})}function pe({scene:e,meshChildrenProvider:n}){const r=e.colliders;return t.jsxRuntimeExports.jsx("group",{children:r&&t.jsxRuntimeExports.jsx(me,{meshChildrenProvider:n,colliders:r})})}function A(){return t.jsxRuntimeExports.jsx(M.Environment,{children:t.jsxRuntimeExports.jsx(fe,{})})}function fe({positions:e=[2,0,2,0,2,0,2,0]}){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(M.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),t.jsxRuntimeExports.jsx("group",{rotation:[0,.5,0],children:t.jsxRuntimeExports.jsx("group",{children:e.map((n,r)=>t.jsxRuntimeExports.jsx(M.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,r*4],scale:[3,1,1]},r))})}),t.jsxRuntimeExports.jsx(M.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),t.jsxRuntimeExports.jsx(M.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),t.jsxRuntimeExports.jsx(M.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),t.jsxRuntimeExports.jsx(M.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),t.jsxRuntimeExports.jsx(M.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}function de(e){if(e.length<3)return console.log("Not enough vertices to define a plane"),{isCoplanar:!1};const n=new j.Vector3(e[0].x,e[0].y,e[0].z),r=new j.Vector3(e[1].x,e[1].y,e[1].z),s=new j.Vector3(e[2].x,e[2].y,e[2].z),o=new j.Vector3().subVectors(r,n),l=new j.Vector3().subVectors(s,n),a=new j.Vector3().crossVectors(o,l).normalize();for(let x=3;x<e.length;x++){const u=new j.Vector3(e[x].x,e[x].y,e[x].z),m=new j.Vector3().subVectors(u,n),p=a.dot(m);if(Math.abs(p)>1e-6)return console.log("Vertices are not on the same plane"),{isCoplanar:!1}}return{isCoplanar:!0,normal:a}}function he({safetyZones:e,...n}){return t.jsxRuntimeExports.jsx("group",{...n,children:e.map((r,s)=>{let o=[];return r.geometry&&(r.geometry.compound?o=r.geometry.compound.child_geometries:r.geometry.convex_hull&&(o=[r.geometry])),o.map((l,a)=>{if(!l.convex_hull)return null;const x=l.convex_hull.vertices.map(p=>new j.Vector3(p.x/1e3,p.y/1e3,p.z/1e3)),u=de(x);if(u.isCoplanar&&u.normal){const i=new j.Vector3().addVectors(x[0],u.normal.multiplyScalar(1e-4));x.push(i)}let m;try{m=new W.ConvexGeometry(x)}catch(p){return console.log("Error creating ConvexGeometry:",p),null}return t.jsxRuntimeExports.jsx("mesh",{geometry:m,children:t.jsxRuntimeExports.jsx("meshStandardMaterial",{attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-a},s)},`${s}-${a}`)})})})}function je({trajectory:e,...n}){var s;const r=((s=e.trajectory)==null?void 0:s.map(o=>o.tcp_pose?new j.Vector3(o.tcp_pose.position.x/1e3,o.tcp_pose.position.z/1e3,-o.tcp_pose.position.y/1e3):null).filter(o=>o!==null))||[];return t.jsxRuntimeExports.jsx("group",{...n,children:r.length>0&&t.jsxRuntimeExports.jsx(M.Line,{points:r,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const F=new Map;async function S(e,n){if(F.has(e))return F.get(e);const r=(async()=>{var a;const s=n||"",o=new E.NovaClient({instanceUrl:s}),l=o.api.motionGroupModels;(a=l.axios)!=null&&a.interceptors&&l.axios.interceptors.request.use(x=>{var u;return(u=x.url)!=null&&u.includes("/glb")&&(x.responseType="blob"),x});try{const x=await o.api.motionGroupModels.getMotionGroupGlbModel(e);return URL.createObjectURL(x)}catch(x){throw console.error("Failed to fetch model:",x),x}})();return F.set(e,r),r}function H(e){function n(r){return r.children.length===0?[r]:[r,...r.children.flatMap(s=>n(s))]}return n(e).filter(r=>K(r))}function J(e){return e.name.endsWith("_FLG")}function K(e){return/_J[0-9]+$/.test(e.name)}function Re(e,n){let r;function s(o){if(J(o)){if(r)throw Error(`Found multiple flange groups in robot model ${n}; first ${r.name} then ${o.name}. Only one _FLG group is allowed.`);r=o}K(o),o.children.map(s)}if(s(e.scene),!r)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}function Y({rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:r,children:s}){const o=f.useRef([]),l=f.useRef([]),a=f.useRef(null),{invalidate:x}=_.useThree();f.useEffect(()=>{const i=e.joint_position.filter(c=>c!==void 0);return a.current=new E.ValueInterpolator(i,{tension:120,friction:20,threshold:.001}),()=>{var c;(c=a.current)==null||c.destroy()}},[]),_.useFrame((i,c)=>{if(a.current){const d=a.current.update(c);m(),d||x()}});function u(i){i&&(l.current=H(i),m(),x())}function m(){var c;const i=((c=a.current)==null?void 0:c.getCurrentValues())||[];if(r)r(l.current,i);else for(const[d,R]of l.current.entries()){const h=n[d],b=h.theta||0,w=h.reverse_rotation_direction?-1:1;R.rotation.y=w*(i[d]||0)+b}}const p=f.useCallback(()=>{const i=e.joint_position.filter(c=>c!==void 0);requestAnimationFrame(()=>{var c;o.current=i,(c=a.current)==null||c.setTarget(i)})},[e]);return f.useEffect(()=>{p()},[e,p]),E.useAutorun(()=>{p()}),t.jsxRuntimeExports.jsx("group",{ref:u,children:s})}const ge="line",ye="mesh";function Ee({rapidlyChangingMotionState:e,dhParameters:n,...r}){const s=new g.Matrix4,o=f.useRef([]),l=f.useRef([]);f.useEffect(()=>{o.current=new Array(n.length).fill(null),l.current=new Array(n.length).fill(null)},[n.length]);function a(m,p){const i=new g.Vector3,c=new g.Quaternion,d=new g.Vector3;s.decompose(i,c,d);const R=i.clone(),h=new g.Matrix4().makeRotationY(m.theta+p*(m.reverse_rotation_direction?-1:1)).multiply(new g.Matrix4().makeTranslation(0,m.d/1e3,0)).multiply(new g.Matrix4().makeTranslation(m.a/1e3,0,0)).multiply(new g.Matrix4().makeRotationX(m.alpha));return s.multiply(h),s.decompose(i,c,d),{a:R,b:i}}function x(m,p,i,c){if(!n)return;const d=n[m];if(!d)return;const{a:R,b:h}=a(d,c);p.geometry.setPositions([R.toArray(),h.toArray()].flat()),i.position.set(h.x,h.y,h.z)}function u(m,p){s.identity();for(let i=0;i<Math.min(m.length,p.length);i++){const c=o.current[i],d=l.current[i];c&&d&&x(i,c,d,p[i])}}return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(Y,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:u,children:t.jsxRuntimeExports.jsxs("group",{...r,name:"Scene",children:[t.jsxRuntimeExports.jsxs("mesh",{children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n.map((m,p)=>{const{a:i,b:c}=a(m,e.joint_position[p]??0),d=`dhrobot_J0${p}`;return t.jsxRuntimeExports.jsxs("group",{name:d,children:[t.jsxRuntimeExports.jsx(M.Line,{ref:R=>{o.current[p]=R},name:ge,points:[i,c],color:"white",lineWidth:5}),t.jsxRuntimeExports.jsxs("mesh",{ref:R=>{l.current[p]=R},name:ye,position:c,children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},"mesh_"+p)]},d)})]})})})}const we=console.warn;function X(){return f.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&we(e)}},[]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{})}function be(e){return e.type==="Mesh"}function Me({url:e,flangeRef:n,postModelRender:r,...s}){const o=M.useGLTF(e);let l;try{l=Re(o,"robot.glb").gltf}catch(u){throw u}const a=f.useCallback(u=>{u&&r&&r()},[r]);function x(u){try{return be(u)?u.geometry?t.jsxRuntimeExports.jsx("mesh",{name:u.name,geometry:u.geometry,material:u.material,position:u.position,rotation:u.rotation},u.uuid):t.jsxRuntimeExports.jsx("group",{name:u.name,position:u.position,rotation:u.rotation},u.uuid):t.jsxRuntimeExports.jsx("group",{name:u.name,position:u.position,rotation:u.rotation,ref:J(u)?n:void 0,children:u.children.map(x)},u.uuid)}catch(m){return console.warn("Error rendering node",u.name,m),null}}return t.jsxRuntimeExports.jsx("group",{...s,dispose:null,ref:a,children:x(l.scene)})}function Q({modelURL:e,flangeRef:n,postModelRender:r,...s}){const[o,l]=f.useState(null);return f.useEffect(()=>{(async()=>{try{if(typeof e=="string")l(e);else{const x=await e;l(x)}}catch(x){console.error("Failed to resolve model URL:",x)}})()},[e]),o?t.jsxRuntimeExports.jsx(Me,{url:o,flangeRef:n,postModelRender:r,...s}):null}const Z=(e,n)=>{e.userData.isGhost||(e.traverse(r=>{if(r instanceof j.Mesh){r.material instanceof j.Material&&(r.material.colorWrite=!1);const s=r.clone(),o=r.clone();s.material=new j.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:j.DoubleSide}),s.userData.isGhost=!0,o.material=new j.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:j.DoubleSide}),o.userData.isGhost=!0,r.parent&&(r.parent.add(s),r.parent.add(o))}}),e.userData.isGhost=!0)},ee=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(r=>{var s;r instanceof j.Mesh&&((s=r.userData)!=null&&s.isGhost?n.push(r):r.material instanceof j.Material&&(r.material.colorWrite=!0))}),n.forEach(r=>{r.parent&&r.parent.remove(r)}),e.userData.isGhost=!1},I=t.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:s=S,flangeRef:o,postModelRender:l,transparentColor:a,instanceUrl:x,...u})=>{const[m,p]=f.useState(null),i=f.useCallback(d=>{p(d)},[]);f.useEffect(()=>{m&&(a?Z(m,a):ee(m))},[m,a]);const c=t.jsxRuntimeExports.jsx(Ee,{rapidlyChangingMotionState:e,dhParameters:r,...u});return t.jsxRuntimeExports.jsxs($.ErrorBoundary,{fallback:c,onError:d=>{console.warn(d)},children:[t.jsxRuntimeExports.jsx(f.Suspense,{fallback:c,children:t.jsxRuntimeExports.jsx("group",{ref:i,children:t.jsxRuntimeExports.jsx(Y,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsxRuntimeExports.jsx(Q,{modelURL:(()=>{const d=s(n,x);if(!d){const R=new Blob([],{type:"model/gltf-binary"}),h=new File([R],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(h))}return d})(),postModelRender:l,flangeRef:o,...u})})})}),t.jsxRuntimeExports.jsx(X,{})]})});function te({connectedMotionGroup:e,getModel:n=S,flangeRef:r,transparentColor:s,postModelRender:o,...l}){return e.dhParameters?t.jsxRuntimeExports.jsx(I,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:s,postModelRender:o,...l}):null}const ve=t.externalizeComponent(ae.observer(({robotName:e,programState:n,safetyState:r,operationMode:s,driveToHomeEnabled:o=!1,onDriveToHomePress:l,onDriveToHomeRelease:a,connectedMotionGroup:x,robotComponent:u=te,customContentComponent:m,className:p})=>{var z;const i=y.useTheme(),{t:c}=ue.useTranslation(),[d,R]=f.useState(!1),h=f.useRef(null),b=f.useRef(null),[w,G]=f.useState(!1),[k,oe]=f.useState({width:400,height:600}),[Le,ie]=f.useState(0);f.useEffect(()=>{const V=()=>{if(b.current){const{offsetWidth:q,offsetHeight:N}=b.current;G(q>N),oe({width:q,height:N})}};V();const O=new ResizeObserver(V);return b.current&&O.observe(b.current),()=>{O.disconnect()}},[]);const D=f.useCallback(()=>{ie(V=>V+1)},[]),C=f.useCallback(()=>{!o||!l||(R(!0),l())},[o,l]),L=f.useCallback(()=>{!o||!a||(R(!1),a())},[o,a]),U=f.useCallback(()=>{d&&a&&(R(!1),a())},[d,a]),v=w?k.width<350:k.height<200,T=w?k.height<310:k.height<450;return t.jsxRuntimeExports.jsx(y.Card,{ref:b,className:p,sx:{width:"100%",height:"100%",display:"flex",flexDirection:w?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:w?{xs:200,sm:240,md:260}:{xs:150,sm:180,md:220},border:`1px solid ${i.palette.divider}`,borderRadius:"18px",boxShadow:"none",backgroundColor:((z=i.palette.backgroundPaperElevation)==null?void 0:z[8])||"#2A2A3F",backgroundImage:"none"},children:w?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(y.Box,{sx:{flex:"0 0 50%",position:"relative",height:"100%",minHeight:"100%",maxHeight:"100%",borderRadius:1,m:{xs:1.5,sm:2,md:3},mr:{xs:.75,sm:1,md:1.5},overflow:"hidden",display:v?"none":"block"},children:!v&&t.jsxRuntimeExports.jsxs(_.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:i.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute",top:0,left:0},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsxRuntimeExports.jsx(A,{}),t.jsxRuntimeExports.jsx(M.Bounds,{fit:!0,observe:!0,margin:1,maxDuration:1,children:t.jsxRuntimeExports.jsx(u,{connectedMotionGroup:x,postModelRender:D})})]})}),t.jsxRuntimeExports.jsxs(y.Box,{sx:{flex:"1",display:"flex",flexDirection:"column",justifyContent:"flex-start",width:v?"100%":"50%"},children:[t.jsxRuntimeExports.jsxs(y.Box,{sx:{p:{xs:1.5,sm:2,md:3},pb:{xs:1,sm:1.5,md:2},textAlign:"left"},children:[t.jsxRuntimeExports.jsx(y.Typography,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsxRuntimeExports.jsx(E.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:s})]}),t.jsxRuntimeExports.jsxs(y.Box,{sx:{p:{xs:1.5,sm:2,md:3},pt:0,flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[!T&&m&&t.jsxRuntimeExports.jsxs(y.Box,{children:[t.jsxRuntimeExports.jsx(m,{}),t.jsxRuntimeExports.jsx(y.Divider,{sx:{mt:1,mb:0,borderColor:i.palette.divider,opacity:.5}})]}),t.jsxRuntimeExports.jsx(y.Box,{sx:{mt:!T&&m?"auto":0},children:t.jsxRuntimeExports.jsx(y.Box,{sx:{display:"flex",justifyContent:"flex-start",mt:{xs:1,sm:1.5,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsxRuntimeExports.jsx(y.Button,{ref:h,variant:"contained",color:"secondary",size:"small",disabled:!o,onMouseDown:C,onMouseUp:L,onMouseLeave:U,onTouchStart:C,onTouchEnd:L,sx:{textTransform:"none",px:1.5,py:.5},children:c("RobotCard.DriveToHome.bt")})})})]})]})]}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs(y.Box,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxRuntimeExports.jsxs(y.Box,{children:[t.jsxRuntimeExports.jsx(y.Typography,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsxRuntimeExports.jsx(E.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:s})]}),t.jsxRuntimeExports.jsx(y.Box,{sx:{flex:v?0:1,position:"relative",minHeight:v?0:{xs:120,sm:150,md:200},height:v?0:"auto",borderRadius:1,overflow:"hidden",display:v?"none":"block"},children:!v&&t.jsxRuntimeExports.jsxs(_.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:i.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute"},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsxRuntimeExports.jsx(A,{}),t.jsxRuntimeExports.jsx(M.Bounds,{fit:!0,clip:!0,observe:!0,margin:1,maxDuration:1,children:t.jsxRuntimeExports.jsx(u,{connectedMotionGroup:x,postModelRender:D})})]})}),t.jsxRuntimeExports.jsxs(y.Box,{children:[!T&&m&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(m,{}),t.jsxRuntimeExports.jsx(y.Divider,{sx:{mt:1,mb:0,borderColor:i.palette.divider,opacity:.5}})]}),t.jsxRuntimeExports.jsx(y.Box,{sx:{display:"flex",justifyContent:"flex-start",mt:!T&&m?{xs:1,sm:2,md:5}:{xs:.5,sm:1,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsxRuntimeExports.jsx(y.Button,{ref:h,variant:"contained",color:"secondary",size:"small",disabled:!o,onMouseDown:C,onMouseUp:L,onMouseLeave:U,onTouchStart:C,onTouchEnd:L,sx:{textTransform:"none",px:1.5,py:.5},children:c("RobotCard.DriveToHome.bt")})})]})]})})})})),_e=Array(6).fill(2*Math.PI);function re({rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:r,children:s}){const o=f.useRef([]),l=f.useRef([]),a=f.useRef(null),{invalidate:x}=_.useThree();f.useEffect(()=>{const i=e.joint_position.filter(c=>c!==void 0);return a.current=new E.ValueInterpolator(i,{tension:120,friction:20,threshold:.001}),()=>{var c;(c=a.current)==null||c.destroy()}},[]),_.useFrame((i,c)=>{if(a.current){const d=a.current.update(c);m(),d||x()}});function u(i){i&&(l.current=H(i),m(),x())}function m(){var c;const i=((c=a.current)==null?void 0:c.getCurrentValues())||[];if(r)r(l.current,i);else for(const[d,R]of l.current.entries()){const b=n[d].reverse_rotation_direction?-1:1;R.position.y=b*(i[d]||0)/1e3}}const p=f.useCallback(()=>{const i=e.joint_position.filter(c=>c!==void 0);requestAnimationFrame(()=>{var c;o.current=i,(c=a.current)==null||c.setTarget(i)})},[e]);return f.useEffect(()=>{p()},[e,p]),E.useAutorun(()=>{p()}),t.jsxRuntimeExports.jsx("group",{ref:u,children:s})}function ne({rapidlyChangingMotionState:e,dhParameters:n,...r}){const s=new g.Matrix4,o=f.useRef(null),l=f.useRef(null);function a(m){const p=new g.Matrix4;for(let R=0;R<n.length;R++){const h=n[R],b=m[R]??0,w=new g.Matrix4().makeRotationY(h.theta).multiply(new g.Matrix4().makeTranslation(h.a/1e3,(h.d+b*(h.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(h.alpha));p.multiply(w)}const i=new g.Vector3,c=new g.Quaternion,d=new g.Vector3;return p.decompose(i,c,d),i}const x=a(e.joint_position);function u(m,p){s.identity();let i=new g.Vector3;for(let h=0;h<n.length;h++){const b=p[h]??0,w=n[h],G=new g.Matrix4().makeRotationY(w.theta).multiply(new g.Matrix4().makeTranslation(w.a/1e3,(w.d+b*(w.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(w.alpha));s.multiply(G)}const c=new g.Vector3,d=new g.Quaternion,R=new g.Vector3;if(s.decompose(c,d,R),i=c,o.current&&o.current.position.set(i.x,i.y,i.z),l.current){const h=l.current.geometry;h&&h.setPositions&&h.setPositions([0,0,0,i.x,i.y,i.z])}}return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsx(re,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:u,children:t.jsxRuntimeExports.jsxs("group",{...r,name:"Scene",children:[t.jsxRuntimeExports.jsxs("mesh",{name:"Base",position:[0,0,0],children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.02,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),t.jsxRuntimeExports.jsx(M.Line,{ref:l,points:[new g.Vector3(0,0,0),x],color:"White",lineWidth:5}),t.jsxRuntimeExports.jsxs("mesh",{ref:o,name:"TCP",position:x,children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.025,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})})}const B=t.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:s=S,flangeRef:o,postModelRender:l,transparentColor:a,instanceUrl:x,...u})=>{const[m,p]=f.useState(null),i=f.useCallback(d=>{p(d)},[]);f.useEffect(()=>{m&&(a?Z(m,a):ee(m))},[m,a]);const c=t.jsxRuntimeExports.jsx(ne,{rapidlyChangingMotionState:e,dhParameters:r,...u});return t.jsxRuntimeExports.jsxs($.ErrorBoundary,{fallback:c,onError:d=>{console.warn(d)},children:[t.jsxRuntimeExports.jsx(f.Suspense,{fallback:c,children:t.jsxRuntimeExports.jsx("group",{ref:i,children:t.jsxRuntimeExports.jsx(re,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsxRuntimeExports.jsx(Q,{modelURL:(()=>{const d=s(n,x);if(!d){const R=new Blob([],{type:"model/gltf-binary"}),h=new File([R],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(h))}return d})(),postModelRender:l,flangeRef:o,...u})})})}),t.jsxRuntimeExports.jsx(X,{})]})});function Se({connectedMotionGroup:e,getModel:n=S,flangeRef:r,transparentColor:s,postModelRender:o,...l}){if(!e.dhParameters)return null;const a=e.modelFromController||"";return a&&n(a)?t.jsxRuntimeExports.jsx(B,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:a,dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:s,postModelRender:o,...l}):t.jsxRuntimeExports.jsx(ne,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,...l})}const P={[E.Manufacturer.Abb]:[0,0,0,0,Math.PI/2,0,0],[E.Manufacturer.Fanuc]:[0,0,0,0,-Math.PI/2,0,0],[E.Manufacturer.Yaskawa]:[0,0,0,0,-Math.PI/2,0,0],[E.Manufacturer.Kuka]:[0,-Math.PI/2,Math.PI/2,0,Math.PI/2,0,0],[E.Manufacturer.Universalrobots]:[0,-Math.PI/2,-Math.PI/2,-Math.PI/2,Math.PI/2,-Math.PI/2,0]};function se(e){const[n]=e.split("_");switch(n){case"ABB":return E.Manufacturer.Abb;case"FANUC":return E.Manufacturer.Fanuc;case"YASKAWA":return E.Manufacturer.Yaskawa;case"KUKA":return E.Manufacturer.Kuka;case"UniversalRobots":return E.Manufacturer.Universalrobots;default:return null}}function ke(e,n){const r=se(e);return r&&r in P?P[r]:n||null}const Ce=t.externalizeComponent(e=>{const{instanceUrl:n,inverseSolver:r,modelFromController:s,...o}=e,[l,a]=f.useState(r),[,x]=f.useState(!1),u=f.useCallback(async()=>{const p=new E.NovaClient({instanceUrl:n});try{const i=await p.api.motionGroupModels.getMotionGroupKinematicModel(s);a(i.inverse_solver)}catch{console.warn(`Failed to fetch kinematic model from API for ${s}, falling back to local config`)}finally{setTimeout(()=>x(!0),0)}},[s,n]);f.useEffect(()=>{r===void 0&&!!s&&!!n&&u()},[r,s,u,n]);const m=f.useMemo(()=>["KUKA_DKP250","KUKA_DKP500_2","Yaskawa_TURN1","Yaskawa_TURN2","Yaskawa_TURN3"].some(p=>p.toLowerCase()===s.toLowerCase()),[s]);return l||m?t.jsxRuntimeExports.jsx(I,{instanceUrl:n,modelFromController:s,...o}):l===null?t.jsxRuntimeExports.jsx(B,{instanceUrl:n,modelFromController:s,...o}):null});exports.CollisionSceneRenderer=pe;exports.LinearAxis=Se;exports.MANUFACTURER_HOME_CONFIGS=P;exports.MotionGroupVisualizer=Ce;exports.PresetEnvironment=A;exports.Robot=te;exports.RobotCard=ve;exports.SafetyZonesRenderer=he;exports.SupportedLinearAxis=B;exports.SupportedRobot=I;exports.TrajectoryRenderer=je;exports.defaultAxisConfig=_e;exports.defaultGetModel=S;exports.extractManufacturer=se;exports.getDefaultHomeConfig=ke;
2
- //# sourceMappingURL=MotionGroupVisualizer-C_fyiA-X.cjs.map