@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.bd2ec84 → 6.4.0-pr.revamp.667.ca77f09
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 +172 -40
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +3 -4
- package/dist/3d.js +35 -38
- package/dist/CurrentPose/index.cjs +1 -1
- package/dist/CurrentPose/index.js +2 -2
- package/dist/CurrentPoseBar/index.cjs +1 -1
- package/dist/CurrentPoseBar/index.js +1 -1
- package/dist/JoggingButtons/index.cjs +1 -1
- package/dist/JoggingButtons/index.js +1 -1
- package/dist/JoggingGizmo/index.cjs +1 -1
- package/dist/JoggingGizmo/index.js +2 -2
- package/dist/JoggingJointSlider/index.cjs +1 -1
- package/dist/JoggingJointSlider/index.js +1 -1
- package/dist/RobotControl/index.cjs +1 -1
- package/dist/RobotControl/index.js +2 -2
- package/dist/RobotControlPanel/index.cjs +1 -1
- package/dist/RobotControlPanel/index.d.ts +1 -1
- package/dist/RobotControlPanel/index.js +1 -1
- package/dist/RobotHeader/index.cjs +1 -1
- package/dist/RobotHeader/index.d.ts +3 -5
- package/dist/RobotHeader/index.js +6 -7
- package/dist/RobotScene/index.cjs +1 -1
- package/dist/RobotScene/index.js +3 -3
- package/dist/RobotView/index.cjs +1 -1
- package/dist/RobotView/index.js +2 -2
- package/dist/SafetyBar/IndicatorWithExplanation.d.ts +12 -1
- package/dist/SafetyBar/SafetyBar.d.ts +15 -1
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.d.ts +0 -1
- package/dist/SafetyBar/index.js +3 -4
- package/dist/SafetyBar/robotSafetyOf.d.ts +1 -0
- package/dist/chunks/{ConnectedMotionGroup-BifrgwV1.js → ConnectedMotionGroup-DNYakgxy.js} +6 -5
- package/dist/chunks/ConnectedMotionGroup-IRTsTxwB.cjs +3 -0
- package/dist/chunks/{CurrentPose-CMqO8oqX.cjs → CurrentPose-CAq9e9JY.cjs} +1 -1
- package/dist/chunks/{CurrentPose-CdD2ZB7B.js → CurrentPose-CgdINEh2.js} +3 -3
- package/dist/chunks/{CurrentPoseBar-CX1xFBtm.js → CurrentPoseBar--HkZBGnN.js} +11 -11
- package/dist/chunks/{CurrentPoseBar-BTBAwIO4.cjs → CurrentPoseBar-DoOUfRRs.cjs} +1 -1
- package/dist/chunks/{JoggingButtons-aijK-3g6.js → JoggingButtons-BNOnpcTH.js} +1 -1
- package/dist/chunks/{JoggingButtons-BOHl7hVq.cjs → JoggingButtons-Boaym2hQ.cjs} +1 -1
- package/dist/chunks/{JoggingGizmo-CoKYUtXq.cjs → JoggingGizmo-CNFjpWDv.cjs} +1 -1
- package/dist/chunks/{JoggingGizmo-DHvrJouR.js → JoggingGizmo-RDiEVQes.js} +1 -1
- package/dist/chunks/{JoggingGizmoOrientation-CIvIAIeO.js → JoggingGizmoOrientation-Dzzz2gEz.js} +1 -1
- package/dist/chunks/{JoggingGizmoOrientation-DVcagPRJ.cjs → JoggingGizmoOrientation-laUrgY0N.cjs} +1 -1
- package/dist/chunks/{JoggingJointSlider-DQtt4-pa.js → JoggingJointSlider-BY-Tof8G.js} +1 -1
- package/dist/chunks/{JoggingJointSlider-CTFYKzsU.cjs → JoggingJointSlider-Dm3vILd3.cjs} +1 -1
- package/dist/chunks/{JoggingRefusedError-BIkUM6-g.js → JoggingRefusedError-C4D8_YR_.js} +5 -3
- package/dist/chunks/JoggingRefusedError-DqyrfUcc.cjs +1 -0
- package/dist/chunks/Pose3-BfBNPRDM.cjs +1 -0
- package/dist/chunks/{Pose3-B_fLR-Wv.js → Pose3-DWxfC6Dj.js} +1 -2
- package/dist/chunks/{Robot-C-IWfxP9.js → Robot-B-VAYuAr.js} +5 -5
- package/dist/chunks/{Robot-Cfhjv9Z8.cjs → Robot-DRf8T9Zf.cjs} +1 -1
- package/dist/chunks/RobotActivation-CRVxXvlx.cjs +1 -0
- package/dist/chunks/RobotActivation-oR-8Y0iq.js +143 -0
- package/dist/chunks/RobotControl-Dbe50ZKM.cjs +1 -0
- package/dist/chunks/RobotControl-Ms1F7fFe.js +332 -0
- package/dist/chunks/RobotControlPanel-B7NxoHsO.cjs +1 -0
- package/dist/chunks/RobotControlPanel-CkQlkq8x.js +1029 -0
- package/dist/chunks/RobotHeader-CjOaf9s6.cjs +1 -0
- package/dist/chunks/RobotHeader-LSuRTDFB.js +395 -0
- package/dist/chunks/RobotScene-Au6zpHH1.cjs +1 -0
- package/dist/chunks/RobotScene-C6XEgaVR.js +1284 -0
- package/dist/chunks/RobotSessionProvider-CoF_tX0O.cjs +1 -0
- package/dist/chunks/RobotSessionProvider-DuHi-dtw.js +30 -0
- package/dist/chunks/{RobotView-BGYlAWj-.cjs → RobotView-Cg6JfGiY.cjs} +1 -1
- package/dist/chunks/{RobotView-D-v8jCM7.js → RobotView-CrAxNkyG.js} +3 -3
- package/dist/chunks/{robotSafetyOf-DuKKma1_.js → SafetyBar-C85BAKsL.js} +244 -215
- package/dist/chunks/SafetyBar-D2l81Omq.cjs +1 -0
- package/dist/chunks/externalizeComponent-CA_sHzyH.cjs +2 -0
- package/dist/chunks/{externalizeComponent-4juwPKL5.js → externalizeComponent-CChY_1bN.js} +34 -8
- package/dist/chunks/{useSmoothedMotionState-BSSV8aZN.js → hooks-BWoeBWLV.js} +43 -87
- package/dist/chunks/hooks-BXe2bNMo.cjs +1 -0
- package/dist/chunks/loadRobotSession-BzY9H3F8.cjs +1 -0
- package/dist/chunks/{loadRobotSession-GHHtv5dv.js → loadRobotSession-Ts2MumBB.js} +1065 -679
- package/dist/chunks/poseText-BxG4Caa-.js +48 -0
- package/dist/chunks/poseText-CwplkbDM.cjs +1 -0
- package/dist/chunks/useSmoothedMotionState-CCXmMZ0S.cjs +1 -0
- package/dist/chunks/useSmoothedMotionState-CELh-YJa.js +50 -0
- package/dist/components/VelocitySlider.d.ts +14 -1
- package/dist/components/connectionWarning/ConnectionWarning.d.ts +18 -4
- package/dist/components/connectionWarning/connectionWarningOf.d.ts +1 -11
- package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +7 -1
- package/dist/components/jogging/JoggingCartesianTab.d.ts +6 -0
- package/dist/components/jogging/JoggingJointTab.d.ts +5 -0
- package/dist/components/jogging/JoggingJointValueControl.d.ts +7 -1
- package/dist/components/jogging/JoggingPanel.d.ts +11 -0
- package/dist/components/jogging/JoggingRefusedError.d.ts +8 -3
- package/dist/components/jogging/JoggingStore.d.ts +206 -17
- package/dist/components/jogging/joggingColors.d.ts +6 -0
- package/dist/components/robotControl/CartesianJogTab.d.ts +14 -3
- package/dist/components/robotControl/JogArea.d.ts +6 -3
- package/dist/components/robotControl/JogDisabledReason.d.ts +15 -0
- package/dist/components/robotControl/JointJogTab.d.ts +10 -2
- package/dist/components/robotControl/MoveToTab.d.ts +24 -3
- package/dist/components/robotControl/PoseField.d.ts +3 -1
- package/dist/components/robotControl/RobotControl.d.ts +3 -0
- package/dist/components/robotControl/RobotControlPanel.d.ts +91 -22
- package/dist/components/robotControl/VelocityRow.d.ts +8 -2
- package/dist/components/robotControl/atPose.d.ts +6 -0
- package/dist/components/robotControl/poseText.d.ts +13 -1
- package/dist/components/robotControl/units.d.ts +10 -2
- package/dist/components/robotControl/useRobotControlProps.d.ts +7 -4
- package/dist/components/robotControl/velocityText.d.ts +18 -0
- package/dist/components/robotHeader/ActivationSwitch.d.ts +13 -2
- package/dist/components/robotHeader/RobotHeader.d.ts +25 -4
- package/dist/components/robotHeader/robotActivationOf.d.ts +1 -8
- package/dist/components/robotScene/RobotScene.d.ts +7 -1
- package/dist/components/robots/MotionGroupVisualizer.d.ts +6 -4
- package/dist/components/robots/SupportedLinearAxis.d.ts +6 -4
- package/dist/components/robots/SupportedRobot.d.ts +7 -5
- package/dist/components/robots/useFrameSmoothedMotionState.d.ts +25 -0
- package/dist/components/utils/useSmoothedMotionState.d.ts +11 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +8 -10
- package/dist/core.js +60 -69
- package/dist/index.cjs +1 -1
- package/dist/index.js +100 -113
- package/dist/lib/ConnectedMotionGroup.d.ts +11 -0
- package/dist/lib/ControllerStateStream.d.ts +9 -9
- package/dist/lib/JoggerConnection.d.ts +48 -13
- package/dist/lib/MotionStreamConnection.d.ts +3 -2
- package/dist/lib/TrajectoryExecutionStore.d.ts +58 -20
- package/dist/lib/controllerStateSource.d.ts +6 -5
- package/dist/lib/robotSession/RobotActivation.d.ts +52 -21
- package/dist/lib/robotSession/RobotSession.d.ts +27 -8
- package/dist/lib/robotSession/RobotTargetPose.d.ts +4 -2
- package/dist/lib/robotSession/loadRobotSession.d.ts +1 -1
- package/dist/lib/robotSession/robotPose.d.ts +0 -6
- package/dist/session.cjs +1 -1
- package/dist/session.d.ts +6 -6
- package/dist/session.js +30 -38
- package/package.json +22 -1
- package/dist/chunks/ConnectedMotionGroup-CybwJHkh.cjs +0 -3
- package/dist/chunks/JoggingRefusedError-BuCGsVsa.cjs +0 -1
- package/dist/chunks/Pose3-Ch4xVeXV.cjs +0 -1
- package/dist/chunks/RobotActivation-Bb0oNSBN.cjs +0 -1
- package/dist/chunks/RobotActivation-C0rrwpQZ.js +0 -115
- package/dist/chunks/RobotControl-Cv6Sr1Ni.js +0 -289
- package/dist/chunks/RobotControl-DFnOYMAa.cjs +0 -1
- package/dist/chunks/RobotControlPanel-B1_9g9D-.js +0 -850
- package/dist/chunks/RobotControlPanel-BpTpRBgy.cjs +0 -1
- package/dist/chunks/RobotScene-0ZJzXL50.cjs +0 -1
- package/dist/chunks/RobotScene-DpFeFpnx.js +0 -1255
- package/dist/chunks/RobotSessionProvider--AekyPqD.cjs +0 -1
- package/dist/chunks/RobotSessionProvider-TVaKGzqa.js +0 -25
- package/dist/chunks/externalizeComponent-Br_U-QAr.cjs +0 -2
- package/dist/chunks/loadRobotSession-DYbeNnTI.cjs +0 -1
- package/dist/chunks/poseText-BXUaQWnK.cjs +0 -1
- package/dist/chunks/poseText-pg4cxE8R.js +0 -41
- package/dist/chunks/robotActivationOf-B4oV10Za.cjs +0 -1
- package/dist/chunks/robotActivationOf-EzcT9g07.js +0 -368
- package/dist/chunks/robotSafetyOf-Dxm6s7Pp.cjs +0 -1
- package/dist/chunks/useSmoothedMotionState-B9WO73k0.cjs +0 -1
- package/dist/components/robotHeader/robotSafetyOf.d.ts +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("react/jsx-runtime"),j=require("@mui/material/Box"),J=require("@mui/material/Stack"),v=require("@mui/material/styles"),G=require("@mui/material/Typography"),x=require("react"),Y=require("./externalizeComponent-
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),j=require("@mui/material/Box"),J=require("@mui/material/Stack"),v=require("@mui/material/styles"),G=require("@mui/material/Typography"),x=require("react"),Y=require("./externalizeComponent-CA_sHzyH.cjs"),y=require("./holdSafety-TeMXlYQe.cjs"),H=2*Math.PI;function Z({min:t,max:n,linear:o},c){const r=t!==void 0,u=n!==void 0;if(r&&u&&n>t)return{min:t,max:n};if(o)return null;if(r&&!u)return{min:t,max:t+H};if(u&&!r)return{min:n-H,max:n};const p=Math.round(c/H)*H;return{min:p-Math.PI,max:p+Math.PI}}function z(t,n){return Math.min(1,Math.max(0,(t-n.min)/(n.max-n.min)))}function X(t,n){const o=Math.min(1,Math.max(0,t));return n.min+o*(n.max-n.min)}function K(t){return t.min>0||t.max<0?null:z(0,t)}function Q(t,n,o){return Math.abs(n-t)<=o?null:n>t?"+":"-"}function tt(t,n,o){return o==="+"?t>=n:t<=n}function nt(t,n){return t?"mm":n}const D={deg:{shown:t=>t*180/Math.PI,decimals:1,limitDecimals:0,suffix:"°"},rad:{shown:t=>t,decimals:3,limitDecimals:2,suffix:" rad"},mm:{shown:t=>t,decimals:1,limitDecimals:0,suffix:" mm"}};function V(t,n){const o=t.toFixed(n);return Number(o)===0?0 .toFixed(n):o}function q(t,n){return D[n].shown(t)}function et(t,n){const{shown:o,decimals:c,suffix:r}=D[n];return`${V(o(t),c)}${r}`}function B(t,n){const{shown:o,limitDecimals:c,suffix:r}=D[n],u=10**c,p=o(t),a=Math.sign(p)*Math.round(Math.abs(p)*u)/u;return`${a>0?"+":""}${V(a,c)}${r}`}const F=16,E=4;function N({railRef:t,at:n,goalAt:o,held:c,zeroAt:r,limits:u,disabled:p}){const a=v.useTheme(),f=a.palette.primary.main,l=`0 0 0 8px ${v.alpha(f,.16)}`;return i.jsxs(i.Fragment,{children:[i.jsxs(j,{ref:t,sx:{position:"absolute",left:0,right:0,top:"50%",height:E,transform:"translateY(-50%)"},children:[i.jsx(j,{sx:{position:"absolute",inset:0,borderRadius:E/2,backgroundColor:v.alpha(f,.38)}}),n!==null&&o!==null&&i.jsx(j,{sx:{position:"absolute",top:0,bottom:0,borderRadius:E/2,backgroundColor:f},style:{left:`${Math.min(n,o)*100}%`,width:`${Math.abs(o-n)*100}%`,opacity:c?1:.5}}),r!==null&&i.jsx(j,{"aria-hidden":!0,sx:{position:"absolute",top:"50%",width:2,height:12,transform:"translate(-50%, -50%)",borderRadius:1,backgroundColor:"text.secondary"},style:{left:`${r*100}%`}}),n!==null&&i.jsx(j,{sx:{position:"absolute",top:"50%",boxSizing:"border-box",width:F,height:F,transform:"translate(-50%, -50%)",borderRadius:"50%",border:`3px solid ${f}`,backgroundColor:"background.paper",boxShadow:c?l:a.shadows[2],transition:"box-shadow 150ms","&:hover":p?{}:{boxShadow:l}},style:{left:`${n*100}%`}})]}),u&&i.jsx(J,{direction:"row",sx:{position:"absolute",left:0,right:0,top:30,justifyContent:"space-between"},children:[u.min,u.max].map((R,w)=>i.jsx(G,{variant:"caption",color:"text.secondary",sx:{fontSize:10,lineHeight:"14px"},children:R},w))})]})}function ot({value:t,onJogStart:n,onJogStop:o,disabled:c}){const r=x.useRef(null),[u,p]=x.useState(null),a=x.useCallback(e=>{r.current=e,p(e)},[]),f=x.useRef({value:t,onJogStart:n,onJogStop:o});f.current={value:t,onJogStart:n,onJogStop:o};const l=x.useCallback((e,b,d)=>{const g=Q(f.current.value,b,d);a({...e,goal:b,direction:g,settledAt:g?null:e.settledAt}),e.direction&&e.direction!==g&&f.current.onJogStop(),g&&g!==e.direction&&f.current.onJogStart(g)},[a]),R=x.useCallback(()=>r.current!==null,[]),w=x.useCallback((e,b,d,g)=>c||r.current?!1:(l({goal:e,direction:null,settledAt:null,pointer:d,element:g},e,b),!0),[c,l]),C=x.useCallback((e,b)=>{const d=r.current;if(d){if(d.direction===null&&d.settledAt!==null&&Math.abs(e-d.settledAt)<=b){a({...d,goal:e});return}l(d,e,b)}},[l,a]),$=x.useCallback(()=>{const e=r.current;e&&(a(null),y.releasePointer(e.element,e.pointer),e.direction&&f.current.onJogStop())},[a]),k=x.useCallback(()=>{var e;return((e=r.current)==null?void 0:e.pointer)??null},[]);return x.useEffect(()=>{const e=r.current;e!=null&&e.direction&&tt(t,e.goal,e.direction)&&(a({...e,direction:null,settledAt:e.goal}),f.current.onJogStop())},[t,a]),y.useEndHoldWhenUnattended(u!==null,c,$),{hold:u,isHolding:R,holdingPointer:k,begin:w,moveGoal:C,end:$}}function rt(t){return t==="mouse"||t==="pen"?1:4}const it=8,st=Y.externalizeComponent(({label:t,name:n,value:o,min:c,max:r,linear:u=!1,angleUnit:p="deg",onJogStart:a,onJogStop:f,disabled:l=!1})=>{const R=v.useTheme(),w=x.useRef(null),{hold:C,isHolding:$,holdingPointer:k,begin:e,moveGoal:b,end:d}=ot({value:o,onJogStart:a,onJogStop:f,disabled:l}),[g,S]=x.useState(null);x.useEffect(()=>{l&&S(null)},[l]);const h=Z({min:c,max:r,linear:u},o),P=nt(u,p),T=s=>et(s,P);function L({clientX:s,pointerType:m}){if(!h||!w.current)return null;const M=w.current.getBoundingClientRect();return M.width<=0?null:{goal:X((s-M.left)/M.width,h),deadband:rt(m)/M.width*(h.max-h.min)}}function _(s){if(!y.startsPointerHold(s)||l||$())return;const m=L(s);m&&(y.capturePointer(s.currentTarget,s.pointerId),e(m.goal,m.deadband,s.pointerId,s.currentTarget))}function W(s){const m=L(s),M=k()===s.pointerId;if(M&&!y.isPointerWithin(s,it)){S(null),d();return}if(S(l?null:(m==null?void 0:m.goal)??null),!!M){if(y.primaryReleased(s)){d();return}m&&b(m.goal,m.deadband)}}function I(s){k()===s.pointerId&&d()}const A=(C==null?void 0:C.goal)??g,O=h&&{min:B(h.min,P),max:B(h.max,P)},U=i.jsxs(J,{direction:"row",sx:{justifyContent:"space-between",gap:1,mb:"-4px"},children:[i.jsxs(G,{variant:"body2",noWrap:!0,children:[t,n&&i.jsx(j,{component:"span",sx:{color:"text.secondary"},children:` - ${n}`})]}),i.jsxs(G,{variant:"body2",sx:{fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:[T(o),h&&A!==null&&i.jsx(j,{component:"span",sx:{color:"text.secondary"},children:` / ${T(A)}`})]})]});return h?i.jsxs(J,{"data-testid":"jogging-joint-slider",children:[U,i.jsx(j,{role:"slider",tabIndex:l?-1:0,"aria-label":n?`${t} ${n}`:t,"aria-valuemin":q(h.min,P),"aria-valuemax":q(h.max,P),"aria-valuenow":q(o,P),"aria-valuetext":T(o),"aria-disabled":l||void 0,onPointerDown:_,onPointerMove:W,onPointerLeave:s=>{S(null),I(s)},onPointerUp:I,onPointerCancel:I,onLostPointerCapture:I,onBlur:d,onContextMenu:y.preventContextMenu,sx:{position:"relative",height:44,borderRadius:1,opacity:l?.5:1,cursor:l?"default":"pointer",touchAction:"none",userSelect:"none",outline:"none","&:focus-visible":{outline:`2px solid ${R.palette.primary.main}`,outlineOffset:"2px"}},children:i.jsx(N,{railRef:w,at:z(o,h),goalAt:A===null?null:z(A,h),held:C!==null,zeroAt:K(h),limits:O??void 0,disabled:l})})]}):i.jsxs(J,{"data-testid":"jogging-joint-slider",children:[U,i.jsx(j,{"aria-hidden":!0,sx:{position:"relative",height:44},children:i.jsx(N,{at:null,goalAt:null,held:!1,zeroAt:null,disabled:!0})})]})});exports.JoggingJointSlider=st;
|
|
@@ -5,14 +5,16 @@ function i(t) {
|
|
|
5
5
|
coordinateSystemId: t.tcpPose.coordSystemId
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
const o = (t = [0, 0, 0], e = [0, 0, 0]) => t.length === e.length && t.every((s,
|
|
8
|
+
const o = (t = [0, 0, 0], e = [0, 0, 0]) => t.length === e.length && t.every((s, n) => s === e[n]);
|
|
9
9
|
function c(t, e) {
|
|
10
10
|
return t.motionGroupId !== e.motionGroupId ? !1 : t.type === "joint" ? e.type === "joint" && o(t.joints, e.joints) : e.type === "joint" ? !1 : t.tcpPose.tcpId === e.tcpPose.tcpId && t.tcpPose.coordSystemId === e.tcpPose.coordSystemId && o(t.tcpPose.pose.position, e.tcpPose.pose.position) && o(t.tcpPose.pose.orientation, e.tcpPose.pose.orientation);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function r(t) {
|
|
13
13
|
switch (t.code) {
|
|
14
14
|
case "locked":
|
|
15
15
|
return "jogging is locked";
|
|
16
|
+
case "blocked":
|
|
17
|
+
return "another client holds the jogging connection";
|
|
16
18
|
case "disconnected":
|
|
17
19
|
return "the robot's live state stopped coming";
|
|
18
20
|
case "safety_state":
|
|
@@ -26,7 +28,7 @@ function n(t) {
|
|
|
26
28
|
class p extends Error {
|
|
27
29
|
/** @internal The jogging store makes it, see JoggingStore */
|
|
28
30
|
constructor(e) {
|
|
29
|
-
super(`Jogging refused: ${
|
|
31
|
+
super(`Jogging refused: ${r(e)}`), this.name = "JoggingRefusedError", this.reason = e;
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function n(e){return e.type==="joint"?{type:"joint",joints:e.joints}:{type:"cartesian",pose:e.tcpPose.pose,coordinateSystemId:e.tcpPose.coordSystemId}}const o=(e=[0,0,0],t=[0,0,0])=>e.length===t.length&&e.every((s,r)=>s===t[r]);function i(e,t){return e.motionGroupId!==t.motionGroupId?!1:e.type==="joint"?t.type==="joint"&&o(e.joints,t.joints):t.type==="joint"?!1:e.tcpPose.tcpId===t.tcpPose.tcpId&&e.tcpPose.coordSystemId===t.tcpPose.coordSystemId&&o(e.tcpPose.pose.position,t.tcpPose.pose.position)&&o(e.tcpPose.pose.orientation,t.tcpPose.pose.orientation)}function c(e){switch(e.code){case"locked":return"jogging is locked";case"blocked":return"another client holds the jogging connection";case"disconnected":return"the robot's live state stopped coming";case"safety_state":return`the safety state is ${e.value}`;case"operation_mode":return`the operation mode is ${e.value}`;case"deactivated":return"the robot is not activated"}}class d extends Error{constructor(t){super(`Jogging refused: ${c(t)}`),this.name="JoggingRefusedError",this.reason=t}}exports.JoggingRefusedError=d;exports.sameRobotPose=i;exports.trajectoryTargetOf=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("three");function a(t,n){if(n==="QUATERNION"&&t)return new i.Quaternion(...t);if(n==="ROTATION_VECTOR"&&t){if(t&&t.length<3)throw new Error(`Invalid rotation vector length: ${t.length}. Expected at least 3 values.`);const o=new i.Vector3(t[0],t[1],t[2]),e=o.length(),s=o.normalize();return new i.Quaternion().setFromAxisAngle(s,e)}else return console.warn(`Unsupported rotation type '${n}'. Only QUATERNION and ROTATION_VECTOR are supported for now.`),new i.Quaternion}function u(t){const n=new i.Vector3(t.x,t.y,t.z),o=2*Math.atan2(n.length(),Math.abs(t.w));n.normalize();const e=(t.w>=0?1:0)-(t.w<0?1:0);return n.multiplyScalar(e).multiplyScalar(o)}class r{constructor(n,o){this.position=n,this.quaternion=o}static fromPose(n){const o=n.orientation?a(n.orientation,"ROTATION_VECTOR"):new i.Quaternion,e=n.position??[0,0,0];return new r(new i.Vector3(e[0]??0,e[1]??0,e[2]??0),o)}static fromRobotTcp(n){const o=n.orientation?a(n.orientation,n.orientation_type??"ROTATION_VECTOR"):new i.Quaternion,e=n.position??[0,0,0];return new r(new i.Vector3(e[0]??0,e[1]??0,e[2]??0),o)}static fromCoordinateSystem(n){const o=n.orientation?a(n.orientation,n.orientation_type??"ROTATION_VECTOR"):new i.Quaternion,e=n.position??[0,0,0];return new r(new i.Vector3(e[0]??0,e[1]??0,e[2]??0),o)}inverse(){const n=this.quaternion.clone().invert();return new r(this.position.clone().applyQuaternion(n).multiplyScalar(-1),n)}multiply(n){return new r(this.position.clone().add(n.position.clone().applyQuaternion(this.quaternion)),this.quaternion.clone().multiply(n.quaternion).normalize())}get orientation(){return u(this.quaternion)}}exports.Pose3=r;exports.parseRotationToQuaternion=a;
|
|
@@ -4,7 +4,7 @@ import { Matrix4 as T, Vector3 as S, Quaternion as I } from "three";
|
|
|
4
4
|
import { ConvexGeometry as v } from "three-stdlib";
|
|
5
5
|
import { Line as E } from "@react-three/drei";
|
|
6
6
|
import { useMemo as L, useCallback as N } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { h as k, d as V, D as Q, f as H } from "./RobotScene-C6XEgaVR.js";
|
|
8
8
|
function U(n) {
|
|
9
9
|
switch (n.shape_type) {
|
|
10
10
|
case "convex_hull":
|
|
@@ -118,8 +118,8 @@ function D(n, o = null, e = []) {
|
|
|
118
118
|
).multiply(new T().makeRotationX(r.alpha ?? 0)), s;
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
const R = "#ff4b4b", A = "#2fa8ff", J = "#8a8d9e", W = 96, X = 0.15, Y = new u.Vector3(0, 1, 0), Z = 0.2,
|
|
122
|
-
function
|
|
121
|
+
const R = "#ff4b4b", A = "#2fa8ff", J = "#8a8d9e", W = 96, X = 0.15, Y = new u.Vector3(0, 1, 0), Z = 0.2, $ = 2;
|
|
122
|
+
function j(n) {
|
|
123
123
|
const { lower_limit: o, upper_limit: e } = n ?? {};
|
|
124
124
|
return typeof o != "number" || typeof e != "number" || !Number.isFinite(o) || !Number.isFinite(e) || !(o < e) ? null : { lower_limit: o, upper_limit: e };
|
|
125
125
|
}
|
|
@@ -222,7 +222,7 @@ function en({
|
|
|
222
222
|
size: i,
|
|
223
223
|
emphasis: r
|
|
224
224
|
}) {
|
|
225
|
-
const a = r === "highlighted" ?
|
|
225
|
+
const a = r === "highlighted" ? $ : 1, s = r === "dimmed" ? Z : 1, t = i * 0.2 * (r === "highlighted" ? 1.4 : 1), c = 2 * a, {
|
|
226
226
|
axisPoints: m,
|
|
227
227
|
axisTip: d,
|
|
228
228
|
origin: p,
|
|
@@ -308,7 +308,7 @@ function un({
|
|
|
308
308
|
[n, o, i]
|
|
309
309
|
);
|
|
310
310
|
return /* @__PURE__ */ l("group", { children: s.map((t, c) => {
|
|
311
|
-
const m =
|
|
311
|
+
const m = j(e[c]);
|
|
312
312
|
return m ? /* @__PURE__ */ l(
|
|
313
313
|
en,
|
|
314
314
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const c=require("react/jsx-runtime"),f=require("three"),I=require("three-stdlib"),A=require("@react-three/drei"),O=require("react"),b=require("./RobotScene-
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),f=require("three"),I=require("three-stdlib"),A=require("@react-three/drei"),O=require("react"),b=require("./RobotScene-Au6zpHH1.cjs");function E(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(o,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return o.default=e,Object.freeze(o)}const u=E(f);function k(e){switch(e.shape_type){case"convex_hull":return new I.ConvexGeometry(e.vertices.map(n=>new u.Vector3(n[0]/1e3,n[1]/1e3,n[2]/1e3)));case"box":return new u.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new u.SphereGeometry(e.radius/1e3);case"capsule":return new u.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new u.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new u.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new u.BufferGeometry}}function F({name:e,collider:o,children:n}){var a,s;const r=((a=o.pose)==null?void 0:a.position)??[0,0,0],i=((s=o.pose)==null?void 0:s.orientation)??[0,0,0];return o.margin&&console.warn(`${e} margin is not supported`),c.jsx("mesh",{name:e,position:new u.Vector3(r[0],r[1],r[2]).divideScalar(1e3),rotation:new u.Euler(i[0],i[1],i[2],"XYZ"),geometry:k(o.shape),children:n})}function N({name:e,colliders:o,meshChildrenProvider:n,...r}){return c.jsx("group",{name:e,...r,children:Object.entries(o).map(([i,a])=>c.jsx(F,{name:i,collider:a,children:n(i,a)},i))})}function V({scene:e,meshChildrenProvider:o}){const n=e.colliders;return c.jsx("group",{children:n&&c.jsx(N,{meshChildrenProvider:o,colliders:n})})}function v(e){const o=(e==null?void 0:e.position)??[],n=(e==null?void 0:e.orientation)??[],r=new f.Vector3(n[0]??0,n[1]??0,n[2]??0),i=r.length(),a=i>0?new f.Quaternion().setFromAxisAngle(r.normalize(),i):new f.Quaternion;return new f.Matrix4().compose(new f.Vector3(o[0]??0,o[1]??0,o[2]??0).divideScalar(1e3),a,new f.Vector3(1,1,1))}function q(e,o=null,n=[]){const r=v(o);return e.map((i,a)=>{const s=r.clone(),t=(i.reverse_rotation_direction?-1:1)*(n[a]??0),l=i.type==="PRISMATIC_JOINT",m=(i.theta??0)+(l?0:t),d=(i.d??0)+(l?t:0);return r.multiply(new f.Matrix4().makeRotationZ(m)).multiply(new f.Matrix4().makeTranslation((i.a??0)/1e3,0,d/1e3)).multiply(new f.Matrix4().makeRotationX(i.alpha??0)),s})}const T="#ff4b4b",L="#2fa8ff",Q="#8a8d9e",z=96,H=.15,U=new u.Vector3(0,1,0),B=.2,D=2;function J(e){const{lower_limit:o,upper_limit:n}=e??{};return typeof o!="number"||typeof n!="number"||!Number.isFinite(o)||!Number.isFinite(n)||!(o<n)?null:{lower_limit:o,upper_limit:n}}function j({base:e,direction:o,size:n,color:r,opacity:i}){const a=new u.Quaternion().setFromUnitVectors(U,o.clone().normalize()),s=e.clone().addScaledVector(o.clone().normalize(),n/2);return c.jsxs("mesh",{position:s,quaternion:a,renderOrder:10,children:[c.jsx("coneGeometry",{args:[n*.35,n,16]}),c.jsx("meshBasicMaterial",{color:r,depthTest:!1,transparent:!0,opacity:i})]})}function P({points:e,color:o,width:n,opacity:r}){return c.jsx(A.Line,{points:e,color:o,lineWidth:n,depthTest:!1,transparent:!0,opacity:r,renderOrder:10})}function G(e,o){const n=[...e];let r=o;for(;n.length>1;){const i=n[n.length-1],a=n[n.length-2],s=i.distanceTo(a);if(s>r)return n[n.length-1]=i.clone().lerp(a,r/s),n;r-=s,n.pop()}return n}function W(e,o,n,r){const i=n*e,a=n*o,s=Math.abs(a-i),t=Math.max(2,Math.ceil(s/(2*Math.PI)*z));return Array.from({length:t+1},(l,m)=>{const d=i+(a-i)*m/t,p=s*m/t/(2*Math.PI),h=r*(1+H*p);return new u.Vector3(Math.cos(d)*h,Math.sin(d)*h,0)})}function X(e,o,n,r){const i=e.theta??0,a=e.d??0,s=e.type==="PRISMATIC_JOINT",t=e.reverse_rotation_direction?-1:1,{lower_limit:l,upper_limit:m}=o;return O.useMemo(()=>{const d=new u.Matrix4().makeRotationZ(i).multiply(new u.Matrix4().makeTranslation(0,0,s?a/1e3:0)),p=(M,_,S)=>new u.Vector3(M,_,S).applyMatrix4(d),h=new u.Vector3().applyMatrix4(d),g=p(0,0,n),x=(s?[p(n*.25,0,t*l/1e3),p(n*.25,0,t*m/1e3)]:W(l,m,t,n*.6)).map(M=>s?M:M.applyMatrix4(d)),y=p(s?n*.25:n*.6,0,0),C=x.slice(1).reduce((M,_,S)=>M+_.distanceTo(x[S]),0),R=Math.min(r,C/3),w=G(G(x,R).reverse(),R).reverse();return{axisPoints:[h,g],axisTip:g,origin:h,restPoints:[h,y],range:x,limitPoints:w,rangeStart:w[0],rangeEnd:w[w.length-1]}},[i,a,s,t,n,l,m,r])}function Y({frame:e,dh:o,limit:n,size:r,emphasis:i}){const a=i==="highlighted"?D:1,s=i==="dimmed"?B:1,t=r*.2*(i==="highlighted"?1.4:1),l=2*a,{axisPoints:m,axisTip:d,origin:p,restPoints:h,range:g,limitPoints:x,rangeStart:y,rangeEnd:C}=X(o,n,r,t),{position:R,quaternion:w}=O.useMemo(()=>{const M=new u.Vector3,_=new u.Quaternion;return e.decompose(M,_,new u.Vector3),{position:M,quaternion:_}},[e]);return c.jsxs("group",{position:R,quaternion:w,children:[c.jsx(P,{points:m,color:L,width:l,opacity:s}),c.jsx(j,{base:d,direction:d.clone().sub(p),size:t,color:L,opacity:s}),c.jsx(P,{points:h,color:Q,width:1.5*a,opacity:s}),c.jsx(P,{points:x,color:T,width:l,opacity:s}),c.jsx(j,{base:y,direction:g[0].clone().sub(y),size:y.distanceTo(g[0]),color:T,opacity:s}),c.jsx(j,{base:C,direction:g[g.length-1].clone().sub(C),size:C.distanceTo(g[g.length-1]),color:T,opacity:s})]})}function Z({dhParameters:e,chainOffset:o=null,limits:n,jointPositions:r,size:i=.15,highlightedJoint:a=null}){const s=O.useMemo(()=>q(e,o,r),[e,o,r]);return c.jsx("group",{children:s.map((t,l)=>{const m=J(n[l]);return m?c.jsx(Y,{frame:t,dh:e[l],limit:m,size:i,emphasis:a===null?"normal":a===l?"highlighted":"dimmed"},l):null})})}function $({trajectory:e,...o}){const n=(e==null?void 0:e.map(r=>{if(r.position&&r.position.length>=3){const[i,a,s]=r.position;if(Number.isFinite(i)&&Number.isFinite(a)&&Number.isFinite(s))return new u.Vector3(i/1e3,s/1e3,-a/1e3)}return null}).filter(r=>r!==null))||[];return c.jsx("group",{...o,children:n.length>0&&c.jsx(A.Line,{points:n,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}function K({motionGroup:e,connectedMotionGroup:o,getModel:n,flangeRef:r,transparentColor:i,postModelRender:a,...s}){const t=e??o,l=t==null?void 0:t.nova,m=O.useCallback((g,x,y)=>b.defaultGetModel(g,l,y),[l]),d=n??m;if(!(t!=null&&t.dhParameters))return null;const p=t.modelFromController||"";return p?c.jsx(b.SupportedLinearAxis,{rapidlyChangingMotionState:t.rapidlyChangingMotionState,modelFromController:p,dhParameters:t.dhParameters,serialNumber:t.serialNumber,kinematicChainOffset:t.kinematicChainOffset,getModel:d,flangeRef:r,transparentColor:i,postModelRender:a,chainOffsetPosition:t.mountingPosition,chainOffsetQuaternion:t.mountingQuaternion,...s}):c.jsx(b.DHLinearAxis,{rapidlyChangingMotionState:t.rapidlyChangingMotionState,dhParameters:t.dhParameters,chainOffsetPosition:t.mountingPosition,chainOffsetQuaternion:t.mountingQuaternion,...s})}function ee({motionGroup:e,connectedMotionGroup:o,getModel:n,flangeRef:r,transparentColor:i,postModelRender:a,...s}){const t=e??o,l=t==null?void 0:t.nova,m=O.useCallback((d,p,h)=>b.defaultGetModel(d,l,h),[l]);return t!=null&&t.dhParameters?c.jsx(b.SupportedRobot,{rapidlyChangingMotionState:t.rapidlyChangingMotionState,modelFromController:t.modelFromController||"",dhParameters:t.dhParameters,serialNumber:t.serialNumber,kinematicChainOffset:t.kinematicChainOffset,getModel:n??m,flangeRef:r,transparentColor:i,postModelRender:a,chainOffsetPosition:t.mountingPosition,chainOffsetQuaternion:t.mountingQuaternion,...s}):null}exports.CollisionSceneRenderer=V;exports.JointLimitGizmo=Z;exports.LinearAxis=K;exports.Robot=ee;exports.TrajectoryRenderer=$;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const h=require("@wandelbots/nova-js"),r=require("mobx"),g=3e4;class l extends Error{constructor(e,s,i){super(e),this.url=s,this.cause=i,this.name="RobotModeChangeError"}}class u{constructor(e,s,i,t,o,n=async()=>{}){this.nova=e,this.ids=s,this.live=i,this.safety=t,this.logger=o,this.releaseControl=n,this.pending=null,this.disposed=!1,r.makeAutoObservable(this,{nova:!1,ids:!1,live:!1,safety:!1,logger:!1,releaseControl:!1,endPending:!1},{autoBind:!0})}get reported(){return this.live.connectionQuality==="critical"?null:this.live.controllerState.mode==="MODE_CONTROL"?"active":"inactive"}get state(){return this.pending??this.reported??"inactive"}async activate(){if(this.refusedAsDisposed())return;if(this.state!=="inactive"){this.logger.warn("Tried to activate while already activating");return}const e=this.safety().activationBlockedReason;if(e){this.logger.warn(`Not enabling control mode for controller "${this.ids.controllerId}" because ${e}`);return}await this.changeMode("activating",()=>this.setMode("ROBOT_SYSTEM_MODE_CONTROL"))}async deactivate(){if(!this.refusedAsDisposed()){if(this.state!=="active"){this.logger.warn("Tried to deactivate while already deactivating");return}await this.changeMode("deactivating",async()=>{await this.releaseControl(),await this.setMode("ROBOT_SYSTEM_MODE_MONITOR")})}}async toggle(){this.state==="inactive"?await this.activate():this.state==="active"&&await this.deactivate()}dispose(){var e;this.disposed=!0,(e=this.endPending)==null||e.call(this)}refusedAsDisposed(){return this.disposed?(this.logger.warn(`Not changing the mode of controller "${this.ids.controllerId}": its session is disposed`),!0):!1}async changeMode(e,s){var a;const i=e==="activating"?"active":"inactive";let t=()=>{},o;const n=()=>{this.endPending===n&&(this.endPending=void 0,t(),clearTimeout(o),this.setPending(null))};(a=this.endPending)==null||a.call(this),this.endPending=n,this.setPending(e),o=setTimeout(n,g),t=r.when(()=>this.reported===i,n);try{await s()}catch(d){throw n(),d}}setPending(e){this.pending=e}async setMode(e){const{cellId:s,controllerId:i}=this.ids;try{await this.nova.api.controller.setDefaultMode(s,i,e)}catch(t){const o=(typeof t=="object"&&t!==null&&"url"in t&&typeof t.url=="string"?t.url:void 0)??`/cells/${s}/controllers/${i}/mode`;throw new l(`Failed to set controller "${i}" to ${e}: ${h.makeErrorMessage(t)}`,o,t)}}}exports.RobotActivation=u;exports.RobotModeChangeError=l;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { makeErrorMessage as d } from "@wandelbots/nova-js";
|
|
2
|
+
import { makeAutoObservable as c, when as h } from "mobx";
|
|
3
|
+
const g = 3e4;
|
|
4
|
+
class u extends Error {
|
|
5
|
+
/** @internal The session makes it, see RobotSession */
|
|
6
|
+
constructor(t, s, i) {
|
|
7
|
+
super(t), this.url = s, this.cause = i, this.name = "RobotModeChangeError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
class p {
|
|
11
|
+
/** @internal The session makes it, see RobotSession */
|
|
12
|
+
constructor(t, s, i, e, n, a = async () => {
|
|
13
|
+
}) {
|
|
14
|
+
this.nova = t, this.ids = s, this.live = i, this.safety = e, this.logger = n, this.releaseControl = a, this.pending = null, this.disposed = !1, c(
|
|
15
|
+
this,
|
|
16
|
+
{
|
|
17
|
+
nova: !1,
|
|
18
|
+
ids: !1,
|
|
19
|
+
live: !1,
|
|
20
|
+
safety: !1,
|
|
21
|
+
logger: !1,
|
|
22
|
+
releaseControl: !1,
|
|
23
|
+
endPending: !1
|
|
24
|
+
},
|
|
25
|
+
{ autoBind: !0 }
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* What the controller reports, or null while its live state does not
|
|
30
|
+
* come: the mode cannot be confirmed then
|
|
31
|
+
*/
|
|
32
|
+
get reported() {
|
|
33
|
+
return this.live.connectionQuality === "critical" ? null : this.live.controllerState.mode === "MODE_CONTROL" ? "active" : "inactive";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The mode change in progress, else what the controller reports. The
|
|
37
|
+
* controller's mode is the source of truth: without a mode change, the
|
|
38
|
+
* state is derived from the live state and nothing else, so it cannot
|
|
39
|
+
* drift from it. Inactive while the live state does not come.
|
|
40
|
+
*/
|
|
41
|
+
get state() {
|
|
42
|
+
return this.pending ?? this.reported ?? "inactive";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Switches the controller to control mode. Does nothing while a mode change
|
|
46
|
+
* is in progress, when the safety state or operation mode would make
|
|
47
|
+
* NOVA refuse it (see {@link RobotSafety.activationBlockedReason}), and
|
|
48
|
+
* once the session is disposed. Rejects with a
|
|
49
|
+
* {@link RobotModeChangeError} when NOVA refuses it.
|
|
50
|
+
*/
|
|
51
|
+
async activate() {
|
|
52
|
+
if (this.refusedAsDisposed()) return;
|
|
53
|
+
if (this.state !== "inactive") {
|
|
54
|
+
this.logger.warn("Tried to activate while already activating");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const t = this.safety().activationBlockedReason;
|
|
58
|
+
if (t) {
|
|
59
|
+
this.logger.warn(
|
|
60
|
+
`Not enabling control mode for controller "${this.ids.controllerId}" because ${t}`
|
|
61
|
+
);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
await this.changeMode(
|
|
65
|
+
"activating",
|
|
66
|
+
() => this.setMode("ROBOT_SYSTEM_MODE_CONTROL")
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Switches the controller to monitor mode, after handing back a planned
|
|
71
|
+
* move, which holds it in control mode. Does nothing once the session is
|
|
72
|
+
* disposed. Rejects with a {@link RobotModeChangeError} when NOVA refuses
|
|
73
|
+
* it.
|
|
74
|
+
*/
|
|
75
|
+
async deactivate() {
|
|
76
|
+
if (!this.refusedAsDisposed()) {
|
|
77
|
+
if (this.state !== "active") {
|
|
78
|
+
this.logger.warn("Tried to deactivate while already deactivating");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
await this.changeMode("deactivating", async () => {
|
|
82
|
+
await this.releaseControl(), await this.setMode("ROBOT_SYSTEM_MODE_MONITOR");
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Activates an inactive robot, deactivates an active one */
|
|
87
|
+
async toggle() {
|
|
88
|
+
this.state === "inactive" ? await this.activate() : this.state === "active" && await this.deactivate();
|
|
89
|
+
}
|
|
90
|
+
/** Ends a mode change's wait; no mode change is asked for afterwards */
|
|
91
|
+
dispose() {
|
|
92
|
+
var t;
|
|
93
|
+
this.disposed = !0, (t = this.endPending) == null || t.call(this);
|
|
94
|
+
}
|
|
95
|
+
/** Whether the session is disposed, which then asks NOVA for nothing */
|
|
96
|
+
refusedAsDisposed() {
|
|
97
|
+
return this.disposed ? (this.logger.warn(
|
|
98
|
+
`Not changing the mode of controller "${this.ids.controllerId}": its session is disposed`
|
|
99
|
+
), !0) : !1;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Shows a mode change until it is over: the controller reports the mode
|
|
103
|
+
* that was asked for, the request fails, or the controller has not
|
|
104
|
+
* confirmed it after 30 s (`MODE_CHANGE_TIMEOUT_MS`). Then the state is
|
|
105
|
+
* what the controller reports again, and the change can be asked for
|
|
106
|
+
* again.
|
|
107
|
+
*/
|
|
108
|
+
async changeMode(t, s) {
|
|
109
|
+
var r;
|
|
110
|
+
const i = t === "activating" ? "active" : "inactive";
|
|
111
|
+
let e = () => {
|
|
112
|
+
}, n;
|
|
113
|
+
const a = () => {
|
|
114
|
+
this.endPending === a && (this.endPending = void 0, e(), clearTimeout(n), this.setPending(null));
|
|
115
|
+
};
|
|
116
|
+
(r = this.endPending) == null || r.call(this), this.endPending = a, this.setPending(t), n = setTimeout(a, g), e = h(() => this.reported === i, a);
|
|
117
|
+
try {
|
|
118
|
+
await s();
|
|
119
|
+
} catch (l) {
|
|
120
|
+
throw a(), l;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
setPending(t) {
|
|
124
|
+
this.pending = t;
|
|
125
|
+
}
|
|
126
|
+
async setMode(t) {
|
|
127
|
+
const { cellId: s, controllerId: i } = this.ids;
|
|
128
|
+
try {
|
|
129
|
+
await this.nova.api.controller.setDefaultMode(s, i, t);
|
|
130
|
+
} catch (e) {
|
|
131
|
+
const n = (typeof e == "object" && e !== null && "url" in e && typeof e.url == "string" ? e.url : void 0) ?? `/cells/${s}/controllers/${i}/mode`;
|
|
132
|
+
throw new u(
|
|
133
|
+
`Failed to set controller "${i}" to ${t}: ${d(e)}`,
|
|
134
|
+
n,
|
|
135
|
+
e
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
p as R,
|
|
142
|
+
u as a
|
|
143
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const Q=require("react/jsx-runtime"),K=require("mobx-react-lite"),d=require("react"),ae=require("./RobotSessionProvider-CoF_tX0O.cjs"),ie=require("./RobotControlPanel-B7NxoHsO.cjs"),l=require("@wandelbots/nova-js"),se=require("@wandelbots/nova-js/v2"),N=require("mobx"),ce=require("react-i18next"),le=require("three"),de=require("./externalizeComponent-CA_sHzyH.cjs"),h=require("./Pose3-BfBNPRDM.cjs"),B=require("./JoggingRefusedError-DqyrfUcc.cjs"),G=require("./coordSystemLabel-BThpFG9n.cjs"),ue=require("./useEveryFrame-NeKiPXY-.cjs");function ge(t){return[t("RobotControl.Joint.Base.lb"),t("RobotControl.Joint.Shoulder.lb"),t("RobotControl.Joint.Elbow.lb"),t("RobotControl.Joint.Forearm.lb"),t("RobotControl.Joint.Wrist.lb"),t("RobotControl.Joint.Flange.lb")]}const O="selected-tcp",V="coordinate-system:",z=t=>Math.round(l.radiansToDegrees(t)*1e6)/1e6;function q(t,r){return"joints"in r?{type:"joint",motionGroupId:t.motionGroupId,joints:r.joints}:{type:"cartesian",motionGroupId:t.motionGroupId,tcpPose:{pose:r,coordSystemId:t.jogging.selectedCoordSystemId,tcpId:t.jogging.selectedTcpId}}}function A(t,r){t.targetPose.plan(q(t,r))}function L(t,r){switch(t.code){case"disconnected":return r("RobotControl.MoveTo.NotMoveable.Disconnected.lb");case"safety_state":return r("RobotControl.MoveTo.NotMoveable.SafetyState.lb",{value:t.value});case"operation_mode":return r("RobotControl.MoveTo.NotMoveable.OperationMode.lb",{value:t.value});case"deactivated":return r("RobotControl.MoveTo.NotMoveable.Deactivated.lb")}}function me(t){const r=ue.useEveryFrame(()=>t.jogger.motionStream.rapidlyChangingMotionState.joint_position.join(" "),!0);return d.useMemo(()=>r?r.split(" ").map(Number):[],[r])}function H(t,r={}){var w;const{disabled:m=!1,gizmoOrientation:s}=r,{t:i}=ce.useTranslation(void 0,{i18n:de.i18n}),e=t.jogging,{trajectory:p,targetPose:u}=t,D=me(e),R=e.jointType===se.JointTypeEnum.PrismaticJoint,b=(w=e.motionGroupDescription.operation_limits.auto_limits)==null?void 0:w.joints,C=D.length===6&&!R?ge(i):void 0,E=p.trajectoryState==="moving"||p.trajectoryState==="stopping",M=t.safety.canBeMoved,x=m||E||!M,T=M?E?"trajectory":e.blocked?"blocked":null:"robot",W={robot:()=>L(t.safety.notMoveableReason??{code:"deactivated"},i),trajectory:()=>i("RobotControl.JogDisabled.Moving.lb"),blocked:()=>i("Jogging.Blocked.lb")};d.useEffect(()=>{if(x)return e.lock("external"),()=>e.unlock("external")},[e,x]);const[Y,U]=d.useState(!1),X=Y?"moveTo":e.currentTab.id==="joint"?"joint":e.selectedCartesianMotionType;function Z(o){U(o==="moveTo"),N.runInAction(()=>{e.selectedTabId=o==="joint"?"joint":"cartesian"}),(o==="translate"||o==="rotate")&&e.setSelectedCartesianMotionType(o)}const $=e.selectedIncrementId==="continuous"?"continuous":"increment",I=d.useRef(e.activeDiscreteIncrement??e.discreteIncrementOptions[0]);e.activeDiscreteIncrement&&(I.current=e.activeDiscreteIncrement);const j=I.current,P=d.useRef(0);function ee(o,n){return e.discreteIncrementOptions.find(a=>o==="translate"?Math.abs(a.mm-n)<1e-9:Math.abs(l.degreesToRadians(a.degrees)-n)<1e-9)}function oe(){if(e.selectedOrientation==="tool"){const o=t.state.rapidlyChangingMotionState.flange_pose,n=o?h.Pose3.fromPose(o).quaternion.clone():new le.Quaternion,a=e.selectedTcpId?t.description.tcpOffsetsById[e.selectedTcpId]:void 0;return a!=null&&a.pose.orientation&&n.multiply(h.parseRotationToQuaternion(a.pose.orientation,"ROTATION_VECTOR")),n}return h.Pose3.fromCoordinateSystem(e.jogCoordSystem).quaternion}function _(o){t.reportError({kind:"jog",message:o instanceof Error?o.message:String(o),cause:o})}function g(o){o.catch(n=>{n instanceof B.JoggingRefusedError||_(n)})}const[f,te]=d.useState(null),F=d.useRef(f);F.current=f;function ne(o){if(te(o),!o){u.resetToLive();return}A(t,o)}d.useEffect(()=>N.reaction(()=>t.safety.canBeMoved,o=>{const n=F.current,{staged:a,confirming:c}=t.targetPose;o&&n&&!a&&!c&&A(t,n)}),[t]);const k=t.safety.notMoveableReason,J=k?L(k,i):M?null:i("RobotControl.MoveTo.NotMoveable.Deactivated.lb"),v=u.staged,re=f!==null&&u.stagedPose!==null&&B.sameRobotPose(u.stagedPose,q(t,f));return{disabled:m,jogDisabled:T!==null,jogDisabledReason:T?W[T]():void 0,onJogRetry:T==="blocked"?()=>e.unblock():void 0,cartesian:e.canJogCartesian,tab:X,onTabChange:Z,jogMode:$,onJogModeChange:o=>{var n;return e.setSelectedIncrementId(o==="continuous"?"continuous":((n=I.current)==null?void 0:n.id)??"continuous")},gizmoOrientation:s,gizmoFrameQuaternion:oe,tcp:e.tcps.length>0?{options:e.tcps.map(o=>({id:o.id,label:o.id})),value:e.selectedTcpId,onChange:o=>{g(e.requestTcpChange(o))}}:void 0,jogFrame:{options:[{id:O,label:i("Jogging.MoveRelativeTo.SelectedTcp.dd")},...e.coordSystems.map(o=>({id:V+o.coordinate_system,label:G.coordSystemLabel(e,o)}))],value:e.selectedOrientation==="tool"?O:V+e.jogCoordSystemId,onChange:o=>o===O?e.setMoveRelativeToSelectedTcp():e.setMoveRelativeToCoordSystem(o.slice(V.length))},velocity:{translate:{value:e.translationVelocityMmPerSec,min:e.minTranslationVelocityMmPerSec,max:e.maxTranslationVelocityMmPerSec},rotate:{value:e.rotationVelocityRadsPerSec,min:l.degreesToRadians(e.minRotationVelocityDegPerSec),max:l.degreesToRadians(e.maxRotationVelocityDegPerSec)}},onVelocityChange:(o,n)=>o==="rotate"?e.setVelocityFromSlider(z(n),!0):e.setVelocityFromSlider(n,!1),onJogStart:(o,n,a)=>g(e.startCartesianJogging(o,n,a)),onJogStop:()=>g(e.stopJogging()),increments:{steps:{translate:e.discreteIncrementOptions.map(o=>o.mm),rotate:e.discreteIncrementOptions.map(o=>l.degreesToRadians(o.degrees))},onStep:(o,n,a,c)=>{const y=ee(o,c);if(!y)return;P.current++;const S=e.runIncrementalCartesianJog(o,n,a,y);g(S),S.finally(()=>{P.current--}).catch(()=>{})},running:e.incrementJogInProgress,onStepStop:()=>{P.current>0&&g(e.stopIncrementalJog())},step:j&&{translate:j.mm,rotate:l.degreesToRadians(j.degrees)},onStepChange:(o,n)=>{const a=e.discreteIncrementOptions.find(c=>o==="translate"?c.mm===n:Math.abs(l.degreesToRadians(c.degrees)-n)<1e-9);a&&e.setSelectedIncrementId(a.id)}},joints:{joints:D.map((o,n)=>{var a,c,y,S;return{value:o,min:(c=(a=b==null?void 0:b[n])==null?void 0:a.position)==null?void 0:c.lower_limit,max:(S=(y=b==null?void 0:b[n])==null?void 0:y.position)==null?void 0:S.upper_limit,name:C==null?void 0:C[n]}}),linear:R,velocity:R?{value:e.translationVelocityMmPerSec,min:e.minTranslationVelocityMmPerSec,max:e.maxTranslationVelocityMmPerSec}:{value:e.rotationVelocityRadsPerSec,min:l.degreesToRadians(e.minRotationVelocityDegPerSec),max:l.degreesToRadians(e.maxRotationVelocityDegPerSec)},onVelocityChange:o=>R?e.setVelocityFromSlider(o,!1):e.setVelocityFromSlider(z(o),!0),onJogStart:(o,n)=>g(e.startJointJogging(o,n)),onJogStop:()=>g(e.stopJogging())},moveTo:{getCurrentPose:()=>{const o=t.state.displayedTcpPose;return!(o!=null&&o.position)||!o.orientation?null:{position:o.position,orientation:o.orientation}},getCurrentJoints:()=>t.state.jointPose,frame:e.canJogCartesian?{options:e.coordSystems.map(o=>({id:o.coordinate_system,label:G.coordSystemLabel(e,o)})),value:e.selectedCoordSystemId,onChange:o=>e.setSelectedCoordSystemId(o)}:void 0,onTargetChange:ne,state:u.confirming?"planning":re?p.trajectoryState:"idle",error:f&&J?J:v!=null&&v.errorKey?i(v.errorKey,{message:v.errorMessage,interpolation:{escapeValue:!1}}):null,notMoveableReason:J,onMoveStart:o=>{u.holdMove(q(t,o))},onMoveStop:()=>{u.releaseMove().catch(_)}}}}const pe=K.observer(function({session:r,...m}){const s=ae.useRobotSessionOf(r),[i,e]=d.useState({robot:s,panel:0}),p=i.robot===s?i.panel:i.panel+1;return i.robot!==s&&e({robot:s,panel:p}),Q.jsx(be,{session:s,...m},p)}),be=K.observer(function({session:r,disabled:m,gizmoOrientation:s,...i}){const e=H(r,{disabled:m,gizmoOrientation:s});return Q.jsx(ie.RobotControlPanel,{...e,...i})});exports.RobotControl=pe;exports.useRobotControlProps=H;
|