@wandelbots/wandelbots-js-react-components 6.4.0-pr.feat-robot-control-panel.656.64cbc22 → 6.4.0-pr.feat-robot-control-panel.656.2211e42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/3d.cjs +1 -1
- package/dist/3d.js +1 -1
- package/dist/RobotControlPanel/index.cjs +1 -1
- package/dist/RobotControlPanel/index.js +1 -1
- package/dist/chunks/RobotControlPanel-B9mziQO2.cjs +1 -0
- package/dist/chunks/{RobotControlPanel-BYWjL0i2.js → RobotControlPanel-B_dcyr-M.js} +249 -240
- package/dist/components/robotControl/HoldToMoveButton.d.ts +4 -1
- package/dist/components/robotControl/RobotControlPanel.d.ts +4 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/RobotControlPanel-DOCMrzoW.cjs +0 -1
package/README.md
CHANGED
|
@@ -264,7 +264,7 @@ const [active, setActive] = useState<number | null>(null)
|
|
|
264
264
|
- `disabled` turns off every control: nothing may move. `jogDisabled` turns off only the jogging of Translate, Rotate and Joint, e.g. while a trajectory moves the robot; Move to stays usable, so a move of its own does not end when the app locks jogging during it.
|
|
265
265
|
- The panel keeps its tab, jog mode and step size itself. An app that keeps them in its own store (to remember them, or because its jogging depends on them) gives `tab`, `jogMode` and `increments.step`, and gets `onTabChange`, `onJogModeChange` and `increments.onStepChange`; each also works alone, to follow a choice without keeping it.
|
|
266
266
|
- `joints` gives the Joint tab: the joints' values and limits (rad, or mm with `linear`), their names, the joint velocity, and `onJogStart(index, direction)` and `onJogStop`. The panel jogs one joint at a time; the turn-around of a slider brings `onJogStop` and `onJogStart` in the same event, as described for `JoggingJointSlider`. Without `joints`, there is no Joint tab.
|
|
267
|
-
- `moveTo` gives the Move to tab. It works as RobotPad's pose field: the coordinates `(x, y, z, rx, ry, rz)` (mm, rotation vector in rad: the format RobotPad copies and pastes) show the TCP's current pose (`getCurrentPose`, read every animation frame), with Copy and Edit pose, and Move to, off until a pose is the target. Edit pose, or a click on the field, makes it editable; Save pose edit (Enter) makes the typed pose the target (`onTargetChange(pose)`): the app plans the move and loads it, and reports `state` (`"planning"`, `"planned"`, `"moving"`, `"stopping"` or `"idle"`, as RobotPad's trajectory) and an `error` (e.g. out of reach). Then Reset shows. Held for 200 ms while `"planned"`, Move to calls `onMoveStart(pose)`, the release `onMoveStop`: the app starts and pauses its trajectory; the button says Moving… and Stopping…. At the target (within 0.5 mm and 0.01 rad) it turns off; once the move no longer runs, the field shows the current pose again (`onTargetChange(null)`), as do Reset and another
|
|
267
|
+
- `moveTo` gives the Move to tab. It works as RobotPad's pose field: the coordinates `(x, y, z, rx, ry, rz)` (mm, rotation vector in rad: the format RobotPad copies and pastes) show the TCP's current pose (`getCurrentPose`, read every animation frame), with Copy and Edit pose, and Move to, off until a pose is the target. Edit pose, or a click on the field, makes it editable; Save pose edit (Enter) makes the typed pose the target (`onTargetChange(pose)`): the app plans the move and loads it, and reports `state` (`"planning"`, `"planned"`, `"moving"`, `"stopping"` or `"idle"`, as RobotPad's trajectory) and an `error` (e.g. out of reach). Then Reset shows. Held for 200 ms while `"planned"`, Move to calls `onMoveStart(pose)`, the release `onMoveStop`: the app starts and pauses its trajectory; the button says Moving… and Stopping…. At the target (within 0.5 mm and 0.01 rad) it turns off; once the move no longer runs, the field shows the current pose again (`onTargetChange(null)`), as do Reset, another tab and another TCP or frame (a held move gets its `onMoveStop` first). While another pose is typed, Move to stays off. `frame` is the "Relative to" select. It moves with `velocity.translate`. Without `moveTo`, there is no Move to tab.
|
|
268
268
|
|
|
269
269
|
```tsx
|
|
270
270
|
const orientation = useRef<Quaternion | null>(null)
|
package/dist/3d.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/Robot-BpCo1iYt.cjs"),t=require("./chunks/JoggingGizmo-xvCp3LCB.cjs"),i=require("./chunks/JoggingGizmoOrientation-BTKo84_4.cjs"),r=require("./chunks/RobotControlPanel-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/Robot-BpCo1iYt.cjs"),t=require("./chunks/JoggingGizmo-xvCp3LCB.cjs"),i=require("./chunks/JoggingGizmoOrientation-BTKo84_4.cjs"),r=require("./chunks/RobotControlPanel-B9mziQO2.cjs"),e=require("./chunks/useSmoothedMotionState-Con0E5Bx.cjs");exports.CollisionSceneRenderer=o.CollisionSceneRenderer;exports.JointLimitGizmo=o.JointLimitGizmo;exports.LinearAxis=o.LinearAxis;exports.MotionGroupVisualizer=o.MotionGroupVisualizer;exports.MotionGroupVisualizerExact=o.MotionGroupVisualizerExact;exports.PresetEnvironment=o.PresetEnvironment;exports.Robot=o.Robot;exports.SafetyZonesRenderer=o.SafetyZonesRenderer;exports.SupportedLinearAxis=o.SupportedLinearAxis;exports.SupportedLinearAxisExact=o.SupportedLinearAxisExact;exports.SupportedRobot=o.SupportedRobot;exports.SupportedRobotExact=o.SupportedRobotExact;exports.TrajectoryRenderer=o.TrajectoryRenderer;exports.defaultGetModel=o.defaultGetModel;exports.JoggingGizmo=t.JoggingGizmo;exports.JoggingGizmoOrientation=i.JoggingGizmoOrientation;exports.RobotControlPanel=r.RobotControlPanel;exports.ValueInterpolator=e.ValueInterpolator;exports.useSmoothedMotionState=e.useSmoothedMotionState;
|
package/dist/3d.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as a, J as r, L as t, M as s, a as i, P as n, R as p, S as d, b as m, c as u, d as x, e as l, T as R, f as S } from "./chunks/Robot-DS2W4y1f.js";
|
|
2
2
|
import { J as c } from "./chunks/JoggingGizmo-CR-9mcYX.js";
|
|
3
3
|
import { J as G } from "./chunks/JoggingGizmoOrientation-DoMYMVlT.js";
|
|
4
|
-
import { R as b } from "./chunks/RobotControlPanel-
|
|
4
|
+
import { R as b } from "./chunks/RobotControlPanel-B_dcyr-M.js";
|
|
5
5
|
import { V as L, a as M } from "./chunks/useSmoothedMotionState-COMJRcOt.js";
|
|
6
6
|
export {
|
|
7
7
|
a as CollisionSceneRenderer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../chunks/RobotControlPanel-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../chunks/RobotControlPanel-B9mziQO2.cjs");exports.RobotControlPanel=o.RobotControlPanel;exports.default=o.RobotControlPanel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),G=require("@mui/material/IconButton"),j=require("@mui/material/Stack"),A=require("@mui/material/Tab"),K=require("@mui/material/Tabs"),q=require("@mui/material/Typography"),W=require("@wandelbots/icons/CloseFilled"),f=require("react"),w=require("react-i18next"),Q=require("./externalizeComponent-BBWF9CMB.cjs"),P=require("@mui/material/Divider"),k=require("@mui/material/Tooltip"),Y=require("@wandelbots/icons/Jog"),Z=require("@wandelbots/icons/ViewModuleFilled"),tt=require("./JoggingGizmo-xvCp3LCB.cjs"),et=require("./JoggingButtons-B341nDtX.cjs"),nt=require("@mui/material/styles"),L=require("@mui/material/ToggleButton"),ot=require("@mui/material/ToggleButtonGroup"),rt=require("@mui/material/Box"),lt=require("@mui/material/MenuItem"),y=require("@wandelbots/mui"),st=require("@mui/material/Slider"),at=require("./JoggingJointSlider-D6ZF4AHZ.cjs"),it=require("@wandelbots/icons/Undo"),ut=require("@wandelbots/icons/NorthEastFilled"),ct=require("./joggingColors-ZDc_2UCp.cjs"),O=require("@wandelbots/icons/CheckFilled"),dt=require("@wandelbots/icons/ContentCopyFilled"),xt=require("@wandelbots/icons/EditFilled");function ft({view:t,onViewChange:n,mode:o,controls:l,gizmoOrientation:s,gizmoFrameQuaternion:i}){const{t:r}=w.useTranslation(),a=t==="gizmo"&&s!==void 0,u=r(a?o==="increment"?"RobotControl.JogArea.Hint.ClickHandle.lb":"RobotControl.JogArea.Hint.HoldHandle.lb":o==="increment"?"RobotControl.JogArea.Hint.ClickButton.lb":"RobotControl.JogArea.Hint.HoldButton.lb"),d=r(a?"RobotControl.JogArea.ShowButtons.bt":"RobotControl.JogArea.ShowGizmo.bt");return e.jsxs(j,{"data-testid":"jog-area",sx:{position:"relative",alignItems:"center",gap:"16px"},children:[s&&e.jsx(k,{title:d,placement:"left",children:e.jsx(G,{"aria-label":d,onClick:()=>n(a?"buttons":"gizmo"),size:"small",sx:x=>{var p;return{position:"absolute",top:0,right:0,zIndex:1,borderRadius:"8px",border:`1px solid ${x.palette.divider}`,background:(p=x.palette.backgroundPaperElevation)==null?void 0:p[11]}},children:a?e.jsx(Z.ViewModuleFilled,{}):e.jsx(Y.Jog,{})})}),a?e.jsx(tt.JoggingGizmo,{...l,orientation:s,frameQuaternion:i,size:180}):e.jsx(et.JoggingButtons,{...l}),e.jsx(q,{variant:"body2",color:"text.secondary",textAlign:"center",children:u})]})}const pt=nt.styled(ot)(({theme:t})=>{var n;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:(n=t.palette.backgroundPaperElevation)==null?void 0:n[11]}}});function gt({value:t,onChange:n,disabled:o}){const{t:l}=w.useTranslation();return e.jsxs(pt,{exclusive:!0,value:t,disabled:o,"aria-label":l("RobotControl.JogMode.lb"),onChange:(s,i)=>{i!==null&&n(i)},children:[e.jsx(L,{value:"continuous",children:l("RobotControl.JogMode.Continuous.bt")}),e.jsx(L,{value:"increment",children:l("RobotControl.JogMode.Increment.bt")})]})}function D(t,n){var o;return((o=t.find(l=>l.id===n))==null?void 0:o.label)??String(n)}function U(t){return t.map(n=>e.jsx(lt,{value:n.id,children:n.label},n.id))}function B({label:t,options:n,value:o,onChange:l,disabled:s}){const i=f.useId();return e.jsx(y.AdornedSelect,{label:t,labelId:i,value:o,disabled:s,renderValue:r=>D(n,r),onChange:r=>l(String(r.target.value)),children:U(n)})}function bt({label:t,options:n,value:o,onChange:l,disabled:s}){const i=f.useId();return e.jsxs(j,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",gap:2},children:[e.jsx(q,{id:i,variant:"body2",color:"text.secondary",children:t}),e.jsx(rt,{sx:{width:"calc((100% - 12px) / 2)",flexShrink:0},children:e.jsx(y.AdornedSelect,{labelId:i,adornedSize:"small",value:o,disabled:s,renderValue:r=>D(n,r),onChange:r=>l(String(r.target.value)),children:U(n)})})]})}function E({children:t}){return e.jsx(j,{sx:{padding:"16px 20px",gap:"16px"},children:t})}function ht(t){return t*180/Math.PI}function Ct(t){return t*Math.PI/180}function z(t,n){return t==="rotate"?ht(n):n}function mt(t,n){return t==="rotate"?Ct(n):n}function jt(t,n){const o=String(Number(z(t,n).toFixed(2)));return t==="rotate"?`${o}°`:`${o} mm`}function vt(t,n){const o=Math.round(z(t,n));return t==="rotate"?`${o}°/s`:`${o} mm/s`}function V({motion:t,velocity:n,onChange:o,disabled:l}){const{t:s}=w.useTranslation(),i=f.useId(),r=a=>z(t,a);return e.jsxs(j,{gap:"4px",children:[e.jsxs(j,{direction:"row",sx:{justifyContent:"space-between"},children:[e.jsx(q,{id:i,variant:"body2",color:"text.secondary",children:s("RobotControl.Velocity.lb")}),e.jsx(q,{variant:"body2",color:"text.primary",sx:{fontVariantNumeric:"tabular-nums"},children:vt(t,n.value)})]}),e.jsx(st,{"aria-labelledby":i,size:"small",value:Math.round(r(n.value)),min:Math.ceil(r(n.min)),max:Math.floor(r(n.max)),disabled:l,onChange:(a,u)=>{typeof u=="number"&&o(mt(t,u))},sx:a=>{var u;return{height:4,"& .MuiSlider-rail":{opacity:.38},"& .MuiSlider-thumb":{width:16,height:16,border:`3px solid ${a.palette.primary.main}`,backgroundColor:(u=a.palette.backgroundPaperElevation)==null?void 0:u[5]}}}})]})}function Rt({motion:t,settings:n,onSettingsChange:o,disabled:l=!1,tcp:s,jogFrame:i,velocity:r,onVelocityChange:a,onJogStart:u,onJogStop:d,increments:x,gizmoOrientation:p,gizmoFrameQuaternion:h}){const{t:g}=w.useTranslation(),c=x?n.mode:"continuous",T=(x==null?void 0:x.steps[t])??[],v=Math.min(n.step[t],T.length-1),C=T[v],M=f.useRef(!1);function I(m,b){if(c==="increment"){x&&C!==void 0&&x.onStep(t,m,b,C);return}M.current=!0,u(t,m,b)}function F(){M.current&&(M.current=!1,d())}return e.jsxs(e.Fragment,{children:[(s||i)&&e.jsxs(e.Fragment,{children:[e.jsx(E,{children:e.jsxs(j,{direction:"row",sx:{gap:"12px"},children:[s&&e.jsx(B,{label:g("RobotControl.Tcp.lb"),...s,disabled:l}),i&&e.jsx(B,{label:g("RobotControl.JogFrame.lb"),...i,disabled:l})]})}),e.jsx(P,{sx:{marginX:"20px"}})]}),e.jsxs(E,{children:[x&&e.jsx(gt,{value:c,onChange:m=>o({...n,mode:m}),disabled:l}),e.jsx(V,{motion:t,velocity:r[t],onChange:m=>a(t,m),disabled:l}),c==="increment"&&C!==void 0&&e.jsx(bt,{label:g("RobotControl.StepSize.lb"),value:String(v),options:T.map((m,b)=>({id:String(b),label:jt(t,m)})),onChange:m=>o({...n,step:{...n.step,[t]:Number(m)}}),disabled:l})]}),e.jsx(P,{sx:{marginX:"20px"}}),e.jsx(E,{children:e.jsx(ft,{view:n.view,onViewChange:m=>o({...n,view:m}),mode:c,controls:{motion:t,onJogStart:I,onJogStop:F,activeHandle:c==="increment"?x==null?void 0:x.running:null,disabled:l},gizmoOrientation:p,gizmoFrameQuaternion:h},c)})]})}function Tt({joints:t,disabled:n}){const o=f.useRef(null),[l,s]=f.useState(null);function i(a,u){o.current!==null&&o.current!==a||(o.current=a,s(a),t.onJogStart(a,u))}function r(a){o.current===a&&(o.current=null,s(null),t.onJogStop())}return e.jsxs(e.Fragment,{children:[e.jsx(E,{children:e.jsx(j,{sx:{gap:"8px",paddingX:"4px"},children:t.joints.map((a,u)=>e.jsx(at.JoggingJointSlider,{label:`J${u+1}`,name:a.name,value:a.value,min:a.min,max:a.max,linear:t.linear,onJogStart:d=>i(u,d),onJogStop:()=>r(u),disabled:n||l!==null&&l!==u},u))})}),e.jsx(P,{sx:{marginX:"20px"}}),e.jsx(E,{children:e.jsx(V,{motion:t.linear?"translate":"rotate",velocity:t.velocity,onChange:t.onVelocityChange,disabled:n})})]})}const Mt=.5,St=.01;function yt(t,n){return t?Math.hypot(t.position[0]-n.position[0],t.position[1]-n.position[1],t.position[2]-n.position[2])<=Mt&&wt(t.orientation,n.orientation)<=St:!1}function _(t){const n=Math.hypot(...t);if(n<1e-12)return[1,0,0,0];const o=Math.sin(n/2)/n;return[Math.cos(n/2),t[0]*o,t[1]*o,t[2]*o]}function wt(t,n){const o=_(t),l=_(n),s=Math.abs(o[0]*l[0]+o[1]*l[1]+o[2]*l[2]+o[3]*l[3]);return 2*Math.acos(Math.min(1,s))}const It="move",Et=200;function qt({state:t,ready:n,atPose:o,disabled:l,onMoveStart:s,onMoveStop:i,stopRef:r}){const{t:a}=w.useTranslation(),[u,d]=f.useState(!1),x=f.useRef(void 0),p=f.useRef(!1),h=f.useRef({onMoveStart:s,onMoveStop:i});h.current={onMoveStart:s,onMoveStop:i};const g=t==="planned",c=g||t==="moving",{handlersFor:T,stop:v}=ct.useHold({onStart:()=>{d(!0),x.current=setTimeout(()=>{x.current=void 0,p.current=!0,h.current.onMoveStart()},Et)},onStop:()=>{d(!1),clearTimeout(x.current),x.current=void 0,p.current&&(p.current=!1,h.current.onMoveStop())},disabled:u?l||!n||!c:l||!n||o||!g,isSame:()=>!0});r&&(r.current=v),f.useEffect(()=>()=>clearTimeout(x.current),[]);const C=a(t==="moving"?"RobotControl.MoveTo.Moving.bt":t==="stopping"?"RobotControl.MoveTo.Stopping.bt":"RobotControl.MoveTo.MoveTo.bt");return e.jsx(k,{title:a(o?"RobotControl.MoveTo.AtPose.lb":"RobotControl.MoveTo.HoldToMove.lb"),placement:"top",children:e.jsx("span",{...T(It),style:{display:"block",flexGrow:1,touchAction:"none",userSelect:"none"},children:e.jsx(y.PrimaryButton,{fullWidth:!0,disabled:l||!n||o||!c,loading:t==="planning"||t==="stopping",loadingPosition:"start",startIcon:e.jsx(ut.NorthEastFilled,{}),"aria-pressed":u,children:C})})})}function Ft({text:t,editing:n,onEdit:o,onDraftChange:l,onCancel:s,onConfirm:i,canConfirm:r,error:a,disabled:u}){const{t:d}=w.useTranslation(),x=f.useRef(null),[p,h]=f.useState(!1);f.useEffect(()=>{const c=x.current;c&&(n?(c.focus(),c.setSelectionRange(c.value.length,c.value.length)):document.activeElement===c&&(c.blur(),c.scrollLeft=0))},[n]),f.useEffect(()=>{if(!p)return;const c=setTimeout(()=>h(!1),3e3);return()=>clearTimeout(c)},[p]);async function g(){var c;try{if(navigator.clipboard){await navigator.clipboard.writeText(t),h(!0);return}}catch{}(c=x.current)==null||c.select();try{document.execCommand("copy")&&h(!0)}catch{}}return e.jsxs(j,{direction:"row",sx:{gap:"8px",alignItems:"flex-start"},children:[e.jsx(y.AdornedTextField,{label:d("RobotControl.MoveTo.Coordinates.lb"),value:t,inputRef:x,onChange:c=>l(c.target.value),onClick:()=>{!n&&!u&&o()},onKeyDown:c=>{n&&(c.key==="Enter"&&r?i():c.key==="Escape"&&s())},error:!!a,helperText:a??void 0,fullWidth:!0,autoComplete:"off",slotProps:{htmlInput:{readOnly:!n,spellCheck:!1}},sx:{"& input":{fontVariantNumeric:"tabular-nums",cursor:n||u?void 0:"text"}}}),e.jsx(j,{direction:"row",sx:{gap:"8px",height:"56px",alignItems:"center"},children:n?e.jsxs(e.Fragment,{children:[e.jsx(y.RoundedIconButton,{icon:e.jsx(W.CloseFilled,{}),ariaLabel:d("RobotControl.MoveTo.Cancel.bt"),onClick:s}),e.jsx(k,{title:d("RobotControl.MoveTo.ConfirmEdit.lb"),placement:"left",children:e.jsx("span",{children:e.jsx(y.RoundedIconButton,{icon:e.jsx(O.CheckFilled,{}),ariaLabel:d("RobotControl.MoveTo.ConfirmEdit.lb"),onClick:i,disabled:!r,sx:{color:"primary.main"}})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(k,{title:d("RobotControl.MoveTo.Copied.lb"),open:p,disableHoverListener:!0,placement:"left",children:e.jsx(y.RoundedIconButton,{icon:p?e.jsx(O.CheckFilled,{}):e.jsx(dt.ContentCopyFilled,{}),ariaLabel:d("RobotControl.MoveTo.Copy.bt"),onClick:()=>void g()})}),e.jsx(y.RoundedIconButton,{icon:e.jsx(xt.EditFilled,{}),ariaLabel:d("RobotControl.MoveTo.Edit.bt"),onClick:o,disabled:u})]})})]})}const Jt=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function X(t){const n=(o,l)=>Number.parseFloat(o.toFixed(l));return`(${[...t.position.map(o=>n(o,1)),...t.orientation.map(o=>n(o,4))].join(", ")})`}function kt(t){let n=t.trim();const o=n.startsWith("("),l=n.endsWith(")");if(o!==l||(o&&(n=n.slice(1,-1)),n.trim()===""))return null;const s=[];for(const p of n.split(",")){const h=p.trim();if(!Jt.test(h))return null;const g=Number(h);if(!Number.isFinite(g))return null;s.push(g)}if(s.length!==6)return null;const[i,r,a,u,d,x]=s;return{position:[i,r,a],orientation:[u,d,x]}}function $(t,n){const o=f.useRef(t);o.current=t;const[l,s]=f.useState(t);return f.useEffect(()=>{if(!n)return;let i=0;const r=()=>{s(o.current()),i=requestAnimationFrame(r)};return r(),()=>cancelAnimationFrame(i)},[n]),l}function At({moveTo:t,tcp:n,velocity:o,onVelocityChange:l,disabled:s}){var S;const{t:i}=w.useTranslation(),[r,a]=f.useState(null),[u,d]=f.useState(null),x=$(()=>{const R=t.getCurrentPose();return R?X(R):""},r===null&&u===null),p=(r==null?void 0:r.text)??x,h=u!==null,g=u===null?null:kt(u),c=r!==null&&!t.error&&!h,T=$(()=>r!==null&&yt(t.getCurrentPose(),r.pose),c)&&c,v=f.useRef(!1),C=f.useRef(null);function M(){var R;(R=C.current)==null||R.call(C),v.current=!1,a(null),d(null),t.onTargetChange(null)}function I(){g===null||s||(v.current=!1,a({pose:g,text:X(g)}),d(null),t.onTargetChange(g))}f.useEffect(()=>{if(c){if(t.state==="moving"){v.current=!0;return}v.current&&T&&t.state!=="stopping"&&M()}},[c,t.state,T]);const F=[n==null?void 0:n.value,(S=t.frame)==null?void 0:S.value].join("\0");f.useEffect(()=>{r&&M()},[F]);const m=f.useRef({target:r,onTargetChange:t.onTargetChange});m.current={target:r,onTargetChange:t.onTargetChange},f.useEffect(()=>()=>{var R;(R=C.current)==null||R.call(C),m.current.target&&m.current.onTargetChange(null)},[]);const b=u!==null?g===null?i("RobotControl.MoveTo.InvalidPose.lb"):null:r?t.error??null:null;return e.jsxs(E,{children:[n&&e.jsx(B,{label:i("RobotControl.Tcp.lb"),...n,disabled:s}),e.jsx(q,{variant:"body1",color:"text.primary",children:i("RobotControl.MoveTo.TargetPose.lb")}),e.jsxs(j,{sx:{gap:"8px"},children:[t.frame&&e.jsx(B,{label:i("RobotControl.MoveTo.RelativeTo.lb"),...t.frame,disabled:s}),e.jsx(Ft,{text:u??p,editing:h,onEdit:()=>{s||d(p)},onDraftChange:d,onCancel:()=>d(null),onConfirm:I,canConfirm:g!==null&&!s&&t.state!=="planning",error:b,disabled:s})]}),e.jsx(V,{motion:"translate",velocity:o,onChange:l,disabled:s}),e.jsxs(j,{direction:"row",sx:{gap:"12px",alignItems:"center"},children:[r&&!h&&e.jsx(k,{title:i("RobotControl.MoveTo.Reset.lb"),placement:"top",children:e.jsx("span",{children:e.jsx(y.RoundedIconButton,{icon:e.jsx(it.Undo,{}),ariaLabel:i("RobotControl.MoveTo.Reset.lb"),onClick:M})})}),e.jsx(qt,{state:r?t.state:"idle",ready:c,atPose:T,disabled:s,onMoveStart:()=>{r&&t.onMoveStart(r.pose)},onMoveStop:t.onMoveStop,stopRef:C})]})]})}const Bt=Q.externalizeComponent(({onClose:t,sx:n,joints:o,moveTo:l,jogDisabled:s=!1,tab:i,onTabChange:r,jogMode:a,onJogModeChange:u,...d})=>{const{t:x}=w.useTranslation(),p=d.disabled??!1,[h,g]=f.useState("translate"),[c,T]=f.useState({mode:"continuous",view:"gizmo",step:{translate:0,rotate:0}}),v=i??h,C=v==="joint"&&!o||v==="moveTo"&&!l?"translate":v,M=Pt(c,a,d.increments),I=x("RobotControl.Title.ti");function F(b){g(b),r==null||r(b)}function m(b){var S,R,N;T(b),b.mode!==M.mode&&(u==null||u(b.mode));for(const J of["translate","rotate"]){const H=(S=d.increments)==null?void 0:S.steps[J][b.step[J]];b.step[J]!==M.step[J]&&H!==void 0&&((N=(R=d.increments)==null?void 0:R.onStepChange)==null||N.call(R,J,H))}}return e.jsxs(j,{"data-testid":"robot-control-panel",sx:[b=>{var S;return{minHeight:0,overflow:"hidden",borderRadius:"16px",background:(S=b.palette.backgroundPaperElevation)==null?void 0:S[5]}},...Array.isArray(n)?n:[n]],children:[e.jsxs(j,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",padding:"20px 20px 8px"},children:[e.jsx(q,{component:"h2",color:"text.primary",sx:{fontSize:"20px"},children:I}),t&&e.jsx(G,{"aria-label":x("RobotControl.Close.bt"),onClick:t,size:"small",children:e.jsx(W.CloseFilled,{})})]}),e.jsxs(K,{value:C,onChange:(b,S)=>F(S),"aria-label":I,variant:"scrollable",scrollButtons:!1,sx:{marginX:"20px",borderBottom:1,borderColor:"divider",background:"transparent"},children:[e.jsx(A,{value:"translate",label:x("RobotControl.Tab.Translate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),e.jsx(A,{value:"rotate",label:x("RobotControl.Tab.Rotate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),o&&e.jsx(A,{value:"joint",label:x("RobotControl.Tab.Joint.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),l&&e.jsx(A,{value:"moveTo",label:x("RobotControl.Tab.MoveTo.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}})]}),e.jsx(j,{sx:{flexGrow:1,overflowY:"auto",overflowX:"hidden"},children:C==="joint"&&o?e.jsx(Tt,{joints:o,disabled:p||s}):C==="moveTo"&&l?e.jsx(At,{moveTo:l,tcp:d.tcp,velocity:d.velocity.translate,onVelocityChange:b=>d.onVelocityChange("translate",b),disabled:p}):e.jsx(Rt,{...d,disabled:p||s,motion:C==="rotate"?"rotate":"translate",settings:M,onSettingsChange:m})})]})});function Pt(t,n,o){const l=s=>{var a;const i=(a=o==null?void 0:o.step)==null?void 0:a[s];if(i===void 0)return t.step[s];const r=o==null?void 0:o.steps[s].findIndex(u=>Math.abs(u-i)<=1e-9*Math.max(1,Math.abs(u)));return r===void 0||r<0?t.step[s]:r};return{...t,mode:n??t.mode,step:{translate:l("translate"),rotate:l("rotate")}}}exports.RobotControlPanel=Bt;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsxs as g, jsx as e, Fragment as
|
|
1
|
+
import { jsxs as g, jsx as e, Fragment as z } from "react/jsx-runtime";
|
|
2
2
|
import Y from "@mui/material/IconButton";
|
|
3
3
|
import C from "@mui/material/Stack";
|
|
4
|
-
import
|
|
4
|
+
import H from "@mui/material/Tab";
|
|
5
5
|
import et from "@mui/material/Tabs";
|
|
6
|
-
import
|
|
6
|
+
import P from "@mui/material/Typography";
|
|
7
7
|
import { CloseFilled as Z } from "@wandelbots/icons/CloseFilled";
|
|
8
|
-
import { useId as _, useRef as
|
|
9
|
-
import { useTranslation as
|
|
8
|
+
import { useId as _, useRef as w, useState as I, useEffect as k } from "react";
|
|
9
|
+
import { useTranslation as J } from "react-i18next";
|
|
10
10
|
import { e as nt } from "./externalizeComponent-DBRjUP0q.js";
|
|
11
11
|
import O from "@mui/material/Divider";
|
|
12
|
-
import
|
|
12
|
+
import N from "@mui/material/Tooltip";
|
|
13
13
|
import { Jog as rt } from "@wandelbots/icons/Jog";
|
|
14
14
|
import { ViewModuleFilled as lt } from "@wandelbots/icons/ViewModuleFilled";
|
|
15
15
|
import { J as at } from "./JoggingGizmo-CR-9mcYX.js";
|
|
@@ -19,35 +19,35 @@ import D from "@mui/material/ToggleButton";
|
|
|
19
19
|
import st from "@mui/material/ToggleButtonGroup";
|
|
20
20
|
import ut from "@mui/material/Box";
|
|
21
21
|
import dt from "@mui/material/MenuItem";
|
|
22
|
-
import { AdornedSelect as j, PrimaryButton as pt, AdornedTextField as ft, RoundedIconButton as
|
|
22
|
+
import { AdornedSelect as j, PrimaryButton as pt, AdornedTextField as ft, RoundedIconButton as V } from "@wandelbots/mui";
|
|
23
23
|
import bt from "@mui/material/Slider";
|
|
24
24
|
import { J as mt } from "./JoggingJointSlider-oTxF8u1r.js";
|
|
25
25
|
import { Undo as gt } from "@wandelbots/icons/Undo";
|
|
26
26
|
import { NorthEastFilled as ht } from "@wandelbots/icons/NorthEastFilled";
|
|
27
27
|
import { d as xt } from "./joggingColors-CuT5u0H8.js";
|
|
28
28
|
import { CheckFilled as q } from "@wandelbots/icons/CheckFilled";
|
|
29
|
-
import { ContentCopyFilled as
|
|
30
|
-
import { EditFilled as
|
|
31
|
-
function
|
|
29
|
+
import { ContentCopyFilled as vt } from "@wandelbots/icons/ContentCopyFilled";
|
|
30
|
+
import { EditFilled as Ct } from "@wandelbots/icons/EditFilled";
|
|
31
|
+
function Rt({
|
|
32
32
|
view: t,
|
|
33
33
|
onViewChange: o,
|
|
34
34
|
mode: n,
|
|
35
35
|
controls: l,
|
|
36
36
|
gizmoOrientation: a,
|
|
37
|
-
gizmoFrameQuaternion:
|
|
37
|
+
gizmoFrameQuaternion: c
|
|
38
38
|
}) {
|
|
39
|
-
const { t: r } =
|
|
39
|
+
const { t: r } = J(), i = t === "gizmo" && a !== void 0, s = r(i ? n === "increment" ? "RobotControl.JogArea.Hint.ClickHandle.lb" : "RobotControl.JogArea.Hint.HoldHandle.lb" : n === "increment" ? "RobotControl.JogArea.Hint.ClickButton.lb" : "RobotControl.JogArea.Hint.HoldButton.lb"), d = r(i ? "RobotControl.JogArea.ShowButtons.bt" : "RobotControl.JogArea.ShowGizmo.bt");
|
|
40
40
|
return /* @__PURE__ */ g(
|
|
41
41
|
C,
|
|
42
42
|
{
|
|
43
43
|
"data-testid": "jog-area",
|
|
44
44
|
sx: { position: "relative", alignItems: "center", gap: "16px" },
|
|
45
45
|
children: [
|
|
46
|
-
a && /* @__PURE__ */ e(
|
|
46
|
+
a && /* @__PURE__ */ e(N, { title: d, placement: "left", children: /* @__PURE__ */ e(
|
|
47
47
|
Y,
|
|
48
48
|
{
|
|
49
|
-
"aria-label":
|
|
50
|
-
onClick: () => o(
|
|
49
|
+
"aria-label": d,
|
|
50
|
+
onClick: () => o(i ? "buttons" : "gizmo"),
|
|
51
51
|
size: "small",
|
|
52
52
|
sx: (p) => {
|
|
53
53
|
var f;
|
|
@@ -61,24 +61,24 @@ function Tt({
|
|
|
61
61
|
background: (f = p.palette.backgroundPaperElevation) == null ? void 0 : f[11]
|
|
62
62
|
};
|
|
63
63
|
},
|
|
64
|
-
children:
|
|
64
|
+
children: i ? /* @__PURE__ */ e(lt, {}) : /* @__PURE__ */ e(rt, {})
|
|
65
65
|
}
|
|
66
66
|
) }),
|
|
67
|
-
|
|
67
|
+
i ? /* @__PURE__ */ e(
|
|
68
68
|
at,
|
|
69
69
|
{
|
|
70
70
|
...l,
|
|
71
71
|
orientation: a,
|
|
72
|
-
frameQuaternion:
|
|
72
|
+
frameQuaternion: c,
|
|
73
73
|
size: 180
|
|
74
74
|
}
|
|
75
75
|
) : /* @__PURE__ */ e(it, { ...l }),
|
|
76
|
-
/* @__PURE__ */ e(
|
|
76
|
+
/* @__PURE__ */ e(P, { variant: "body2", color: "text.secondary", textAlign: "center", children: s })
|
|
77
77
|
]
|
|
78
78
|
}
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const Tt = ct(st)(({ theme: t }) => {
|
|
82
82
|
var o;
|
|
83
83
|
return {
|
|
84
84
|
gap: "4px",
|
|
@@ -101,16 +101,16 @@ function Mt({
|
|
|
101
101
|
onChange: o,
|
|
102
102
|
disabled: n
|
|
103
103
|
}) {
|
|
104
|
-
const { t: l } =
|
|
104
|
+
const { t: l } = J();
|
|
105
105
|
return /* @__PURE__ */ g(
|
|
106
|
-
|
|
106
|
+
Tt,
|
|
107
107
|
{
|
|
108
108
|
exclusive: !0,
|
|
109
109
|
value: t,
|
|
110
110
|
disabled: n,
|
|
111
111
|
"aria-label": l("RobotControl.JogMode.lb"),
|
|
112
|
-
onChange: (a,
|
|
113
|
-
|
|
112
|
+
onChange: (a, c) => {
|
|
113
|
+
c !== null && o(c);
|
|
114
114
|
},
|
|
115
115
|
children: [
|
|
116
116
|
/* @__PURE__ */ e(D, { value: "continuous", children: l("RobotControl.JogMode.Continuous.bt") }),
|
|
@@ -133,12 +133,12 @@ function L({
|
|
|
133
133
|
onChange: l,
|
|
134
134
|
disabled: a
|
|
135
135
|
}) {
|
|
136
|
-
const
|
|
136
|
+
const c = _();
|
|
137
137
|
return /* @__PURE__ */ e(
|
|
138
138
|
j,
|
|
139
139
|
{
|
|
140
140
|
label: t,
|
|
141
|
-
labelId:
|
|
141
|
+
labelId: c,
|
|
142
142
|
value: n,
|
|
143
143
|
disabled: a,
|
|
144
144
|
renderValue: (r) => tt(o, r),
|
|
@@ -154,18 +154,18 @@ function yt({
|
|
|
154
154
|
onChange: l,
|
|
155
155
|
disabled: a
|
|
156
156
|
}) {
|
|
157
|
-
const
|
|
157
|
+
const c = _();
|
|
158
158
|
return /* @__PURE__ */ g(
|
|
159
159
|
C,
|
|
160
160
|
{
|
|
161
161
|
direction: "row",
|
|
162
162
|
sx: { alignItems: "center", justifyContent: "space-between", gap: 2 },
|
|
163
163
|
children: [
|
|
164
|
-
/* @__PURE__ */ e(
|
|
164
|
+
/* @__PURE__ */ e(P, { id: c, variant: "body2", color: "text.secondary", children: t }),
|
|
165
165
|
/* @__PURE__ */ e(ut, { sx: { width: "calc((100% - 12px) / 2)", flexShrink: 0 }, children: /* @__PURE__ */ e(
|
|
166
166
|
j,
|
|
167
167
|
{
|
|
168
|
-
labelId:
|
|
168
|
+
labelId: c,
|
|
169
169
|
adornedSize: "small",
|
|
170
170
|
value: n,
|
|
171
171
|
disabled: a,
|
|
@@ -178,7 +178,7 @@ function yt({
|
|
|
178
178
|
}
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function A({ children: t }) {
|
|
182
182
|
return /* @__PURE__ */ e(C, { sx: { padding: "16px 20px", gap: "16px" }, children: t });
|
|
183
183
|
}
|
|
184
184
|
function St(t) {
|
|
@@ -207,12 +207,12 @@ function $({
|
|
|
207
207
|
onChange: n,
|
|
208
208
|
disabled: l
|
|
209
209
|
}) {
|
|
210
|
-
const { t: a } =
|
|
210
|
+
const { t: a } = J(), c = _(), r = (i) => X(t, i);
|
|
211
211
|
return /* @__PURE__ */ g(C, { gap: "4px", children: [
|
|
212
212
|
/* @__PURE__ */ g(C, { direction: "row", sx: { justifyContent: "space-between" }, children: [
|
|
213
|
-
/* @__PURE__ */ e(
|
|
213
|
+
/* @__PURE__ */ e(P, { id: c, variant: "body2", color: "text.secondary", children: a("RobotControl.Velocity.lb") }),
|
|
214
214
|
/* @__PURE__ */ e(
|
|
215
|
-
|
|
215
|
+
P,
|
|
216
216
|
{
|
|
217
217
|
variant: "body2",
|
|
218
218
|
color: "text.primary",
|
|
@@ -224,16 +224,16 @@ function $({
|
|
|
224
224
|
/* @__PURE__ */ e(
|
|
225
225
|
bt,
|
|
226
226
|
{
|
|
227
|
-
"aria-labelledby":
|
|
227
|
+
"aria-labelledby": c,
|
|
228
228
|
size: "small",
|
|
229
229
|
value: Math.round(r(o.value)),
|
|
230
230
|
min: Math.ceil(r(o.min)),
|
|
231
231
|
max: Math.floor(r(o.max)),
|
|
232
232
|
disabled: l,
|
|
233
|
-
onChange: (
|
|
233
|
+
onChange: (i, s) => {
|
|
234
234
|
typeof s == "number" && n(It(t, s));
|
|
235
235
|
},
|
|
236
|
-
sx: (
|
|
236
|
+
sx: (i) => {
|
|
237
237
|
var s;
|
|
238
238
|
return {
|
|
239
239
|
// The rail and the hollow thumb of the joint sliders, as in the
|
|
@@ -243,8 +243,8 @@ function $({
|
|
|
243
243
|
"& .MuiSlider-thumb": {
|
|
244
244
|
width: 16,
|
|
245
245
|
height: 16,
|
|
246
|
-
border: `3px solid ${
|
|
247
|
-
backgroundColor: (s =
|
|
246
|
+
border: `3px solid ${i.palette.primary.main}`,
|
|
247
|
+
backgroundColor: (s = i.palette.backgroundPaperElevation) == null ? void 0 : s[5]
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
}
|
|
@@ -258,54 +258,54 @@ function Et({
|
|
|
258
258
|
onSettingsChange: n,
|
|
259
259
|
disabled: l = !1,
|
|
260
260
|
tcp: a,
|
|
261
|
-
jogFrame:
|
|
261
|
+
jogFrame: c,
|
|
262
262
|
velocity: r,
|
|
263
|
-
onVelocityChange:
|
|
263
|
+
onVelocityChange: i,
|
|
264
264
|
onJogStart: s,
|
|
265
|
-
onJogStop:
|
|
265
|
+
onJogStop: d,
|
|
266
266
|
increments: p,
|
|
267
267
|
gizmoOrientation: f,
|
|
268
|
-
gizmoFrameQuaternion:
|
|
268
|
+
gizmoFrameQuaternion: h
|
|
269
269
|
}) {
|
|
270
|
-
const { t:
|
|
271
|
-
function
|
|
272
|
-
if (
|
|
273
|
-
p &&
|
|
270
|
+
const { t: b } = J(), u = p ? o.mode : "continuous", M = (p == null ? void 0 : p.steps[t]) ?? [], R = Math.min(o.step[t], M.length - 1), x = M[R], y = w(!1);
|
|
271
|
+
function E(v, m) {
|
|
272
|
+
if (u === "increment") {
|
|
273
|
+
p && x !== void 0 && p.onStep(t, v, m, x);
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
|
|
276
|
+
y.current = !0, s(t, v, m);
|
|
277
277
|
}
|
|
278
|
-
function
|
|
279
|
-
|
|
278
|
+
function B() {
|
|
279
|
+
y.current && (y.current = !1, d());
|
|
280
280
|
}
|
|
281
|
-
return /* @__PURE__ */ g(
|
|
282
|
-
(a ||
|
|
283
|
-
/* @__PURE__ */ e(
|
|
281
|
+
return /* @__PURE__ */ g(z, { children: [
|
|
282
|
+
(a || c) && /* @__PURE__ */ g(z, { children: [
|
|
283
|
+
/* @__PURE__ */ e(A, { children: /* @__PURE__ */ g(C, { direction: "row", sx: { gap: "12px" }, children: [
|
|
284
284
|
a && /* @__PURE__ */ e(
|
|
285
285
|
L,
|
|
286
286
|
{
|
|
287
|
-
label:
|
|
287
|
+
label: b("RobotControl.Tcp.lb"),
|
|
288
288
|
...a,
|
|
289
289
|
disabled: l
|
|
290
290
|
}
|
|
291
291
|
),
|
|
292
|
-
|
|
292
|
+
c && /* @__PURE__ */ e(
|
|
293
293
|
L,
|
|
294
294
|
{
|
|
295
|
-
label:
|
|
296
|
-
...
|
|
295
|
+
label: b("RobotControl.JogFrame.lb"),
|
|
296
|
+
...c,
|
|
297
297
|
disabled: l
|
|
298
298
|
}
|
|
299
299
|
)
|
|
300
300
|
] }) }),
|
|
301
301
|
/* @__PURE__ */ e(O, { sx: { marginX: "20px" } })
|
|
302
302
|
] }),
|
|
303
|
-
/* @__PURE__ */ g(
|
|
303
|
+
/* @__PURE__ */ g(A, { children: [
|
|
304
304
|
p && /* @__PURE__ */ e(
|
|
305
305
|
Mt,
|
|
306
306
|
{
|
|
307
|
-
value:
|
|
308
|
-
onChange: (
|
|
307
|
+
value: u,
|
|
308
|
+
onChange: (v) => n({ ...o, mode: v }),
|
|
309
309
|
disabled: l
|
|
310
310
|
}
|
|
311
311
|
),
|
|
@@ -314,45 +314,45 @@ function Et({
|
|
|
314
314
|
{
|
|
315
315
|
motion: t,
|
|
316
316
|
velocity: r[t],
|
|
317
|
-
onChange: (
|
|
317
|
+
onChange: (v) => i(t, v),
|
|
318
318
|
disabled: l
|
|
319
319
|
}
|
|
320
320
|
),
|
|
321
|
-
|
|
321
|
+
u === "increment" && x !== void 0 && /* @__PURE__ */ e(
|
|
322
322
|
yt,
|
|
323
323
|
{
|
|
324
|
-
label:
|
|
325
|
-
value: String(
|
|
326
|
-
options:
|
|
327
|
-
id: String(
|
|
328
|
-
label: Jt(t,
|
|
324
|
+
label: b("RobotControl.StepSize.lb"),
|
|
325
|
+
value: String(R),
|
|
326
|
+
options: M.map((v, m) => ({
|
|
327
|
+
id: String(m),
|
|
328
|
+
label: Jt(t, v)
|
|
329
329
|
})),
|
|
330
|
-
onChange: (
|
|
330
|
+
onChange: (v) => n({
|
|
331
331
|
...o,
|
|
332
|
-
step: { ...o.step, [t]: Number(
|
|
332
|
+
step: { ...o.step, [t]: Number(v) }
|
|
333
333
|
}),
|
|
334
334
|
disabled: l
|
|
335
335
|
}
|
|
336
336
|
)
|
|
337
337
|
] }),
|
|
338
338
|
/* @__PURE__ */ e(O, { sx: { marginX: "20px" } }),
|
|
339
|
-
/* @__PURE__ */ e(
|
|
340
|
-
|
|
339
|
+
/* @__PURE__ */ e(A, { children: /* @__PURE__ */ e(
|
|
340
|
+
Rt,
|
|
341
341
|
{
|
|
342
342
|
view: o.view,
|
|
343
|
-
onViewChange: (
|
|
344
|
-
mode:
|
|
343
|
+
onViewChange: (v) => n({ ...o, view: v }),
|
|
344
|
+
mode: u,
|
|
345
345
|
controls: {
|
|
346
346
|
motion: t,
|
|
347
|
-
onJogStart:
|
|
348
|
-
onJogStop:
|
|
349
|
-
activeHandle:
|
|
347
|
+
onJogStart: E,
|
|
348
|
+
onJogStop: B,
|
|
349
|
+
activeHandle: u === "increment" ? p == null ? void 0 : p.running : null,
|
|
350
350
|
disabled: l
|
|
351
351
|
},
|
|
352
352
|
gizmoOrientation: f,
|
|
353
|
-
gizmoFrameQuaternion:
|
|
353
|
+
gizmoFrameQuaternion: h
|
|
354
354
|
},
|
|
355
|
-
|
|
355
|
+
u
|
|
356
356
|
) })
|
|
357
357
|
] });
|
|
358
358
|
}
|
|
@@ -360,31 +360,31 @@ function At({
|
|
|
360
360
|
joints: t,
|
|
361
361
|
disabled: o
|
|
362
362
|
}) {
|
|
363
|
-
const n =
|
|
364
|
-
function i
|
|
365
|
-
n.current !== null && n.current !==
|
|
363
|
+
const n = w(null), [l, a] = I(null);
|
|
364
|
+
function c(i, s) {
|
|
365
|
+
n.current !== null && n.current !== i || (n.current = i, a(i), t.onJogStart(i, s));
|
|
366
366
|
}
|
|
367
|
-
function r(
|
|
368
|
-
n.current ===
|
|
367
|
+
function r(i) {
|
|
368
|
+
n.current === i && (n.current = null, a(null), t.onJogStop());
|
|
369
369
|
}
|
|
370
|
-
return /* @__PURE__ */ g(
|
|
371
|
-
/* @__PURE__ */ e(
|
|
370
|
+
return /* @__PURE__ */ g(z, { children: [
|
|
371
|
+
/* @__PURE__ */ e(A, { children: /* @__PURE__ */ e(C, { sx: { gap: "8px", paddingX: "4px" }, children: t.joints.map((i, s) => /* @__PURE__ */ e(
|
|
372
372
|
mt,
|
|
373
373
|
{
|
|
374
374
|
label: `J${s + 1}`,
|
|
375
|
-
name:
|
|
376
|
-
value:
|
|
377
|
-
min:
|
|
378
|
-
max:
|
|
375
|
+
name: i.name,
|
|
376
|
+
value: i.value,
|
|
377
|
+
min: i.min,
|
|
378
|
+
max: i.max,
|
|
379
379
|
linear: t.linear,
|
|
380
|
-
onJogStart: (
|
|
380
|
+
onJogStart: (d) => c(s, d),
|
|
381
381
|
onJogStop: () => r(s),
|
|
382
382
|
disabled: o || l !== null && l !== s
|
|
383
383
|
},
|
|
384
384
|
s
|
|
385
385
|
)) }) }),
|
|
386
386
|
/* @__PURE__ */ e(O, { sx: { marginX: "20px" } }),
|
|
387
|
-
/* @__PURE__ */ e(
|
|
387
|
+
/* @__PURE__ */ e(A, { children: /* @__PURE__ */ e(
|
|
388
388
|
$,
|
|
389
389
|
{
|
|
390
390
|
motion: t.linear ? "translate" : "rotate",
|
|
@@ -403,7 +403,7 @@ function Ft(t, o) {
|
|
|
403
403
|
t.position[2] - o.position[2]
|
|
404
404
|
) <= Pt && Vt(t.orientation, o.orientation) <= Bt : !1;
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function K(t) {
|
|
407
407
|
const o = Math.hypot(...t);
|
|
408
408
|
if (o < 1e-12) return [1, 0, 0, 0];
|
|
409
409
|
const n = Math.sin(o / 2) / o;
|
|
@@ -415,43 +415,44 @@ function Q(t) {
|
|
|
415
415
|
];
|
|
416
416
|
}
|
|
417
417
|
function Vt(t, o) {
|
|
418
|
-
const n =
|
|
418
|
+
const n = K(t), l = K(o), a = Math.abs(n[0] * l[0] + n[1] * l[1] + n[2] * l[2] + n[3] * l[3]);
|
|
419
419
|
return 2 * Math.acos(Math.min(1, a));
|
|
420
420
|
}
|
|
421
|
-
const zt = "move",
|
|
422
|
-
function
|
|
421
|
+
const zt = "move", Nt = 200;
|
|
422
|
+
function Ht({
|
|
423
423
|
state: t,
|
|
424
424
|
ready: o,
|
|
425
425
|
atPose: n,
|
|
426
426
|
disabled: l,
|
|
427
427
|
onMoveStart: a,
|
|
428
|
-
onMoveStop:
|
|
428
|
+
onMoveStop: c,
|
|
429
|
+
stopRef: r
|
|
429
430
|
}) {
|
|
430
|
-
const { t:
|
|
431
|
-
|
|
432
|
-
const b = t === "planned",
|
|
431
|
+
const { t: i } = J(), [s, d] = I(!1), p = w(void 0), f = w(!1), h = w({ onMoveStart: a, onMoveStop: c });
|
|
432
|
+
h.current = { onMoveStart: a, onMoveStop: c };
|
|
433
|
+
const b = t === "planned", u = b || t === "moving", { handlersFor: M, stop: R } = xt({
|
|
433
434
|
onStart: () => {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
},
|
|
435
|
+
d(!0), p.current = setTimeout(() => {
|
|
436
|
+
p.current = void 0, f.current = !0, h.current.onMoveStart();
|
|
437
|
+
}, Nt);
|
|
437
438
|
},
|
|
438
439
|
onStop: () => {
|
|
439
|
-
|
|
440
|
+
d(!1), clearTimeout(p.current), p.current = void 0, f.current && (f.current = !1, h.current.onMoveStop());
|
|
440
441
|
},
|
|
441
|
-
disabled:
|
|
442
|
+
disabled: s ? l || !o || !u : l || !o || n || !b,
|
|
442
443
|
isSame: () => !0
|
|
443
444
|
});
|
|
444
|
-
|
|
445
|
-
const
|
|
445
|
+
r && (r.current = R), k(() => () => clearTimeout(p.current), []);
|
|
446
|
+
const x = i(t === "moving" ? "RobotControl.MoveTo.Moving.bt" : t === "stopping" ? "RobotControl.MoveTo.Stopping.bt" : "RobotControl.MoveTo.MoveTo.bt");
|
|
446
447
|
return /* @__PURE__ */ e(
|
|
447
|
-
|
|
448
|
+
N,
|
|
448
449
|
{
|
|
449
|
-
title:
|
|
450
|
+
title: i(n ? "RobotControl.MoveTo.AtPose.lb" : "RobotControl.MoveTo.HoldToMove.lb"),
|
|
450
451
|
placement: "top",
|
|
451
452
|
children: /* @__PURE__ */ e(
|
|
452
453
|
"span",
|
|
453
454
|
{
|
|
454
|
-
...
|
|
455
|
+
...M(zt),
|
|
455
456
|
style: {
|
|
456
457
|
display: "block",
|
|
457
458
|
flexGrow: 1,
|
|
@@ -462,12 +463,12 @@ function Nt({
|
|
|
462
463
|
pt,
|
|
463
464
|
{
|
|
464
465
|
fullWidth: !0,
|
|
465
|
-
disabled: l || !o || n || !
|
|
466
|
+
disabled: l || !o || n || !u,
|
|
466
467
|
loading: t === "planning" || t === "stopping",
|
|
467
468
|
loadingPosition: "start",
|
|
468
469
|
startIcon: /* @__PURE__ */ e(ht, {}),
|
|
469
|
-
"aria-pressed":
|
|
470
|
-
children:
|
|
470
|
+
"aria-pressed": s,
|
|
471
|
+
children: x
|
|
471
472
|
}
|
|
472
473
|
)
|
|
473
474
|
}
|
|
@@ -481,32 +482,32 @@ function Lt({
|
|
|
481
482
|
onEdit: n,
|
|
482
483
|
onDraftChange: l,
|
|
483
484
|
onCancel: a,
|
|
484
|
-
onConfirm:
|
|
485
|
+
onConfirm: c,
|
|
485
486
|
canConfirm: r,
|
|
486
|
-
error:
|
|
487
|
+
error: i,
|
|
487
488
|
disabled: s
|
|
488
489
|
}) {
|
|
489
|
-
const { t:
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
}, [o]),
|
|
490
|
+
const { t: d } = J(), p = w(null), [f, h] = I(!1);
|
|
491
|
+
k(() => {
|
|
492
|
+
const u = p.current;
|
|
493
|
+
u && (o ? (u.focus(), u.setSelectionRange(u.value.length, u.value.length)) : document.activeElement === u && (u.blur(), u.scrollLeft = 0));
|
|
494
|
+
}, [o]), k(() => {
|
|
494
495
|
if (!f) return;
|
|
495
|
-
const
|
|
496
|
-
return () => clearTimeout(
|
|
496
|
+
const u = setTimeout(() => h(!1), 3e3);
|
|
497
|
+
return () => clearTimeout(u);
|
|
497
498
|
}, [f]);
|
|
498
|
-
async function
|
|
499
|
-
var
|
|
499
|
+
async function b() {
|
|
500
|
+
var u;
|
|
500
501
|
try {
|
|
501
502
|
if (navigator.clipboard) {
|
|
502
|
-
await navigator.clipboard.writeText(t),
|
|
503
|
+
await navigator.clipboard.writeText(t), h(!0);
|
|
503
504
|
return;
|
|
504
505
|
}
|
|
505
506
|
} catch {
|
|
506
507
|
}
|
|
507
|
-
(
|
|
508
|
+
(u = p.current) == null || u.select();
|
|
508
509
|
try {
|
|
509
|
-
document.execCommand("copy") &&
|
|
510
|
+
document.execCommand("copy") && h(!0);
|
|
510
511
|
} catch {
|
|
511
512
|
}
|
|
512
513
|
}
|
|
@@ -514,18 +515,18 @@ function Lt({
|
|
|
514
515
|
/* @__PURE__ */ e(
|
|
515
516
|
ft,
|
|
516
517
|
{
|
|
517
|
-
label:
|
|
518
|
+
label: d("RobotControl.MoveTo.Coordinates.lb"),
|
|
518
519
|
value: t,
|
|
519
520
|
inputRef: p,
|
|
520
|
-
onChange: (
|
|
521
|
+
onChange: (u) => l(u.target.value),
|
|
521
522
|
onClick: () => {
|
|
522
523
|
!o && !s && n();
|
|
523
524
|
},
|
|
524
|
-
onKeyDown: (
|
|
525
|
-
o && (
|
|
525
|
+
onKeyDown: (u) => {
|
|
526
|
+
o && (u.key === "Enter" && r ? c() : u.key === "Escape" && a());
|
|
526
527
|
},
|
|
527
|
-
error: !!
|
|
528
|
-
helperText:
|
|
528
|
+
error: !!i,
|
|
529
|
+
helperText: i ?? void 0,
|
|
529
530
|
fullWidth: !0,
|
|
530
531
|
autoComplete: "off",
|
|
531
532
|
slotProps: {
|
|
@@ -544,55 +545,55 @@ function Lt({
|
|
|
544
545
|
{
|
|
545
546
|
direction: "row",
|
|
546
547
|
sx: { gap: "8px", height: "56px", alignItems: "center" },
|
|
547
|
-
children: o ? /* @__PURE__ */ g(
|
|
548
|
+
children: o ? /* @__PURE__ */ g(z, { children: [
|
|
548
549
|
/* @__PURE__ */ e(
|
|
549
|
-
|
|
550
|
+
V,
|
|
550
551
|
{
|
|
551
552
|
icon: /* @__PURE__ */ e(Z, {}),
|
|
552
|
-
ariaLabel:
|
|
553
|
+
ariaLabel: d("RobotControl.MoveTo.Cancel.bt"),
|
|
553
554
|
onClick: a
|
|
554
555
|
}
|
|
555
556
|
),
|
|
556
557
|
/* @__PURE__ */ e(
|
|
557
|
-
|
|
558
|
+
N,
|
|
558
559
|
{
|
|
559
|
-
title:
|
|
560
|
+
title: d("RobotControl.MoveTo.ConfirmEdit.lb"),
|
|
560
561
|
placement: "left",
|
|
561
562
|
children: /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
|
|
562
|
-
|
|
563
|
+
V,
|
|
563
564
|
{
|
|
564
565
|
icon: /* @__PURE__ */ e(q, {}),
|
|
565
|
-
ariaLabel:
|
|
566
|
-
onClick:
|
|
566
|
+
ariaLabel: d("RobotControl.MoveTo.ConfirmEdit.lb"),
|
|
567
|
+
onClick: c,
|
|
567
568
|
disabled: !r,
|
|
568
569
|
sx: { color: "primary.main" }
|
|
569
570
|
}
|
|
570
571
|
) })
|
|
571
572
|
}
|
|
572
573
|
)
|
|
573
|
-
] }) : /* @__PURE__ */ g(
|
|
574
|
+
] }) : /* @__PURE__ */ g(z, { children: [
|
|
574
575
|
/* @__PURE__ */ e(
|
|
575
|
-
|
|
576
|
+
N,
|
|
576
577
|
{
|
|
577
|
-
title:
|
|
578
|
+
title: d("RobotControl.MoveTo.Copied.lb"),
|
|
578
579
|
open: f,
|
|
579
580
|
disableHoverListener: !0,
|
|
580
581
|
placement: "left",
|
|
581
582
|
children: /* @__PURE__ */ e(
|
|
582
|
-
|
|
583
|
+
V,
|
|
583
584
|
{
|
|
584
|
-
icon: f ? /* @__PURE__ */ e(q, {}) : /* @__PURE__ */ e(
|
|
585
|
-
ariaLabel:
|
|
586
|
-
onClick: () => void
|
|
585
|
+
icon: f ? /* @__PURE__ */ e(q, {}) : /* @__PURE__ */ e(vt, {}),
|
|
586
|
+
ariaLabel: d("RobotControl.MoveTo.Copy.bt"),
|
|
587
|
+
onClick: () => void b()
|
|
587
588
|
}
|
|
588
589
|
)
|
|
589
590
|
}
|
|
590
591
|
),
|
|
591
592
|
/* @__PURE__ */ e(
|
|
592
|
-
|
|
593
|
+
V,
|
|
593
594
|
{
|
|
594
|
-
icon: /* @__PURE__ */ e(
|
|
595
|
-
ariaLabel:
|
|
595
|
+
icon: /* @__PURE__ */ e(Ct, {}),
|
|
596
|
+
ariaLabel: d("RobotControl.MoveTo.Edit.bt"),
|
|
596
597
|
onClick: n,
|
|
597
598
|
disabled: s
|
|
598
599
|
}
|
|
@@ -603,7 +604,7 @@ function Lt({
|
|
|
603
604
|
] });
|
|
604
605
|
}
|
|
605
606
|
const Ot = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
|
|
606
|
-
function
|
|
607
|
+
function Q(t) {
|
|
607
608
|
const o = (n, l) => Number.parseFloat(n.toFixed(l));
|
|
608
609
|
return `(${[
|
|
609
610
|
...t.position.map((n) => o(n, 1)),
|
|
@@ -616,27 +617,27 @@ function _t(t) {
|
|
|
616
617
|
if (n !== l || (n && (o = o.slice(1, -1)), o.trim() === "")) return null;
|
|
617
618
|
const a = [];
|
|
618
619
|
for (const f of o.split(",")) {
|
|
619
|
-
const
|
|
620
|
-
if (!Ot.test(
|
|
621
|
-
const
|
|
622
|
-
if (!Number.isFinite(
|
|
623
|
-
a.push(
|
|
620
|
+
const h = f.trim();
|
|
621
|
+
if (!Ot.test(h)) return null;
|
|
622
|
+
const b = Number(h);
|
|
623
|
+
if (!Number.isFinite(b)) return null;
|
|
624
|
+
a.push(b);
|
|
624
625
|
}
|
|
625
626
|
if (a.length !== 6) return null;
|
|
626
|
-
const [
|
|
627
|
-
return { position: [
|
|
627
|
+
const [c, r, i, s, d, p] = a;
|
|
628
|
+
return { position: [c, r, i], orientation: [s, d, p] };
|
|
628
629
|
}
|
|
629
|
-
function
|
|
630
|
-
const n =
|
|
630
|
+
function U(t, o) {
|
|
631
|
+
const n = w(t);
|
|
631
632
|
n.current = t;
|
|
632
|
-
const [l, a] =
|
|
633
|
-
return
|
|
633
|
+
const [l, a] = I(t);
|
|
634
|
+
return k(() => {
|
|
634
635
|
if (!o) return;
|
|
635
|
-
let
|
|
636
|
+
let c = 0;
|
|
636
637
|
const r = () => {
|
|
637
|
-
a(n.current()),
|
|
638
|
+
a(n.current()), c = requestAnimationFrame(r);
|
|
638
639
|
};
|
|
639
|
-
return r(), () => cancelAnimationFrame(
|
|
640
|
+
return r(), () => cancelAnimationFrame(c);
|
|
640
641
|
}, [o]), l;
|
|
641
642
|
}
|
|
642
643
|
function Xt({
|
|
@@ -646,54 +647,61 @@ function Xt({
|
|
|
646
647
|
onVelocityChange: l,
|
|
647
648
|
disabled: a
|
|
648
649
|
}) {
|
|
649
|
-
|
|
650
|
+
var S;
|
|
651
|
+
const { t: c } = J(), [r, i] = I(null), [s, d] = I(null), p = U(
|
|
650
652
|
() => {
|
|
651
|
-
const
|
|
652
|
-
return
|
|
653
|
+
const T = t.getCurrentPose();
|
|
654
|
+
return T ? Q(T) : "";
|
|
653
655
|
},
|
|
654
656
|
r === null && s === null
|
|
655
|
-
), f = (r == null ? void 0 : r.text) ?? p, b = s === null ? null : _t(s),
|
|
657
|
+
), f = (r == null ? void 0 : r.text) ?? p, h = s !== null, b = s === null ? null : _t(s), u = r !== null && !t.error && !h, M = U(
|
|
656
658
|
() => r !== null && Ft(t.getCurrentPose(), r.pose),
|
|
657
|
-
|
|
658
|
-
) &&
|
|
659
|
-
function
|
|
660
|
-
|
|
659
|
+
u
|
|
660
|
+
) && u, R = w(!1), x = w(null);
|
|
661
|
+
function y() {
|
|
662
|
+
var T;
|
|
663
|
+
(T = x.current) == null || T.call(x), R.current = !1, i(null), d(null), t.onTargetChange(null);
|
|
661
664
|
}
|
|
662
|
-
function
|
|
663
|
-
b === null || a || (
|
|
665
|
+
function E() {
|
|
666
|
+
b === null || a || (R.current = !1, i({ pose: b, text: Q(b) }), d(null), t.onTargetChange(b));
|
|
664
667
|
}
|
|
665
|
-
|
|
666
|
-
if (
|
|
668
|
+
k(() => {
|
|
669
|
+
if (u) {
|
|
667
670
|
if (t.state === "moving") {
|
|
668
|
-
|
|
671
|
+
R.current = !0;
|
|
669
672
|
return;
|
|
670
673
|
}
|
|
671
|
-
|
|
674
|
+
R.current && M && t.state !== "stopping" && y();
|
|
672
675
|
}
|
|
673
|
-
}, [
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
+
}, [u, t.state, M]);
|
|
677
|
+
const B = [o == null ? void 0 : o.value, (S = t.frame) == null ? void 0 : S.value].join("\0");
|
|
678
|
+
k(() => {
|
|
679
|
+
r && y();
|
|
680
|
+
}, [B]);
|
|
681
|
+
const v = w({ target: r, onTargetChange: t.onTargetChange });
|
|
682
|
+
v.current = { target: r, onTargetChange: t.onTargetChange }, k(
|
|
676
683
|
() => () => {
|
|
677
|
-
|
|
684
|
+
var T;
|
|
685
|
+
(T = x.current) == null || T.call(x), v.current.target && v.current.onTargetChange(null);
|
|
678
686
|
},
|
|
679
687
|
[]
|
|
680
688
|
);
|
|
681
|
-
const
|
|
682
|
-
return /* @__PURE__ */ g(
|
|
689
|
+
const m = s !== null ? b === null ? c("RobotControl.MoveTo.InvalidPose.lb") : null : r ? t.error ?? null : null;
|
|
690
|
+
return /* @__PURE__ */ g(A, { children: [
|
|
683
691
|
o && /* @__PURE__ */ e(
|
|
684
692
|
L,
|
|
685
693
|
{
|
|
686
|
-
label:
|
|
694
|
+
label: c("RobotControl.Tcp.lb"),
|
|
687
695
|
...o,
|
|
688
696
|
disabled: a
|
|
689
697
|
}
|
|
690
698
|
),
|
|
691
|
-
/* @__PURE__ */ e(
|
|
699
|
+
/* @__PURE__ */ e(P, { variant: "body1", color: "text.primary", children: c("RobotControl.MoveTo.TargetPose.lb") }),
|
|
692
700
|
/* @__PURE__ */ g(C, { sx: { gap: "8px" }, children: [
|
|
693
701
|
t.frame && /* @__PURE__ */ e(
|
|
694
702
|
L,
|
|
695
703
|
{
|
|
696
|
-
label:
|
|
704
|
+
label: c("RobotControl.MoveTo.RelativeTo.lb"),
|
|
697
705
|
...t.frame,
|
|
698
706
|
disabled: a
|
|
699
707
|
}
|
|
@@ -702,15 +710,15 @@ function Xt({
|
|
|
702
710
|
Lt,
|
|
703
711
|
{
|
|
704
712
|
text: s ?? f,
|
|
705
|
-
editing:
|
|
713
|
+
editing: h,
|
|
706
714
|
onEdit: () => {
|
|
707
|
-
a ||
|
|
715
|
+
a || d(f);
|
|
708
716
|
},
|
|
709
|
-
onDraftChange:
|
|
710
|
-
onCancel: () =>
|
|
711
|
-
onConfirm:
|
|
717
|
+
onDraftChange: d,
|
|
718
|
+
onCancel: () => d(null),
|
|
719
|
+
onConfirm: E,
|
|
712
720
|
canConfirm: b !== null && !a && t.state !== "planning",
|
|
713
|
-
error:
|
|
721
|
+
error: m,
|
|
714
722
|
disabled: a
|
|
715
723
|
}
|
|
716
724
|
)
|
|
@@ -725,57 +733,58 @@ function Xt({
|
|
|
725
733
|
}
|
|
726
734
|
),
|
|
727
735
|
/* @__PURE__ */ g(C, { direction: "row", sx: { gap: "12px", alignItems: "center" }, children: [
|
|
728
|
-
r && /* @__PURE__ */ e(
|
|
729
|
-
|
|
736
|
+
r && !h && /* @__PURE__ */ e(N, { title: c("RobotControl.MoveTo.Reset.lb"), placement: "top", children: /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
|
|
737
|
+
V,
|
|
730
738
|
{
|
|
731
739
|
icon: /* @__PURE__ */ e(gt, {}),
|
|
732
|
-
ariaLabel:
|
|
733
|
-
onClick:
|
|
740
|
+
ariaLabel: c("RobotControl.MoveTo.Reset.lb"),
|
|
741
|
+
onClick: y
|
|
734
742
|
}
|
|
735
743
|
) }) }),
|
|
736
744
|
/* @__PURE__ */ e(
|
|
737
|
-
|
|
745
|
+
Ht,
|
|
738
746
|
{
|
|
739
747
|
state: r ? t.state : "idle",
|
|
740
|
-
ready:
|
|
741
|
-
atPose:
|
|
748
|
+
ready: u,
|
|
749
|
+
atPose: M,
|
|
742
750
|
disabled: a,
|
|
743
751
|
onMoveStart: () => {
|
|
744
752
|
r && t.onMoveStart(r.pose);
|
|
745
753
|
},
|
|
746
|
-
onMoveStop: t.onMoveStop
|
|
754
|
+
onMoveStop: t.onMoveStop,
|
|
755
|
+
stopRef: x
|
|
747
756
|
}
|
|
748
757
|
)
|
|
749
758
|
] })
|
|
750
759
|
] });
|
|
751
760
|
}
|
|
752
|
-
const
|
|
761
|
+
const Ro = nt(
|
|
753
762
|
({
|
|
754
763
|
onClose: t,
|
|
755
764
|
sx: o,
|
|
756
765
|
joints: n,
|
|
757
766
|
moveTo: l,
|
|
758
767
|
jogDisabled: a = !1,
|
|
759
|
-
tab:
|
|
768
|
+
tab: c,
|
|
760
769
|
onTabChange: r,
|
|
761
|
-
jogMode:
|
|
770
|
+
jogMode: i,
|
|
762
771
|
onJogModeChange: s,
|
|
763
|
-
...
|
|
772
|
+
...d
|
|
764
773
|
}) => {
|
|
765
|
-
const { t: p } =
|
|
774
|
+
const { t: p } = J(), f = d.disabled ?? !1, [h, b] = I("translate"), [u, M] = I({
|
|
766
775
|
mode: "continuous",
|
|
767
776
|
view: "gizmo",
|
|
768
777
|
step: { translate: 0, rotate: 0 }
|
|
769
|
-
}),
|
|
770
|
-
function
|
|
771
|
-
m
|
|
778
|
+
}), R = c ?? h, x = R === "joint" && !n || R === "moveTo" && !l ? "translate" : R, y = $t(u, i, d.increments), E = p("RobotControl.Title.ti");
|
|
779
|
+
function B(m) {
|
|
780
|
+
b(m), r == null || r(m);
|
|
772
781
|
}
|
|
773
|
-
function
|
|
774
|
-
var
|
|
775
|
-
|
|
776
|
-
for (const
|
|
777
|
-
const G = (
|
|
778
|
-
|
|
782
|
+
function v(m) {
|
|
783
|
+
var S, T, W;
|
|
784
|
+
M(m), m.mode !== y.mode && (s == null || s(m.mode));
|
|
785
|
+
for (const F of ["translate", "rotate"]) {
|
|
786
|
+
const G = (S = d.increments) == null ? void 0 : S.steps[F][m.step[F]];
|
|
787
|
+
m.step[F] !== y.step[F] && G !== void 0 && ((W = (T = d.increments) == null ? void 0 : T.onStepChange) == null || W.call(T, F, G));
|
|
779
788
|
}
|
|
780
789
|
}
|
|
781
790
|
return /* @__PURE__ */ g(
|
|
@@ -783,13 +792,13 @@ const To = nt(
|
|
|
783
792
|
{
|
|
784
793
|
"data-testid": "robot-control-panel",
|
|
785
794
|
sx: [
|
|
786
|
-
(
|
|
787
|
-
var
|
|
795
|
+
(m) => {
|
|
796
|
+
var S;
|
|
788
797
|
return {
|
|
789
798
|
minHeight: 0,
|
|
790
799
|
overflow: "hidden",
|
|
791
800
|
borderRadius: "16px",
|
|
792
|
-
background: (
|
|
801
|
+
background: (S = m.palette.backgroundPaperElevation) == null ? void 0 : S[5]
|
|
793
802
|
};
|
|
794
803
|
},
|
|
795
804
|
...Array.isArray(o) ? o : [o]
|
|
@@ -806,12 +815,12 @@ const To = nt(
|
|
|
806
815
|
},
|
|
807
816
|
children: [
|
|
808
817
|
/* @__PURE__ */ e(
|
|
809
|
-
|
|
818
|
+
P,
|
|
810
819
|
{
|
|
811
820
|
component: "h2",
|
|
812
821
|
color: "text.primary",
|
|
813
822
|
sx: { fontSize: "20px" },
|
|
814
|
-
children:
|
|
823
|
+
children: E
|
|
815
824
|
}
|
|
816
825
|
),
|
|
817
826
|
t && /* @__PURE__ */ e(
|
|
@@ -829,9 +838,9 @@ const To = nt(
|
|
|
829
838
|
/* @__PURE__ */ g(
|
|
830
839
|
et,
|
|
831
840
|
{
|
|
832
|
-
value:
|
|
833
|
-
onChange: (
|
|
834
|
-
"aria-label":
|
|
841
|
+
value: x,
|
|
842
|
+
onChange: (m, S) => B(S),
|
|
843
|
+
"aria-label": E,
|
|
835
844
|
variant: "scrollable",
|
|
836
845
|
scrollButtons: !1,
|
|
837
846
|
sx: {
|
|
@@ -844,7 +853,7 @@ const To = nt(
|
|
|
844
853
|
},
|
|
845
854
|
children: [
|
|
846
855
|
/* @__PURE__ */ e(
|
|
847
|
-
|
|
856
|
+
H,
|
|
848
857
|
{
|
|
849
858
|
value: "translate",
|
|
850
859
|
label: p("RobotControl.Tab.Translate.bt"),
|
|
@@ -852,7 +861,7 @@ const To = nt(
|
|
|
852
861
|
}
|
|
853
862
|
),
|
|
854
863
|
/* @__PURE__ */ e(
|
|
855
|
-
|
|
864
|
+
H,
|
|
856
865
|
{
|
|
857
866
|
value: "rotate",
|
|
858
867
|
label: p("RobotControl.Tab.Rotate.bt"),
|
|
@@ -860,7 +869,7 @@ const To = nt(
|
|
|
860
869
|
}
|
|
861
870
|
),
|
|
862
871
|
n && /* @__PURE__ */ e(
|
|
863
|
-
|
|
872
|
+
H,
|
|
864
873
|
{
|
|
865
874
|
value: "joint",
|
|
866
875
|
label: p("RobotControl.Tab.Joint.bt"),
|
|
@@ -868,7 +877,7 @@ const To = nt(
|
|
|
868
877
|
}
|
|
869
878
|
),
|
|
870
879
|
l && /* @__PURE__ */ e(
|
|
871
|
-
|
|
880
|
+
H,
|
|
872
881
|
{
|
|
873
882
|
value: "moveTo",
|
|
874
883
|
label: p("RobotControl.Tab.MoveTo.bt"),
|
|
@@ -878,23 +887,23 @@ const To = nt(
|
|
|
878
887
|
]
|
|
879
888
|
}
|
|
880
889
|
),
|
|
881
|
-
/* @__PURE__ */ e(C, { sx: { flexGrow: 1, overflowY: "auto", overflowX: "hidden" }, children:
|
|
890
|
+
/* @__PURE__ */ e(C, { sx: { flexGrow: 1, overflowY: "auto", overflowX: "hidden" }, children: x === "joint" && n ? /* @__PURE__ */ e(At, { joints: n, disabled: f || a }) : x === "moveTo" && l ? /* @__PURE__ */ e(
|
|
882
891
|
Xt,
|
|
883
892
|
{
|
|
884
893
|
moveTo: l,
|
|
885
|
-
tcp:
|
|
886
|
-
velocity:
|
|
887
|
-
onVelocityChange: (
|
|
894
|
+
tcp: d.tcp,
|
|
895
|
+
velocity: d.velocity.translate,
|
|
896
|
+
onVelocityChange: (m) => d.onVelocityChange("translate", m),
|
|
888
897
|
disabled: f
|
|
889
898
|
}
|
|
890
899
|
) : /* @__PURE__ */ e(
|
|
891
900
|
Et,
|
|
892
901
|
{
|
|
893
|
-
...
|
|
902
|
+
...d,
|
|
894
903
|
disabled: f || a,
|
|
895
|
-
motion:
|
|
896
|
-
settings:
|
|
897
|
-
onSettingsChange:
|
|
904
|
+
motion: x === "rotate" ? "rotate" : "translate",
|
|
905
|
+
settings: y,
|
|
906
|
+
onSettingsChange: v
|
|
898
907
|
}
|
|
899
908
|
) })
|
|
900
909
|
]
|
|
@@ -904,11 +913,11 @@ const To = nt(
|
|
|
904
913
|
);
|
|
905
914
|
function $t(t, o, n) {
|
|
906
915
|
const l = (a) => {
|
|
907
|
-
var
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
916
|
+
var i;
|
|
917
|
+
const c = (i = n == null ? void 0 : n.step) == null ? void 0 : i[a];
|
|
918
|
+
if (c === void 0) return t.step[a];
|
|
910
919
|
const r = n == null ? void 0 : n.steps[a].findIndex(
|
|
911
|
-
(s) => Math.abs(s -
|
|
920
|
+
(s) => Math.abs(s - c) <= 1e-9 * Math.max(1, Math.abs(s))
|
|
912
921
|
);
|
|
913
922
|
return r === void 0 || r < 0 ? t.step[a] : r;
|
|
914
923
|
};
|
|
@@ -919,5 +928,5 @@ function $t(t, o, n) {
|
|
|
919
928
|
};
|
|
920
929
|
}
|
|
921
930
|
export {
|
|
922
|
-
|
|
931
|
+
Ro as R
|
|
923
932
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
1
2
|
import type { RobotControlMoveState } from "./RobotControlPanel";
|
|
2
3
|
type HoldToMoveButtonProps = {
|
|
3
4
|
state: RobotControlMoveState;
|
|
@@ -8,6 +9,8 @@ type HoldToMoveButtonProps = {
|
|
|
8
9
|
disabled: boolean;
|
|
9
10
|
onMoveStart: () => void;
|
|
10
11
|
onMoveStop: () => void;
|
|
12
|
+
/** Gets the function that ends a hold, e.g. before the target goes */
|
|
13
|
+
stopRef?: RefObject<(() => void) | null>;
|
|
11
14
|
};
|
|
12
15
|
/**
|
|
13
16
|
* The Move to button, as RobotPad's: held for 200 ms while the move is
|
|
@@ -18,5 +21,5 @@ type HoldToMoveButtonProps = {
|
|
|
18
21
|
* until the release: the hold sits on the wrapper, which keeps the pointer
|
|
19
22
|
* while the button turns off.
|
|
20
23
|
*/
|
|
21
|
-
export declare function HoldToMoveButton({ state, ready, atPose, disabled, onMoveStart, onMoveStop, }: HoldToMoveButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function HoldToMoveButton({ state, ready, atPose, disabled, onMoveStart, onMoveStop, stopRef, }: HoldToMoveButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
22
25
|
export {};
|
|
@@ -115,7 +115,8 @@ export type RobotControlMoveTo = {
|
|
|
115
115
|
/**
|
|
116
116
|
* A typed pose became the target: plan the move to it and load it, so that
|
|
117
117
|
* the button can start it at once. null: the field shows the current pose
|
|
118
|
-
* again (Reset, the TCP arrived,
|
|
118
|
+
* again (Reset, the TCP arrived, another tab was chosen, or the TCP or the
|
|
119
|
+
* frame changed): drop the plan. A held move gets its `onMoveStop` first.
|
|
119
120
|
*/
|
|
120
121
|
onTargetChange: (pose: RobotControlPose | null) => void;
|
|
121
122
|
/** Where the move is: the button waits, says Moving… or Stopping… */
|
|
@@ -125,8 +126,8 @@ export type RobotControlMoveTo = {
|
|
|
125
126
|
/** The button was held 200 ms while the move was "planned": start it */
|
|
126
127
|
onMoveStart: (pose: RobotControlPose) => void;
|
|
127
128
|
/**
|
|
128
|
-
* The button was let go after a start, or the
|
|
129
|
-
*
|
|
129
|
+
* The button was let go after a start, or the hold ended otherwise (e.g.
|
|
130
|
+
* another tab, or editing another pose): pause the move
|
|
130
131
|
*/
|
|
131
132
|
onMoveStop: () => void;
|
|
132
133
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/Robot-BpCo1iYt.cjs"),n=require("./chunks/JoggingGizmo-xvCp3LCB.cjs"),i=require("./chunks/JoggingGizmoOrientation-BTKo84_4.cjs"),r=require("./chunks/RobotControlPanel-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/Robot-BpCo1iYt.cjs"),n=require("./chunks/JoggingGizmo-xvCp3LCB.cjs"),i=require("./chunks/JoggingGizmoOrientation-BTKo84_4.cjs"),r=require("./chunks/RobotControlPanel-B9mziQO2.cjs"),t=require("./chunks/useSmoothedMotionState-Con0E5Bx.cjs");require("@wandelbots/mui");const o=require("./chunks/ConnectedMotionGroup-CNYRk4fK.cjs"),a=require("./chunks/JoggingButtons-B341nDtX.cjs"),g=require("./chunks/JoggingJointSlider-D6ZF4AHZ.cjs"),l=require("./chunks/externalizeComponent-BBWF9CMB.cjs"),u=require("./chunks/SafetyBar-Cy-uqTmC.cjs");exports.CollisionSceneRenderer=e.CollisionSceneRenderer;exports.JointLimitGizmo=e.JointLimitGizmo;exports.LinearAxis=e.LinearAxis;exports.MotionGroupVisualizer=e.MotionGroupVisualizer;exports.MotionGroupVisualizerExact=e.MotionGroupVisualizerExact;exports.PresetEnvironment=e.PresetEnvironment;exports.Robot=e.Robot;exports.SafetyZonesRenderer=e.SafetyZonesRenderer;exports.SupportedLinearAxis=e.SupportedLinearAxis;exports.SupportedLinearAxisExact=e.SupportedLinearAxisExact;exports.SupportedRobot=e.SupportedRobot;exports.SupportedRobotExact=e.SupportedRobotExact;exports.TrajectoryRenderer=e.TrajectoryRenderer;exports.defaultGetModel=e.defaultGetModel;exports.JoggingGizmo=n.JoggingGizmo;exports.JoggingGizmoOrientation=i.JoggingGizmoOrientation;exports.RobotControlPanel=r.RobotControlPanel;exports.ValueInterpolator=t.ValueInterpolator;exports.useInterpolation=t.useInterpolation;exports.useSmoothedMotionState=t.useSmoothedMotionState;exports.AppHeader=o.AppHeader;exports.ConnectedMotionGroup=o.ConnectedMotionGroup;exports.JoggerConnection=o.JoggerConnection;exports.JoggingCartesianAxisControl=o.JoggingCartesianAxisControl;exports.JoggingJointValueControl=o.JoggingJointValueControl;exports.JoggingPanel=o.JoggingPanel;exports.JoggingStore=o.JoggingStore;exports.LoadingCover=o.LoadingCover;exports.LoadingErrorMessage=o.LoadingErrorMessage;exports.MotionStreamConnection=o.MotionStreamConnection;exports.NoMotionGroupModal=o.NoMotionGroupModal;exports.VelocitySlider=o.VelocitySlider;exports.VelocitySliderLabel=o.VelocitySliderLabel;exports.jointValuesEqual=o.jointValuesEqual;exports.poseEqual=o.poseEqual;exports.tcpMotionEqual=o.tcpMotionEqual;exports.unwrapRotationVector=o.unwrapRotationVector;exports.JoggingButtons=a.JoggingButtons;exports.JoggingJointSlider=g.JoggingJointSlider;exports.i18n=l.i18n;exports.SafetyBar=u.SafetyBar;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as t, J as r, L as s, M as n, a as i, P as p, R as g, S as l, b as u, c as d, d as m, e as J, T as x, f as S } from "./chunks/Robot-DS2W4y1f.js";
|
|
2
2
|
import { J as c } from "./chunks/JoggingGizmo-CR-9mcYX.js";
|
|
3
3
|
import { J as C } from "./chunks/JoggingGizmoOrientation-DoMYMVlT.js";
|
|
4
|
-
import { R as V } from "./chunks/RobotControlPanel-
|
|
4
|
+
import { R as V } from "./chunks/RobotControlPanel-B_dcyr-M.js";
|
|
5
5
|
import { V as E, u as G, a as b } from "./chunks/useSmoothedMotionState-COMJRcOt.js";
|
|
6
6
|
import "@wandelbots/mui";
|
|
7
7
|
import { A as y, C as z, J as P, a as j, b as q, c as v, d as B, L as I, e as N, M as T, N as h, V as w, f as H, j as O, p as Z, t as k, u as D } from "./chunks/ConnectedMotionGroup-B_Mg1jSN.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "6.4.0-pr.feat-robot-control-panel.656.
|
|
3
|
+
"version": "6.4.0-pr.feat-robot-control-panel.656.2211e42",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),G=require("@mui/material/IconButton"),m=require("@mui/material/Stack"),A=require("@mui/material/Tab"),Q=require("@mui/material/Tabs"),q=require("@mui/material/Typography"),W=require("@wandelbots/icons/CloseFilled"),p=require("react"),S=require("react-i18next"),K=require("./externalizeComponent-BBWF9CMB.cjs"),P=require("@mui/material/Divider"),J=require("@mui/material/Tooltip"),Y=require("@wandelbots/icons/Jog"),Z=require("@wandelbots/icons/ViewModuleFilled"),tt=require("./JoggingGizmo-xvCp3LCB.cjs"),et=require("./JoggingButtons-B341nDtX.cjs"),nt=require("@mui/material/styles"),L=require("@mui/material/ToggleButton"),ot=require("@mui/material/ToggleButtonGroup"),rt=require("@mui/material/Box"),lt=require("@mui/material/MenuItem"),M=require("@wandelbots/mui"),st=require("@mui/material/Slider"),at=require("./JoggingJointSlider-D6ZF4AHZ.cjs"),it=require("@wandelbots/icons/Undo"),ct=require("@wandelbots/icons/NorthEastFilled"),ut=require("./joggingColors-ZDc_2UCp.cjs"),O=require("@wandelbots/icons/CheckFilled"),dt=require("@wandelbots/icons/ContentCopyFilled"),xt=require("@wandelbots/icons/EditFilled");function pt({view:t,onViewChange:n,mode:o,controls:l,gizmoOrientation:s,gizmoFrameQuaternion:a}){const{t:r}=S.useTranslation(),i=t==="gizmo"&&s!==void 0,c=r(i?o==="increment"?"RobotControl.JogArea.Hint.ClickHandle.lb":"RobotControl.JogArea.Hint.HoldHandle.lb":o==="increment"?"RobotControl.JogArea.Hint.ClickButton.lb":"RobotControl.JogArea.Hint.HoldButton.lb"),u=r(i?"RobotControl.JogArea.ShowButtons.bt":"RobotControl.JogArea.ShowGizmo.bt");return e.jsxs(m,{"data-testid":"jog-area",sx:{position:"relative",alignItems:"center",gap:"16px"},children:[s&&e.jsx(J,{title:u,placement:"left",children:e.jsx(G,{"aria-label":u,onClick:()=>n(i?"buttons":"gizmo"),size:"small",sx:x=>{var f;return{position:"absolute",top:0,right:0,zIndex:1,borderRadius:"8px",border:`1px solid ${x.palette.divider}`,background:(f=x.palette.backgroundPaperElevation)==null?void 0:f[11]}},children:i?e.jsx(Z.ViewModuleFilled,{}):e.jsx(Y.Jog,{})})}),i?e.jsx(tt.JoggingGizmo,{...l,orientation:s,frameQuaternion:a,size:180}):e.jsx(et.JoggingButtons,{...l}),e.jsx(q,{variant:"body2",color:"text.secondary",textAlign:"center",children:c})]})}const ft=nt.styled(ot)(({theme:t})=>{var n;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:(n=t.palette.backgroundPaperElevation)==null?void 0:n[11]}}});function gt({value:t,onChange:n,disabled:o}){const{t:l}=S.useTranslation();return e.jsxs(ft,{exclusive:!0,value:t,disabled:o,"aria-label":l("RobotControl.JogMode.lb"),onChange:(s,a)=>{a!==null&&n(a)},children:[e.jsx(L,{value:"continuous",children:l("RobotControl.JogMode.Continuous.bt")}),e.jsx(L,{value:"increment",children:l("RobotControl.JogMode.Increment.bt")})]})}function D(t,n){var o;return((o=t.find(l=>l.id===n))==null?void 0:o.label)??String(n)}function U(t){return t.map(n=>e.jsx(lt,{value:n.id,children:n.label},n.id))}function B({label:t,options:n,value:o,onChange:l,disabled:s}){const a=p.useId();return e.jsx(M.AdornedSelect,{label:t,labelId:a,value:o,disabled:s,renderValue:r=>D(n,r),onChange:r=>l(String(r.target.value)),children:U(n)})}function bt({label:t,options:n,value:o,onChange:l,disabled:s}){const a=p.useId();return e.jsxs(m,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",gap:2},children:[e.jsx(q,{id:a,variant:"body2",color:"text.secondary",children:t}),e.jsx(rt,{sx:{width:"calc((100% - 12px) / 2)",flexShrink:0},children:e.jsx(M.AdornedSelect,{labelId:a,adornedSize:"small",value:o,disabled:s,renderValue:r=>D(n,r),onChange:r=>l(String(r.target.value)),children:U(n)})})]})}function E({children:t}){return e.jsx(m,{sx:{padding:"16px 20px",gap:"16px"},children:t})}function ht(t){return t*180/Math.PI}function Ct(t){return t*Math.PI/180}function z(t,n){return t==="rotate"?ht(n):n}function mt(t,n){return t==="rotate"?Ct(n):n}function jt(t,n){const o=String(Number(z(t,n).toFixed(2)));return t==="rotate"?`${o}°`:`${o} mm`}function vt(t,n){const o=Math.round(z(t,n));return t==="rotate"?`${o}°/s`:`${o} mm/s`}function V({motion:t,velocity:n,onChange:o,disabled:l}){const{t:s}=S.useTranslation(),a=p.useId(),r=i=>z(t,i);return e.jsxs(m,{gap:"4px",children:[e.jsxs(m,{direction:"row",sx:{justifyContent:"space-between"},children:[e.jsx(q,{id:a,variant:"body2",color:"text.secondary",children:s("RobotControl.Velocity.lb")}),e.jsx(q,{variant:"body2",color:"text.primary",sx:{fontVariantNumeric:"tabular-nums"},children:vt(t,n.value)})]}),e.jsx(st,{"aria-labelledby":a,size:"small",value:Math.round(r(n.value)),min:Math.ceil(r(n.min)),max:Math.floor(r(n.max)),disabled:l,onChange:(i,c)=>{typeof c=="number"&&o(mt(t,c))},sx:i=>{var c;return{height:4,"& .MuiSlider-rail":{opacity:.38},"& .MuiSlider-thumb":{width:16,height:16,border:`3px solid ${i.palette.primary.main}`,backgroundColor:(c=i.palette.backgroundPaperElevation)==null?void 0:c[5]}}}})]})}function Rt({motion:t,settings:n,onSettingsChange:o,disabled:l=!1,tcp:s,jogFrame:a,velocity:r,onVelocityChange:i,onJogStart:c,onJogStop:u,increments:x,gizmoOrientation:f,gizmoFrameQuaternion:g}){const{t:b}=S.useTranslation(),d=x?n.mode:"continuous",j=(x==null?void 0:x.steps[t])??[],T=Math.min(n.step[t],j.length-1),R=j[T],v=p.useRef(!1);function w(C,h){if(d==="increment"){x&&R!==void 0&&x.onStep(t,C,h,R);return}v.current=!0,c(t,C,h)}function I(){v.current&&(v.current=!1,u())}return e.jsxs(e.Fragment,{children:[(s||a)&&e.jsxs(e.Fragment,{children:[e.jsx(E,{children:e.jsxs(m,{direction:"row",sx:{gap:"12px"},children:[s&&e.jsx(B,{label:b("RobotControl.Tcp.lb"),...s,disabled:l}),a&&e.jsx(B,{label:b("RobotControl.JogFrame.lb"),...a,disabled:l})]})}),e.jsx(P,{sx:{marginX:"20px"}})]}),e.jsxs(E,{children:[x&&e.jsx(gt,{value:d,onChange:C=>o({...n,mode:C}),disabled:l}),e.jsx(V,{motion:t,velocity:r[t],onChange:C=>i(t,C),disabled:l}),d==="increment"&&R!==void 0&&e.jsx(bt,{label:b("RobotControl.StepSize.lb"),value:String(T),options:j.map((C,h)=>({id:String(h),label:jt(t,C)})),onChange:C=>o({...n,step:{...n.step,[t]:Number(C)}}),disabled:l})]}),e.jsx(P,{sx:{marginX:"20px"}}),e.jsx(E,{children:e.jsx(pt,{view:n.view,onViewChange:C=>o({...n,view:C}),mode:d,controls:{motion:t,onJogStart:w,onJogStop:I,activeHandle:d==="increment"?x==null?void 0:x.running:null,disabled:l},gizmoOrientation:f,gizmoFrameQuaternion:g},d)})]})}function Tt({joints:t,disabled:n}){const o=p.useRef(null),[l,s]=p.useState(null);function a(i,c){o.current!==null&&o.current!==i||(o.current=i,s(i),t.onJogStart(i,c))}function r(i){o.current===i&&(o.current=null,s(null),t.onJogStop())}return e.jsxs(e.Fragment,{children:[e.jsx(E,{children:e.jsx(m,{sx:{gap:"8px",paddingX:"4px"},children:t.joints.map((i,c)=>e.jsx(at.JoggingJointSlider,{label:`J${c+1}`,name:i.name,value:i.value,min:i.min,max:i.max,linear:t.linear,onJogStart:u=>a(c,u),onJogStop:()=>r(c),disabled:n||l!==null&&l!==c},c))})}),e.jsx(P,{sx:{marginX:"20px"}}),e.jsx(E,{children:e.jsx(V,{motion:t.linear?"translate":"rotate",velocity:t.velocity,onChange:t.onVelocityChange,disabled:n})})]})}const Mt=.5,St=.01;function yt(t,n){return t?Math.hypot(t.position[0]-n.position[0],t.position[1]-n.position[1],t.position[2]-n.position[2])<=Mt&&wt(t.orientation,n.orientation)<=St:!1}function _(t){const n=Math.hypot(...t);if(n<1e-12)return[1,0,0,0];const o=Math.sin(n/2)/n;return[Math.cos(n/2),t[0]*o,t[1]*o,t[2]*o]}function wt(t,n){const o=_(t),l=_(n),s=Math.abs(o[0]*l[0]+o[1]*l[1]+o[2]*l[2]+o[3]*l[3]);return 2*Math.acos(Math.min(1,s))}const It="move",Et=200;function qt({state:t,ready:n,atPose:o,disabled:l,onMoveStart:s,onMoveStop:a}){const{t:r}=S.useTranslation(),[i,c]=p.useState(!1),u=p.useRef(void 0),x=p.useRef(!1),f=p.useRef({onMoveStart:s,onMoveStop:a});f.current={onMoveStart:s,onMoveStop:a};const g=t==="planned",b=g||t==="moving",{handlersFor:d}=ut.useHold({onStart:()=>{c(!0),u.current=setTimeout(()=>{u.current=void 0,x.current=!0,f.current.onMoveStart()},Et)},onStop:()=>{c(!1),clearTimeout(u.current),u.current=void 0,x.current&&(x.current=!1,f.current.onMoveStop())},disabled:i?l||!n||!b:l||!n||o||!g,isSame:()=>!0});p.useEffect(()=>()=>clearTimeout(u.current),[]);const j=r(t==="moving"?"RobotControl.MoveTo.Moving.bt":t==="stopping"?"RobotControl.MoveTo.Stopping.bt":"RobotControl.MoveTo.MoveTo.bt");return e.jsx(J,{title:r(o?"RobotControl.MoveTo.AtPose.lb":"RobotControl.MoveTo.HoldToMove.lb"),placement:"top",children:e.jsx("span",{...d(It),style:{display:"block",flexGrow:1,touchAction:"none",userSelect:"none"},children:e.jsx(M.PrimaryButton,{fullWidth:!0,disabled:l||!n||o||!b,loading:t==="planning"||t==="stopping",loadingPosition:"start",startIcon:e.jsx(ct.NorthEastFilled,{}),"aria-pressed":i,children:j})})})}function Ft({text:t,editing:n,onEdit:o,onDraftChange:l,onCancel:s,onConfirm:a,canConfirm:r,error:i,disabled:c}){const{t:u}=S.useTranslation(),x=p.useRef(null),[f,g]=p.useState(!1);p.useEffect(()=>{const d=x.current;d&&(n?(d.focus(),d.setSelectionRange(d.value.length,d.value.length)):document.activeElement===d&&(d.blur(),d.scrollLeft=0))},[n]),p.useEffect(()=>{if(!f)return;const d=setTimeout(()=>g(!1),3e3);return()=>clearTimeout(d)},[f]);async function b(){var d;try{if(navigator.clipboard){await navigator.clipboard.writeText(t),g(!0);return}}catch{}(d=x.current)==null||d.select();try{document.execCommand("copy")&&g(!0)}catch{}}return e.jsxs(m,{direction:"row",sx:{gap:"8px",alignItems:"flex-start"},children:[e.jsx(M.AdornedTextField,{label:u("RobotControl.MoveTo.Coordinates.lb"),value:t,inputRef:x,onChange:d=>l(d.target.value),onClick:()=>{!n&&!c&&o()},onKeyDown:d=>{n&&(d.key==="Enter"&&r?a():d.key==="Escape"&&s())},error:!!i,helperText:i??void 0,fullWidth:!0,autoComplete:"off",slotProps:{htmlInput:{readOnly:!n,spellCheck:!1}},sx:{"& input":{fontVariantNumeric:"tabular-nums",cursor:n||c?void 0:"text"}}}),e.jsx(m,{direction:"row",sx:{gap:"8px",height:"56px",alignItems:"center"},children:n?e.jsxs(e.Fragment,{children:[e.jsx(M.RoundedIconButton,{icon:e.jsx(W.CloseFilled,{}),ariaLabel:u("RobotControl.MoveTo.Cancel.bt"),onClick:s}),e.jsx(J,{title:u("RobotControl.MoveTo.ConfirmEdit.lb"),placement:"left",children:e.jsx("span",{children:e.jsx(M.RoundedIconButton,{icon:e.jsx(O.CheckFilled,{}),ariaLabel:u("RobotControl.MoveTo.ConfirmEdit.lb"),onClick:a,disabled:!r,sx:{color:"primary.main"}})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{title:u("RobotControl.MoveTo.Copied.lb"),open:f,disableHoverListener:!0,placement:"left",children:e.jsx(M.RoundedIconButton,{icon:f?e.jsx(O.CheckFilled,{}):e.jsx(dt.ContentCopyFilled,{}),ariaLabel:u("RobotControl.MoveTo.Copy.bt"),onClick:()=>void b()})}),e.jsx(M.RoundedIconButton,{icon:e.jsx(xt.EditFilled,{}),ariaLabel:u("RobotControl.MoveTo.Edit.bt"),onClick:o,disabled:c})]})})]})}const Jt=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function X(t){const n=(o,l)=>Number.parseFloat(o.toFixed(l));return`(${[...t.position.map(o=>n(o,1)),...t.orientation.map(o=>n(o,4))].join(", ")})`}function kt(t){let n=t.trim();const o=n.startsWith("("),l=n.endsWith(")");if(o!==l||(o&&(n=n.slice(1,-1)),n.trim()===""))return null;const s=[];for(const f of n.split(",")){const g=f.trim();if(!Jt.test(g))return null;const b=Number(g);if(!Number.isFinite(b))return null;s.push(b)}if(s.length!==6)return null;const[a,r,i,c,u,x]=s;return{position:[a,r,i],orientation:[c,u,x]}}function $(t,n){const o=p.useRef(t);o.current=t;const[l,s]=p.useState(t);return p.useEffect(()=>{if(!n)return;let a=0;const r=()=>{s(o.current()),a=requestAnimationFrame(r)};return r(),()=>cancelAnimationFrame(a)},[n]),l}function At({moveTo:t,tcp:n,velocity:o,onVelocityChange:l,disabled:s}){const{t:a}=S.useTranslation(),[r,i]=p.useState(null),[c,u]=p.useState(null),x=$(()=>{const I=t.getCurrentPose();return I?X(I):""},r===null&&c===null),f=(r==null?void 0:r.text)??x,g=c===null?null:kt(c),b=r!==null&&!t.error,d=$(()=>r!==null&&yt(t.getCurrentPose(),r.pose),b)&&b,j=p.useRef(!1);function T(){j.current=!1,i(null),u(null),t.onTargetChange(null)}function R(){g===null||s||(j.current=!1,i({pose:g,text:X(g)}),u(null),t.onTargetChange(g))}p.useEffect(()=>{if(b){if(t.state==="moving"){j.current=!0;return}j.current&&d&&t.state!=="stopping"&&T()}},[b,t.state,d]);const v=p.useRef({target:r,onTargetChange:t.onTargetChange});v.current={target:r,onTargetChange:t.onTargetChange},p.useEffect(()=>()=>{v.current.target&&v.current.onTargetChange(null)},[]);const w=c!==null?g===null?a("RobotControl.MoveTo.InvalidPose.lb"):null:r?t.error??null:null;return e.jsxs(E,{children:[n&&e.jsx(B,{label:a("RobotControl.Tcp.lb"),...n,disabled:s}),e.jsx(q,{variant:"body1",color:"text.primary",children:a("RobotControl.MoveTo.TargetPose.lb")}),e.jsxs(m,{sx:{gap:"8px"},children:[t.frame&&e.jsx(B,{label:a("RobotControl.MoveTo.RelativeTo.lb"),...t.frame,disabled:s}),e.jsx(Ft,{text:c??f,editing:c!==null,onEdit:()=>{s||u(f)},onDraftChange:u,onCancel:()=>u(null),onConfirm:R,canConfirm:g!==null&&!s&&t.state!=="planning",error:w,disabled:s})]}),e.jsx(V,{motion:"translate",velocity:o,onChange:l,disabled:s}),e.jsxs(m,{direction:"row",sx:{gap:"12px",alignItems:"center"},children:[r&&e.jsx(J,{title:a("RobotControl.MoveTo.Reset.lb"),placement:"top",children:e.jsx("span",{children:e.jsx(M.RoundedIconButton,{icon:e.jsx(it.Undo,{}),ariaLabel:a("RobotControl.MoveTo.Reset.lb"),onClick:T})})}),e.jsx(qt,{state:r?t.state:"idle",ready:b,atPose:d,disabled:s,onMoveStart:()=>{r&&t.onMoveStart(r.pose)},onMoveStop:t.onMoveStop})]})]})}const Bt=K.externalizeComponent(({onClose:t,sx:n,joints:o,moveTo:l,jogDisabled:s=!1,tab:a,onTabChange:r,jogMode:i,onJogModeChange:c,...u})=>{const{t:x}=S.useTranslation(),f=u.disabled??!1,[g,b]=p.useState("translate"),[d,j]=p.useState({mode:"continuous",view:"gizmo",step:{translate:0,rotate:0}}),T=a??g,R=T==="joint"&&!o||T==="moveTo"&&!l?"translate":T,v=Pt(d,i,u.increments),w=x("RobotControl.Title.ti");function I(h){b(h),r==null||r(h)}function C(h){var y,k,H;j(h),h.mode!==v.mode&&(c==null||c(h.mode));for(const F of["translate","rotate"]){const N=(y=u.increments)==null?void 0:y.steps[F][h.step[F]];h.step[F]!==v.step[F]&&N!==void 0&&((H=(k=u.increments)==null?void 0:k.onStepChange)==null||H.call(k,F,N))}}return e.jsxs(m,{"data-testid":"robot-control-panel",sx:[h=>{var y;return{minHeight:0,overflow:"hidden",borderRadius:"16px",background:(y=h.palette.backgroundPaperElevation)==null?void 0:y[5]}},...Array.isArray(n)?n:[n]],children:[e.jsxs(m,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",padding:"20px 20px 8px"},children:[e.jsx(q,{component:"h2",color:"text.primary",sx:{fontSize:"20px"},children:w}),t&&e.jsx(G,{"aria-label":x("RobotControl.Close.bt"),onClick:t,size:"small",children:e.jsx(W.CloseFilled,{})})]}),e.jsxs(Q,{value:R,onChange:(h,y)=>I(y),"aria-label":w,variant:"scrollable",scrollButtons:!1,sx:{marginX:"20px",borderBottom:1,borderColor:"divider",background:"transparent"},children:[e.jsx(A,{value:"translate",label:x("RobotControl.Tab.Translate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),e.jsx(A,{value:"rotate",label:x("RobotControl.Tab.Rotate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),o&&e.jsx(A,{value:"joint",label:x("RobotControl.Tab.Joint.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),l&&e.jsx(A,{value:"moveTo",label:x("RobotControl.Tab.MoveTo.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}})]}),e.jsx(m,{sx:{flexGrow:1,overflowY:"auto",overflowX:"hidden"},children:R==="joint"&&o?e.jsx(Tt,{joints:o,disabled:f||s}):R==="moveTo"&&l?e.jsx(At,{moveTo:l,tcp:u.tcp,velocity:u.velocity.translate,onVelocityChange:h=>u.onVelocityChange("translate",h),disabled:f}):e.jsx(Rt,{...u,disabled:f||s,motion:R==="rotate"?"rotate":"translate",settings:v,onSettingsChange:C})})]})});function Pt(t,n,o){const l=s=>{var i;const a=(i=o==null?void 0:o.step)==null?void 0:i[s];if(a===void 0)return t.step[s];const r=o==null?void 0:o.steps[s].findIndex(c=>Math.abs(c-a)<=1e-9*Math.max(1,Math.abs(c)));return r===void 0||r<0?t.step[s]:r};return{...t,mode:n??t.mode,step:{translate:l("translate"),rotate:l("rotate")}}}exports.RobotControlPanel=Bt;
|