@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.403aa7c → 6.4.0-pr.revamp.667.4e5a9e6
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 +54 -5
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +3 -0
- package/dist/3d.js +25 -20
- package/dist/CurrentPose/index.cjs +1 -0
- package/dist/CurrentPose/index.d.ts +3 -0
- package/dist/CurrentPose/index.js +9 -0
- 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 -0
- package/dist/RobotControl/index.d.ts +3 -0
- package/dist/RobotControl/index.js +9 -0
- package/dist/RobotControlPanel/index.cjs +1 -1
- package/dist/RobotControlPanel/index.js +1 -1
- package/dist/RobotHeader/index.cjs +1 -1
- package/dist/RobotHeader/index.d.ts +2 -0
- package/dist/RobotHeader/index.js +6 -3
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.d.ts +1 -0
- package/dist/SafetyBar/index.js +4 -3
- package/dist/chunks/CurrentPose-BIPvpQLG.cjs +1 -0
- package/dist/chunks/CurrentPose-DYKoKD2D.js +51 -0
- package/dist/chunks/{CurrentPoseBar-CyHUWmjM.cjs → CurrentPoseBar-CAEEifBY.cjs} +1 -1
- package/dist/chunks/{CurrentPoseBar-zTZi68tY.js → CurrentPoseBar-Cb_Pk2jp.js} +2 -2
- package/dist/chunks/{JoggingButtons-CbL-5LMK.cjs → JoggingButtons-DC0jII72.cjs} +1 -1
- package/dist/chunks/{JoggingButtons-CXaozFVz.js → JoggingButtons-DluWqNuO.js} +1 -1
- package/dist/chunks/{JoggingGizmo-DGbFLWgT.cjs → JoggingGizmo-DT7iX5Ka.cjs} +1 -1
- package/dist/chunks/{JoggingGizmo-SuS9MmL7.js → JoggingGizmo-Hy42DAQU.js} +1 -1
- package/dist/chunks/{JoggingGizmoOrientation-x_crT_64.js → JoggingGizmoOrientation-Bba8HLQJ.js} +1 -1
- package/dist/chunks/{JoggingGizmoOrientation-dzned4f4.cjs → JoggingGizmoOrientation-l2slmUE_.cjs} +1 -1
- package/dist/chunks/{JoggingJointSlider-R3_A9Ppj.cjs → JoggingJointSlider-C0lI_9W5.cjs} +1 -1
- package/dist/chunks/{JoggingJointSlider-CZ-k6XCa.js → JoggingJointSlider-DePZ3JHW.js} +1 -1
- package/dist/chunks/Pose3-B_fLR-Wv.js +80 -0
- package/dist/chunks/Pose3-Ch4xVeXV.cjs +1 -0
- package/dist/chunks/RobotControl-C1JzXIAa.js +285 -0
- package/dist/chunks/RobotControl-ku4CNQCb.cjs +1 -0
- package/dist/chunks/{RobotControlPanel-BXtBHEe9.cjs → RobotControlPanel-B4u3D3yO.cjs} +1 -1
- package/dist/chunks/{RobotControlPanel-BiLexAWI.js → RobotControlPanel-Cy5LwU1h.js} +5 -5
- package/dist/chunks/coordSystemLabel-BJKeaGA3.cjs +1 -0
- package/dist/chunks/coordSystemLabel-C1jfhEh5.js +29 -0
- package/dist/chunks/{externalizeComponent-BdxGBLIv.cjs → externalizeComponent-Bl23ayrr.cjs} +1 -1
- package/dist/chunks/{externalizeComponent-_w2d1_pz.js → externalizeComponent-CSzPVfuG.js} +4 -2
- package/dist/chunks/{loadRobotSession-dh1V1ljR.js → loadRobotSession-DVkuHA-V.js} +814 -702
- package/dist/chunks/loadRobotSession-cQNeaBOf.cjs +3 -0
- package/dist/chunks/robotActivationOf-DUHukd46.js +371 -0
- package/dist/chunks/robotActivationOf-DeJsI4H5.cjs +1 -0
- package/dist/chunks/robotModelSource-C2Mi0LtR.js +1296 -0
- package/dist/chunks/robotModelSource-D7VR89r_.cjs +1 -0
- package/dist/chunks/{SafetyBar-BVk-SH_0.cjs → robotSafetyOf-Cb4qlwd_.cjs} +1 -1
- package/dist/chunks/{SafetyBar-eYzCHOFD.js → robotSafetyOf-Dr5Q4rCp.js} +44 -34
- package/dist/chunks/useEveryFrame-CHxg25f4.cjs +1 -0
- package/dist/chunks/useEveryFrame-DAuNawGP.js +155 -0
- package/dist/chunks/{Pose3-pocKPrHN.js → useSmoothedMotionState-COMJRcOt.js} +63 -141
- package/dist/chunks/useSmoothedMotionState-Con0E5Bx.cjs +1 -0
- package/dist/components/currentPoseBar/CurrentPose.d.ts +23 -0
- package/dist/components/currentPoseBar/useCurrentPoseProps.d.ts +16 -0
- package/dist/components/jogging/coordSystemLabel.d.ts +7 -0
- package/dist/components/robotControl/RobotControl.d.ts +23 -0
- package/dist/components/robotControl/poseText.d.ts +21 -5
- package/dist/components/robotControl/useRobotControlProps.d.ts +28 -0
- package/dist/components/robotHeader/robotActivationOf.d.ts +8 -0
- package/dist/components/robotHeader/robotSafetyOf.d.ts +11 -0
- package/dist/components/robotSession/RobotSessionProvider.d.ts +13 -0
- package/dist/components/robots/LinearAxis.d.ts +12 -11
- package/dist/components/robots/Robot.d.ts +26 -9
- package/dist/components/robots/robotModelSource.d.ts +38 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +8 -0
- package/dist/core.js +65 -50
- package/dist/index.cjs +1 -1
- package/dist/index.js +91 -71
- package/dist/lib/ConnectedMotionGroup.d.ts +5 -1
- package/dist/lib/robotSession/RobotDescription.d.ts +6 -2
- package/dist/lib/robotSession/RobotLiveState.d.ts +7 -0
- package/dist/lib/robotSession/RobotSession.d.ts +3 -0
- package/dist/lib/robotSession/RobotTargetPose.d.ts +78 -0
- package/dist/lib/robotSession/robotPose.d.ts +28 -0
- package/package.json +1 -1
- package/dist/chunks/Pose3-DIyg-aZA.cjs +0 -1
- package/dist/chunks/Robot-B3vKEVXP.cjs +0 -1
- package/dist/chunks/Robot-DDD382dk.js +0 -1272
- package/dist/chunks/RobotHeader-BvIzk8Fw.js +0 -244
- package/dist/chunks/RobotHeader-Daft80jq.cjs +0 -1
- package/dist/chunks/loadRobotSession-C8vDrOsJ.cjs +0 -3
- package/dist/chunks/useEveryFrame-G_-ma1nC.js +0 -142
- package/dist/chunks/useEveryFrame-dmPPTKtT.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("react/jsx-runtime"),w=require("@mui/material/Box"),P=require("@mui/material/Stack"),J=require("@mui/material/styles"),z=require("@mui/material/Typography"),h=require("react"),tt=require("./externalizeComponent-
|
|
1
|
+
"use strict";const u=require("react/jsx-runtime"),w=require("@mui/material/Box"),P=require("@mui/material/Stack"),J=require("@mui/material/styles"),z=require("@mui/material/Typography"),h=require("react"),tt=require("./externalizeComponent-Bl23ayrr.cjs"),S=require("./holdSafety-BtoZ5We3.cjs"),I=2*Math.PI;function nt({min:t,max:n,linear:o},f){const s=t!==void 0,c=n!==void 0;if(s&&c&&n>t)return{min:t,max:n};if(o)return null;if(s&&!c)return{min:t,max:t+I};if(c&&!s)return{min:n-I,max:n};const b=Math.round(f/I)*I;return{min:b-Math.PI,max:b+Math.PI}}function G(t,n){return Math.min(1,Math.max(0,(t-n.min)/(n.max-n.min)))}function et(t,n){const o=Math.min(1,Math.max(0,t));return n.min+o*(n.max-n.min)}function ot(t){return t.min>0||t.max<0?null:G(0,t)}function O(t,n,o){return Math.abs(n-t)<=o?null:n>t?"+":"-"}function rt(t,n,o){return o==="+"?t>=n:t<=n}function it(t,n){return t?"mm":n}const L={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 W(t,n){const o=t.toFixed(n);return Number(o)===0?0 .toFixed(n):o}function v(t,n){return L[n].shown(t)}function st(t,n){const{shown:o,decimals:f,suffix:s}=L[n];return`${W(o(t),f)}${s}`}function K(t,n){const{shown:o,limitDecimals:f,suffix:s}=L[n],c=10**f,b=o(t),d=Math.sign(b)*Math.round(Math.abs(b)*c)/c;return`${d>0?"+":""}${W(d,f)}${s}`}const N=16,U=4;function V({railRef:t,at:n,goalAt:o,held:f,zeroAt:s,limits:c,disabled:b}){const d=J.useTheme(),x=d.palette.primary.main,l=`0 0 0 8px ${J.alpha(x,.16)}`;return u.jsxs(u.Fragment,{children:[u.jsxs(w,{ref:t,sx:{position:"absolute",left:0,right:0,top:"50%",height:U,transform:"translateY(-50%)"},children:[u.jsx(w,{sx:{position:"absolute",inset:0,borderRadius:U/2,backgroundColor:J.alpha(x,.38)}}),n!==null&&o!==null&&u.jsx(w,{sx:{position:"absolute",top:0,bottom:0,borderRadius:U/2,backgroundColor:x},style:{left:`${Math.min(n,o)*100}%`,width:`${Math.abs(o-n)*100}%`,opacity:f?1:.5}}),s!==null&&u.jsx(w,{"aria-hidden":!0,sx:{position:"absolute",top:"50%",width:2,height:12,transform:"translate(-50%, -50%)",borderRadius:1,backgroundColor:"text.secondary"},style:{left:`${s*100}%`}}),n!==null&&u.jsx(w,{sx:{position:"absolute",top:"50%",boxSizing:"border-box",width:N,height:N,transform:"translate(-50%, -50%)",borderRadius:"50%",border:`3px solid ${x}`,backgroundColor:"background.paper",boxShadow:f?l:d.shadows[2],transition:"box-shadow 150ms","&:hover":b?{}:{boxShadow:l}},style:{left:`${n*100}%`}})]}),c&&u.jsx(P,{direction:"row",sx:{position:"absolute",left:0,right:0,top:30,justifyContent:"space-between"},children:[c.min,c.max].map((k,j)=>u.jsx(z,{variant:"caption",color:"text.secondary",sx:{fontSize:10,lineHeight:"14px"},children:k},j))})]})}function ut({value:t,onJogStart:n,onJogStop:o,disabled:f}){const s=h.useRef(null),[c,b]=h.useState(null),d=h.useCallback(e=>{s.current=e,b(e)},[]),x=h.useRef({value:t,onJogStart:n,onJogStop:o});x.current={value:t,onJogStart:n,onJogStop:o};const l=h.useCallback((e,m,g)=>{const y=O(x.current.value,m,g);d({...e,goal:m,direction:y,settledAt:y?null:e.settledAt}),e.direction&&e.direction!==y&&x.current.onJogStop(),y&&y!==e.direction&&x.current.onJogStart(y)},[d]),k=h.useCallback(()=>s.current!==null,[]),j=h.useCallback((e,m,g)=>f||s.current?!1:(l({goal:e,direction:null,settledAt:null,by:g},e,m),!0),[f,l]),M=h.useCallback((e,m)=>{const g=s.current;if(g){if(g.direction===null&&g.settledAt!==null&&Math.abs(e-g.settledAt)<=m){d({...g,goal:e});return}l(g,e,m)}},[l,d]),C=h.useCallback(()=>{const e=s.current;e&&(d(null),e.direction&&x.current.onJogStop())},[d]),D=h.useCallback(()=>{var e;return((e=s.current)==null?void 0:e.by)??null},[]),$=h.useCallback(e=>{const m=s.current;m&&e(m.by)&&C()},[C]);return h.useEffect(()=>{const e=s.current;e!=null&&e.direction&&rt(t,e.goal,e.direction)&&(d({...e,direction:null,settledAt:e.goal}),x.current.onJogStop())},[t,d]),S.useEndHoldWhenUnattended(c!==null,f,C),{hold:c,isHolding:k,heldBy:D,begin:j,moveGoal:M,end:C,endIfHeldBy:$}}function lt(t){return t==="mouse"||t==="pen"?1:4}function at(t){return t==="ArrowRight"||t==="ArrowUp"?"+":t==="ArrowLeft"||t==="ArrowDown"?"-":null}const ct=tt.externalizeComponent(({label:t,name:n,value:o,min:f,max:s,linear:c=!1,angleUnit:b="deg",onJogStart:d,onJogStop:x,disabled:l=!1})=>{const k=J.useTheme(),j=h.useRef(null),{hold:M,isHolding:C,heldBy:D,begin:$,moveGoal:e,end:m,endIfHeldBy:g}=ut({value:o,onJogStart:d,onJogStop:x,disabled:l}),[y,q]=h.useState(null);h.useEffect(()=>{l&&q(null)},[l]);const a=nt({min:f,max:s,linear:c},o),R=it(c,b),B=r=>st(r,R);function E({clientX:r,pointerType:i}){if(!a||!j.current)return null;const p=j.current.getBoundingClientRect();return p.width<=0?null:{goal:et((r-p.left)/p.width,a),deadband:lt(i)/p.width*(a.max-a.min)}}function Y(r){var p,H;if(!S.startsPointerHold(r)||l||C())return;const i=E(r);if(i){try{(H=(p=r.currentTarget).setPointerCapture)==null||H.call(p,r.pointerId)}catch{}$(i.goal,i.deadband,{pointer:r.pointerId})}}function Z(r){const i=E(r);q(l?null:(i==null?void 0:i.goal)??null);const p=D();if(!(!p||!("pointer"in p)||p.pointer!==r.pointerId)){if(S.primaryReleased(r)){m();return}i&&e(i.goal,i.deadband)}}function T(r){g(i=>"pointer"in i&&i.pointer===r.pointerId)}function _(r){const i=at(r.key);if(i&&r.preventDefault(),C()){S.endsHold(r)&&m();return}if(!i||!S.startsKeyHold(r)||l||!a)return;const p=i==="+"?a.max:a.min,H=(a.max-a.min)*1e-4;O(o,p,H)===i&&$(p,H,{key:r.key})}function Q(r){g(i=>"key"in i&&i.key===r.key)}const A=(M==null?void 0:M.goal)??y,X=a&&{min:K(a.min,R),max:K(a.max,R)},F=u.jsxs(P,{direction:"row",sx:{justifyContent:"space-between",gap:1,mb:"-4px"},children:[u.jsxs(z,{variant:"body2",noWrap:!0,children:[t,n&&u.jsx(w,{component:"span",sx:{color:"text.secondary"},children:` - ${n}`})]}),u.jsxs(z,{variant:"body2",sx:{fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:[B(o),a&&A!==null&&u.jsx(w,{component:"span",sx:{color:"text.secondary"},children:` / ${B(A)}`})]})]});return a?u.jsxs(P,{"data-testid":"jogging-joint-slider",children:[F,u.jsx(w,{role:"slider",tabIndex:l?-1:0,"aria-label":n?`${t} ${n}`:t,"aria-valuemin":v(a.min,R),"aria-valuemax":v(a.max,R),"aria-valuenow":v(o,R),"aria-valuetext":B(o),"aria-disabled":l||void 0,onPointerDown:Y,onPointerMove:Z,onPointerLeave:()=>q(null),onPointerUp:T,onPointerCancel:T,onLostPointerCapture:T,onKeyDown:_,onKeyUp:Q,onBlur:m,onContextMenu:S.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 ${k.palette.primary.main}`,outlineOffset:"2px"}},children:u.jsx(V,{railRef:j,at:G(o,a),goalAt:A===null?null:G(A,a),held:M!==null,zeroAt:ot(a),limits:X??void 0,disabled:l})})]}):u.jsxs(P,{"data-testid":"jogging-joint-slider",children:[F,u.jsx(w,{"aria-hidden":!0,sx:{position:"relative",height:44},children:u.jsx(V,{at:null,goalAt:null,held:!1,zeroAt:null,disabled:!0})})]})});exports.JoggingJointSlider=ct;
|
|
@@ -4,7 +4,7 @@ import J from "@mui/material/Stack";
|
|
|
4
4
|
import { useTheme as Y, alpha as N } from "@mui/material/styles";
|
|
5
5
|
import G from "@mui/material/Typography";
|
|
6
6
|
import { useRef as L, useState as Z, useCallback as y, useEffect as _ } from "react";
|
|
7
|
-
import { e as it } from "./externalizeComponent-
|
|
7
|
+
import { e as it } from "./externalizeComponent-CSzPVfuG.js";
|
|
8
8
|
import { u as st, p as at, b as lt, a as ut, e as ct, s as dt } from "./holdSafety-Di1GZAWg.js";
|
|
9
9
|
const k = 2 * Math.PI;
|
|
10
10
|
function ft({ min: t, max: n, linear: r }, d) {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Quaternion as r, Vector3 as a } from "three";
|
|
2
|
+
function s(t, n) {
|
|
3
|
+
if (n === "QUATERNION" && t)
|
|
4
|
+
return new r(...t);
|
|
5
|
+
if (n === "ROTATION_VECTOR" && t) {
|
|
6
|
+
if (t && t.length < 3)
|
|
7
|
+
throw new Error(
|
|
8
|
+
`Invalid rotation vector length: ${t.length}. Expected at least 3 values.`
|
|
9
|
+
);
|
|
10
|
+
const e = new a(
|
|
11
|
+
t[0],
|
|
12
|
+
t[1],
|
|
13
|
+
t[2]
|
|
14
|
+
), o = e.length(), l = e.normalize();
|
|
15
|
+
return new r().setFromAxisAngle(l, o);
|
|
16
|
+
} else
|
|
17
|
+
return console.warn(
|
|
18
|
+
`Unsupported rotation type '${n}'. Only QUATERNION and ROTATION_VECTOR are supported for now.`
|
|
19
|
+
), new r();
|
|
20
|
+
}
|
|
21
|
+
function u(t) {
|
|
22
|
+
const n = new a(t.x, t.y, t.z), e = 2 * Math.atan2(n.length(), Math.abs(t.w));
|
|
23
|
+
n.normalize();
|
|
24
|
+
const o = (t.w >= 0 ? 1 : 0) - (t.w < 0 ? 1 : 0);
|
|
25
|
+
return n.multiplyScalar(o).multiplyScalar(e);
|
|
26
|
+
}
|
|
27
|
+
class i {
|
|
28
|
+
constructor(n, e) {
|
|
29
|
+
this.position = n, this.quaternion = e;
|
|
30
|
+
}
|
|
31
|
+
static fromPose(n) {
|
|
32
|
+
const e = n.orientation ? s(n.orientation, "ROTATION_VECTOR") : new r(), o = n.position ?? [0, 0, 0];
|
|
33
|
+
return new i(
|
|
34
|
+
new a(o[0] ?? 0, o[1] ?? 0, o[2] ?? 0),
|
|
35
|
+
e
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
/** A TCP's offset from the flange */
|
|
39
|
+
static fromRobotTcp(n) {
|
|
40
|
+
const e = n.orientation ? s(
|
|
41
|
+
n.orientation,
|
|
42
|
+
n.orientation_type ?? "ROTATION_VECTOR"
|
|
43
|
+
) : new r(), o = n.position ?? [0, 0, 0];
|
|
44
|
+
return new i(
|
|
45
|
+
new a(o[0] ?? 0, o[1] ?? 0, o[2] ?? 0),
|
|
46
|
+
e
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
static fromCoordinateSystem(n) {
|
|
50
|
+
const e = n.orientation ? s(
|
|
51
|
+
n.orientation,
|
|
52
|
+
n.orientation_type ?? "ROTATION_VECTOR"
|
|
53
|
+
) : new r(), o = n.position ?? [0, 0, 0];
|
|
54
|
+
return new i(
|
|
55
|
+
new a(o[0] ?? 0, o[1] ?? 0, o[2] ?? 0),
|
|
56
|
+
e
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
inverse() {
|
|
60
|
+
const n = this.quaternion.clone().invert();
|
|
61
|
+
return new i(
|
|
62
|
+
this.position.clone().applyQuaternion(n).multiplyScalar(-1),
|
|
63
|
+
n
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
multiply(n) {
|
|
67
|
+
return new i(
|
|
68
|
+
this.position.clone().add(n.position.clone().applyQuaternion(this.quaternion)),
|
|
69
|
+
this.quaternion.clone().multiply(n.quaternion).normalize()
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
get orientation() {
|
|
73
|
+
return u(this.quaternion);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
i as P,
|
|
78
|
+
s as p,
|
|
79
|
+
u as q
|
|
80
|
+
};
|
|
@@ -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 e=new i.Vector3(t[0],t[1],t[2]),o=e.length(),u=e.normalize();return new i.Quaternion().setFromAxisAngle(u,o)}else return console.warn(`Unsupported rotation type '${n}'. Only QUATERNION and ROTATION_VECTOR are supported for now.`),new i.Quaternion}function s(t){const n=new i.Vector3(t.x,t.y,t.z),e=2*Math.atan2(n.length(),Math.abs(t.w));n.normalize();const o=(t.w>=0?1:0)-(t.w<0?1:0);return n.multiplyScalar(o).multiplyScalar(e)}class r{constructor(n,e){this.position=n,this.quaternion=e}static fromPose(n){const e=n.orientation?a(n.orientation,"ROTATION_VECTOR"):new i.Quaternion,o=n.position??[0,0,0];return new r(new i.Vector3(o[0]??0,o[1]??0,o[2]??0),e)}static fromRobotTcp(n){const e=n.orientation?a(n.orientation,n.orientation_type??"ROTATION_VECTOR"):new i.Quaternion,o=n.position??[0,0,0];return new r(new i.Vector3(o[0]??0,o[1]??0,o[2]??0),e)}static fromCoordinateSystem(n){const e=n.orientation?a(n.orientation,n.orientation_type??"ROTATION_VECTOR"):new i.Quaternion,o=n.position??[0,0,0];return new r(new i.Vector3(o[0]??0,o[1]??0,o[2]??0),e)}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 s(this.quaternion)}}exports.Pose3=r;exports.parseRotationToQuaternion=a;exports.quaternionToRotationVector=s;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { jsx as G } from "react/jsx-runtime";
|
|
2
|
+
import { observer as W } from "mobx-react-lite";
|
|
3
|
+
import { c as _, a as Y } from "./coordSystemLabel-C1jfhEh5.js";
|
|
4
|
+
import { R as $ } from "./RobotControlPanel-Cy5LwU1h.js";
|
|
5
|
+
import { degreesToRadians as c, radiansToDegrees as H } from "@wandelbots/nova-js";
|
|
6
|
+
import { JointTypeEnum as Z } from "@wandelbots/nova-js/v2";
|
|
7
|
+
import { runInAction as tt, when as et } from "mobx";
|
|
8
|
+
import { useEffect as ot, useState as nt, useRef as P, useMemo as rt } from "react";
|
|
9
|
+
import { useTranslation as at } from "react-i18next";
|
|
10
|
+
import { Quaternion as it } from "three";
|
|
11
|
+
import { i as ct } from "./externalizeComponent-CSzPVfuG.js";
|
|
12
|
+
import { P as st, p as D } from "./Pose3-B_fLR-Wv.js";
|
|
13
|
+
import { u as lt } from "./useEveryFrame-DAuNawGP.js";
|
|
14
|
+
const E = [
|
|
15
|
+
"Base",
|
|
16
|
+
"Shoulder",
|
|
17
|
+
"Elbow",
|
|
18
|
+
"Forearm",
|
|
19
|
+
"Wrist",
|
|
20
|
+
"Flange"
|
|
21
|
+
], I = "selected-tcp", R = "coordinate-system:", F = (a) => Math.round(H(a) * 1e6) / 1e6;
|
|
22
|
+
function mt(a) {
|
|
23
|
+
const s = lt(
|
|
24
|
+
() => a.jogger.motionStream.rapidlyChangingMotionState.joint_position.join(
|
|
25
|
+
" "
|
|
26
|
+
),
|
|
27
|
+
!0
|
|
28
|
+
);
|
|
29
|
+
return rt(() => s ? s.split(" ").map(Number) : [], [s]);
|
|
30
|
+
}
|
|
31
|
+
function dt(a, s = {}) {
|
|
32
|
+
var O;
|
|
33
|
+
const { disabled: S = !1, gizmoOrientation: T } = s, { t: f } = at(void 0, { i18n: ct }), t = a.jogging, { trajectory: i, targetPose: y } = a, V = mt(t), m = t.jointType === Z.PrismaticJoint, d = (O = t.motionGroupDescription.operation_limits.auto_limits) == null ? void 0 : O.joints, b = i.trajectoryState === "moving" || i.trajectoryState === "stopping", w = S || b;
|
|
34
|
+
ot(() => {
|
|
35
|
+
w ? t.lock("external") : t.unlock("external");
|
|
36
|
+
}, [t, w]);
|
|
37
|
+
const [k, x] = nt(!1), A = k ? "moveTo" : t.currentTab.id === "joint" ? "joint" : t.selectedCartesianMotionType;
|
|
38
|
+
function N(e) {
|
|
39
|
+
x(e === "moveTo"), tt(() => {
|
|
40
|
+
t.selectedTabId = e === "joint" ? "joint" : "cartesian";
|
|
41
|
+
}), (e === "translate" || e === "rotate") && t.setSelectedCartesianMotionType(e);
|
|
42
|
+
}
|
|
43
|
+
const Q = t.selectedIncrementId === "continuous" ? "continuous" : "increment", j = P(
|
|
44
|
+
t.activeDiscreteIncrement ?? t.discreteIncrementOptions[0]
|
|
45
|
+
);
|
|
46
|
+
t.activeDiscreteIncrement && (j.current = t.activeDiscreteIncrement);
|
|
47
|
+
const C = j.current, u = P(0);
|
|
48
|
+
async function B(e, o, n) {
|
|
49
|
+
const r = ++u.current;
|
|
50
|
+
t.isLocked || (await t.activate(), r === u.current && (e === "translate" ? await t.jogger.translateTCP({
|
|
51
|
+
axis: o,
|
|
52
|
+
direction: n,
|
|
53
|
+
velocityMmPerSec: t.translationVelocityMmPerSec
|
|
54
|
+
}) : await t.jogger.rotateTCP({
|
|
55
|
+
axis: o,
|
|
56
|
+
direction: n,
|
|
57
|
+
velocityRadsPerSec: t.rotationVelocityRadsPerSec
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
60
|
+
async function L(e, o) {
|
|
61
|
+
const n = ++u.current;
|
|
62
|
+
await t.activate(), n === u.current && await t.jogger.rotateJoints({
|
|
63
|
+
joint: e,
|
|
64
|
+
direction: o,
|
|
65
|
+
velocityUnit: m ? "mm/s" : "rad/s",
|
|
66
|
+
velocityValue: m ? t.translationVelocityMmPerSec : t.rotationVelocityRadsPerSec
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async function J() {
|
|
70
|
+
const e = ++u.current;
|
|
71
|
+
await t.jogger.stop(), e === u.current && await t.deactivate();
|
|
72
|
+
}
|
|
73
|
+
async function U(e, o, n, r) {
|
|
74
|
+
const p = t.discreteIncrementOptions.find(
|
|
75
|
+
(g) => e === "translate" ? Math.abs(g.mm - r) < 1e-9 : Math.abs(c(g.degrees) - r) < 1e-9
|
|
76
|
+
);
|
|
77
|
+
!p || t.isLocked || await t.withMotionLock(async () => {
|
|
78
|
+
try {
|
|
79
|
+
const M = (await t.activate()).motionStream.rapidlyChangingMotionState;
|
|
80
|
+
if (!M.tcp_pose) return;
|
|
81
|
+
t.setCurrentIncrementJog({ axis: o, direction: n }), await t.jogger.runIncrementalCartesianMotion({
|
|
82
|
+
currentTcpPose: M.tcp_pose,
|
|
83
|
+
currentJoints: M.joint_position,
|
|
84
|
+
velocityInRelevantUnits: e === "translate" ? t.translationVelocityMmPerSec : t.rotationVelocityRadsPerSec,
|
|
85
|
+
axis: o,
|
|
86
|
+
direction: n,
|
|
87
|
+
motion: e === "translate" ? { type: "translate", distanceMm: p.mm } : {
|
|
88
|
+
type: "rotate",
|
|
89
|
+
distanceRads: c(p.degrees)
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
} finally {
|
|
93
|
+
t.setCurrentIncrementJog(null), await t.deactivate();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function q() {
|
|
98
|
+
if (t.selectedOrientation === "tool") {
|
|
99
|
+
const o = a.state.rapidlyChangingMotionState.flange_pose, n = o ? st.fromPose(o).quaternion.clone() : new it(), r = t.selectedTcpId ? a.description.tcpOffsetsById[t.selectedTcpId] : void 0;
|
|
100
|
+
return r != null && r.pose.orientation && n.multiply(
|
|
101
|
+
D(r.pose.orientation, "ROTATION_VECTOR")
|
|
102
|
+
), n;
|
|
103
|
+
}
|
|
104
|
+
const e = t.jogCoordSystem;
|
|
105
|
+
return D(
|
|
106
|
+
e.orientation ?? [1, 0, 0, 0],
|
|
107
|
+
e.orientation_type ?? "QUATERNION"
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
function l(e) {
|
|
111
|
+
a.reportError({
|
|
112
|
+
kind: "jog",
|
|
113
|
+
message: e instanceof Error ? e.message : String(e),
|
|
114
|
+
cause: e
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const h = P(!1);
|
|
118
|
+
function z(e) {
|
|
119
|
+
if (!e) {
|
|
120
|
+
y.resetToLive();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
y.setDraft(
|
|
124
|
+
`(${[...e.position, ...e.orientation].join(", ")})`
|
|
125
|
+
), y.confirmEdit();
|
|
126
|
+
}
|
|
127
|
+
function K() {
|
|
128
|
+
i.trajectoryState === "planned" && i.plannedTrajectory && (h.current = !0, i.start());
|
|
129
|
+
}
|
|
130
|
+
async function X() {
|
|
131
|
+
h.current && (h.current = !1, await et(() => i.trajectoryState !== "planned", {
|
|
132
|
+
timeout: 2e3
|
|
133
|
+
}).catch(() => {
|
|
134
|
+
}), i.trajectoryState === "moving" && await i.pause());
|
|
135
|
+
}
|
|
136
|
+
const v = y.staged;
|
|
137
|
+
return {
|
|
138
|
+
disabled: S,
|
|
139
|
+
// Jogging waits for a trajectory, and for another client's jogging
|
|
140
|
+
jogDisabled: b || t.blocked,
|
|
141
|
+
// A linear axis or a turntable jogs its joints only
|
|
142
|
+
cartesian: t.canJogCartesian,
|
|
143
|
+
tab: A,
|
|
144
|
+
onTabChange: N,
|
|
145
|
+
jogMode: Q,
|
|
146
|
+
onJogModeChange: (e) => {
|
|
147
|
+
var o;
|
|
148
|
+
return t.setSelectedIncrementId(
|
|
149
|
+
e === "continuous" ? "continuous" : ((o = j.current) == null ? void 0 : o.id) ?? "continuous"
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
gizmoOrientation: T,
|
|
153
|
+
gizmoFrameQuaternion: q,
|
|
154
|
+
tcp: t.tcps.length > 0 ? {
|
|
155
|
+
options: t.tcps.map((e) => ({ id: e.id, label: e.id })),
|
|
156
|
+
value: t.selectedTcpId,
|
|
157
|
+
onChange: (e) => {
|
|
158
|
+
t.requestTcpChange(e).catch(l);
|
|
159
|
+
}
|
|
160
|
+
} : void 0,
|
|
161
|
+
jogFrame: {
|
|
162
|
+
options: [
|
|
163
|
+
{
|
|
164
|
+
id: I,
|
|
165
|
+
label: f("Jogging.MoveRelativeTo.SelectedTcp.dd")
|
|
166
|
+
},
|
|
167
|
+
...t.coordSystems.map((e) => ({
|
|
168
|
+
id: R + e.coordinate_system,
|
|
169
|
+
label: _(t, e)
|
|
170
|
+
}))
|
|
171
|
+
],
|
|
172
|
+
value: t.selectedOrientation === "tool" ? I : R + t.jogCoordSystemId,
|
|
173
|
+
onChange: (e) => e === I ? t.setMoveRelativeToSelectedTcp() : t.setMoveRelativeToCoordSystem(e.slice(R.length))
|
|
174
|
+
},
|
|
175
|
+
velocity: {
|
|
176
|
+
translate: {
|
|
177
|
+
value: t.translationVelocityMmPerSec,
|
|
178
|
+
min: t.minTranslationVelocityMmPerSec,
|
|
179
|
+
max: t.maxTranslationVelocityMmPerSec
|
|
180
|
+
},
|
|
181
|
+
rotate: {
|
|
182
|
+
value: t.rotationVelocityRadsPerSec,
|
|
183
|
+
min: c(t.minRotationVelocityDegPerSec),
|
|
184
|
+
max: c(t.maxRotationVelocityDegPerSec)
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
onVelocityChange: (e, o) => e === "rotate" ? t.setVelocityFromSlider(F(o), !0) : t.setVelocityFromSlider(o, !1),
|
|
188
|
+
onJogStart: (e, o, n) => {
|
|
189
|
+
B(e, o, n).catch(l);
|
|
190
|
+
},
|
|
191
|
+
onJogStop: () => {
|
|
192
|
+
J().catch(l);
|
|
193
|
+
},
|
|
194
|
+
increments: {
|
|
195
|
+
steps: {
|
|
196
|
+
translate: t.discreteIncrementOptions.map((e) => e.mm),
|
|
197
|
+
rotate: t.discreteIncrementOptions.map(
|
|
198
|
+
(e) => c(e.degrees)
|
|
199
|
+
)
|
|
200
|
+
},
|
|
201
|
+
onStep: (e, o, n, r) => {
|
|
202
|
+
U(e, o, n, r).catch(l);
|
|
203
|
+
},
|
|
204
|
+
running: t.incrementJogInProgress,
|
|
205
|
+
// The store's increments pair a distance with an angle
|
|
206
|
+
step: C && {
|
|
207
|
+
translate: C.mm,
|
|
208
|
+
rotate: c(C.degrees)
|
|
209
|
+
},
|
|
210
|
+
onStepChange: (e, o) => {
|
|
211
|
+
const n = t.discreteIncrementOptions.find(
|
|
212
|
+
(r) => e === "translate" ? r.mm === o : Math.abs(c(r.degrees) - o) < 1e-9
|
|
213
|
+
);
|
|
214
|
+
n && t.setSelectedIncrementId(n.id);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
joints: {
|
|
218
|
+
joints: V.map((e, o) => {
|
|
219
|
+
var n, r, p, g;
|
|
220
|
+
return {
|
|
221
|
+
value: e,
|
|
222
|
+
min: (r = (n = d == null ? void 0 : d[o]) == null ? void 0 : n.position) == null ? void 0 : r.lower_limit,
|
|
223
|
+
max: (g = (p = d == null ? void 0 : d[o]) == null ? void 0 : p.position) == null ? void 0 : g.upper_limit,
|
|
224
|
+
name: V.length === E.length && !m ? E[o] : void 0
|
|
225
|
+
};
|
|
226
|
+
}),
|
|
227
|
+
linear: m,
|
|
228
|
+
velocity: m ? {
|
|
229
|
+
value: t.translationVelocityMmPerSec,
|
|
230
|
+
min: t.minTranslationVelocityMmPerSec,
|
|
231
|
+
max: t.maxTranslationVelocityMmPerSec
|
|
232
|
+
} : {
|
|
233
|
+
value: t.rotationVelocityRadsPerSec,
|
|
234
|
+
min: c(t.minRotationVelocityDegPerSec),
|
|
235
|
+
max: c(t.maxRotationVelocityDegPerSec)
|
|
236
|
+
},
|
|
237
|
+
onVelocityChange: (e) => m ? t.setVelocityFromSlider(e, !1) : t.setVelocityFromSlider(F(e), !0),
|
|
238
|
+
onJogStart: (e, o) => {
|
|
239
|
+
L(e, o).catch(l);
|
|
240
|
+
},
|
|
241
|
+
onJogStop: () => {
|
|
242
|
+
J().catch(l);
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
moveTo: {
|
|
246
|
+
getCurrentPose: () => {
|
|
247
|
+
const e = a.state.displayedTcpPose;
|
|
248
|
+
return !(e != null && e.position) || !e.orientation ? null : {
|
|
249
|
+
position: e.position,
|
|
250
|
+
orientation: e.orientation
|
|
251
|
+
};
|
|
252
|
+
},
|
|
253
|
+
// The typed pose is read in the coordinate system of the displayed pose
|
|
254
|
+
frame: {
|
|
255
|
+
options: t.coordSystems.map((e) => ({
|
|
256
|
+
id: e.coordinate_system,
|
|
257
|
+
label: _(t, e)
|
|
258
|
+
})),
|
|
259
|
+
value: t.selectedCoordSystemId,
|
|
260
|
+
onChange: (e) => t.setSelectedCoordSystemId(e)
|
|
261
|
+
},
|
|
262
|
+
onTargetChange: z,
|
|
263
|
+
// The trajectory's states are the panel's
|
|
264
|
+
state: y.confirming ? "planning" : i.trajectoryState,
|
|
265
|
+
error: v != null && v.errorKey ? f(v.errorKey) : null,
|
|
266
|
+
onMoveStart: K,
|
|
267
|
+
onMoveStop: () => {
|
|
268
|
+
X().catch(l);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
const It = W(function({
|
|
274
|
+
session: s,
|
|
275
|
+
disabled: S,
|
|
276
|
+
gizmoOrientation: T,
|
|
277
|
+
...f
|
|
278
|
+
}) {
|
|
279
|
+
const t = Y(s), i = dt(t, { disabled: S, gizmoOrientation: T });
|
|
280
|
+
return /* @__PURE__ */ G($, { ...i, ...f });
|
|
281
|
+
});
|
|
282
|
+
export {
|
|
283
|
+
It as R,
|
|
284
|
+
dt as u
|
|
285
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const W=require("react/jsx-runtime"),Y=require("mobx-react-lite"),V=require("./coordSystemLabel-BJKeaGA3.cjs"),$=require("./RobotControlPanel-B4u3D3yO.cjs"),s=require("@wandelbots/nova-js"),Z=require("@wandelbots/nova-js/v2"),q=require("mobx"),y=require("react"),ee=require("react-i18next"),te=require("three"),oe=require("./externalizeComponent-Bl23ayrr.cjs"),M=require("./Pose3-Ch4xVeXV.cjs"),ne=require("./useEveryFrame-CHxg25f4.cjs"),D=["Base","Shoulder","Elbow","Forearm","Wrist","Flange"],b="selected-tcp",I="coordinate-system:",F=a=>Math.round(s.radiansToDegrees(a)*1e6)/1e6;function re(a){const c=ne.useEveryFrame(()=>a.jogger.motionStream.rapidlyChangingMotionState.joint_position.join(" "),!0);return y.useMemo(()=>c?c.split(" ").map(Number):[],[c])}function x(a,c={}){var _;const{disabled:f=!1,gizmoOrientation:R}=c,{t:T}=ee.useTranslation(void 0,{i18n:oe.i18n}),e=a.jogging,{trajectory:i,targetPose:S}=a,w=re(e),m=e.jointType===Z.JointTypeEnum.PrismaticJoint,d=(_=e.motionGroupDescription.operation_limits.auto_limits)==null?void 0:_.joints,J=i.trajectoryState==="moving"||i.trajectoryState==="stopping",E=f||J;y.useEffect(()=>{E?e.lock("external"):e.unlock("external")},[e,E]);const[k,L]=y.useState(!1),A=k?"moveTo":e.currentTab.id==="joint"?"joint":e.selectedCartesianMotionType;function N(t){L(t==="moveTo"),q.runInAction(()=>{e.selectedTabId=t==="joint"?"joint":"cartesian"}),(t==="translate"||t==="rotate")&&e.setSelectedCartesianMotionType(t)}const Q=e.selectedIncrementId==="continuous"?"continuous":"increment",C=y.useRef(e.activeDiscreteIncrement??e.discreteIncrementOptions[0]);e.activeDiscreteIncrement&&(C.current=e.activeDiscreteIncrement);const j=C.current,u=y.useRef(0);async function z(t,o,n){const r=++u.current;e.isLocked||(await e.activate(),r===u.current&&(t==="translate"?await e.jogger.translateTCP({axis:o,direction:n,velocityMmPerSec:e.translationVelocityMmPerSec}):await e.jogger.rotateTCP({axis:o,direction:n,velocityRadsPerSec:e.rotationVelocityRadsPerSec})))}async function B(t,o){const n=++u.current;await e.activate(),n===u.current&&await e.jogger.rotateJoints({joint:t,direction:o,velocityUnit:m?"mm/s":"rad/s",velocityValue:m?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec})}async function O(){const t=++u.current;await e.jogger.stop(),t===u.current&&await e.deactivate()}async function U(t,o,n,r){const g=e.discreteIncrementOptions.find(p=>t==="translate"?Math.abs(p.mm-r)<1e-9:Math.abs(s.degreesToRadians(p.degrees)-r)<1e-9);!g||e.isLocked||await e.withMotionLock(async()=>{try{const h=(await e.activate()).motionStream.rapidlyChangingMotionState;if(!h.tcp_pose)return;e.setCurrentIncrementJog({axis:o,direction:n}),await e.jogger.runIncrementalCartesianMotion({currentTcpPose:h.tcp_pose,currentJoints:h.joint_position,velocityInRelevantUnits:t==="translate"?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec,axis:o,direction:n,motion:t==="translate"?{type:"translate",distanceMm:g.mm}:{type:"rotate",distanceRads:s.degreesToRadians(g.degrees)}})}finally{e.setCurrentIncrementJog(null),await e.deactivate()}})}function K(){if(e.selectedOrientation==="tool"){const o=a.state.rapidlyChangingMotionState.flange_pose,n=o?M.Pose3.fromPose(o).quaternion.clone():new te.Quaternion,r=e.selectedTcpId?a.description.tcpOffsetsById[e.selectedTcpId]:void 0;return r!=null&&r.pose.orientation&&n.multiply(M.parseRotationToQuaternion(r.pose.orientation,"ROTATION_VECTOR")),n}const t=e.jogCoordSystem;return M.parseRotationToQuaternion(t.orientation??[1,0,0,0],t.orientation_type??"QUATERNION")}function l(t){a.reportError({kind:"jog",message:t instanceof Error?t.message:String(t),cause:t})}const P=y.useRef(!1);function X(t){if(!t){S.resetToLive();return}S.setDraft(`(${[...t.position,...t.orientation].join(", ")})`),S.confirmEdit()}function G(){i.trajectoryState==="planned"&&i.plannedTrajectory&&(P.current=!0,i.start())}async function H(){P.current&&(P.current=!1,await q.when(()=>i.trajectoryState!=="planned",{timeout:2e3}).catch(()=>{}),i.trajectoryState==="moving"&&await i.pause())}const v=S.staged;return{disabled:f,jogDisabled:J||e.blocked,cartesian:e.canJogCartesian,tab:A,onTabChange:N,jogMode:Q,onJogModeChange:t=>{var o;return e.setSelectedIncrementId(t==="continuous"?"continuous":((o=C.current)==null?void 0:o.id)??"continuous")},gizmoOrientation:R,gizmoFrameQuaternion:K,tcp:e.tcps.length>0?{options:e.tcps.map(t=>({id:t.id,label:t.id})),value:e.selectedTcpId,onChange:t=>{e.requestTcpChange(t).catch(l)}}:void 0,jogFrame:{options:[{id:b,label:T("Jogging.MoveRelativeTo.SelectedTcp.dd")},...e.coordSystems.map(t=>({id:I+t.coordinate_system,label:V.coordSystemLabel(e,t)}))],value:e.selectedOrientation==="tool"?b:I+e.jogCoordSystemId,onChange:t=>t===b?e.setMoveRelativeToSelectedTcp():e.setMoveRelativeToCoordSystem(t.slice(I.length))},velocity:{translate:{value:e.translationVelocityMmPerSec,min:e.minTranslationVelocityMmPerSec,max:e.maxTranslationVelocityMmPerSec},rotate:{value:e.rotationVelocityRadsPerSec,min:s.degreesToRadians(e.minRotationVelocityDegPerSec),max:s.degreesToRadians(e.maxRotationVelocityDegPerSec)}},onVelocityChange:(t,o)=>t==="rotate"?e.setVelocityFromSlider(F(o),!0):e.setVelocityFromSlider(o,!1),onJogStart:(t,o,n)=>{z(t,o,n).catch(l)},onJogStop:()=>{O().catch(l)},increments:{steps:{translate:e.discreteIncrementOptions.map(t=>t.mm),rotate:e.discreteIncrementOptions.map(t=>s.degreesToRadians(t.degrees))},onStep:(t,o,n,r)=>{U(t,o,n,r).catch(l)},running:e.incrementJogInProgress,step:j&&{translate:j.mm,rotate:s.degreesToRadians(j.degrees)},onStepChange:(t,o)=>{const n=e.discreteIncrementOptions.find(r=>t==="translate"?r.mm===o:Math.abs(s.degreesToRadians(r.degrees)-o)<1e-9);n&&e.setSelectedIncrementId(n.id)}},joints:{joints:w.map((t,o)=>{var n,r,g,p;return{value:t,min:(r=(n=d==null?void 0:d[o])==null?void 0:n.position)==null?void 0:r.lower_limit,max:(p=(g=d==null?void 0:d[o])==null?void 0:g.position)==null?void 0:p.upper_limit,name:w.length===D.length&&!m?D[o]:void 0}}),linear:m,velocity:m?{value:e.translationVelocityMmPerSec,min:e.minTranslationVelocityMmPerSec,max:e.maxTranslationVelocityMmPerSec}:{value:e.rotationVelocityRadsPerSec,min:s.degreesToRadians(e.minRotationVelocityDegPerSec),max:s.degreesToRadians(e.maxRotationVelocityDegPerSec)},onVelocityChange:t=>m?e.setVelocityFromSlider(t,!1):e.setVelocityFromSlider(F(t),!0),onJogStart:(t,o)=>{B(t,o).catch(l)},onJogStop:()=>{O().catch(l)}},moveTo:{getCurrentPose:()=>{const t=a.state.displayedTcpPose;return!(t!=null&&t.position)||!t.orientation?null:{position:t.position,orientation:t.orientation}},frame:{options:e.coordSystems.map(t=>({id:t.coordinate_system,label:V.coordSystemLabel(e,t)})),value:e.selectedCoordSystemId,onChange:t=>e.setSelectedCoordSystemId(t)},onTargetChange:X,state:S.confirming?"planning":i.trajectoryState,error:v!=null&&v.errorKey?T(v.errorKey):null,onMoveStart:G,onMoveStop:()=>{H().catch(l)}}}}const ae=Y.observer(function({session:c,disabled:f,gizmoOrientation:R,...T}){const e=V.useRobotSessionOf(c),i=x(e,{disabled:f,gizmoOrientation:R});return W.jsx($.RobotControlPanel,{...i,...T})});exports.RobotControl=ae;exports.useRobotControlProps=x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),$=require("@mui/material/IconButton"),v=require("@mui/material/Stack"),z=require("@mui/material/Tab"),W=require("@mui/material/Tabs"),F=require("@mui/material/Typography"),D=require("@wandelbots/icons/CloseFilled"),b=require("react"),w=require("react-i18next"),K=require("./externalizeComponent-BdxGBLIv.cjs"),V=require("@mui/material/Divider"),P=require("@mui/material/Tooltip"),Q=require("@wandelbots/icons/Jog"),U=require("@wandelbots/icons/ViewModuleFilled"),Y=require("./JoggingGizmo-DGbFLWgT.cjs"),Z=require("./JoggingButtons-CbL-5LMK.cjs"),tt=require("@mui/material/styles"),X=require("@mui/material/ToggleButton"),et=require("@mui/material/ToggleButtonGroup"),T=require("./useEveryFrame-dmPPTKtT.cjs"),ot=require("@mui/material/Slider"),nt=require("./JoggingJointSlider-R3_A9Ppj.cjs"),rt=require("@wandelbots/icons/Undo"),I=require("@wandelbots/mui"),lt=require("@wandelbots/icons/NorthEastFilled"),st=require("./joggingColors-ZDc_2UCp.cjs"),_=require("@wandelbots/icons/CheckFilled"),at=require("@wandelbots/icons/ContentCopyFilled"),it=require("@wandelbots/icons/EditFilled");function ct({view:t,onViewChange:o,mode:n,controls:s,gizmoOrientation:a,gizmoFrameQuaternion:d}){const{t:l}=w.useTranslation(),r=t==="gizmo"&&a!==void 0,i=l(r?n==="increment"?"RobotControl.JogArea.Hint.ClickHandle.lb":"RobotControl.JogArea.Hint.HoldHandle.lb":n==="increment"?"RobotControl.JogArea.Hint.ClickButton.lb":"RobotControl.JogArea.Hint.HoldButton.lb"),x=l(r?"RobotControl.JogArea.ShowButtons.bt":"RobotControl.JogArea.ShowGizmo.bt");return e.jsxs(v,{"data-testid":"jog-area",sx:{position:"relative",alignItems:"center",gap:"16px"},children:[a&&e.jsx(P,{title:x,placement:"left",children:e.jsx($,{"aria-label":x,onClick:()=>o(r?"buttons":"gizmo"),size:"small",sx:c=>{var g;return{position:"absolute",top:0,right:0,zIndex:1,borderRadius:"8px",border:`1px solid ${c.palette.divider}`,background:(g=c.palette.backgroundPaperElevation)==null?void 0:g[11]}},children:r?e.jsx(U.ViewModuleFilled,{}):e.jsx(Q.Jog,{})})}),r?e.jsx(Y.JoggingGizmo,{...s,orientation:a,frameQuaternion:d,size:180}):e.jsx(Z.JoggingButtons,{...s}),e.jsx(F,{variant:"body2",color:"text.secondary",textAlign:"center",children:i})]})}const ut=tt.styled(et)(({theme:t})=>{var o;return{gap:"4px","& .MuiToggleButton-root":{border:"none",borderRadius:"8px",padding:"6px 16px",textTransform:"none",fontSize:"14px",color:t.palette.text.secondary},"& .MuiToggleButton-root.Mui-selected":{color:t.palette.text.primary,background:(o=t.palette.backgroundPaperElevation)==null?void 0:o[11]}}});function dt({value:t,onChange:o,disabled:n}){const{t:s}=w.useTranslation();return e.jsxs(ut,{exclusive:!0,value:t,disabled:n,"aria-label":s("RobotControl.JogMode.lb"),onChange:(a,d)=>{d!==null&&o(d)},children:[e.jsx(X,{value:"continuous",children:s("RobotControl.JogMode.Continuous.bt")}),e.jsx(X,{value:"increment",children:s("RobotControl.JogMode.Increment.bt")})]})}function J({children:t}){return e.jsx(v,{sx:{padding:"16px 20px",gap:"16px"},children:t})}function xt(t){return t*180/Math.PI}function pt(t){return t*Math.PI/180}function H(t,o){return t==="rotate"?xt(o):o}function gt(t,o){return t==="rotate"?pt(o):o}function bt(t,o){const n=String(Number(H(t,o).toFixed(2)));return t==="rotate"?`${n}°`:`${n} mm`}function ft(t,o){const n=Math.round(H(t,o));return t==="rotate"?`${n}°/s`:`${n} mm/s`}function L({motion:t,velocity:o,onChange:n,disabled:s}){const{t:a}=w.useTranslation(),d=b.useId(),l=r=>H(t,r);return e.jsxs(v,{gap:"4px",children:[e.jsxs(v,{direction:"row",sx:{justifyContent:"space-between"},children:[e.jsx(F,{id:d,variant:"body2",color:"text.secondary",children:a("RobotControl.Velocity.lb")}),e.jsx(F,{variant:"body2",color:"text.primary",sx:{fontVariantNumeric:"tabular-nums"},children:ft(t,o.value)})]}),e.jsx(ot,{"aria-labelledby":d,size:"small",value:Math.round(l(o.value)),min:Math.ceil(l(o.min)),max:Math.floor(l(o.max)),disabled:s,onChange:(r,i)=>{typeof i=="number"&&n(gt(t,i))},sx:r=>{var i;return{height:4,"& .MuiSlider-rail":{opacity:.38},"& .MuiSlider-thumb":{width:16,height:16,border:`3px solid ${r.palette.primary.main}`,backgroundColor:(i=r.palette.backgroundPaperElevation)==null?void 0:i[5]}}}})]})}function ht({motion:t,settings:o,onSettingsChange:n,disabled:s=!1,tcp:a,jogFrame:d,velocity:l,onVelocityChange:r,onJogStart:i,onJogStop:x,increments:c,gizmoOrientation:g,gizmoFrameQuaternion:j}){const{t:h}=w.useTranslation(),u=c?o.mode:"continuous",R=(c==null?void 0:c.steps[t])??[],m=Math.min(o.step[t],R.length-1),C=R[m],M=b.useRef(!1);function S(f,y){if(u==="increment"){c&&C!==void 0&&c.onStep(t,f,y,C);return}M.current=!0,i(t,f,y)}function E(){M.current&&(M.current=!1,x())}return e.jsxs(e.Fragment,{children:[(a||d)&&e.jsxs(e.Fragment,{children:[e.jsx(J,{children:e.jsxs(v,{direction:"row",sx:{gap:"12px"},children:[a&&e.jsx(T.PanelSelect,{label:h("RobotControl.Tcp.lb"),...a,disabled:s}),d&&e.jsx(T.PanelSelect,{label:h("RobotControl.JogFrame.lb"),...d,disabled:s})]})}),e.jsx(V,{sx:{marginX:"20px"}})]}),e.jsxs(J,{children:[c&&e.jsx(dt,{value:u,onChange:f=>n({...o,mode:f}),disabled:s}),e.jsx(L,{motion:t,velocity:l[t],onChange:f=>r(t,f),disabled:s}),u==="increment"&&C!==void 0&&e.jsx(T.InlineSelect,{label:h("RobotControl.StepSize.lb"),value:String(m),options:R.map((f,y)=>({id:String(y),label:bt(t,f)})),onChange:f=>n({...o,step:{...o.step,[t]:Number(f)}}),disabled:s})]}),e.jsx(V,{sx:{marginX:"20px"}}),e.jsx(J,{children:e.jsx(ct,{view:o.view,onViewChange:f=>n({...o,view:f}),mode:u,controls:{motion:t,onJogStart:S,onJogStop:E,activeHandle:u==="increment"?c==null?void 0:c.running:null,disabled:s},gizmoOrientation:g,gizmoFrameQuaternion:j},u)})]})}function Ct({joints:t,disabled:o}){const n=b.useRef(null),[s,a]=b.useState(null);function d(r,i){n.current!==null&&n.current!==r||(n.current=r,a(r),t.onJogStart(r,i))}function l(r){n.current===r&&(n.current=null,a(null),t.onJogStop())}return e.jsxs(e.Fragment,{children:[e.jsx(J,{children:e.jsx(v,{sx:{gap:"8px",paddingX:"4px"},children:t.joints.map((r,i)=>e.jsx(nt.JoggingJointSlider,{label:`J${i+1}`,name:r.name,value:r.value,min:r.min,max:r.max,linear:t.linear,onJogStart:x=>d(i,x),onJogStop:()=>l(i),disabled:o||s!==null&&s!==i},i))})}),e.jsx(V,{sx:{marginX:"20px"}}),e.jsx(J,{children:e.jsx(L,{motion:t.linear?"translate":"rotate",velocity:t.velocity,onChange:t.onVelocityChange,disabled:o})})]})}const jt=.5,vt=.01;function Rt(t,o){return t?Math.hypot(t.position[0]-o.position[0],t.position[1]-o.position[1],t.position[2]-o.position[2])<=jt&&mt(t.orientation,o.orientation)<=vt:!1}function G(t){const o=Math.hypot(...t);if(o<1e-12)return[1,0,0,0];const n=Math.sin(o/2)/o;return[Math.cos(o/2),t[0]*n,t[1]*n,t[2]*n]}function mt(t,o){const n=G(t),s=G(o),a=Math.abs(n[0]*s[0]+n[1]*s[1]+n[2]*s[2]+n[3]*s[3]);return 2*Math.acos(Math.min(1,a))}const Tt="move",Mt=200;function St({state:t,ready:o,atPose:n,disabled:s,onMoveStart:a,onMoveStop:d,stopRef:l}){const{t:r}=w.useTranslation(),[i,x]=b.useState(!1),c=b.useRef(void 0),g=b.useRef(!1),j=b.useRef({onMoveStart:a,onMoveStop:d});j.current={onMoveStart:a,onMoveStop:d};const h=t==="planned",u=h||t==="moving",{handlersFor:R,stop:m}=st.useHold({onStart:()=>{x(!0),c.current=setTimeout(()=>{c.current=void 0,g.current=!0,j.current.onMoveStart()},Mt)},onStop:()=>{x(!1),clearTimeout(c.current),c.current=void 0,g.current&&(g.current=!1,j.current.onMoveStop())},disabled:i?s||!o||!u:s||!o||n||!h,isSame:()=>!0});l&&(l.current=m),b.useEffect(()=>()=>clearTimeout(c.current),[]);const C=r(t==="moving"?"RobotControl.MoveTo.Moving.bt":t==="stopping"?"RobotControl.MoveTo.Stopping.bt":"RobotControl.MoveTo.MoveTo.bt");return e.jsx(P,{title:r(n?"RobotControl.MoveTo.AtPose.lb":"RobotControl.MoveTo.HoldToMove.lb"),placement:"top",children:e.jsx("span",{...R(Tt),style:{display:"block",flexGrow:1,touchAction:"none",userSelect:"none"},children:e.jsx(I.PrimaryButton,{fullWidth:!0,disabled:s||!o||n||!u,loading:t==="planning"||t==="stopping",loadingPosition:"start",startIcon:e.jsx(lt.NorthEastFilled,{}),"aria-pressed":i,children:C})})})}function yt({text:t,editing:o,onEdit:n,onDraftChange:s,onCancel:a,onConfirm:d,canConfirm:l,error:r,disabled:i}){const{t:x}=w.useTranslation(),c=b.useRef(null),{copied:g,copy:j}=T.useCopyText();b.useEffect(()=>{const u=c.current;u&&(o?(u.focus(),u.setSelectionRange(u.value.length,u.value.length)):document.activeElement===u&&(u.blur(),u.scrollLeft=0))},[o]);function h(){return j(t,()=>{var u;return(u=c.current)==null?void 0:u.select()})}return e.jsxs(v,{direction:"row",sx:{gap:"8px",alignItems:"flex-start"},children:[e.jsx(I.AdornedTextField,{label:x("RobotControl.MoveTo.Coordinates.lb"),value:t,inputRef:c,onChange:u=>s(u.target.value),onClick:()=>{!o&&!i&&n()},onKeyDown:u=>{o&&(u.key==="Enter"&&l?d():u.key==="Escape"&&a())},error:!!r,helperText:r??void 0,fullWidth:!0,autoComplete:"off",slotProps:{htmlInput:{readOnly:!o,spellCheck:!1}},sx:{"& input":{fontVariantNumeric:"tabular-nums",cursor:o||i?void 0:"text"}}}),e.jsx(v,{direction:"row",sx:{gap:"8px",height:"56px",alignItems:"center"},children:o?e.jsxs(e.Fragment,{children:[e.jsx(I.RoundedIconButton,{icon:e.jsx(D.CloseFilled,{}),ariaLabel:x("RobotControl.MoveTo.Cancel.bt"),onClick:a}),e.jsx(P,{title:x("RobotControl.MoveTo.ConfirmEdit.lb"),placement:"left",children:e.jsx("span",{children:e.jsx(I.RoundedIconButton,{icon:e.jsx(_.CheckFilled,{}),ariaLabel:x("RobotControl.MoveTo.ConfirmEdit.lb"),onClick:d,disabled:!l,sx:{color:"primary.main"}})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{title:x("RobotControl.MoveTo.Copied.lb"),open:g,disableHoverListener:!0,placement:"left",children:e.jsx(I.RoundedIconButton,{icon:g?e.jsx(_.CheckFilled,{}):e.jsx(at.ContentCopyFilled,{}),ariaLabel:x("RobotControl.MoveTo.Copy.bt"),onClick:()=>void h()})}),e.jsx(I.RoundedIconButton,{icon:e.jsx(it.EditFilled,{}),ariaLabel:x("RobotControl.MoveTo.Edit.bt"),onClick:n,disabled:i})]})})]})}function wt({moveTo:t,tcp:o,velocity:n,onVelocityChange:s,disabled:a}){var B;const{t:d}=w.useTranslation(),[l,r]=b.useState(null),[i,x]=b.useState(null),c=T.useEveryFrame(()=>{const p=t.getCurrentPose();return p?T.poseToText(p):""},l===null&&i===null),g=(l==null?void 0:l.text)??c,j=i!==null,h=i===null?null:T.parsePoseText(i),u=l!==null&&!t.error&&!j,R=T.useEveryFrame(()=>l!==null&&Rt(t.getCurrentPose(),l.pose),u)&&u,m=b.useRef(!1),C=b.useRef(null);function M(){var p;(p=C.current)==null||p.call(C),m.current=!1,r(null),x(null),t.onTargetChange(null)}function S(){h===null||a||(m.current=!1,r({pose:h,text:T.poseToText(h)}),x(null),t.onTargetChange(h))}b.useEffect(()=>{if(u){if(t.state==="moving"){m.current=!0;return}m.current&&R&&t.state!=="stopping"&&M()}},[u,t.state,R]);const E=[o==null?void 0:o.value,(B=t.frame)==null?void 0:B.value].join("\0");b.useEffect(()=>{l&&M()},[E]);const f=b.useRef({target:l,onTargetChange:t.onTargetChange});f.current={target:l,onTargetChange:t.onTargetChange},b.useEffect(()=>()=>{var p;(p=C.current)==null||p.call(C),f.current.target&&f.current.onTargetChange(null)},[]);const y=i!==null?h===null?d("RobotControl.MoveTo.InvalidPose.lb"):null:l?t.error??null:null;return e.jsxs(J,{children:[o&&e.jsx(T.PanelSelect,{label:d("RobotControl.Tcp.lb"),...o,disabled:a}),e.jsx(F,{variant:"body1",color:"text.primary",children:d("RobotControl.MoveTo.TargetPose.lb")}),e.jsxs(v,{sx:{gap:"8px"},children:[t.frame&&e.jsx(T.PanelSelect,{label:d("RobotControl.MoveTo.RelativeTo.lb"),...t.frame,disabled:a}),e.jsx(yt,{text:i??g,editing:j,onEdit:()=>{a||x(g)},onDraftChange:x,onCancel:()=>x(null),onConfirm:S,canConfirm:h!==null&&!a&&t.state!=="planning",error:y,disabled:a})]}),e.jsx(L,{motion:"translate",velocity:n,onChange:s,disabled:a}),e.jsxs(v,{direction:"row",sx:{gap:"12px",alignItems:"center"},children:[l&&!j&&e.jsx(P,{title:d("RobotControl.MoveTo.Reset.lb"),placement:"top",children:e.jsx("span",{children:e.jsx(I.RoundedIconButton,{icon:e.jsx(rt.Undo,{}),ariaLabel:d("RobotControl.MoveTo.Reset.lb"),onClick:M})})}),e.jsx(St,{state:l?t.state:"idle",ready:u,atPose:R,disabled:a,onMoveStart:()=>{l&&t.onMoveStart(l.pose)},onMoveStop:t.onMoveStop,stopRef:C})]})]})}const Et=K.externalizeComponent(({onClose:t,sx:o,joints:n,moveTo:s,jogDisabled:a=!1,cartesian:d=!0,tab:l,onTabChange:r,jogMode:i,onJogModeChange:x,...c})=>{const{t:g}=w.useTranslation(),j=c.disabled??!1,[h,u]=b.useState("translate"),[R,m]=b.useState({mode:"continuous",view:"gizmo",step:{translate:0,rotate:0}}),C=[...d?["translate","rotate"]:[],...n?["joint"]:[],...s?["moveTo"]:[]],M=l??h,S=C.includes(M)?M:C[0],E=qt(R,i,c.increments),f=g("RobotControl.Title.ti");function y(p){u(p),r==null||r(p)}function B(p){var q,A,N;m(p),p.mode!==E.mode&&(x==null||x(p.mode));for(const k of["translate","rotate"]){const O=(q=c.increments)==null?void 0:q.steps[k][p.step[k]];p.step[k]!==E.step[k]&&O!==void 0&&((N=(A=c.increments)==null?void 0:A.onStepChange)==null||N.call(A,k,O))}}return e.jsxs(v,{"data-testid":"robot-control-panel",sx:[p=>{var q;return{minHeight:0,overflow:"hidden",borderRadius:"16px",background:(q=p.palette.backgroundPaperElevation)==null?void 0:q[5]}},...Array.isArray(o)?o:[o]],children:[e.jsxs(v,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",padding:"20px 20px 8px"},children:[e.jsx(F,{component:"h2",color:"text.primary",sx:{fontSize:"20px"},children:f}),t&&e.jsx($,{"aria-label":g("RobotControl.Close.bt"),onClick:t,size:"small",children:e.jsx(D.CloseFilled,{})})]}),e.jsxs(W,{value:S??!1,onChange:(p,q)=>y(q),"aria-label":f,variant:"scrollable",scrollButtons:!1,sx:{marginX:"20px",borderBottom:1,borderColor:"divider",background:"transparent"},children:[d&&e.jsx(z,{value:"translate",label:g("RobotControl.Tab.Translate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),d&&e.jsx(z,{value:"rotate",label:g("RobotControl.Tab.Rotate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),n&&e.jsx(z,{value:"joint",label:g("RobotControl.Tab.Joint.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),s&&e.jsx(z,{value:"moveTo",label:g("RobotControl.Tab.MoveTo.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}})]}),e.jsx(v,{sx:{flexGrow:1,overflowY:"auto",overflowX:"hidden"},children:S==="joint"&&n?e.jsx(Ct,{joints:n,disabled:j||a}):S==="moveTo"&&s?e.jsx(wt,{moveTo:s,tcp:c.tcp,velocity:c.velocity.translate,onVelocityChange:p=>c.onVelocityChange("translate",p),disabled:j}):S==="translate"||S==="rotate"?e.jsx(ht,{...c,disabled:j||a,motion:S,settings:E,onSettingsChange:B}):null})]})});function qt(t,o,n){const s=a=>{var r;const d=(r=n==null?void 0:n.step)==null?void 0:r[a];if(d===void 0)return t.step[a];const l=n==null?void 0:n.steps[a].findIndex(i=>Math.abs(i-d)<=1e-9*Math.max(1,Math.abs(i)));return l===void 0||l<0?t.step[a]:l};return{...t,mode:o??t.mode,step:{translate:s("translate"),rotate:s("rotate")}}}exports.RobotControlPanel=Et;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),$=require("@mui/material/IconButton"),v=require("@mui/material/Stack"),z=require("@mui/material/Tab"),W=require("@mui/material/Tabs"),F=require("@mui/material/Typography"),D=require("@wandelbots/icons/CloseFilled"),b=require("react"),w=require("react-i18next"),K=require("./externalizeComponent-Bl23ayrr.cjs"),V=require("@mui/material/Divider"),P=require("@mui/material/Tooltip"),Q=require("@wandelbots/icons/Jog"),U=require("@wandelbots/icons/ViewModuleFilled"),Y=require("./JoggingGizmo-DT7iX5Ka.cjs"),Z=require("./JoggingButtons-DC0jII72.cjs"),tt=require("@mui/material/styles"),X=require("@mui/material/ToggleButton"),et=require("@mui/material/ToggleButtonGroup"),T=require("./useEveryFrame-CHxg25f4.cjs"),ot=require("@mui/material/Slider"),nt=require("./JoggingJointSlider-C0lI_9W5.cjs"),rt=require("@wandelbots/icons/Undo"),I=require("@wandelbots/mui"),lt=require("@wandelbots/icons/NorthEastFilled"),st=require("./joggingColors-ZDc_2UCp.cjs"),_=require("@wandelbots/icons/CheckFilled"),at=require("@wandelbots/icons/ContentCopyFilled"),it=require("@wandelbots/icons/EditFilled");function ct({view:t,onViewChange:o,mode:n,controls:s,gizmoOrientation:a,gizmoFrameQuaternion:d}){const{t:l}=w.useTranslation(),r=t==="gizmo"&&a!==void 0,i=l(r?n==="increment"?"RobotControl.JogArea.Hint.ClickHandle.lb":"RobotControl.JogArea.Hint.HoldHandle.lb":n==="increment"?"RobotControl.JogArea.Hint.ClickButton.lb":"RobotControl.JogArea.Hint.HoldButton.lb"),x=l(r?"RobotControl.JogArea.ShowButtons.bt":"RobotControl.JogArea.ShowGizmo.bt");return e.jsxs(v,{"data-testid":"jog-area",sx:{position:"relative",alignItems:"center",gap:"16px"},children:[a&&e.jsx(P,{title:x,placement:"left",children:e.jsx($,{"aria-label":x,onClick:()=>o(r?"buttons":"gizmo"),size:"small",sx:c=>{var g;return{position:"absolute",top:0,right:0,zIndex:1,borderRadius:"8px",border:`1px solid ${c.palette.divider}`,background:(g=c.palette.backgroundPaperElevation)==null?void 0:g[11]}},children:r?e.jsx(U.ViewModuleFilled,{}):e.jsx(Q.Jog,{})})}),r?e.jsx(Y.JoggingGizmo,{...s,orientation:a,frameQuaternion:d,size:180}):e.jsx(Z.JoggingButtons,{...s}),e.jsx(F,{variant:"body2",color:"text.secondary",textAlign:"center",children:i})]})}const ut=tt.styled(et)(({theme:t})=>{var o;return{gap:"4px","& .MuiToggleButton-root":{border:"none",borderRadius:"8px",padding:"6px 16px",textTransform:"none",fontSize:"14px",color:t.palette.text.secondary},"& .MuiToggleButton-root.Mui-selected":{color:t.palette.text.primary,background:(o=t.palette.backgroundPaperElevation)==null?void 0:o[11]}}});function dt({value:t,onChange:o,disabled:n}){const{t:s}=w.useTranslation();return e.jsxs(ut,{exclusive:!0,value:t,disabled:n,"aria-label":s("RobotControl.JogMode.lb"),onChange:(a,d)=>{d!==null&&o(d)},children:[e.jsx(X,{value:"continuous",children:s("RobotControl.JogMode.Continuous.bt")}),e.jsx(X,{value:"increment",children:s("RobotControl.JogMode.Increment.bt")})]})}function J({children:t}){return e.jsx(v,{sx:{padding:"16px 20px",gap:"16px"},children:t})}function xt(t){return t*180/Math.PI}function pt(t){return t*Math.PI/180}function H(t,o){return t==="rotate"?xt(o):o}function gt(t,o){return t==="rotate"?pt(o):o}function bt(t,o){const n=String(Number(H(t,o).toFixed(2)));return t==="rotate"?`${n}°`:`${n} mm`}function ft(t,o){const n=Math.round(H(t,o));return t==="rotate"?`${n}°/s`:`${n} mm/s`}function L({motion:t,velocity:o,onChange:n,disabled:s}){const{t:a}=w.useTranslation(),d=b.useId(),l=r=>H(t,r);return e.jsxs(v,{gap:"4px",children:[e.jsxs(v,{direction:"row",sx:{justifyContent:"space-between"},children:[e.jsx(F,{id:d,variant:"body2",color:"text.secondary",children:a("RobotControl.Velocity.lb")}),e.jsx(F,{variant:"body2",color:"text.primary",sx:{fontVariantNumeric:"tabular-nums"},children:ft(t,o.value)})]}),e.jsx(ot,{"aria-labelledby":d,size:"small",value:Math.round(l(o.value)),min:Math.ceil(l(o.min)),max:Math.floor(l(o.max)),disabled:s,onChange:(r,i)=>{typeof i=="number"&&n(gt(t,i))},sx:r=>{var i;return{height:4,"& .MuiSlider-rail":{opacity:.38},"& .MuiSlider-thumb":{width:16,height:16,border:`3px solid ${r.palette.primary.main}`,backgroundColor:(i=r.palette.backgroundPaperElevation)==null?void 0:i[5]}}}})]})}function ht({motion:t,settings:o,onSettingsChange:n,disabled:s=!1,tcp:a,jogFrame:d,velocity:l,onVelocityChange:r,onJogStart:i,onJogStop:x,increments:c,gizmoOrientation:g,gizmoFrameQuaternion:j}){const{t:h}=w.useTranslation(),u=c?o.mode:"continuous",R=(c==null?void 0:c.steps[t])??[],m=Math.min(o.step[t],R.length-1),C=R[m],M=b.useRef(!1);function S(f,y){if(u==="increment"){c&&C!==void 0&&c.onStep(t,f,y,C);return}M.current=!0,i(t,f,y)}function E(){M.current&&(M.current=!1,x())}return e.jsxs(e.Fragment,{children:[(a||d)&&e.jsxs(e.Fragment,{children:[e.jsx(J,{children:e.jsxs(v,{direction:"row",sx:{gap:"12px"},children:[a&&e.jsx(T.PanelSelect,{label:h("RobotControl.Tcp.lb"),...a,disabled:s}),d&&e.jsx(T.PanelSelect,{label:h("RobotControl.JogFrame.lb"),...d,disabled:s})]})}),e.jsx(V,{sx:{marginX:"20px"}})]}),e.jsxs(J,{children:[c&&e.jsx(dt,{value:u,onChange:f=>n({...o,mode:f}),disabled:s}),e.jsx(L,{motion:t,velocity:l[t],onChange:f=>r(t,f),disabled:s}),u==="increment"&&C!==void 0&&e.jsx(T.InlineSelect,{label:h("RobotControl.StepSize.lb"),value:String(m),options:R.map((f,y)=>({id:String(y),label:bt(t,f)})),onChange:f=>n({...o,step:{...o.step,[t]:Number(f)}}),disabled:s})]}),e.jsx(V,{sx:{marginX:"20px"}}),e.jsx(J,{children:e.jsx(ct,{view:o.view,onViewChange:f=>n({...o,view:f}),mode:u,controls:{motion:t,onJogStart:S,onJogStop:E,activeHandle:u==="increment"?c==null?void 0:c.running:null,disabled:s},gizmoOrientation:g,gizmoFrameQuaternion:j},u)})]})}function Ct({joints:t,disabled:o}){const n=b.useRef(null),[s,a]=b.useState(null);function d(r,i){n.current!==null&&n.current!==r||(n.current=r,a(r),t.onJogStart(r,i))}function l(r){n.current===r&&(n.current=null,a(null),t.onJogStop())}return e.jsxs(e.Fragment,{children:[e.jsx(J,{children:e.jsx(v,{sx:{gap:"8px",paddingX:"4px"},children:t.joints.map((r,i)=>e.jsx(nt.JoggingJointSlider,{label:`J${i+1}`,name:r.name,value:r.value,min:r.min,max:r.max,linear:t.linear,onJogStart:x=>d(i,x),onJogStop:()=>l(i),disabled:o||s!==null&&s!==i},i))})}),e.jsx(V,{sx:{marginX:"20px"}}),e.jsx(J,{children:e.jsx(L,{motion:t.linear?"translate":"rotate",velocity:t.velocity,onChange:t.onVelocityChange,disabled:o})})]})}const jt=.5,vt=.01;function Rt(t,o){return t?Math.hypot(t.position[0]-o.position[0],t.position[1]-o.position[1],t.position[2]-o.position[2])<=jt&&mt(t.orientation,o.orientation)<=vt:!1}function G(t){const o=Math.hypot(...t);if(o<1e-12)return[1,0,0,0];const n=Math.sin(o/2)/o;return[Math.cos(o/2),t[0]*n,t[1]*n,t[2]*n]}function mt(t,o){const n=G(t),s=G(o),a=Math.abs(n[0]*s[0]+n[1]*s[1]+n[2]*s[2]+n[3]*s[3]);return 2*Math.acos(Math.min(1,a))}const Tt="move",Mt=200;function St({state:t,ready:o,atPose:n,disabled:s,onMoveStart:a,onMoveStop:d,stopRef:l}){const{t:r}=w.useTranslation(),[i,x]=b.useState(!1),c=b.useRef(void 0),g=b.useRef(!1),j=b.useRef({onMoveStart:a,onMoveStop:d});j.current={onMoveStart:a,onMoveStop:d};const h=t==="planned",u=h||t==="moving",{handlersFor:R,stop:m}=st.useHold({onStart:()=>{x(!0),c.current=setTimeout(()=>{c.current=void 0,g.current=!0,j.current.onMoveStart()},Mt)},onStop:()=>{x(!1),clearTimeout(c.current),c.current=void 0,g.current&&(g.current=!1,j.current.onMoveStop())},disabled:i?s||!o||!u:s||!o||n||!h,isSame:()=>!0});l&&(l.current=m),b.useEffect(()=>()=>clearTimeout(c.current),[]);const C=r(t==="moving"?"RobotControl.MoveTo.Moving.bt":t==="stopping"?"RobotControl.MoveTo.Stopping.bt":"RobotControl.MoveTo.MoveTo.bt");return e.jsx(P,{title:r(n?"RobotControl.MoveTo.AtPose.lb":"RobotControl.MoveTo.HoldToMove.lb"),placement:"top",children:e.jsx("span",{...R(Tt),style:{display:"block",flexGrow:1,touchAction:"none",userSelect:"none"},children:e.jsx(I.PrimaryButton,{fullWidth:!0,disabled:s||!o||n||!u,loading:t==="planning"||t==="stopping",loadingPosition:"start",startIcon:e.jsx(lt.NorthEastFilled,{}),"aria-pressed":i,children:C})})})}function yt({text:t,editing:o,onEdit:n,onDraftChange:s,onCancel:a,onConfirm:d,canConfirm:l,error:r,disabled:i}){const{t:x}=w.useTranslation(),c=b.useRef(null),{copied:g,copy:j}=T.useCopyText();b.useEffect(()=>{const u=c.current;u&&(o?(u.focus(),u.setSelectionRange(u.value.length,u.value.length)):document.activeElement===u&&(u.blur(),u.scrollLeft=0))},[o]);function h(){return j(t,()=>{var u;return(u=c.current)==null?void 0:u.select()})}return e.jsxs(v,{direction:"row",sx:{gap:"8px",alignItems:"flex-start"},children:[e.jsx(I.AdornedTextField,{label:x("RobotControl.MoveTo.Coordinates.lb"),value:t,inputRef:c,onChange:u=>s(u.target.value),onClick:()=>{!o&&!i&&n()},onKeyDown:u=>{o&&(u.key==="Enter"&&l?d():u.key==="Escape"&&a())},error:!!r,helperText:r??void 0,fullWidth:!0,autoComplete:"off",slotProps:{htmlInput:{readOnly:!o,spellCheck:!1}},sx:{"& input":{fontVariantNumeric:"tabular-nums",cursor:o||i?void 0:"text"}}}),e.jsx(v,{direction:"row",sx:{gap:"8px",height:"56px",alignItems:"center"},children:o?e.jsxs(e.Fragment,{children:[e.jsx(I.RoundedIconButton,{icon:e.jsx(D.CloseFilled,{}),ariaLabel:x("RobotControl.MoveTo.Cancel.bt"),onClick:a}),e.jsx(P,{title:x("RobotControl.MoveTo.ConfirmEdit.lb"),placement:"left",children:e.jsx("span",{children:e.jsx(I.RoundedIconButton,{icon:e.jsx(_.CheckFilled,{}),ariaLabel:x("RobotControl.MoveTo.ConfirmEdit.lb"),onClick:d,disabled:!l,sx:{color:"primary.main"}})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{title:x("RobotControl.MoveTo.Copied.lb"),open:g,disableHoverListener:!0,placement:"left",children:e.jsx(I.RoundedIconButton,{icon:g?e.jsx(_.CheckFilled,{}):e.jsx(at.ContentCopyFilled,{}),ariaLabel:x("RobotControl.MoveTo.Copy.bt"),onClick:()=>void h()})}),e.jsx(I.RoundedIconButton,{icon:e.jsx(it.EditFilled,{}),ariaLabel:x("RobotControl.MoveTo.Edit.bt"),onClick:n,disabled:i})]})})]})}function wt({moveTo:t,tcp:o,velocity:n,onVelocityChange:s,disabled:a}){var B;const{t:d}=w.useTranslation(),[l,r]=b.useState(null),[i,x]=b.useState(null),c=T.useEveryFrame(()=>{const p=t.getCurrentPose();return p?T.poseToText(p):""},l===null&&i===null),g=(l==null?void 0:l.text)??c,j=i!==null,h=i===null?null:T.parsePoseText(i),u=l!==null&&!t.error&&!j,R=T.useEveryFrame(()=>l!==null&&Rt(t.getCurrentPose(),l.pose),u)&&u,m=b.useRef(!1),C=b.useRef(null);function M(){var p;(p=C.current)==null||p.call(C),m.current=!1,r(null),x(null),t.onTargetChange(null)}function S(){h===null||a||(m.current=!1,r({pose:h,text:T.poseToText(h)}),x(null),t.onTargetChange(h))}b.useEffect(()=>{if(u){if(t.state==="moving"){m.current=!0;return}m.current&&R&&t.state!=="stopping"&&M()}},[u,t.state,R]);const E=[o==null?void 0:o.value,(B=t.frame)==null?void 0:B.value].join("\0");b.useEffect(()=>{l&&M()},[E]);const f=b.useRef({target:l,onTargetChange:t.onTargetChange});f.current={target:l,onTargetChange:t.onTargetChange},b.useEffect(()=>()=>{var p;(p=C.current)==null||p.call(C),f.current.target&&f.current.onTargetChange(null)},[]);const y=i!==null?h===null?d("RobotControl.MoveTo.InvalidPose.lb"):null:l?t.error??null:null;return e.jsxs(J,{children:[o&&e.jsx(T.PanelSelect,{label:d("RobotControl.Tcp.lb"),...o,disabled:a}),e.jsx(F,{variant:"body1",color:"text.primary",children:d("RobotControl.MoveTo.TargetPose.lb")}),e.jsxs(v,{sx:{gap:"8px"},children:[t.frame&&e.jsx(T.PanelSelect,{label:d("RobotControl.MoveTo.RelativeTo.lb"),...t.frame,disabled:a}),e.jsx(yt,{text:i??g,editing:j,onEdit:()=>{a||x(g)},onDraftChange:x,onCancel:()=>x(null),onConfirm:S,canConfirm:h!==null&&!a&&t.state!=="planning",error:y,disabled:a})]}),e.jsx(L,{motion:"translate",velocity:n,onChange:s,disabled:a}),e.jsxs(v,{direction:"row",sx:{gap:"12px",alignItems:"center"},children:[l&&!j&&e.jsx(P,{title:d("RobotControl.MoveTo.Reset.lb"),placement:"top",children:e.jsx("span",{children:e.jsx(I.RoundedIconButton,{icon:e.jsx(rt.Undo,{}),ariaLabel:d("RobotControl.MoveTo.Reset.lb"),onClick:M})})}),e.jsx(St,{state:l?t.state:"idle",ready:u,atPose:R,disabled:a,onMoveStart:()=>{l&&t.onMoveStart(l.pose)},onMoveStop:t.onMoveStop,stopRef:C})]})]})}const Et=K.externalizeComponent(({onClose:t,sx:o,joints:n,moveTo:s,jogDisabled:a=!1,cartesian:d=!0,tab:l,onTabChange:r,jogMode:i,onJogModeChange:x,...c})=>{const{t:g}=w.useTranslation(),j=c.disabled??!1,[h,u]=b.useState("translate"),[R,m]=b.useState({mode:"continuous",view:"gizmo",step:{translate:0,rotate:0}}),C=[...d?["translate","rotate"]:[],...n?["joint"]:[],...s?["moveTo"]:[]],M=l??h,S=C.includes(M)?M:C[0],E=qt(R,i,c.increments),f=g("RobotControl.Title.ti");function y(p){u(p),r==null||r(p)}function B(p){var q,A,N;m(p),p.mode!==E.mode&&(x==null||x(p.mode));for(const k of["translate","rotate"]){const O=(q=c.increments)==null?void 0:q.steps[k][p.step[k]];p.step[k]!==E.step[k]&&O!==void 0&&((N=(A=c.increments)==null?void 0:A.onStepChange)==null||N.call(A,k,O))}}return e.jsxs(v,{"data-testid":"robot-control-panel",sx:[p=>{var q;return{minHeight:0,overflow:"hidden",borderRadius:"16px",background:(q=p.palette.backgroundPaperElevation)==null?void 0:q[5]}},...Array.isArray(o)?o:[o]],children:[e.jsxs(v,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",padding:"20px 20px 8px"},children:[e.jsx(F,{component:"h2",color:"text.primary",sx:{fontSize:"20px"},children:f}),t&&e.jsx($,{"aria-label":g("RobotControl.Close.bt"),onClick:t,size:"small",children:e.jsx(D.CloseFilled,{})})]}),e.jsxs(W,{value:S??!1,onChange:(p,q)=>y(q),"aria-label":f,variant:"scrollable",scrollButtons:!1,sx:{marginX:"20px",borderBottom:1,borderColor:"divider",background:"transparent"},children:[d&&e.jsx(z,{value:"translate",label:g("RobotControl.Tab.Translate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),d&&e.jsx(z,{value:"rotate",label:g("RobotControl.Tab.Rotate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),n&&e.jsx(z,{value:"joint",label:g("RobotControl.Tab.Joint.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),s&&e.jsx(z,{value:"moveTo",label:g("RobotControl.Tab.MoveTo.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}})]}),e.jsx(v,{sx:{flexGrow:1,overflowY:"auto",overflowX:"hidden"},children:S==="joint"&&n?e.jsx(Ct,{joints:n,disabled:j||a}):S==="moveTo"&&s?e.jsx(wt,{moveTo:s,tcp:c.tcp,velocity:c.velocity.translate,onVelocityChange:p=>c.onVelocityChange("translate",p),disabled:j}):S==="translate"||S==="rotate"?e.jsx(ht,{...c,disabled:j||a,motion:S,settings:E,onSettingsChange:B}):null})]})});function qt(t,o,n){const s=a=>{var r;const d=(r=n==null?void 0:n.step)==null?void 0:r[a];if(d===void 0)return t.step[a];const l=n==null?void 0:n.steps[a].findIndex(i=>Math.abs(i-d)<=1e-9*Math.max(1,Math.abs(i)));return l===void 0||l<0?t.step[a]:l};return{...t,mode:o??t.mode,step:{translate:s("translate"),rotate:s("rotate")}}}exports.RobotControlPanel=Et;
|
|
@@ -7,19 +7,19 @@ import H from "@mui/material/Typography";
|
|
|
7
7
|
import { CloseFilled as j } from "@wandelbots/icons/CloseFilled";
|
|
8
8
|
import { useId as ot, useRef as S, useState as P, useEffect as V } from "react";
|
|
9
9
|
import { useTranslation as J } from "react-i18next";
|
|
10
|
-
import { e as nt } from "./externalizeComponent-
|
|
10
|
+
import { e as nt } from "./externalizeComponent-CSzPVfuG.js";
|
|
11
11
|
import _ from "@mui/material/Divider";
|
|
12
12
|
import F from "@mui/material/Tooltip";
|
|
13
13
|
import { Jog as et } from "@wandelbots/icons/Jog";
|
|
14
14
|
import { ViewModuleFilled as rt } from "@wandelbots/icons/ViewModuleFilled";
|
|
15
|
-
import { J as lt } from "./JoggingGizmo-
|
|
16
|
-
import { J as at } from "./JoggingButtons-
|
|
15
|
+
import { J as lt } from "./JoggingGizmo-Hy42DAQU.js";
|
|
16
|
+
import { J as at } from "./JoggingButtons-DluWqNuO.js";
|
|
17
17
|
import { styled as it } from "@mui/material/styles";
|
|
18
18
|
import K from "@mui/material/ToggleButton";
|
|
19
19
|
import ct from "@mui/material/ToggleButtonGroup";
|
|
20
|
-
import { P as X, I as st,
|
|
20
|
+
import { P as X, I as st, c as ut, u as Q, b as q, a as pt } from "./useEveryFrame-DAuNawGP.js";
|
|
21
21
|
import dt from "@mui/material/Slider";
|
|
22
|
-
import { J as ft } from "./JoggingJointSlider-
|
|
22
|
+
import { J as ft } from "./JoggingJointSlider-DePZ3JHW.js";
|
|
23
23
|
import { Undo as bt } from "@wandelbots/icons/Undo";
|
|
24
24
|
import { PrimaryButton as gt, AdornedTextField as ht, RoundedIconButton as B } from "@wandelbots/mui";
|
|
25
25
|
import { NorthEastFilled as mt } from "@wandelbots/icons/NorthEastFilled";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),n=require("react"),s=n.createContext(null);function u({session:e,children:o}){return i.jsx(s.Provider,{value:e,children:o})}function a(){return r(void 0)}function r(e){const o=n.useContext(s),t=e??o;if(!t)throw new Error("No robot session: put the component inside a RobotSessionProvider, or give it a `session`");return t}function c(e,o){return o.name&&(e.coordSystemCountByName[o.name]??0)>1?`${o.name} / ${o.coordinate_system}`:o.name||o.coordinate_system}exports.RobotSessionProvider=u;exports.coordSystemLabel=c;exports.useRobotSession=a;exports.useRobotSessionOf=r;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as s, createContext as i } from "react";
|
|
3
|
+
const n = i(null);
|
|
4
|
+
function d({
|
|
5
|
+
session: e,
|
|
6
|
+
children: o
|
|
7
|
+
}) {
|
|
8
|
+
return /* @__PURE__ */ r(n.Provider, { value: e, children: o });
|
|
9
|
+
}
|
|
10
|
+
function c() {
|
|
11
|
+
return a(void 0);
|
|
12
|
+
}
|
|
13
|
+
function a(e) {
|
|
14
|
+
const o = s(n), t = e ?? o;
|
|
15
|
+
if (!t)
|
|
16
|
+
throw new Error(
|
|
17
|
+
"No robot session: put the component inside a RobotSessionProvider, or give it a `session`"
|
|
18
|
+
);
|
|
19
|
+
return t;
|
|
20
|
+
}
|
|
21
|
+
function b(e, o) {
|
|
22
|
+
return o.name && (e.coordSystemCountByName[o.name] ?? 0) > 1 ? `${o.name} / ${o.coordinate_system}` : o.name || o.coordinate_system;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
d as R,
|
|
26
|
+
a,
|
|
27
|
+
b as c,
|
|
28
|
+
c as u
|
|
29
|
+
};
|