@wandelbots/wandelbots-js-react-components 6.4.0-pr.feat-robot-control-panel.656.64cbc22 → 6.4.0-pr.feat-motion-stream-from-robotpad.657.4d52bae
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 +2 -55
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +0 -1
- package/dist/3d.js +14 -17
- 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 +4 -5
- package/dist/JoggingJointSlider/index.cjs +1 -1
- package/dist/JoggingJointSlider/index.js +1 -1
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.js +1 -1
- package/dist/chunks/ConnectedMotionGroup-C-EWMFfp.cjs +3 -0
- package/dist/chunks/{ConnectedMotionGroup-B_Mg1jSN.js → ConnectedMotionGroup-CPLkRVuY.js} +446 -414
- package/dist/chunks/{JoggingButtons-B341nDtX.cjs → JoggingButtons-DgY-YE8q.cjs} +1 -1
- package/dist/chunks/{JoggingButtons-DllZXh9D.js → JoggingButtons-kGOqdBLg.js} +2 -2
- package/dist/chunks/{JoggingGizmo-CR-9mcYX.js → JoggingGizmoOrientation-BmOWii4T.js} +116 -108
- package/dist/chunks/{JoggingGizmo-xvCp3LCB.cjs → JoggingGizmoOrientation-CZOk2twA.cjs} +1 -1
- package/dist/chunks/{JoggingJointSlider-oTxF8u1r.js → JoggingJointSlider-BbkQFd8e.js} +1 -1
- package/dist/chunks/{JoggingJointSlider-D6ZF4AHZ.cjs → JoggingJointSlider-OjqvmrWG.cjs} +1 -1
- package/dist/chunks/{Robot-BpCo1iYt.cjs → Robot-BMhAW_mu.cjs} +1 -1
- package/dist/chunks/{Robot-DS2W4y1f.js → Robot-Co5UAtdQ.js} +1 -1
- package/dist/chunks/{SafetyBar-CO9JPuKQ.js → SafetyBar-CnD99VSR.js} +1 -1
- package/dist/chunks/{SafetyBar-Cy-uqTmC.cjs → SafetyBar-DEl7Z9dZ.cjs} +1 -1
- package/dist/chunks/externalizeComponent-Dsfd1iPK.cjs +2 -0
- package/dist/chunks/{externalizeComponent-DBRjUP0q.js → externalizeComponent-ITlhrXC6.js} +18 -86
- package/dist/chunks/{joggingColors-CuT5u0H8.js → joggingColors-C8BsrO7B.js} +1 -2
- package/dist/chunks/{joggingColors-ZDc_2UCp.cjs → joggingColors-D8gtUzHS.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +27 -24
- package/dist/index.cjs +1 -1
- package/dist/index.js +42 -42
- package/dist/lib/MotionStreamConnection.d.ts +12 -1
- package/dist/lib/connectionLogger.d.ts +9 -0
- package/dist/lib/motionStateUpdate.d.ts +27 -0
- package/package.json +1 -1
- package/dist/RobotControlPanel/index.cjs +0 -1
- package/dist/RobotControlPanel/index.d.ts +0 -2
- package/dist/RobotControlPanel/index.js +0 -5
- package/dist/chunks/ConnectedMotionGroup-CNYRk4fK.cjs +0 -4
- package/dist/chunks/JoggingGizmoOrientation-BTKo84_4.cjs +0 -1
- package/dist/chunks/JoggingGizmoOrientation-DoMYMVlT.js +0 -14
- package/dist/chunks/RobotControlPanel-BYWjL0i2.js +0 -923
- package/dist/chunks/RobotControlPanel-DOCMrzoW.cjs +0 -1
- package/dist/chunks/externalizeComponent-BBWF9CMB.cjs +0 -2
- package/dist/components/robotControl/CartesianJogTab.d.ts +0 -21
- package/dist/components/robotControl/HoldToMoveButton.d.ts +0 -22
- package/dist/components/robotControl/JogArea.d.ts +0 -22
- package/dist/components/robotControl/JogModeToggle.d.ts +0 -8
- package/dist/components/robotControl/JointJogTab.d.ts +0 -11
- package/dist/components/robotControl/MoveToTab.d.ts +0 -18
- package/dist/components/robotControl/PanelSelect.d.ts +0 -13
- package/dist/components/robotControl/PoseField.d.ts +0 -21
- package/dist/components/robotControl/RobotControlPanel.d.ts +0 -211
- package/dist/components/robotControl/Section.d.ts +0 -5
- package/dist/components/robotControl/VelocityRow.d.ts +0 -14
- package/dist/components/robotControl/atPose.d.ts +0 -8
- package/dist/components/robotControl/poseText.d.ts +0 -15
- package/dist/components/robotControl/units.d.ts +0 -16
- package/dist/components/robotControl/useEveryFrame.d.ts +0 -6
package/README.md
CHANGED
|
@@ -72,7 +72,6 @@ Browse the full icon set at https://wandelbotsgmbh.github.io/nova-design-system/
|
|
|
72
72
|
- **`/JoggingGizmo`** — Only `JoggingGizmo` (also as the default export) and `JoggingGizmoOrientation`. Requires in addition three and @react-three/fiber.
|
|
73
73
|
- **`/JoggingButtons`** — Only `JoggingButtons` (also as the default export). No 3D packages needed.
|
|
74
74
|
- **`/JoggingJointSlider`** — Only `JoggingJointSlider` (also as the default export). No 3D packages needed.
|
|
75
|
-
- **`/RobotControlPanel`** — The whole Robot control panel, `RobotControlPanel` (also as the default export). It shows the jog gizmo, so it requires in addition three and @react-three/fiber, as `/JoggingGizmo` does.
|
|
76
75
|
|
|
77
76
|
A component's own entry point brings only what that component needs, e.g. `/JoggingButtons` no three.js and no NOVA client, unlike `/core`. The entry points share their common code, so an app that imports a component from both `/core` and its own entry point gets one copy of it:
|
|
78
77
|
|
|
@@ -90,9 +89,9 @@ import JoggingJointSlider from "@wandelbots/wandelbots-js-react-components/Joggi
|
|
|
90
89
|
| `@wandelbots/mui` | ^2 |
|
|
91
90
|
| `mobx` | ^6.13.6 |
|
|
92
91
|
| `mobx-react-lite` | ^4.1.0 |
|
|
93
|
-
| `three` (only `/3d`, `/JoggingGizmo
|
|
92
|
+
| `three` (only `/3d`, `/JoggingGizmo`) | >=0.182 |
|
|
94
93
|
| `three-stdlib` (only `/3d`) | >=2 |
|
|
95
|
-
| `@react-three/fiber` (only `/3d`, `/JoggingGizmo
|
|
94
|
+
| `@react-three/fiber` (only `/3d`, `/JoggingGizmo`) | ^9 |
|
|
96
95
|
| `@react-three/drei` (only `/3d`) | ^10 |
|
|
97
96
|
|
|
98
97
|
These packages are peer dependencies because the app and the library must use the same copy: React, the MUI theme of the app, the MobX stores that the app reads with its own `observer`, and the `<Canvas>` of React Three Fiber.
|
|
@@ -255,58 +254,6 @@ const [active, setActive] = useState<number | null>(null)
|
|
|
255
254
|
))}
|
|
256
255
|
```
|
|
257
256
|
|
|
258
|
-
**RobotControlPanel** (from `/3d` or `/RobotControlPanel`) - The Robot control panel of the design, built from the parts above: the tabs Translate and Rotate, with the TCP and the frame to jog along, Continuous or Increment, the velocity, the step size, and the gizmo or the buttons with a switch between them; the tab Joint, with a `JoggingJointSlider` per joint and the joint velocity; and the tab Move to, with a typed target pose (or the current one), the frame it is relative to, and a button to hold to move there. An app that wants the whole panel imports this; an app that wants one part imports that part.
|
|
259
|
-
|
|
260
|
-
- It moves nothing itself, as its parts: `onJogStart(motion, axis, direction)` and `onJogStop` for jogging while held, and `increments.onStep(motion, axis, direction, distance)` for one step per press. The app keeps the velocity and the selects in its own store; the panel keeps the tab, the mode, the step size and the view.
|
|
261
|
-
- Velocities and step sizes are in NOVA's units: mm and mm/s to translate, rad and rad/s to rotate. The panel shows mm/s and °/s.
|
|
262
|
-
- `tcp` and `jogFrame` show a select each, filled by the app. Without `increments`, there is no Continuous/Increment toggle. Without `gizmoOrientation` (from a `JoggingGizmoOrientation` in the app's 3D scene), it jogs with buttons only.
|
|
263
|
-
- `onJogStop` also comes when the tab, the mode or the view changes while a control is held: the jog of that press must not go on.
|
|
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
|
-
- 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
|
-
- `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 tab. `frame` is the "Relative to" select. It moves with `velocity.translate`. Without `moveTo`, there is no Move to tab.
|
|
268
|
-
|
|
269
|
-
```tsx
|
|
270
|
-
const orientation = useRef<Quaternion | null>(null)
|
|
271
|
-
|
|
272
|
-
<RobotControlPanel
|
|
273
|
-
gizmoOrientation={orientation}
|
|
274
|
-
tcp={{ options: tcps, value: tcp, onChange: setTcp }}
|
|
275
|
-
jogFrame={{ options: frames, value: frame, onChange: setFrame }}
|
|
276
|
-
velocity={{
|
|
277
|
-
translate: { value: mmPerSec, min: 1, max: 250 },
|
|
278
|
-
rotate: { value: radPerSec, min: 0.02, max: 1 },
|
|
279
|
-
}}
|
|
280
|
-
onVelocityChange={(motion, value) => setVelocity(motion, value)}
|
|
281
|
-
onJogStart={(motion, axis, direction) => startJogging(motion, axis, direction)}
|
|
282
|
-
onJogStop={() => stopJogging()}
|
|
283
|
-
increments={{
|
|
284
|
-
steps: { translate: [0.1, 1, 5, 10], rotate: [0.001, 0.01, 0.05] },
|
|
285
|
-
onStep: (motion, axis, direction, distance) =>
|
|
286
|
-
jogStep(motion, axis, direction, distance),
|
|
287
|
-
}}
|
|
288
|
-
joints={{
|
|
289
|
-
joints: jointValues.map((value, index) => ({
|
|
290
|
-
value,
|
|
291
|
-
min: limits[index].lower_limit,
|
|
292
|
-
max: limits[index].upper_limit,
|
|
293
|
-
})),
|
|
294
|
-
velocity: { value: jointRadPerSec, min: 0.02, max: 1 },
|
|
295
|
-
onVelocityChange: setJointVelocity,
|
|
296
|
-
onJogStart: (index, direction) => startJointJogging(index, direction),
|
|
297
|
-
onJogStop: () => stopJogging(),
|
|
298
|
-
}}
|
|
299
|
-
moveTo={{
|
|
300
|
-
getCurrentPose: () => currentTcpPose(),
|
|
301
|
-
onTargetChange: (pose) => planAndLoad(pose), // or drop the plan (null)
|
|
302
|
-
state: trajectoryState, // "planning" | "planned" | "moving" | "stopping" | "idle"
|
|
303
|
-
error,
|
|
304
|
-
onMoveStart: () => startTrajectory(),
|
|
305
|
-
onMoveStop: () => pauseTrajectory(),
|
|
306
|
-
}}
|
|
307
|
-
/>
|
|
308
|
-
```
|
|
309
|
-
|
|
310
257
|
### 3D Visualization & Robotics
|
|
311
258
|
|
|
312
259
|
3D components for robot visualization. They render inside the `<Canvas>` of React Three Fiber.
|
package/dist/3d.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/Robot-BMhAW_mu.cjs"),o=require("./chunks/JoggingGizmoOrientation-CZOk2twA.cjs"),t=require("./chunks/useSmoothedMotionState-Con0E5Bx.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=o.JoggingGizmo;exports.JoggingGizmoOrientation=o.JoggingGizmoOrientation;exports.ValueInterpolator=t.ValueInterpolator;exports.useSmoothedMotionState=t.useSmoothedMotionState;
|
package/dist/3d.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export { JoggingGizmo, type JoggingGizmoProps, } from "./components/jogging/gizm
|
|
|
7
7
|
export { JoggingGizmoOrientation, type JoggingGizmoOrientationProps, } from "./components/jogging/gizmo/JoggingGizmoOrientation";
|
|
8
8
|
export type { JogAxis, JogDirection, JogHandle, } from "./components/jogging/jogHandle";
|
|
9
9
|
export type { JogControlsProps } from "./components/jogging/useJogControls";
|
|
10
|
-
export { type JogMotion, RobotControlPanel, type RobotControlIncrements, type RobotControlJogMode, type RobotControlJoint, type RobotControlJoints, type RobotControlMoveState, type RobotControlMoveTo, type RobotControlOption, type RobotControlPanelProps, type RobotControlPose, type RobotControlSelect, type RobotControlTab, type RobotControlVelocity, } from "./components/robotControl/RobotControlPanel";
|
|
11
10
|
export * from "./components/robots/LinearAxis";
|
|
12
11
|
export * from "./components/robots/MotionGroupVisualizer";
|
|
13
12
|
export * from "./components/robots/Robot";
|
package/dist/3d.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import { C as a, J as
|
|
2
|
-
import { J as
|
|
3
|
-
import {
|
|
4
|
-
import { R as b } from "./chunks/RobotControlPanel-BYWjL0i2.js";
|
|
5
|
-
import { V as L, a as M } from "./chunks/useSmoothedMotionState-COMJRcOt.js";
|
|
1
|
+
import { C as a, J as t, L as r, M as s, a as i, P as n, R as p, S as d, b as u, c as m, d as x, e as S, T as l, f as R } from "./chunks/Robot-Co5UAtdQ.js";
|
|
2
|
+
import { J as f, a as g } from "./chunks/JoggingGizmoOrientation-BmOWii4T.js";
|
|
3
|
+
import { V as z, a as J } from "./chunks/useSmoothedMotionState-COMJRcOt.js";
|
|
6
4
|
export {
|
|
7
5
|
a as CollisionSceneRenderer,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
f as JoggingGizmo,
|
|
7
|
+
g as JoggingGizmoOrientation,
|
|
8
|
+
t as JointLimitGizmo,
|
|
9
|
+
r as LinearAxis,
|
|
12
10
|
s as MotionGroupVisualizer,
|
|
13
11
|
i as MotionGroupVisualizerExact,
|
|
14
12
|
n as PresetEnvironment,
|
|
15
13
|
p as Robot,
|
|
16
|
-
b as RobotControlPanel,
|
|
17
14
|
d as SafetyZonesRenderer,
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
u as SupportedLinearAxis,
|
|
16
|
+
m as SupportedLinearAxisExact,
|
|
20
17
|
x as SupportedRobot,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
S as SupportedRobotExact,
|
|
19
|
+
l as TrajectoryRenderer,
|
|
20
|
+
z as ValueInterpolator,
|
|
21
|
+
R as defaultGetModel,
|
|
22
|
+
J as useSmoothedMotionState
|
|
26
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../chunks/JoggingButtons-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../chunks/JoggingButtons-DgY-YE8q.cjs");exports.JoggingButtons=t.JoggingButtons;exports.default=t.JoggingButtons;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../chunks/
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../chunks/JoggingGizmoOrientation-CZOk2twA.cjs");exports.JoggingGizmo=i.JoggingGizmo;exports.JoggingGizmoOrientation=i.JoggingGizmoOrientation;exports.default=i.JoggingGizmo;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { J as i, J as
|
|
2
|
-
import { J as t } from "../chunks/JoggingGizmoOrientation-DoMYMVlT.js";
|
|
1
|
+
import { J as g, a as i, J as n } from "../chunks/JoggingGizmoOrientation-BmOWii4T.js";
|
|
3
2
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
g as JoggingGizmo,
|
|
4
|
+
i as JoggingGizmoOrientation,
|
|
5
|
+
n as default
|
|
7
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/JoggingJointSlider-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/JoggingJointSlider-OjqvmrWG.cjs");exports.JoggingJointSlider=e.JoggingJointSlider;exports.default=e.JoggingJointSlider;
|
package/dist/SafetyBar/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/SafetyBar-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/SafetyBar-DEl7Z9dZ.cjs");exports.SafetyBar=e.SafetyBar;exports.default=e.SafetyBar;
|
package/dist/SafetyBar/index.js
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),Ot=require("@mui/material/AppBar"),pt=require("@mui/material/Backdrop"),L=require("@mui/material/Box"),Pt=require("@mui/material/Menu"),$=require("@mui/material/MenuItem"),At=require("@mui/material/Toolbar"),_=require("@mui/material/Typography"),Vt=require("@wandelbots/design-tokens"),Dt=require("@wandelbots/icons/ExpandMoreFilled"),Lt=require("@wandelbots/mui"),E=require("mobx-react-lite"),C=require("react"),W=require("./externalizeComponent-Dsfd1iPK.cjs"),qt=require("@mui/icons-material/OpenWith"),Ft=require("@mui/icons-material/Share"),v=require("@mui/material/Stack"),Bt=require("@mui/material/Tab"),$t=require("@mui/material/Tabs"),x=require("mobx"),V=require("react-i18next"),M=require("@wandelbots/nova-js"),D=require("@wandelbots/nova-js/v2"),ot=require("three/src/math/Vector3.js"),A=require("./useSmoothedMotionState-Con0E5Bx.cjs"),ft=require("@mui/material/CircularProgress"),Nt=require("@mui/material/utils"),xt=require("lodash-es"),zt=require("./SafetyBar-DEl7Z9dZ.cjs"),Gt=require("@mui/material/Alert"),Ut=require("@mui/material/AlertTitle"),it=require("@mui/material/Button"),q=require("@mui/material/styles"),N=require("@mui/material/Divider"),gt=require("@mui/material/ToggleButton"),X=require("@mui/material/IconButton"),z=require("./joggingColors-D8gtUzHS.cjs"),Wt=require("lodash-es/isEqual.js"),Ht=require("@mui/material/InputAdornment"),Yt=require("@mui/material/FormControl"),Zt=require("@mui/material/InputLabel"),Xt=require("@mui/material/Select"),Y=require("lodash-es/keyBy.js"),Kt=require("lodash-es/uniqueId.js"),Qt=require("@mui/material/ToggleButtonGroup"),yt=require("@mui/material/Slider"),te=require("lodash-es/isNumber.js"),ee=require("@mui/icons-material/ChevronLeft"),oe=require("@mui/icons-material/ChevronRight"),ie=require("lodash-es/throttle.js"),ne=require("@mui/material/Dialog"),re=require("@mui/material/DialogActions"),se=require("@mui/material/DialogContent"),ae=require("@mui/material/DialogTitle"),nt=require("three");function jt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const b=jt(C),dt=jt(nt),le=W.externalizeComponent(E.observer(e=>{const{appIcon:t,appName:o,apps:i=[],onAppSelect:r,disabled:s=!1,sx:l}=e,[a,d]=C.useState(null),u=!!a,h=c=>{d(c.currentTarget)},p=()=>{d(null)},g=c=>{p(),c.onClick?c.onClick():c.href&&(window.location.href=c.href),r==null||r(c)};return n.jsxs(n.Fragment,{children:[n.jsx(Ot,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...l},children:n.jsxs(At,{sx:{minHeight:"62px !important"},children:[n.jsx(L,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),n.jsxs(L,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[n.jsx(_,{component:"h1",variant:"subtitle1",children:o}),i.length>0&&n.jsx(Lt.RoundedIconButton,{icon:n.jsx(Dt.ExpandMoreFilled,{size:20}),ariaLabel:"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:h,disabled:s,sx:{ml:1}})]})]})}),n.jsx(pt,{open:u,onClick:p,sx:{backdropFilter:"blur(4px)",backgroundColor:Vt.ZeroGravityComponentsBackdropFill,zIndex:c=>c.zIndex.modal-1}}),n.jsx(Pt,{id:"app-menu",anchorEl:a,open:u,onClose:p,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:c=>c.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:i.map(c=>n.jsxs($,{onClick:()=>g(c),children:[n.jsx(L,{sx:{display:"flex",alignItems:"center"},children:c.icon}),n.jsx(_,{variant:"body1",sx:{ml:2},children:c.name})]},c.id))})]})})),ce=({title:e,titleId:t,...o},i)=>b.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.createElement("g",{id:"JogMinus"},b.createElement("path",{id:"Minus",d:"M0 13V8H21V13H0Z",fill:"white"}))),ge=C.forwardRef(ce),de=({title:e,titleId:t,...o},i)=>b.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.createElement("g",{id:"JogPlus"},b.createElement("g",{id:"Plus"},b.createElement("path",{d:"M0 13V8H8V13H0Z",fill:"white"}),b.createElement("path",{d:"M8 0L13 2.18557e-07L13 21H8L8 0Z",fill:"white"}),b.createElement("path",{d:"M13 13V8H21V13H13Z",fill:"white"})))),ue=C.forwardRef(de),rt=W.externalizeComponent(E.observer(({colors:e,label:t,getDisplayedValue:o,startJogging:i,stopJogging:r,disabled:s,activeJoggingDirection:l,...a})=>{var w,T,R,k,O,F,B;A.useAnimationFrame(()=>{const J=o(),P=g.current;P&&(P.textContent=J)});const d=q.useTheme(),[u,h]=C.useState(null);C.useEffect(()=>{s&&I()},[s]);const p=l||u,g=C.useRef(null);e||(e={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const c=p?(w=e.buttonBackgroundColor)==null?void 0:w.pressed:e.borderColor,y={width:"55px",color:e.color,path:{fill:e.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},f={...y,backgroundColor:(T=e.buttonBackgroundColor)==null?void 0:T.default,":hover":{backgroundColor:(R=e.buttonBackgroundColor)==null?void 0:R.hovered},":active":{backgroundColor:(k=e.buttonBackgroundColor)==null?void 0:k.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor}},":disabled":{backgroundColor:(O=e.buttonBackgroundColor)==null?void 0:O.disabled,"svg path":{fill:d.palette.action.disabled}}},m={...y,backgroundColor:(F=e.buttonBackgroundColor)==null?void 0:F.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor},":disabled":{backgroundColor:(B=e.buttonBackgroundColor)==null?void 0:B.pressed,"svg path":{fill:d.palette.action.disabled}}};function j(J,P){s||J.button===0&&(h(P),i(P))}function I(){h(null),r()}return n.jsxs(v,{height:"64px",direction:"row",justifyContent:"center",...a,children:[n.jsx(X,{disabled:s,disableRipple:!0,onPointerDown:J=>j(J,"-"),onPointerUp:I,onPointerOut:I,size:"large",sx:{...p==="-"?m:f,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${c??"#fff"}`,borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:n.jsx(ge,{})}),n.jsxs(v,{spacing:"6px",sx:{width:"150px",backgroundColor:e.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:[n.jsx(v,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:e.color,".MuiTypography-root":{fontWeight:700,...s?{color:d.palette.action.disabled}:{}},...s?{"svg path":{fill:d.palette.action.disabled}}:{}},children:t}),n.jsx(_,{height:"22px",sx:{fontSize:"15px",color:s?d.palette.action.disabled:e.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:g,children:o()})]}),n.jsx(X,{disableRipple:!0,disabled:s,onPointerDown:J=>j(J,"+"),onPointerUp:I,onPointerOut:I,size:"large",sx:{...p==="+"?m:f,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${c??"#fff"}`,borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:n.jsx(ue,{})})]})})),St=W.externalizeComponent(E.observer(({startJogging:e,stopJogging:t,lowerLimit:o,upperLimit:i,useDegree:r,getValue:s,disabled:l,...a})=>{var k,O,F,B,J,P,H;const{t:d}=V.useTranslation(),[u,h]=C.useState(),p=q.useTheme(),g={background:(k=p.palette.backgroundPaperElevation)==null?void 0:k[4],color:(O=p.palette.backgroundPaperElevation)==null?void 0:O[11]},c=E.useLocalObservable(()=>({activeJoggingDir:null,startJogging(S){this.activeJoggingDir=S,e(S)},stopJogging(){this.activeJoggingDir=null,t()}})),y=ie(()=>{const S=r?f(s()):s();(S===void 0||u===void 0||Math.abs(u-S)>1e-9)&&h(S)},50);A.useAnimationFrame(y);function f(S){if(S!==void 0)return M.radiansToDegrees(S)}function m(S){S.button===0&&c.startJogging("-")}function j(S){S.button===0&&c.startJogging("+")}function I(S){c.stopJogging()}function w(S){c.stopJogging()}function T(S,G=1){if(S===void 0||Number.isNaN(S))return"";const U=d("General.degree.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${U}`:U}function R(S,G=1){if(S===void 0||Number.isNaN(S))return"";const U=d("General.mm.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${U}`:U}return n.jsxs(v,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...a,sx:{"& .MuiIconButton-root":{width:"52px",color:p.palette.text.primary,alignContent:"center",backgroundColor:(F=p.palette.backgroundPaperElevation)==null?void 0:F[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:(B=p.palette.backgroundPaperElevation)==null?void 0:B[11],color:p.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(J=p.palette.backgroundPaperElevation)==null?void 0:J[9]},"&:active":{...g}}},children:[n.jsx(X,{onPointerDown:m,onPointerUp:I,onPointerOut:w,disabled:l,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...c.activeJoggingDir==="-"?g:{}},children:n.jsx(ee,{sx:{pointerEvents:"none",color:z.jointArrowColor}})}),n.jsxs(v,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:(P=p.palette.backgroundPaperElevation)==null?void 0:P[11],paddingLeft:"20px",paddingRight:"20px",zIndex:1},children:[n.jsx(_,{sx:{fontSize:"15px",fontWeight:700,position:"relative",top:"5px",fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center",color:l?p.palette.action.disabled:p.palette.text.primary},children:r?T(u):R(u)}),n.jsx(yt,{disabled:!0,"aria-label":"Joint position",min:r?f(o):o,max:r?f(i):i,value:u||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:l?p.palette.action.disabled:p.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:l?p.palette.action.disabled:p.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(H=p.palette.backgroundPaperElevation)==null?void 0:H[5],opacity:1}},marks:o!==void 0&&i!==void 0&&[{value:r?f(o):o,label:r?T(f(o),0):R(o)},{value:r?f(i):i,label:r?T(f(i),0):R(i)}]})]}),n.jsx(X,{onPointerDown:j,onPointerUp:I,onPointerOut:w,disabled:l,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...c.activeJoggingDir==="+"?g:{}},children:n.jsx(oe,{sx:{pointerEvents:"none",color:z.jointArrowColor}})})]})}));function bt(e,t,o){return t.length!==e.length?!1:vt(e,t,o)}function at(e,t,o){return t.length!==e.length?!0:vt(e,t,o)}function vt(e,t,o){for(let i=0;i<t.length;i++)if(Math.abs((t[i]??0)-(e[i]??0))>o)return!1;return!0}function Ct(e,t,o){if(e===void 0&&t||e&&t===void 0||(e==null?void 0:e.orientation)===void 0||(t==null?void 0:t.orientation)===void 0||(e==null?void 0:e.position)===void 0||(t==null?void 0:t.position)===void 0)return!1;if(e===void 0||t===void 0)return!0;let i=0;return i+=Math.abs(e.orientation[0]-t.orientation[0]),i+=Math.abs(e.orientation[1]-t.orientation[1]),i+=Math.abs(e.orientation[2]-t.orientation[2]),i+=Math.abs(e.position[0]-t.position[0]),i+=Math.abs(e.position[1]-t.position[1]),i+=Math.abs(e.position[2]-t.position[2]),i<=o}function lt(e,t,o){return e.coordinate_system===t.coordinate_system&&e.tcp===t.tcp&&Ct(e.tcp_pose,t.tcp_pose,o)}function It(e,t){const o=new nt.Vector3(t[0],t[1],t[2]),i=new nt.Vector3(e[0],e[1],e[2]),r=o.length(),s=o.normalize();let l=i.length(),a=i.normalize();a.dot(s)<0&&(l=-l,a=a.multiplyScalar(-1));let d=l-r;return d-=2*Math.PI*Math.floor((d+Math.PI)/(2*Math.PI)),l=r+d,[...a.multiplyScalar(l)]}const he=2e-4;function wt(e){const{joint_position:t,tcp_pose:o,tcp:i,coordinate_system:r}=e;return{joint_position:t,tcp_pose:o,tcp:i,coordinate_system:r}}function Mt(e,t){return e.tcp===t.tcp&&e.coordinate_system===t.coordinate_system&&e.tcp_pose===void 0==(t.tcp_pose===void 0)&&bt(e.joint_position,t.joint_position,he)}const ut=1e-4;class Q{constructor(t,o,i,r,s,l,a="cell",d={}){this.controller=o,this.motionGroup=i,this.description=r,this.initialMotionState=s,this.motionStateSocket=l,this.cellId=a,this.nova=A.createNovaClient(t),this.logger=d.logger??console,this.rapidlyChangingMotionState=s,l.addEventListener("message",u=>{var c;const h=(c=M.tryParseJson(u.data))==null?void 0:c.result;if(!h)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${u.data}`);lt(this.rapidlyChangingMotionState,h,ut)||x.runInAction(()=>{var y,f,m;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=h.tcp_pose:(y=h.tcp_pose)!=null&&y.orientation&&((f=h.tcp_pose)!=null&&f.position)&&((m=this.rapidlyChangingMotionState.tcp_pose)!=null&&m.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:h.tcp_pose.position,orientation:It(h.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:this.logger.debug("Received incomplete tcp_pose, ignoring",{tcpPose:h.tcp_pose})}),at(this.rapidlyChangingMotionState.joint_position,h.joint_position,ut)||x.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=h.joint_position}),h.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==h.tcp&&x.runInAction(()=>{this.rapidlyChangingMotionState.tcp=h.tcp}),this.rapidlyChangingMotionState.standstill!==h.standstill&&x.runInAction(()=>{this.rapidlyChangingMotionState.standstill=h.standstill});const p=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,g=h.joint_limit_reached.limit_reached;p.some((y,f)=>y!==g[f])&&x.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=h.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==h.execute&&x.runInAction(()=>{this.rapidlyChangingMotionState.execute=h.execute})}),x.makeAutoObservable(this,{logger:!1,readoutState:x.computed({equals:Mt,keepAlive:!0})})}static async open(t,o,i={}){var f;const r=A.createNovaClient(t),s=i.cellId??A.cellIdOf(t)??"cell",[l,a]=o.split("@"),d=await r.api.controller.getCurrentRobotControllerState(s,a),u=d==null?void 0:d.motion_groups.find(m=>m.motion_group===o);if(!d||!u)throw new Error(`Controller ${a} or motion group ${o} not found`);const h=r.openReconnectingWebsocket(`/cells/${s}/controllers/${a}/motion-groups/${o}/state-stream`),p=await h.firstMessage(),g=(f=M.tryParseJson(p.data))==null?void 0:f.result;if(!g)throw new Error(`Unable to parse initial motion state message ${p.data}`);const c=i.logger??console;c.info("Connected motion state websocket to motion group",{motionGroup:u.motion_group,initialMotionState:g});const y=await r.api.motionGroup.getMotionGroupDescription(s,a,u.motion_group);return new Q(r,d,u,y,g,h,s,{logger:c})}get readoutState(){return wt(this.rapidlyChangingMotionState)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((t,o)=>({index:o}))}dispose(){this.motionStateSocket.close()}}const ht="Movement request rejected. Another client is currently executing a 'Jogging' motion!";class tt{constructor(t,o={}){this.motionStream=t,this.options=o,this.DEFAULT_MODE="off",this.DEFAULT_TCP="Flange",this.NO_TCP=void 0,this.DEFAULT_INIT_TIMEOUT=5e3,this.DEFAULT_ORIENTATION="coordsys",this.mode="off",this.joggingSocket=null,this.trajectorySocket=null,this.timeout=this.DEFAULT_INIT_TIMEOUT,this.ownsMotionStream=!1,this.tcp=(o==null?void 0:o.tcp)||t.motionGroup.tcp||this.getDefaultTcp(t),this.orientation=(o==null?void 0:o.orientation)||this.DEFAULT_ORIENTATION,this.timeout=(o==null?void 0:o.timeout)||this.DEFAULT_INIT_TIMEOUT,this.mode=(o==null?void 0:o.mode)||this.DEFAULT_MODE,this.onError=o==null?void 0:o.onError}static async open(t,o,i={}){const r=await Q.open(t,o,{cellId:i.cellId}),s=new tt(r,i);s.ownsMotionStream=!0;try{await s.setJoggingMode(s.mode)}catch(l){throw s.dispose(),l}return s}getDefaultTcp(t){var i,r;const o=(r=(i=t.description.dh_parameters)==null?void 0:i[0])==null?void 0:r.type;return t.joints.length<6&&(o===D.JointTypeEnum.RevoluteJoint||o===D.JointTypeEnum.PrismaticJoint)?this.NO_TCP:this.DEFAULT_TCP}async setOptions(t){return t.tcp&&(this.tcp=t.tcp),t.orientation&&(this.orientation=t.orientation),t.timeout&&(this.timeout=t.timeout),t.mode&&(this.mode=t.mode),t.onError&&(this.onError=t.onError),this.setJoggingMode(this.mode,!1)}get motionGroupId(){return this.motionStream.motionGroupId}get nova(){return this.motionStream.nova}get cellId(){return this.motionStream.cellId}get numJoints(){return this.motionStream.joints.length}async stop(){if(this.joggingSocket){const t=new Array(this.numJoints).fill(0);this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:t})}this.trajectorySocket&&this.trajectorySocket.sendJson({message_type:"PauseMovementRequest"})}async dispose(){const t=this.closeJoggingSockets();return this.ownsMotionStream&&this.motionStream.dispose(),t}closeJoggingSockets(){var o;(o=this.endJoggingInit)==null||o.call(this);const t=[this.joggingSocket,this.trajectorySocket].filter(i=>i!==null);return t.forEach(i=>{i.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(i=>i.closed()))}async setJoggingMode(t,o=!0){if(!(this.mode===t&&o)&&(this.closeJoggingSockets(),this.mode=t,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((t,o)=>{const i=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`);this.joggingSocket=i;let r=!1;const s=setTimeout(()=>{l(new Error(`Jogging initialization timeout after ${this.timeout} ms`))},this.timeout),l=u=>{r||(r=!0,clearTimeout(s),i.removeEventListener("close",d),this.endJoggingInit===a&&(this.endJoggingInit=void 0),u?o(u):t())},a=()=>l(),d=()=>{i.disposed&&l()};this.endJoggingInit=a,i.addEventListener("close",d),i.addEventListener("message",u=>{var p,g,c;const h=M.tryParseJson(u.data);if(((p=h==null?void 0:h.result)==null?void 0:p.kind)==="INITIALIZE_RECEIVED"){l();return}if(((g=h==null?void 0:h.result)==null?void 0:g.kind)==="MOTION_ERROR")if(this.onBlocked&&((c=h==null?void 0:h.result)!=null&&c.message.includes(ht))){l(),i.dispose(),this.onBlocked();return}else this.onError?(l(),this.onError(u.data)):l(new Error(u.data))}),i.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:o,velocityValue:i,velocityUnit:r}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'");const s=new Array(this.numJoints).fill(0);s[t]=o==="-"?-i:i,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:s})}async translateTCP({axis:t,direction:o,velocityMmPerSec:i}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=[0,0,0],s=[0,0,0];s[M.XYZ_TO_VECTOR[t]]=o==="-"?-i:i,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:s,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:o,velocityRadsPerSec:i}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=[0,0,0],s=[0,0,0];r[M.XYZ_TO_VECTOR[t]]=o==="-"?-i:i,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:s,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async runIncrementalCartesianMotion({currentTcpPose:t,currentJoints:o,velocityInRelevantUnits:i,axis:r,direction:s,motion:l}){const a=[];if(this.mode!=="trajectory")throw new Error("Set jogging mode to 'trajectory' to run incremental cartesian motions");if(l.type==="translate"){if(!t.position)throw new Error("Current pose has no position, cannot perform translation");const m=[...t.position];m[M.XYZ_TO_VECTOR[r]]+=l.distanceMm*(s==="-"?-1:1),a.push({limits_override:{tcp_velocity_limit:i},path:{path_definition_name:"PathLine",target_pose:{position:m,orientation:t.orientation}}})}else if(l.type==="rotate"){if(!t.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const m=new ot.Vector3(t.orientation[0],t.orientation[1],t.orientation[2]),j=m.length(),I=m.clone().normalize(),w=l.distanceRads*(s==="-"?-1:1),T=new ot.Vector3(0,0,0);T[r]=1;const R=Math.cos(.5*w)*Math.cos(.5*j),k=Math.sin(.5*w)*Math.sin(.5*j),O=Math.sin(.5*w)*Math.cos(.5*j),F=Math.cos(.5*w)*Math.sin(.5*j),B=T.dot(I),J=T.clone().cross(I),P=2*Math.acos(R-k*B),H=P/Math.sin(.5*P),S=new ot.Vector3().addScaledVector(J,k).addScaledVector(T,O).addScaledVector(I,F).multiplyScalar(H);a.push({limits_override:{tcp_orientation_velocity_limit:i},path:{path_definition_name:"PathLine",target_pose:{position:t.position,orientation:[...S]}}})}const d=this.motionStream.description;if(d.cycle_time===void 0){console.warn("Current motion group has no cycle time, cannot plan jogging motion");return}const u={motion_group_model:d.motion_group_model,cycle_time:d.cycle_time,mounting:d.mounting,global:d.operation_limits.auto_limits},h=await this.nova.api.trajectoryPlanning.planTrajectory(this.cellId,{motion_group_setup:u,start_joint_position:o,motion_commands:a}),p=h.response;if(!p)throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(h)}`);this.trajectorySocket&&(console.warn("Trajectory jogging websocket already open; will close"),this.trajectorySocket.dispose()),this.trajectorySocket=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);const g=m=>{var j;if(!m||m.add_trajectory_error||m.message)if(this.onError)this.onError(m);else throw new Error(((j=m==null?void 0:m.add_trajectory_error)==null?void 0:j.message)||(m==null?void 0:m.message)||"Failed to execute trajectory, unknown error");if(!this.trajectorySocket)throw new Error("Failed to execute trajectory, websocket not available anymore");this.trajectorySocket.sendJson({message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"})},c=async()=>{var m;await x.when(()=>!this.motionStream.rapidlyChangingMotionState.standstill),await x.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(m=this.trajectorySocket)==null||m.dispose(),this.trajectorySocket=null},y=async()=>{var m;await x.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(m=this.trajectorySocket)==null||m.dispose(),this.trajectorySocket=null},f=async m=>{if(m!=null&&m.message)if(this.onError){this.onError(m);return}else throw new Error(m.message||"Failed to execute trajectory, unknown error");this.motionStream.rapidlyChangingMotionState.standstill?await c():await y()};this.trajectorySocket.addEventListener("message",m=>{var I,w;const j=M.tryParseJson(m.data);if(!((I=j==null?void 0:j.result)!=null&&I.kind))throw new Error(`Failed to execute trajectory: Received invalid message ${m.data}`);if(this.onBlocked&&((w=j.result.message)!=null&&w.includes(ht))){this.onBlocked();return}if(j.result.kind==="INITIALIZE_RECEIVED")g(j.result);else if(j.result.kind==="START_RECEIVED")f(j);else if(j.result.kind!=="PAUSE_RECEIVED")if(j.result.kind==="MOTION_ERROR"&&j.result.message)if(this.onError){this.onError(j);return}else throw new Error(j.result.message);else throw new Error(`Failed to execute trajectory, cannot handle message type "${j.result.kind}"`)}),this.trajectorySocket.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:p,tcp:this.tcp}})}}const _t=e=>{const t=e.softTimeout||3e3,[o,i]=C.useState(!1);return C.useEffect(()=>{const r=setTimeout(()=>{i(!0)},t);return()=>clearTimeout(r)}),n.jsx(v,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:"text.primary"},children:e.error?n.jsx(Et,{loadingMessage:e.message,error:e.error}):n.jsxs(n.Fragment,{children:[n.jsx(ft,{sx:{mb:3}}),!!e.message&&n.jsx(_,{variant:"body1",children:e.message}),n.jsx(_,{variant:"body2",sx:{visibility:o?"visible":"hidden",mt:2,color:"text.secondary"},children:"This is taking longer than expected..."})]})})},Et=e=>{const t=zt.makeErrorMessage(e.error),o=e.error instanceof Error?e.error.stack:null;return n.jsxs(v,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",p:2,overflow:"auto",color:"error.main"},children:[n.jsx(_,{variant:"body1",children:(e.loadingMessage?`Error while ${xt.lowerFirst(Nt.capitalize(e.loadingMessage))} - `:"")+t}),o&&n.jsx(L,{component:"pre",sx:{typography:"body2",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",mt:2,pb:6},children:o})]})},me=E.observer(({store:e})=>{const{t}=V.useTranslation();return n.jsx(pt,{"data-testid":"jogging-blocked","aria-label":"jogging-blocked",open:!0,sx:{position:"absolute",zIndex:o=>o.zIndex.drawer+1,color:"#fff",background:"rgba(15, 15, 15, 0.88)",justifyContent:"flex-start",alignItems:"flex-start"},children:n.jsxs(v,{sx:{m:2,width:"100%"},children:[n.jsxs(Gt,{severity:"error",sx:{mb:2},children:[n.jsx(Ut,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),n.jsx(it,{variant:"contained",color:"secondary",onClick:()=>e.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),pe=({title:e,titleId:t,...o},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M5.131.312a.9.9 0 0 1 0 1.272L3.07 3.645h12.44l-2.06-2.061A.9.9 0 0 1 14.72.313l3.596 3.596a.9.9 0 0 1 0 1.271l-3.596 3.597a.9.9 0 0 1-1.271-1.272l2.061-2.062H3.07L5.13 7.505A.9.9 0 0 1 3.86 8.777L.263 5.18a.9.9 0 0 1 0-1.271L3.86.312a.9.9 0 0 1 1.271 0",clipRule:"evenodd"})),fe=C.forwardRef(pe),xe=({title:e,titleId:t,...o},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M5.131.312a.9.9 0 0 1 0 1.272L3.07 3.645h12.44l-2.06-2.061A.9.9 0 0 1 14.72.313l3.596 3.596a.9.9 0 0 1 0 1.271l-3.596 3.597a.9.9 0 0 1-1.271-1.272l2.061-2.062H3.07L5.13 7.505A.9.9 0 0 1 3.86 8.777L.263 5.18a.9.9 0 0 1 0-1.271L3.86.312a.9.9 0 0 1 1.271 0",clipRule:"evenodd"})),ye=C.forwardRef(xe),je=({title:e,titleId:t,...o},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:10,height:19,fill:"none",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M9.522 14.811A.899.899 0 1 0 8.25 13.54L6.19 15.601V3.16L8.25 5.221A.9.9 0 0 0 9.522 3.95L5.926.354a.9.9 0 0 0-1.272 0L1.058 3.95a.9.9 0 1 0 1.271 1.271L4.391 3.16v12.442L2.329 13.54a.899.899 0 1 0-1.271 1.271l3.596 3.597a.9.9 0 0 0 1.272 0z",clipRule:"evenodd"})),Se=C.forwardRef(je),be=({title:e,titleId:t,...o},i)=>b.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.createElement("path",{d:"M8 16C5.76667 16 3.875 15.225 2.325 13.675C0.775 12.125 0 10.2333 0 8C0 5.76667 0.775 3.875 2.325 2.325C3.875 0.775 5.76667 0 8 0C9.15 0 10.25 0.2375 11.3 0.7125C12.35 1.1875 13.25 1.86667 14 2.75V0H16V7H9V5H13.2C12.6667 4.06667 11.9375 3.33333 11.0125 2.8C10.0875 2.26667 9.08333 2 8 2C6.33333 2 4.91667 2.58333 3.75 3.75C2.58333 4.91667 2 6.33333 2 8C2 9.66667 2.58333 11.0833 3.75 12.25C4.91667 13.4167 6.33333 14 8 14C9.28333 14 10.4417 13.6333 11.475 12.9C11.0583 14.1 12.5083 12.1667 11.475 12.9L12.9 14.325C11.4667 15.4417 9.83333 16 8 16Z",fill:"white"})),ve=C.forwardRef(be),Tt=E.observer(({store:e})=>{const{t}=V.useTranslation(),[o,i]=C.useState(e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),r=C.useRef(o);A.useAnimationFrame(()=>{const l=e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;Wt(r.current,l)||(r.current=l,i(l))});const s=[];for(const[l,a]of o.entries())a&&s.push(l);return n.jsx(L,{sx:{display:"flex",flexDirection:"row",justifyContent:"center"},children:n.jsx(_,{"data-testid":"jogging-joint-limit-detector","aria-label":"jogging-joint-limit-detector",color:"error",variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2,visibility:s.length?"visible":"hidden"},children:t("Jogging.JointLimitsReached.lb",{jointNumbers:s.map(l=>l+1).join(", ")})})})}),Ce=q.styled(Yt)(({theme:e})=>({"&.MuiFormControl-root":{".MuiSelect-select":{paddingTop:"20px",paddingLeft:"12px"},label:{pointerEvents:"none",fontSize:"16px"},".MuiInputLabel-root":{"&.Mui-focused":{color:e.palette.text.primary}}}}));function Z({labelValue:e,...t}){return n.jsxs(Ce,{fullWidth:!0,variant:"filled",children:[n.jsx(Zt,{id:t.labelId,children:e}),n.jsx(Xt,{...t})]})}const st=[{id:"0.1",mm:.1,degrees:.05},{id:"1",mm:1,degrees:.5},{id:"5",mm:5,degrees:2.5},{id:"10",mm:10,degrees:5}],Ie=[{id:"continuous"},...st],we=["coordsys","tool"];class et{constructor(t,o,i,r,s){var l,a,d;this.jogger=t,this.coordSystems=o,this.motionGroupDescription=i,this.tcps=r,this.inverseSolverValue=s,this.selectedTabId="cartesian",this.locks=new Set,this.blocked=!1,this.selectedCoordSystemId="world",this.selectedTcpId="",this.tcpChangeInProgress=!1,this.selectedOrientation="coordsys",this.selectedIncrementId="continuous",this.selectedCartesianMotionType="translate",this.incrementJogInProgress=null,this.translationVelocityMmPerSec=10,this.rotationVelocityDegPerSec=1,this.minTranslationVelocityMmPerSec=5,this.maxTranslationVelocityMmPerSec=250,this.minRotationVelocityDegPerSec=1,this.maxRotationVelocityDegPerSec=60,this.showCoordSystemSelect=!1,this.showTcpSelect=!0,this.showOrientationSelect=!0,this.showIncrementSelect=!0,this.showTabIcons=!1,this.showVelocitySliderLabel=!0,this.showVelocityLegend=!1,this.showJointsLegend=!1,this.disposers=[],this.inverseSolver=void 0,this.jointType=D.JointTypeEnum.RevoluteJoint;for(const u of o)if(u.coordinate_system===""){u.coordinate_system="world";break}this.selectedCoordSystemId=((l=o[0])==null?void 0:l.coordinate_system)||"world",this.selectedTcpId=t.motionStream.rapidlyChangingMotionState.tcp??"",this.tcpChangeInProgress=this.tcps.length>0&&!this.selectedTcpId,this.inverseSolver=s,this.jointType=((d=(a=i==null?void 0:i.dh_parameters)==null?void 0:a[0])==null?void 0:d.type)??D.JointTypeEnum.RevoluteJoint,x.makeAutoObservable(this,{},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()},this.loadFromLocalStorage(),this.disposers.push(x.autorun(()=>this.saveToLocalStorage())),this.disposers.push(x.autorun(()=>{const u=this.jogger.motionStream.rapidlyChangingMotionState.tcp;u&&u!==this.selectedTcpId&&x.runInAction(()=>{this.selectedTcpId=u,this.tcpChangeInProgress=!1})})),window.joggingStore=this}static async loadFor(t){const{nova:o,cellId:i}=t,[r,s]=await Promise.all([o.api.controller.listCoordinateSystems(i,t.motionStream.controllerId,"ROTATION_VECTOR"),o.api.motionGroup.getMotionGroupDescription(i,t.motionStream.controllerId,t.motionGroupId)]),l=await o.api.motionGroupModels.getMotionGroupKinematicModel(s.motion_group_model),a=Object.entries(s.tcps||{}).map(([d,u])=>({id:d,readable_name:u.name,position:u.pose.position,orientation:u.pose.orientation}));return new et(t,r||[],s,a,l.inverse_solver)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return xt.countBy(this.coordSystems,t=>t.name)}async deactivate(){this.jogger.mode==="jogging"&&await this.jogger.setJoggingMode("off")}async activate(){return this.currentTab.id==="cartesian"?((this.jogger.tcp!==this.selectedTcpId||this.jogger.orientation!==this.selectedOrientation)&&await this.jogger.setOptions({tcp:this.selectedTcpId||void 0,orientation:this.selectedOrientation}),this.activeDiscreteIncrement?await this.jogger.setJoggingMode("trajectory"):await this.jogger.setJoggingMode("jogging")):await this.jogger.setJoggingMode("jogging"),this.jogger}loadFromLocalStorage(){const t=M.tryParseJson(localStorage.getItem("joggingToolStore"));t&&(this.tabsById[t.selectedTabId]&&(this.selectedTabId=t.selectedTabId),this.coordSystemsById[t.selectedCoordSystemId]&&(this.selectedCoordSystemId=t.selectedCoordSystemId),this.incrementOptionsById[t.selectedIncrementId]&&(this.selectedIncrementId=t.selectedIncrementId),["translate","rotate"].includes(t.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=t.selectedCartesianMotionType),["coordsys","tool"].includes(t.selectedOrientation)&&(this.selectedOrientation=t.selectedOrientation))}saveToLocalStorage(){localStorage.setItem("joggingToolStore",JSON.stringify(this.localStorageSave))}get isLocked(){return this.locks.size>0}get localStorageSave(){return{selectedTabId:this.selectedTabId,selectedCoordSystemId:this.selectedCoordSystemId,selectedOrientation:this.selectedOrientation,selectedIncrementId:this.selectedIncrementId,selectedCartesianMotionType:this.selectedCartesianMotionType}}get tabs(){const t=[{id:"joint",label:"Joints"}];return this.inverseSolver!==null&&t.unshift({id:"cartesian",label:"Cartesian"}),t}get incrementOptions(){return Ie}get discreteIncrementOptions(){return st}get incrementOptionsById(){return Y(this.incrementOptions,t=>t.id)}get tabsById(){return Y(this.tabs,t=>t.id)}get currentTab(){return this.tabsById[this.selectedTabId]||this.tabs[0]}get tabIndex(){return this.tabs.indexOf(this.currentTab)}get coordSystemsById(){return Y(this.coordSystems,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get tcpsById(){return Y(this.tcps,t=>t.id)}get activeDiscreteIncrement(){return this.selectedOrientation==="tool"?void 0:st.find(t=>t.id===this.selectedIncrementId)}get rotationVelocityRadsPerSec(){return this.rotationVelocityDegPerSec*Math.PI/180}velocityInDisplayUnits(t){return t?this.rotationVelocityDegPerSec:this.translationVelocityMmPerSec}minVelocityInDisplayUnits(t){return t?this.minRotationVelocityDegPerSec:this.minTranslationVelocityMmPerSec}maxVelocityInDisplayUnits(t){return t?this.maxRotationVelocityDegPerSec:this.maxTranslationVelocityMmPerSec}onTabChange(t,o){const i=this.tabs[o]||this.tabs[0];this.selectedTabId=i.id}setSelectedCoordSystemId(t){this.selectedCoordSystemId=t}setSelectedTcpId(t){this.requestTcpChange(t).catch(o=>{console.error("Failed to change TCP:",o)})}async requestTcpChange(t){if(t===this.selectedTcpId)return;this.tcpChangeInProgress=!0;const o=this.jogger.tcp,i=this.jogger.mode!=="jogging";try{this.jogger.tcp=t,i?await this.jogger.setJoggingMode("jogging"):await this.jogger.setJoggingMode("jogging",!1);let r=await this.waitForTcpConfirmation(t,1e3);i&&await this.jogger.setJoggingMode("off"),r||(r=await this.waitForTcpConfirmation(t,2e3)),x.runInAction(()=>{r?this.selectedTcpId=t:(this.jogger.tcp=o,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??"")})}catch(r){throw i&&await this.jogger.setJoggingMode("off").catch(()=>{}),x.runInAction(()=>{this.jogger.tcp=o,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??""}),r}finally{x.runInAction(()=>{this.tcpChangeInProgress=!1})}}waitForTcpConfirmation(t,o){return new Promise(i=>{const r=setTimeout(()=>{s(),i(!1)},o),s=x.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===t,()=>{clearTimeout(r),i(!0)})})}setSelectedOrientation(t){this.selectedOrientation=t}setSelectedIncrementId(t){this.selectedIncrementId=t}setCurrentIncrementJog(t){this.incrementJogInProgress=t}setVelocityFromSlider(t,o){o?this.rotationVelocityDegPerSec=t:this.translationVelocityMmPerSec=t}setSelectedCartesianMotionType(t){this.selectedCartesianMotionType=t}lock(t){this.locks.add(t)}unlock(t){this.locks.delete(t)}block(){this.blocked=!0}unblock(){this.blocked=!1,this.jogger.mode==="jogging"&&this.jogger.initializeJoggingWebsocket().catch(t=>{console.error("Failed to initialize jogging:",t)})}async withMotionLock(t){const o=Kt();this.lock(o);try{return await t()}finally{this.unlock(o)}}}const Me=E.observer(({store:e,useDegree:t})=>{var l;const{t:o}=V.useTranslation(),i=C.useId(),r=[];function s(a){switch(a){case"coordsys":return o("Jogging.Orientation.coordsys");case"tool":return o("Jogging.Orientation.tool");default:return a}}return e.showCoordSystemSelect&&r.push(n.jsx(Z,{labelId:`jogging-coord-select-${i}`,labelValue:o("Jogging.CoordinateSystem.hlb"),value:e.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:a=>e.setSelectedCoordSystemId(a.target.value),children:e.coordSystems.map(a=>n.jsx($,{value:a.coordinate_system,children:a.name&&e.coordSystemCountByName[a.name]>1?`${a.name} / ${a.coordinate_system}`:a.name||a.coordinate_system},a.coordinate_system))},"coord")),e.showTcpSelect&&r.push(n.jsx(Z,{labelId:`jogging-tcp-select-${i}`,labelValue:"TCP",value:e.selectedTcpId,size:"small",variant:"filled",displayEmpty:e.tcpChangeInProgress,onChange:a=>{e.requestTcpChange(a.target.value).catch(d=>{console.error("Failed to change TCP:",d)})},disabled:e.tcpChangeInProgress,endAdornment:e.tcpChangeInProgress?n.jsx(Ht,{position:"end",children:n.jsx(ft,{size:16})}):void 0,children:e.tcps.map(a=>n.jsx($,{value:a.id,children:a.id},a.id))},"tcp")),e.showOrientationSelect&&r.push(n.jsx(Z,{labelValue:o("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${i}`,value:e.selectedOrientation,onChange:a=>e.setSelectedOrientation(a.target.value),children:we.map(a=>n.jsx($,{value:a,children:s(a)},a))},"orientation")),e.showIncrementSelect&&r.push(n.jsxs(Z,{labelValue:o("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${i}`,size:"small",variant:"filled",value:((l=e.activeDiscreteIncrement)==null?void 0:l.id)||"continuous",onChange:a=>e.setSelectedIncrementId(a.target.value),children:[n.jsx($,{value:"continuous",children:o("Jogging.Increment.Continuous.dd")},"continuous"),e.selectedOrientation==="tool"?null:e.discreteIncrementOptions.map(a=>n.jsx($,{value:a.id,children:t?`${a.degrees}°`:`${a.mm}mm`},a.id))]},"increment")),n.jsx(L,{component:"div","data-testid":"jogging-options","aria-label":"jogging-options",sx:{display:"grid",gap:"16px",gridTemplateColumns:"1fr 1fr",gridAutoRows:"min-content","& label":{opacity:.7,fontSize:"12px",marginBottom:"4px"}},children:r.map((a,d)=>n.jsx(L,{sx:{gridColumn:r.length%2===1&&d===r.length-1?"span 2":"auto"},children:a},d))})}),_e=q.styled(Qt)(({theme:e})=>{var t;return{"&.MuiToggleButtonGroup-root":{background:(t=e.palette.backgroundPaperElevation)==null?void 0:t[8],borderRadius:"8px",padding:"4px",gap:"4px",button:{border:"none",borderRadius:"4px",flex:"1 1 0px",minWidth:0,"&.MuiToggleButtonGroup-firstButton":{borderRadius:"8px 4px 4px 8px"},"&.MuiToggleButtonGroup-lastButton":{borderRadius:"4px 8px 8px 4px"}}}}}),kt=W.externalizeComponent(E.observer(e=>{const{store:t}=e,{t:o}=V.useTranslation();function i(r,s){s===e.velocity||!te(s)||e.onVelocityChange(s,e.useDegree)}return n.jsxs(v,{direction:"row",gap:2,alignItems:"center","data-testid":"velocity-slider","aria-label":"velocity-slider",children:[t.showVelocityLegend&&n.jsx(_,{sx:{color:z.velocitySliderLegendColor,fontSize:"14px"},children:o("Jogging.Velocity.bt")}),n.jsx(yt,{value:e.velocity,color:"secondary",onChange:i,min:e.min,max:e.max,"aria-labelledby":"input-slider",disabled:e.disabled,sx:{"& .MuiSlider-valueLabelOpen":{zIndex:100,backgroundColor:"transparent",top:"0px"}}}),t.showVelocitySliderLabel&&(e.renderValue?e.renderValue(e.velocity):n.jsx(ct,{value:e.velocity.toString()}))]})}));function ct({value:e,sx:t}){var i;const o=q.useTheme();return n.jsx(v,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(i=o.palette.backgroundPaperElevation)==null?void 0:i[8],borderRadius:"10px",minWidth:"111px",...t},children:n.jsx(_,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:o.palette.text.primary,whiteSpace:"nowrap"},children:e})})}const Jt=E.observer(({store:e,useDegree:t})=>{const{t:o}=V.useTranslation();function i(r,s){return s?`ω = ${o("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:r})}`:`v = ${o("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:r})}`}return n.jsx(kt,{store:e,velocity:e.velocityInDisplayUnits(t),min:e.minVelocityInDisplayUnits(t),max:e.maxVelocityInDisplayUnits(t),onVelocityChange:e.setVelocityFromSlider,useDegree:t,disabled:e.isLocked,renderValue:r=>n.jsx(ct,{value:i(r,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),Rt=E.observer(({store:e})=>{var r,s,l;const{t}=V.useTranslation(),o=q.useTheme(),i=((l=(s=(r=e.jogger.motionStream.rapidlyChangingMotionState.execute)==null?void 0:r.details)==null?void 0:s.state)==null?void 0:l.kind)??"KIND_UNKNOWN";return n.jsxs(L,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",color:o.palette.text.primary},children:[n.jsx(_,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:t("Jogging.StreamStateSection.lb")}),n.jsx(_,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},"data-testid":i,children:t(`Jogging.StreamStateSection.${i}.lb`)})]})}),Ee=E.observer(({store:e,children:t})=>{const{t:o}=V.useTranslation(),i=q.useTheme(),r=C.useRef(0);function s(g,c){(c==="translate"||c==="rotate")&&e.setSelectedCartesianMotionType(c)}async function l(g,c){const y=await e.activate(),f=y.motionStream.rapidlyChangingMotionState.tcp_pose,m=y.motionStream.rapidlyChangingMotionState.joint_position;f&&await e.withMotionLock(async()=>{try{e.setCurrentIncrementJog({axis:g.axis,direction:g.direction}),await e.jogger.runIncrementalCartesianMotion({currentTcpPose:f,currentJoints:m,coordSystemId:e.activeCoordSystemId,velocityInRelevantUnits:e.selectedCartesianMotionType==="translate"?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec,axis:g.axis,direction:g.direction,motion:e.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:c.mm}:{type:"rotate",distanceRads:M.degreesToRadians(c.degrees)}})}finally{e.setCurrentIncrementJog(null),await e.deactivate()}})}async function a(g){if(e.isLocked)return;const c=++r.current;try{if(await e.activate(),c!==r.current)return;if(e.activeDiscreteIncrement)return await l(g,e.activeDiscreteIncrement);g.motionType==="translate"?await e.jogger.translateTCP({axis:g.axis,direction:g.direction,velocityMmPerSec:e.translationVelocityMmPerSec}):await e.jogger.rotateTCP({axis:g.axis,direction:g.direction,velocityRadsPerSec:e.rotationVelocityRadsPerSec})}catch(y){console.error("Jogging failed:",y)}}async function d(){e.isLocked||e.activeDiscreteIncrement||(r.current++,await e.deactivate())}const u=[{id:"x",icon:n.jsx(fe,{}),colors:z.cartesianAxisColors.X},{id:"y",icon:n.jsx(ye,{}),colors:z.cartesianAxisColors.Y},{id:"z",icon:n.jsx(Se,{}),colors:z.cartesianAxisColors.Z}];function h(g){return o("General.mm.variable",{amount:g.toFixed(1)})}function p(g){return o("General.degree.variable",{amount:M.radiansToDegrees(g).toFixed(1)})}return n.jsxs(v,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[n.jsxs(v,{gap:2,children:[n.jsx(Me,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),n.jsx(Jt,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),n.jsx(N,{})]}),n.jsx(v,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:n.jsxs(v,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[n.jsxs(_e,{value:e.selectedCartesianMotionType,onChange:s,exclusive:!0,"aria-label":o("Jogging.Cartesian.MotionType.lb"),sx:{justifyContent:"center"},children:[n.jsx(gt,{value:"translate",children:o("Jogging.Cartesian.Translation.bt")}),n.jsx(gt,{value:"rotate",children:o("Jogging.Cartesian.Rotation.bt")})]}),e.selectedCartesianMotionType==="translate"&&u.map(g=>{var c,y;return n.jsx(rt,{"data-testid":`jogging-cartesian-axis-control-${g.id}`,"aria-label":`jogging-cartesian-axis-control-${g.id}`,colors:g.colors,disabled:e.isLocked,activeJoggingDirection:((c=e.incrementJogInProgress)==null?void 0:c.axis)===g.id?e.incrementJogInProgress.direction:void 0,label:n.jsxs(n.Fragment,{children:[g.icon,n.jsx(_,{sx:{fontSize:"24px",color:((y=g.colors)==null?void 0:y.labelColor)??i.palette.text.primary},children:g.id.toUpperCase()})]}),getDisplayedValue:()=>{var f,m;return h(((m=(f=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:f.position)==null?void 0:m[M.XYZ_TO_VECTOR[g.id]])||0)},startJogging:f=>a({axis:g.id,motionType:"translate",direction:f}),stopJogging:d},g.id)}),e.selectedCartesianMotionType==="rotate"&&u.map(g=>{var c,y;return n.jsx(rt,{"data-testid":`jogging-cartesian-axis-control-${g.id}`,"aria-label":`jogging-cartesian-axis-control-${g.id}`,colors:g.colors,disabled:e.isLocked,activeJoggingDirection:((c=e.incrementJogInProgress)==null?void 0:c.axis)===g.id?e.incrementJogInProgress.direction:void 0,label:n.jsxs(n.Fragment,{children:[n.jsx(ve,{}),n.jsx(_,{sx:{fontSize:"24px",color:((y=g.colors)==null?void 0:y.labelColor)??i.palette.text.primary},children:g.id.toUpperCase()})]}),getDisplayedValue:()=>{var f,m;return p(((m=(f=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:f.orientation)==null?void 0:m[M.XYZ_TO_VECTOR[g.id]])||0)},startJogging:f=>a({axis:g.id,motionType:"rotate",direction:f}),stopJogging:d},g.id)})]})}),n.jsx(Tt,{store:e}),n.jsx(N,{}),n.jsx(Rt,{store:e}),t&&n.jsx(N,{}),t]})}),Te=E.observer(({store:e,children:t})=>{const o=q.useTheme(),i=C.useRef(0);async function r(l){const a=++i.current;try{if(await e.activate(),a!==i.current)return;await e.jogger.rotateJoints({joint:l.joint,direction:l.direction,velocityUnit:e.jointType===D.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:e.jointType===D.JointTypeEnum.PrismaticJoint?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec})}catch(d){console.error("Jogging failed:",d)}}async function s(){i.current++,await e.jogger.stop(),await e.deactivate()}return n.jsxs(v,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[n.jsx(Jt,{store:e,useDegree:e.jointType===D.JointTypeEnum.RevoluteJoint}),n.jsx(N,{}),n.jsx(v,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:n.jsx(v,{"data-testid":"jogging-joint-value-controls-wrapper","aria-label":"jogging-joint-value-controls-wrapper",alignItems:"center",gap:"24px",children:e.jogger.motionStream.joints.map(l=>{var d,u,h;const a=(h=(u=(d=e.motionGroupDescription.operation_limits.auto_limits)==null?void 0:d.joints)==null?void 0:u[l.index])==null?void 0:h.position;return n.jsxs(v,{"data-testid":`jogging-joint-value-control-${l.index}`,"aria-label":`jogging-joint-value-control-${l.index}`,direction:"row",alignItems:"center",justifyContent:"center",spacing:1.5,width:"100%",children:[e.showJointsLegend&&n.jsx(_,{color:e.isLocked?o.palette.text.disabled:o.palette.text.secondary,children:`G${l.index+1}`}),n.jsx(St,{disabled:e.isLocked,lowerLimit:a==null?void 0:a.lower_limit,upperLimit:a==null?void 0:a.upper_limit,useDegree:e.jointType===D.JointTypeEnum.RevoluteJoint,getValue:()=>{const p=e.jogger.motionStream.rapidlyChangingMotionState.joint_position[l.index];return p!==void 0?p:void 0},startJogging:p=>r({joint:l.index,direction:p}),stopJogging:s})]},`joint-${l.index}`)})})}),n.jsx(Tt,{store:e}),n.jsx(N,{}),n.jsx(Rt,{store:e}),t&&n.jsx(N,{}),t]})}),ke=W.externalizeComponent(E.observer(e=>{const t=E.useLocalObservable(()=>({joggingStore:null,loadingError:null}));return C.useEffect(()=>{let o=!1,i;async function r(){x.runInAction(()=>{t.loadingError=null,t.joggingStore=null});try{let s=e.store;if(!s){const l=await tt.open(e.nova,e.motionGroupId,{cellId:e.cellId});if(o){l.dispose();return}try{s=await et.loadFor(l)}catch(a){throw l.dispose(),a}if(i=s,o){s.dispose();return}}x.runInAction(()=>{t.joggingStore=s}),e.onSetup&&e.onSetup(s)}catch(s){if(o)return;x.runInAction(()=>{t.loadingError=s})}}return r(),()=>{o=!0,i==null||i.dispose()}},[e.store,e.nova,e.motionGroupId,e.cellId]),C.useEffect(()=>{const o=t.joggingStore;o&&(e.locked?o.lock("external"):o.unlock("external"))},[t.joggingStore,e.locked]),n.jsx(v,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...e.sx},children:t.joggingStore?n.jsx(Je,{store:t.joggingStore,children:e.children}):n.jsx(_t,{message:"Loading jogging",error:t.loadingError})})})),Je=E.observer(({store:e,children:t})=>{const{t:o}=V.useTranslation();function i(){if(e.currentTab.id==="cartesian")return n.jsx(Ee,{store:e,children:t});if(e.currentTab.id==="joint")return n.jsx(Te,{store:e,children:t})}return n.jsxs(v,{flexGrow:1,sx:{overflow:"hidden"},children:[n.jsx($t,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:e.tabIndex,onChange:e.onTabChange,variant:"fullWidth",children:e.tabs.map(r=>{const s=r.label==="Cartesian"?o("Jogging.Cartesian.bt"):o("Jogging.Joints.bt"),l=r.label==="cartesian"?n.jsx(qt,{fontSize:"small",sx:{mr:1}}):n.jsx(Ft,{fontSize:"small",sx:{mr:1}});return n.jsx(Bt,{"data-testid":`jogging-tab-${r.id}`,"aria-label":`jogging-tab-${r.id}`,label:e.showTabIcons?n.jsxs(v,{direction:"row",alignItems:"center",children:[l,s]}):s,id:`jogging-tab-${r.id}`,"aria-controls":`jogging-tab-${r.id}`},r.id)})}),n.jsx(v,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:i()}),e.blocked&&n.jsx(me,{store:e})]})});function Re(){const e=window.location.href;return e.substring(0,e.indexOf("/",e.indexOf("//")+2))}function Oe({baseUrl:e=Re(),...t}){return n.jsxs(ne,{"aria-labelledby":"no-motion-group-modal-title",open:!0,fullWidth:!0,sx:{"& .MuiModal-backdrop":{backdropFilter:"blur(10px)"},"& .MuiDialog-paper":{"::before":{content:'""',height:"8px",width:"100%",background:"linear-gradient(90deg, #FF0E65 0%, #47D3FF 100%)"},background:"#101629"}},children:[n.jsx(ae,{id:"no-motion-group-modal-title",children:"No motion group found"}),n.jsxs(se,{sx:{marginTop:"3rem",marginBottom:"1.5rem",textAlign:"center"},children:[n.jsx(_,{color:"#fff",children:"Found no devices to connect to."}),n.jsx(_,{color:"#fff",children:"Please ensure a motion group has been created."})]}),n.jsx(re,{children:n.jsxs(v,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[n.jsx(it,{href:`${e}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),n.jsx(it,{href:`${e}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}const mt=1e-4,Pe={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class K{constructor(t,o,i,r,s,l,a,d,u,h,p="cell"){this.controller=o,this.motionGroup=i,this.initialMotionState=r,this.motionStateSocket=s,this.isVirtual=l,this.tcps=a,this.description=d,this.initialControllerState=u,this.controllerStateSocket=h,this.cellId=p,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.nova=A.createNovaClient(t),this.rapidlyChangingMotionState=r,this.controllerState=u,h.addEventListener("message",g=>{var y;const c=(y=M.tryParseJson(g.data))==null?void 0:y.result;c&&x.runInAction(()=>{this.controllerState=c})}),s.addEventListener("message",g=>{var y;const c=(y=M.tryParseJson(g.data))==null?void 0:y.result;if(!c)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${g.data}`);at(this.rapidlyChangingMotionState.joint_position,c.joint_position,mt)||x.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=c.joint_position}),lt(this.rapidlyChangingMotionState,c,mt)||x.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=c.tcp_pose}),c.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==c.tcp&&x.runInAction(()=>{this.rapidlyChangingMotionState.tcp=c.tcp}),this.rapidlyChangingMotionState.standstill!==c.standstill&&x.runInAction(()=>{this.rapidlyChangingMotionState.standstill=c.standstill})}),x.makeAutoObservable(this)}static async connectMultiple(t,o,i={}){const r=A.createNovaClient(t),s=i.cellId??A.cellIdOf(t);return Promise.all(o.map(l=>K.connect(r,l,{...i,cellId:s})))}static async connect(t,o,i={}){var T,R;const r=A.createNovaClient(t),s=i.cellId??A.cellIdOf(t)??"cell",[l,a]=o.split("@"),d=await r.api.controller.getCurrentRobotControllerState(s,a),u=d==null?void 0:d.motion_groups.find(k=>k.motion_group===o);if(!d||!u)throw new Error(`Controller ${a} or motion group ${o} not found`);const h=r.openReconnectingWebsocket(`/cells/${s}/controllers/${a}/motion-groups/${o}/state-stream`),p=await h.firstMessage(),g=(T=M.tryParseJson(p.data))==null?void 0:T.result;if(!g)throw new Error(`Unable to parse initial motion state message ${p.data}`);console.log(`Connected motion state websocket to motion group ${u.motion_group}. Initial state:
|
|
2
|
+
`,g);const y=(await r.api.controller.getRobotController(s,d.controller)).configuration.kind==="VirtualController",f=await r.api.motionGroup.getMotionGroupDescription(s,a,u.motion_group),m=Object.entries(f.tcps||{}).map(([k,O])=>({id:k,readable_name:O.name,position:O.pose.position,orientation:O.pose.orientation})),j=r.openReconnectingWebsocket(`/cells/${s}/controllers/${d.controller}/state-stream?response_rate=1000`),I=await j.firstMessage(),w=(R=M.tryParseJson(I.data))==null?void 0:R.result;if(!w)throw new Error(`Unable to parse initial controller state message ${I.data}`);return console.log(`Connected controller state websocket to controller ${d.controller}. Initial state:
|
|
3
|
+
`,w),new K(r,d,u,g,h,y,m,f,w,j,s)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get modelFromController(){return this.description.motion_group_model}get joggingVelocityRads(){return this.joggingVelocity*Math.PI/180}get joints(){return this.initialMotionState.joint_position.map((t,o)=>({index:o}))}get dhParameters(){if(this.description.dh_parameters!==void 0)return this.description.dh_parameters.map(t=>({...Pe,...t}))}get safetyZones(){return this.description.safety_zones}get mountingPosition(){var t,o,i;return this.description.mounting?[(((t=this.description.mounting.position)==null?void 0:t[0])||0)/1e3,(((o=this.description.mounting.position)==null?void 0:o[1])||0)/1e3,(((i=this.description.mounting.position)==null?void 0:i[2])||0)/1e3]:[0,0,0]}get mountingQuaternion(){var r,s,l,a,d,u;const t=new dt.Vector3(((s=(r=this.description.mounting)==null?void 0:r.orientation)==null?void 0:s[0])||0,((a=(l=this.description.mounting)==null?void 0:l.orientation)==null?void 0:a[1])||0,((u=(d=this.description.mounting)==null?void 0:d.orientation)==null?void 0:u[2])||0),o=t.length(),i=t.normalize();return new dt.Quaternion().setFromAxisAngle(i,o)}get isEstopActive(){return["SAFETY_STATE_ROBOT_EMERGENCY_STOP","SAFETY_STATE_DEVICE_EMERGENCY_STOP"].includes(this.controllerState.safety_state)}get isMoveableSafetyState(){return["SAFETY_STATE_NORMAL","SAFETY_STATE_REDUCED"].includes(this.controllerState.safety_state)}get isMoveableOperationMode(){return["OPERATION_MODE_AUTO","OPERATION_MODE_MANUAL","OPERATION_MODE_MANUAL_T1","OPERATION_MODE_MANUAL_T2"].includes(this.controllerState.operation_mode)}get canBeMoved(){return this.isMoveableSafetyState&&this.isMoveableOperationMode&&this.activationState==="active"}async deactivate(){if(this.activationState!=="active"){console.error("Tried to deactivate while already deactivating");return}x.runInAction(()=>{this.activationState="deactivating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_MONITOR"),x.runInAction(()=>{this.activationState="inactive"})}catch(t){throw x.runInAction(()=>{this.activationState="active"}),t}}async activate(){if(this.activationState!=="inactive"){console.error("Tried to activate while already activating");return}x.runInAction(()=>{this.activationState="activating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_CONTROL"),x.runInAction(()=>{this.activationState="active"})}catch(t){throw x.runInAction(()=>{this.activationState="inactive"}),t}}toggleActivation(){this.activationState==="inactive"?this.activate():this.activationState==="active"&&this.deactivate()}dispose(){this.motionStateSocket.close(),this.controllerStateSocket.close(),this.connectedJoggingSocket&&this.connectedJoggingSocket.close()}setJoggingVelocity(t){this.joggingVelocity=t}}exports.AppHeader=le;exports.ConnectedMotionGroup=K;exports.JoggerConnection=tt;exports.JoggingCartesianAxisControl=rt;exports.JoggingJointValueControl=St;exports.JoggingPanel=ke;exports.JoggingStore=et;exports.LoadingCover=_t;exports.LoadingErrorMessage=Et;exports.MotionStreamConnection=Q;exports.NoMotionGroupModal=Oe;exports.VelocitySlider=kt;exports.VelocitySliderLabel=ct;exports.jointValuesEqual=bt;exports.jointValuesUnchanged=at;exports.poseEqual=Ct;exports.readoutOf=wt;exports.readoutsEqual=Mt;exports.tcpMotionEqual=lt;exports.unwrapRotationVector=It;
|