@wandelbots/wandelbots-js-react-components 4.2.0 → 4.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/README.md +1 -1
- package/dist/3d.cjs.js +1 -1
- package/dist/3d.es.js +1 -1
- package/dist/{MotionGroupVisualizer-CrLamHYm.js → MotionGroupVisualizer-BgvrTXeT.js} +93 -93
- package/dist/{MotionGroupVisualizer-CrLamHYm.js.map → MotionGroupVisualizer-BgvrTXeT.js.map} +1 -1
- package/dist/{MotionGroupVisualizer-C3CB-L2z.cjs → MotionGroupVisualizer-C_fyiA-X.cjs} +2 -2
- package/dist/{MotionGroupVisualizer-C3CB-L2z.cjs.map → MotionGroupVisualizer-C_fyiA-X.cjs.map} +1 -1
- package/dist/components/jogging/JoggingJointTab.d.ts +1 -1
- package/dist/components/jogging/JoggingJointTab.d.ts.map +1 -1
- package/dist/components/jogging/JoggingJointValueControl.d.ts +16 -0
- package/dist/components/jogging/JoggingJointValueControl.d.ts.map +1 -0
- package/dist/components/jogging/JoggingStore.d.ts +17 -19
- package/dist/components/jogging/JoggingStore.d.ts.map +1 -1
- package/dist/core.cjs.js +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.es.js +8 -8
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +10 -10
- package/dist/{interpolation-Cs2pC1zE.js → interpolation-6ZZN4S_x.js} +2 -2
- package/dist/{interpolation-Cs2pC1zE.js.map → interpolation-6ZZN4S_x.js.map} +1 -1
- package/dist/{interpolation-C5OTEwAm.cjs → interpolation-CyO6DaVa.cjs} +2 -2
- package/dist/{interpolation-C5OTEwAm.cjs.map → interpolation-CyO6DaVa.cjs.map} +1 -1
- package/dist/lib/JoggerConnection.d.ts +4 -3
- package/dist/lib/JoggerConnection.d.ts.map +1 -1
- package/dist/{theming-Dk07SE2_.cjs → theming-Cqo-msxF.cjs} +36 -36
- package/dist/theming-Cqo-msxF.cjs.map +1 -0
- package/dist/{theming-C-zvh022.js → theming-gUgI75AD.js} +2915 -2891
- package/dist/theming-gUgI75AD.js.map +1 -0
- package/package.json +2 -2
- package/src/components/jogging/JoggingJointTab.tsx +18 -18
- package/src/components/jogging/{JoggingJointRotationControl.tsx → JoggingJointValueControl.tsx} +51 -28
- package/src/components/jogging/JoggingPanel.tsx +1 -1
- package/src/components/jogging/JoggingStore.ts +42 -12
- package/src/components/robots/MotionGroupVisualizer.tsx +4 -4
- package/src/core.ts +2 -1
- package/src/lib/JoggerConnection.test.ts +4 -2
- package/src/lib/JoggerConnection.ts +8 -4
- package/dist/components/jogging/JoggingJointRotationControl.d.ts +0 -15
- package/dist/components/jogging/JoggingJointRotationControl.d.ts.map +0 -1
- package/dist/theming-C-zvh022.js.map +0 -1
- package/dist/theming-Dk07SE2_.cjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const t=require("./externalizeComponent-CkVWk2F_.cjs"),g=require("three"),K=require("three-stdlib"),_=require("@react-three/fiber"),M=require("@react-three/drei"),y=require("@mui/material"),ae=require("mobx-react-lite"),p=require("react"),ue=require("react-i18next"),E=require("./interpolation-C5OTEwAm.cjs"),N=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 K.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 F(){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),f=a.dot(m);if(Math.abs(f)>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(f=>new j.Vector3(f.x/1e3,f.y/1e3,f.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 K.ConvexGeometry(x)}catch(f){return console.log("Error creating ConvexGeometry:",f),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 G=new Map;async function S(e,n){if(G.has(e))return G.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 G.set(e,r),r}function $(e){function n(r){return r.children.length===0?[r]:[r,...r.children.flatMap(s=>n(s))]}return n(e).filter(r=>J(r))}function H(e){return e.name.endsWith("_FLG")}function J(e){return/_J[0-9]+$/.test(e.name)}function Re(e,n){let r;function s(o){if(H(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}J(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=p.useRef([]),l=p.useRef([]),a=p.useRef(null),{invalidate:x}=_.useThree();p.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=$(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],w=h.theta||0,b=h.reverse_rotation_direction?-1:1;R.rotation.y=b*(i[d]||0)+w}}const f=p.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 p.useEffect(()=>{f()},[e,f]),E.useAutorun(()=>{f()}),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=p.useRef([]),l=p.useRef([]);p.useEffect(()=>{o.current=new Array(n.length).fill(null),l.current=new Array(n.length).fill(null)},[n.length]);function a(m,f){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+f*(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,f,i,c){if(!n)return;const d=n[m];if(!d)return;const{a:R,b:h}=a(d,c);f.geometry.setPositions([R.toArray(),h.toArray()].flat()),i.position.set(h.x,h.y,h.z)}function u(m,f){s.identity();for(let i=0;i<Math.min(m.length,f.length);i++){const c=o.current[i],d=l.current[i];c&&d&&x(i,c,d,f[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,f)=>{const{a:i,b:c}=a(m,e.joint_position[f]??0),d=`dhrobot_J0${f}`;return t.jsxRuntimeExports.jsxs("group",{name:d,children:[t.jsxRuntimeExports.jsx(M.Line,{ref:R=>{o.current[f]=R},name:ge,points:[i,c],color:"white",lineWidth:5}),t.jsxRuntimeExports.jsxs("mesh",{ref:R=>{l.current[f]=R},name:ye,position:c,children:[t.jsxRuntimeExports.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsxRuntimeExports.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},"mesh_"+f)]},d)})]})})})}const be=console.warn;function X(){return p.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&be(e)}},[]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{})}function we(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=p.useCallback(u=>{u&&r&&r()},[r]);function x(u){try{return we(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:H(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]=p.useState(null);return p.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,f]=p.useState(null),i=p.useCallback(d=>{f(d)},[]);p.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(N.ErrorBoundary,{fallback:c,onError:d=>{console.warn(d)},children:[t.jsxRuntimeExports.jsx(p.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:f})=>{var z;const i=y.useTheme(),{t:c}=ue.useTranslation(),[d,R]=p.useState(!1),h=p.useRef(null),w=p.useRef(null),[b,V]=p.useState(!1),[A,oe]=p.useState({width:400,height:600}),[Te,ie]=p.useState(0);p.useEffect(()=>{const L=()=>{if(w.current){const{offsetWidth:W,offsetHeight:q}=w.current;V(W>q),oe({width:W,height:q})}};L();const O=new ResizeObserver(L);return w.current&&O.observe(w.current),()=>{O.disconnect()}},[]);const D=p.useCallback(()=>{ie(L=>L+1)},[]),C=p.useCallback(()=>{!o||!l||(R(!0),l())},[o,l]),T=p.useCallback(()=>{!o||!a||(R(!1),a())},[o,a]),U=p.useCallback(()=>{d&&a&&(R(!1),a())},[d,a]),v=b?A.width<350:A.height<200,k=b?A.height<310:A.height<450;return t.jsxRuntimeExports.jsx(y.Card,{ref:w,className:f,sx:{width:"100%",height:"100%",display:"flex",flexDirection:b?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:b?{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:b?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(F,{}),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:[!k&&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:!k&&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:T,onMouseLeave:U,onTouchStart:C,onTouchEnd:T,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(F,{}),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:[!k&&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:!k&&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:T,onMouseLeave:U,onTouchStart:C,onTouchEnd:T,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=p.useRef([]),l=p.useRef([]),a=p.useRef(null),{invalidate:x}=_.useThree();p.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=$(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 w=n[d].reverse_rotation_direction?-1:1;R.position.y=w*(i[d]||0)/1e3}}const f=p.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 p.useEffect(()=>{f()},[e,f]),E.useAutorun(()=>{f()}),t.jsxRuntimeExports.jsx("group",{ref:u,children:s})}function ne({rapidlyChangingMotionState:e,dhParameters:n,...r}){const s=new g.Matrix4,o=p.useRef(null),l=p.useRef(null);function a(m){const f=new g.Matrix4;for(let R=0;R<n.length;R++){const h=n[R],w=m[R]??0,b=new g.Matrix4().makeRotationY(h.theta).multiply(new g.Matrix4().makeTranslation(h.a/1e3,(h.d+w*(h.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(h.alpha));f.multiply(b)}const i=new g.Vector3,c=new g.Quaternion,d=new g.Vector3;return f.decompose(i,c,d),i}const x=a(e.joint_position);function u(m,f){s.identity();let i=new g.Vector3;for(let h=0;h<n.length;h++){const w=f[h]??0,b=n[h],V=new g.Matrix4().makeRotationY(b.theta).multiply(new g.Matrix4().makeTranslation(b.a/1e3,(b.d+w*(b.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(b.alpha));s.multiply(V)}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,f]=p.useState(null),i=p.useCallback(d=>{f(d)},[]);p.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(N.ErrorBoundary,{fallback:c,onError:d=>{console.warn(d)},children:[t.jsxRuntimeExports.jsx(p.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 Ae(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]=p.useState(r),[,x]=p.useState(!1),u=p.useCallback(async()=>{const f=new E.NovaClient({instanceUrl:n});try{const i=await f.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]);p.useEffect(()=>{r===void 0&&!!s&&!!n&&u()},[r,s,u,n]);const m=p.useMemo(()=>["KUKA_DKP250","KUKA_DKP500_2","YASKAWA_TURN1","YASKAWA_TURN2","YASKAWA_TURN3"].includes(s),[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=F;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=Ae;
|
|
2
|
-
//# sourceMappingURL=MotionGroupVisualizer-
|
|
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
|