@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.5d2eede → 6.4.0-pr.revamp.667.d7cab79
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 +56 -5
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +1 -0
- package/dist/3d.js +16 -15
- package/dist/CurrentPoseBar/index.cjs +1 -1
- package/dist/CurrentPoseBar/index.js +1 -1
- package/dist/RobotControlPanel/index.cjs +1 -1
- package/dist/RobotControlPanel/index.js +1 -1
- package/dist/RobotHeader/index.js +1 -1
- package/dist/SafetyBar/index.js +1 -1
- package/dist/chunks/{CurrentPoseBar-zTZi68tY.js → CurrentPoseBar-DENCilvf.js} +1 -1
- package/dist/chunks/{CurrentPoseBar-CyHUWmjM.cjs → CurrentPoseBar-DrXTcV-I.cjs} +1 -1
- package/dist/chunks/{RobotControlPanel-BXtBHEe9.cjs → RobotControlPanel-DTE8-v2j.cjs} +1 -1
- package/dist/chunks/{RobotControlPanel-BiLexAWI.js → RobotControlPanel-E-hUzMIL.js} +1 -1
- package/dist/chunks/{RobotHeader-DDmDkUoV.js → RobotHeader-BvIzk8Fw.js} +1 -1
- package/dist/chunks/{SafetyBar-RkN0I1Cb.js → SafetyBar-eYzCHOFD.js} +1 -1
- package/dist/chunks/{converters-DAr6IQbG.js → converters-D9KpJ2HD.js} +2 -2
- package/dist/chunks/loadRobotSession-DlRzFjYE.cjs +3 -0
- package/dist/chunks/loadRobotSession-kKQ96rWu.js +4721 -0
- package/dist/chunks/robotModelSource-Bv1Z_miZ.cjs +1 -0
- package/dist/chunks/robotModelSource-CKuBOeQ-.js +1295 -0
- package/dist/chunks/useEveryFrame-B8t_yz-G.js +155 -0
- package/dist/chunks/useEveryFrame-CHxg25f4.cjs +1 -0
- package/dist/components/robotControl/poseText.d.ts +21 -5
- package/dist/components/robots/LinearAxis.d.ts +12 -11
- package/dist/components/robots/Robot.d.ts +26 -9
- package/dist/components/robots/robotModelSource.d.ts +38 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +10 -0
- package/dist/core.js +58 -39
- package/dist/index.cjs +1 -1
- package/dist/index.js +86 -66
- package/dist/lib/ConnectedMotionGroup.d.ts +5 -1
- package/dist/lib/controllerStateSource.d.ts +6 -4
- package/dist/lib/motionGroupModelResources.d.ts +1 -0
- package/dist/lib/nats/natsControllerStateSource.d.ts +27 -0
- package/dist/lib/robotSession/RobotActivation.d.ts +48 -0
- package/dist/lib/robotSession/RobotDescription.d.ts +84 -0
- package/dist/lib/robotSession/RobotLiveState.d.ts +56 -0
- package/dist/lib/robotSession/RobotLoadProgress.d.ts +72 -0
- package/dist/lib/robotSession/RobotSafety.d.ts +59 -0
- package/dist/lib/robotSession/RobotSession.d.ts +78 -0
- package/dist/lib/robotSession/RobotTargetPose.d.ts +78 -0
- package/dist/lib/robotSession/loadRobotResources.d.ts +46 -0
- package/dist/lib/robotSession/loadRobotSession.d.ts +81 -0
- package/dist/lib/robotSession/robotPose.d.ts +28 -0
- package/dist/nats.cjs +1 -0
- package/dist/nats.d.ts +4 -0
- package/dist/nats.js +131 -0
- package/package.json +11 -1
- package/dist/chunks/Robot-B3vKEVXP.cjs +0 -1
- package/dist/chunks/Robot-DXhaz1tq.js +0 -1272
- package/dist/chunks/TrajectoryExecutionStore-CKfEoKo8.cjs +0 -3
- package/dist/chunks/TrajectoryExecutionStore-DYVukgCz.js +0 -3613
- package/dist/chunks/useEveryFrame-G_-ma1nC.js +0 -142
- package/dist/chunks/useEveryFrame-dmPPTKtT.cjs +0 -1
|
@@ -0,0 +1,4721 @@
|
|
|
1
|
+
import { jsxs as _, Fragment as st, jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import Se from "@mui/material/AppBar";
|
|
3
|
+
import Gt from "@mui/material/Backdrop";
|
|
4
|
+
import B from "@mui/material/Box";
|
|
5
|
+
import ve from "@mui/material/Menu";
|
|
6
|
+
import W from "@mui/material/MenuItem";
|
|
7
|
+
import _e from "@mui/material/Toolbar";
|
|
8
|
+
import M from "@mui/material/Typography";
|
|
9
|
+
import { ZeroGravityComponentsBackdropFill as be } from "@wandelbots/design-tokens";
|
|
10
|
+
import { ExpandMoreFilled as Ce } from "@wandelbots/icons/ExpandMoreFilled";
|
|
11
|
+
import { RoundedIconButton as we } from "@wandelbots/mui";
|
|
12
|
+
import { observer as A, useLocalObservable as Ut } from "mobx-react-lite";
|
|
13
|
+
import * as b from "react";
|
|
14
|
+
import { useState as ot, forwardRef as Y, useEffect as at, useRef as gt, useId as Ee } from "react";
|
|
15
|
+
import { e as it } from "./externalizeComponent-_w2d1_pz.js";
|
|
16
|
+
import Ie from "@mui/icons-material/OpenWith";
|
|
17
|
+
import Me from "@mui/icons-material/Share";
|
|
18
|
+
import C from "@mui/material/Stack";
|
|
19
|
+
import Te from "@mui/material/Tab";
|
|
20
|
+
import je from "@mui/material/Tabs";
|
|
21
|
+
import { runInAction as S, makeAutoObservable as D, computed as zt, when as lt, autorun as Et, reaction as Z } from "mobx";
|
|
22
|
+
import { useTranslation as F } from "react-i18next";
|
|
23
|
+
import Wt from "@mui/material/CircularProgress";
|
|
24
|
+
import { capitalize as xe } from "@mui/material/utils";
|
|
25
|
+
import { lowerFirst as Oe, countBy as ke } from "lodash-es";
|
|
26
|
+
import { m as Re } from "./SafetyBar-eYzCHOFD.js";
|
|
27
|
+
import Ae from "@mui/material/Alert";
|
|
28
|
+
import Pe from "@mui/material/AlertTitle";
|
|
29
|
+
import St from "@mui/material/Button";
|
|
30
|
+
import { useTheme as K, styled as Ht } from "@mui/material/styles";
|
|
31
|
+
import H from "@mui/material/Divider";
|
|
32
|
+
import It from "@mui/material/ToggleButton";
|
|
33
|
+
import { radiansToDegrees as Yt, tryParseJson as J, XYZ_TO_VECTOR as Mt, degreesToRadians as Je, makeErrorMessage as z } from "@wandelbots/nova-js";
|
|
34
|
+
import ct from "@mui/material/IconButton";
|
|
35
|
+
import { d as wt, p as Tt, q as De, c as U, e as X, P as V } from "./Pose3-pocKPrHN.js";
|
|
36
|
+
import { e as jt, v as $e, c as pt } from "./joggingColors-CuT5u0H8.js";
|
|
37
|
+
import Kt from "lodash-es/isEqual.js";
|
|
38
|
+
import Le from "@mui/material/InputAdornment";
|
|
39
|
+
import Ne from "@mui/material/FormControl";
|
|
40
|
+
import Ve from "@mui/material/InputLabel";
|
|
41
|
+
import Fe from "@mui/material/Select";
|
|
42
|
+
import Be from "@mui/material/ToggleButtonGroup";
|
|
43
|
+
import Qt from "@mui/material/Slider";
|
|
44
|
+
import Ge from "lodash-es/isNumber.js";
|
|
45
|
+
import { JointTypeEnum as N } from "@wandelbots/nova-js/v2";
|
|
46
|
+
import Ue from "@mui/icons-material/ChevronLeft";
|
|
47
|
+
import ze from "@mui/icons-material/ChevronRight";
|
|
48
|
+
import We from "lodash-es/throttle.js";
|
|
49
|
+
import He from "@mui/material/Dialog";
|
|
50
|
+
import Ye from "@mui/material/DialogActions";
|
|
51
|
+
import Ke from "@mui/material/DialogContent";
|
|
52
|
+
import Qe from "@mui/material/DialogTitle";
|
|
53
|
+
import * as xt from "three";
|
|
54
|
+
import { Vector3 as tt, Quaternion as qe } from "three";
|
|
55
|
+
import { t as qt } from "./converters-D9KpJ2HD.js";
|
|
56
|
+
import { isAxiosError as Zt } from "axios";
|
|
57
|
+
import q from "lodash-es/keyBy.js";
|
|
58
|
+
import Ze from "lodash-es/uniqueId.js";
|
|
59
|
+
import { j as Ot, b as kt, p as Xe, a as to } from "./useEveryFrame-B8t_yz-G.js";
|
|
60
|
+
const Tn = it(
|
|
61
|
+
A((o) => {
|
|
62
|
+
const {
|
|
63
|
+
appIcon: t,
|
|
64
|
+
appName: e,
|
|
65
|
+
apps: i = [],
|
|
66
|
+
onAppSelect: n,
|
|
67
|
+
disabled: r = !1,
|
|
68
|
+
sx: s
|
|
69
|
+
} = o, [a, d] = ot(null), h = !!a, c = (l) => {
|
|
70
|
+
d(l.currentTarget);
|
|
71
|
+
}, m = () => {
|
|
72
|
+
d(null);
|
|
73
|
+
}, u = (l) => {
|
|
74
|
+
m(), l.onClick ? l.onClick() : l.href && (window.location.href = l.href), n == null || n(l);
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ _(st, { children: [
|
|
77
|
+
/* @__PURE__ */ g(
|
|
78
|
+
Se,
|
|
79
|
+
{
|
|
80
|
+
position: "static",
|
|
81
|
+
sx: {
|
|
82
|
+
boxShadow: "none",
|
|
83
|
+
backgroundImage: "none",
|
|
84
|
+
"& .MuiAppBar-root": {
|
|
85
|
+
backgroundImage: "none",
|
|
86
|
+
backgroundColor: "transparent"
|
|
87
|
+
},
|
|
88
|
+
...s
|
|
89
|
+
},
|
|
90
|
+
children: /* @__PURE__ */ _(_e, { sx: { minHeight: "62px !important" }, children: [
|
|
91
|
+
/* @__PURE__ */ g(B, { sx: { mr: 1, display: "flex", alignItems: "center" }, children: t }),
|
|
92
|
+
/* @__PURE__ */ _(B, { sx: { display: "flex", alignItems: "center", flexGrow: 1 }, children: [
|
|
93
|
+
/* @__PURE__ */ g(M, { component: "h1", variant: "subtitle1", children: e }),
|
|
94
|
+
i.length > 0 && /* @__PURE__ */ g(
|
|
95
|
+
we,
|
|
96
|
+
{
|
|
97
|
+
icon: /* @__PURE__ */ g(Ce, { size: 20 }),
|
|
98
|
+
ariaLabel: "switch app",
|
|
99
|
+
"aria-controls": "app-menu",
|
|
100
|
+
"aria-haspopup": "true",
|
|
101
|
+
onClick: c,
|
|
102
|
+
disabled: r,
|
|
103
|
+
sx: { ml: 1 }
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] })
|
|
107
|
+
] })
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ g(
|
|
111
|
+
Gt,
|
|
112
|
+
{
|
|
113
|
+
open: h,
|
|
114
|
+
onClick: m,
|
|
115
|
+
sx: {
|
|
116
|
+
backdropFilter: "blur(4px)",
|
|
117
|
+
backgroundColor: be,
|
|
118
|
+
zIndex: (l) => l.zIndex.modal - 1
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
/* @__PURE__ */ g(
|
|
123
|
+
ve,
|
|
124
|
+
{
|
|
125
|
+
id: "app-menu",
|
|
126
|
+
anchorEl: a,
|
|
127
|
+
open: h,
|
|
128
|
+
onClose: m,
|
|
129
|
+
anchorOrigin: {
|
|
130
|
+
vertical: "bottom",
|
|
131
|
+
horizontal: "left"
|
|
132
|
+
},
|
|
133
|
+
transformOrigin: {
|
|
134
|
+
vertical: "top",
|
|
135
|
+
horizontal: "left"
|
|
136
|
+
},
|
|
137
|
+
sx: {
|
|
138
|
+
zIndex: (l) => l.zIndex.modal,
|
|
139
|
+
"& .MuiPaper-root": {
|
|
140
|
+
minWidth: 200,
|
|
141
|
+
mt: 1
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
children: i.map((l) => /* @__PURE__ */ _(W, { onClick: () => u(l), children: [
|
|
145
|
+
/* @__PURE__ */ g(B, { sx: { display: "flex", alignItems: "center" }, children: l.icon }),
|
|
146
|
+
/* @__PURE__ */ g(M, { variant: "body1", sx: { ml: 2 }, children: l.name })
|
|
147
|
+
] }, l.id))
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
] });
|
|
151
|
+
})
|
|
152
|
+
), eo = ({
|
|
153
|
+
title: o,
|
|
154
|
+
titleId: t,
|
|
155
|
+
...e
|
|
156
|
+
}, i) => /* @__PURE__ */ 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, ...e }, o ? /* @__PURE__ */ b.createElement("title", { id: t }, o) : null, /* @__PURE__ */ b.createElement("g", { id: "JogMinus" }, /* @__PURE__ */ b.createElement("path", { id: "Minus", d: "M0 13V8H21V13H0Z", fill: "white" }))), oo = Y(eo), io = ({
|
|
157
|
+
title: o,
|
|
158
|
+
titleId: t,
|
|
159
|
+
...e
|
|
160
|
+
}, i) => /* @__PURE__ */ 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, ...e }, o ? /* @__PURE__ */ b.createElement("title", { id: t }, o) : null, /* @__PURE__ */ b.createElement("g", { id: "JogPlus" }, /* @__PURE__ */ b.createElement("g", { id: "Plus" }, /* @__PURE__ */ b.createElement("path", { d: "M0 13V8H8V13H0Z", fill: "white" }), /* @__PURE__ */ b.createElement("path", { d: "M8 0L13 2.18557e-07L13 21H8L8 0Z", fill: "white" }), /* @__PURE__ */ b.createElement("path", { d: "M13 13V8H21V13H13Z", fill: "white" })))), no = Y(io), Rt = it(
|
|
161
|
+
A(
|
|
162
|
+
({
|
|
163
|
+
colors: o,
|
|
164
|
+
label: t,
|
|
165
|
+
getDisplayedValue: e,
|
|
166
|
+
startJogging: i,
|
|
167
|
+
stopJogging: n,
|
|
168
|
+
disabled: r,
|
|
169
|
+
activeJoggingDirection: s,
|
|
170
|
+
...a
|
|
171
|
+
}) => {
|
|
172
|
+
var T, j, x, E, O, L, G;
|
|
173
|
+
wt(() => {
|
|
174
|
+
const P = e(), $ = u.current;
|
|
175
|
+
$ && ($.textContent = P);
|
|
176
|
+
});
|
|
177
|
+
const d = K(), [h, c] = ot(null);
|
|
178
|
+
at(() => {
|
|
179
|
+
r && I();
|
|
180
|
+
}, [r]);
|
|
181
|
+
const m = s || h, u = gt(null);
|
|
182
|
+
o || (o = {
|
|
183
|
+
color: "#fff",
|
|
184
|
+
backgroundColor: "#000",
|
|
185
|
+
borderColor: "#000",
|
|
186
|
+
buttonBackgroundColor: {
|
|
187
|
+
disabled: "#000",
|
|
188
|
+
default: "#000",
|
|
189
|
+
hovered: "#000",
|
|
190
|
+
pressed: "#000"
|
|
191
|
+
},
|
|
192
|
+
labelColor: "#000"
|
|
193
|
+
});
|
|
194
|
+
const l = m ? (T = o.buttonBackgroundColor) == null ? void 0 : T.pressed : o.borderColor, p = {
|
|
195
|
+
width: "55px",
|
|
196
|
+
color: o.color,
|
|
197
|
+
path: { fill: o.color },
|
|
198
|
+
alignContent: "center",
|
|
199
|
+
fontSize: "37px",
|
|
200
|
+
svg: {
|
|
201
|
+
pointerEvents: "none"
|
|
202
|
+
}
|
|
203
|
+
}, f = {
|
|
204
|
+
...p,
|
|
205
|
+
backgroundColor: (j = o.buttonBackgroundColor) == null ? void 0 : j.default,
|
|
206
|
+
":hover": {
|
|
207
|
+
backgroundColor: (x = o.buttonBackgroundColor) == null ? void 0 : x.hovered
|
|
208
|
+
},
|
|
209
|
+
":active": {
|
|
210
|
+
backgroundColor: (E = o.buttonBackgroundColor) == null ? void 0 : E.pressed,
|
|
211
|
+
color: o.backgroundColor,
|
|
212
|
+
path: { fill: o.backgroundColor }
|
|
213
|
+
},
|
|
214
|
+
":disabled": {
|
|
215
|
+
backgroundColor: (O = o.buttonBackgroundColor) == null ? void 0 : O.disabled,
|
|
216
|
+
"svg path": { fill: d.palette.action.disabled }
|
|
217
|
+
}
|
|
218
|
+
}, v = {
|
|
219
|
+
...p,
|
|
220
|
+
backgroundColor: (L = o.buttonBackgroundColor) == null ? void 0 : L.pressed,
|
|
221
|
+
color: o.backgroundColor,
|
|
222
|
+
path: { fill: o.backgroundColor },
|
|
223
|
+
":disabled": {
|
|
224
|
+
backgroundColor: (G = o.buttonBackgroundColor) == null ? void 0 : G.pressed,
|
|
225
|
+
"svg path": { fill: d.palette.action.disabled }
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
function w(P, $) {
|
|
229
|
+
r || P.button === 0 && (c($), i($));
|
|
230
|
+
}
|
|
231
|
+
function I() {
|
|
232
|
+
c(null), n();
|
|
233
|
+
}
|
|
234
|
+
return /* @__PURE__ */ _(C, { height: "64px", direction: "row", justifyContent: "center", ...a, children: [
|
|
235
|
+
/* @__PURE__ */ g(
|
|
236
|
+
ct,
|
|
237
|
+
{
|
|
238
|
+
disabled: r,
|
|
239
|
+
disableRipple: !0,
|
|
240
|
+
onPointerDown: (P) => w(P, "-"),
|
|
241
|
+
onPointerUp: I,
|
|
242
|
+
onPointerOut: I,
|
|
243
|
+
size: "large",
|
|
244
|
+
sx: {
|
|
245
|
+
...m === "-" ? v : f,
|
|
246
|
+
borderRadius: "16px 0px 0px 16px",
|
|
247
|
+
borderLeft: `2px solid ${l ?? "#fff"}`,
|
|
248
|
+
borderBottom: `2px solid ${l ?? "#fff"}`,
|
|
249
|
+
borderTop: `2px solid ${l ?? "#fff"}`
|
|
250
|
+
},
|
|
251
|
+
children: /* @__PURE__ */ g(oo, {})
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
/* @__PURE__ */ _(
|
|
255
|
+
C,
|
|
256
|
+
{
|
|
257
|
+
spacing: "6px",
|
|
258
|
+
sx: {
|
|
259
|
+
width: "150px",
|
|
260
|
+
backgroundColor: o.backgroundColor,
|
|
261
|
+
alignItems: "center",
|
|
262
|
+
justifyContent: "center",
|
|
263
|
+
opacity: "0.9",
|
|
264
|
+
borderBottom: `2px solid ${l ?? "#fff"}`,
|
|
265
|
+
borderTop: `2px solid ${l ?? "#fff"}`
|
|
266
|
+
},
|
|
267
|
+
children: [
|
|
268
|
+
/* @__PURE__ */ g(
|
|
269
|
+
C,
|
|
270
|
+
{
|
|
271
|
+
height: "22px",
|
|
272
|
+
direction: "row",
|
|
273
|
+
alignItems: "center",
|
|
274
|
+
justifyItems: "center",
|
|
275
|
+
spacing: 1,
|
|
276
|
+
sx: {
|
|
277
|
+
userSelect: "none",
|
|
278
|
+
color: o.color,
|
|
279
|
+
".MuiTypography-root": {
|
|
280
|
+
fontWeight: 700,
|
|
281
|
+
...r ? { color: d.palette.action.disabled } : {}
|
|
282
|
+
},
|
|
283
|
+
...r ? { "svg path": { fill: d.palette.action.disabled } } : {}
|
|
284
|
+
},
|
|
285
|
+
children: t
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
/* @__PURE__ */ g(
|
|
289
|
+
M,
|
|
290
|
+
{
|
|
291
|
+
height: "22px",
|
|
292
|
+
sx: {
|
|
293
|
+
fontSize: "15px",
|
|
294
|
+
color: r ? d.palette.action.disabled : o.color,
|
|
295
|
+
fontWeight: 700,
|
|
296
|
+
fontVariantNumeric: "tabular-nums",
|
|
297
|
+
minWidth: "80px",
|
|
298
|
+
textAlign: "center"
|
|
299
|
+
},
|
|
300
|
+
ref: u,
|
|
301
|
+
children: e()
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
/* @__PURE__ */ g(
|
|
308
|
+
ct,
|
|
309
|
+
{
|
|
310
|
+
disableRipple: !0,
|
|
311
|
+
disabled: r,
|
|
312
|
+
onPointerDown: (P) => w(P, "+"),
|
|
313
|
+
onPointerUp: I,
|
|
314
|
+
onPointerOut: I,
|
|
315
|
+
size: "large",
|
|
316
|
+
sx: {
|
|
317
|
+
...m === "+" ? v : f,
|
|
318
|
+
borderRadius: "0px 16px 16px 0px",
|
|
319
|
+
borderRight: `2px solid ${l ?? "#fff"}`,
|
|
320
|
+
borderBottom: `2px solid ${l ?? "#fff"}`,
|
|
321
|
+
borderTop: `2px solid ${l ?? "#fff"}`
|
|
322
|
+
},
|
|
323
|
+
children: /* @__PURE__ */ g(no, {})
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
] });
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
), ro = it(
|
|
330
|
+
A(
|
|
331
|
+
({
|
|
332
|
+
startJogging: o,
|
|
333
|
+
stopJogging: t,
|
|
334
|
+
lowerLimit: e,
|
|
335
|
+
upperLimit: i,
|
|
336
|
+
useDegree: n,
|
|
337
|
+
getValue: r,
|
|
338
|
+
disabled: s,
|
|
339
|
+
...a
|
|
340
|
+
}) => {
|
|
341
|
+
var E, O, L, G, P, $, nt;
|
|
342
|
+
const { t: d } = F(), [h, c] = ot(), m = K(), u = {
|
|
343
|
+
background: (E = m.palette.backgroundPaperElevation) == null ? void 0 : E[4],
|
|
344
|
+
color: (O = m.palette.backgroundPaperElevation) == null ? void 0 : O[11]
|
|
345
|
+
}, l = Ut(() => ({
|
|
346
|
+
activeJoggingDir: null,
|
|
347
|
+
startJogging(y) {
|
|
348
|
+
this.activeJoggingDir = y, o(y);
|
|
349
|
+
},
|
|
350
|
+
stopJogging() {
|
|
351
|
+
this.activeJoggingDir = null, t();
|
|
352
|
+
}
|
|
353
|
+
})), p = We(() => {
|
|
354
|
+
const y = n ? f(r()) : r();
|
|
355
|
+
(y === void 0 || h === void 0 || Math.abs(h - y) > 1e-9) && c(y);
|
|
356
|
+
}, 50);
|
|
357
|
+
wt(p);
|
|
358
|
+
function f(y) {
|
|
359
|
+
if (y !== void 0)
|
|
360
|
+
return Yt(y);
|
|
361
|
+
}
|
|
362
|
+
function v(y) {
|
|
363
|
+
y.button === 0 && l.startJogging("-");
|
|
364
|
+
}
|
|
365
|
+
function w(y) {
|
|
366
|
+
y.button === 0 && l.startJogging("+");
|
|
367
|
+
}
|
|
368
|
+
function I(y) {
|
|
369
|
+
l.stopJogging();
|
|
370
|
+
}
|
|
371
|
+
function T(y) {
|
|
372
|
+
l.stopJogging();
|
|
373
|
+
}
|
|
374
|
+
function j(y, k = 1) {
|
|
375
|
+
if (y === void 0 || Number.isNaN(y)) return "";
|
|
376
|
+
const R = d("General.degree.variable", {
|
|
377
|
+
amount: y.toFixed(k)
|
|
378
|
+
});
|
|
379
|
+
return y > 0 && k === 0 ? `+${R}` : R;
|
|
380
|
+
}
|
|
381
|
+
function x(y, k = 1) {
|
|
382
|
+
if (y === void 0 || Number.isNaN(y)) return "";
|
|
383
|
+
const R = d("General.mm.variable", {
|
|
384
|
+
amount: y.toFixed(k)
|
|
385
|
+
});
|
|
386
|
+
return y > 0 && k === 0 ? `+${R}` : R;
|
|
387
|
+
}
|
|
388
|
+
return /* @__PURE__ */ _(
|
|
389
|
+
C,
|
|
390
|
+
{
|
|
391
|
+
height: "64px",
|
|
392
|
+
width: "100%",
|
|
393
|
+
maxWidth: "260px",
|
|
394
|
+
direction: "row",
|
|
395
|
+
...a,
|
|
396
|
+
sx: {
|
|
397
|
+
"& .MuiIconButton-root": {
|
|
398
|
+
width: "52px",
|
|
399
|
+
color: m.palette.text.primary,
|
|
400
|
+
alignContent: "center",
|
|
401
|
+
backgroundColor: (L = m.palette.backgroundPaperElevation) == null ? void 0 : L[11],
|
|
402
|
+
"& svg": {
|
|
403
|
+
width: "42px",
|
|
404
|
+
height: "42px"
|
|
405
|
+
},
|
|
406
|
+
"&.Mui-disabled": {
|
|
407
|
+
backgroundColor: (G = m.palette.backgroundPaperElevation) == null ? void 0 : G[11],
|
|
408
|
+
color: m.palette.action.disabled,
|
|
409
|
+
opacity: 1
|
|
410
|
+
},
|
|
411
|
+
"&:hover": {
|
|
412
|
+
backgroundColor: (P = m.palette.backgroundPaperElevation) == null ? void 0 : P[9]
|
|
413
|
+
},
|
|
414
|
+
"&:active": {
|
|
415
|
+
...u
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
children: [
|
|
420
|
+
/* @__PURE__ */ g(
|
|
421
|
+
ct,
|
|
422
|
+
{
|
|
423
|
+
onPointerDown: v,
|
|
424
|
+
onPointerUp: I,
|
|
425
|
+
onPointerOut: T,
|
|
426
|
+
disabled: s,
|
|
427
|
+
disableRipple: !0,
|
|
428
|
+
sx: {
|
|
429
|
+
borderRadius: "16px 0px 0px 16px",
|
|
430
|
+
...l.activeJoggingDir === "-" ? u : {}
|
|
431
|
+
},
|
|
432
|
+
children: /* @__PURE__ */ g(
|
|
433
|
+
Ue,
|
|
434
|
+
{
|
|
435
|
+
sx: {
|
|
436
|
+
pointerEvents: "none",
|
|
437
|
+
color: jt
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
}
|
|
442
|
+
),
|
|
443
|
+
/* @__PURE__ */ _(
|
|
444
|
+
C,
|
|
445
|
+
{
|
|
446
|
+
flexGrow: 1,
|
|
447
|
+
alignItems: "center",
|
|
448
|
+
justifyContent: "center",
|
|
449
|
+
sx: {
|
|
450
|
+
borderStyle: "solid",
|
|
451
|
+
borderLeftWidth: 0,
|
|
452
|
+
borderRightWidth: 0,
|
|
453
|
+
border: "none",
|
|
454
|
+
backgroundColor: ($ = m.palette.backgroundPaperElevation) == null ? void 0 : $[11],
|
|
455
|
+
paddingLeft: "20px",
|
|
456
|
+
paddingRight: "20px",
|
|
457
|
+
zIndex: 1
|
|
458
|
+
},
|
|
459
|
+
children: [
|
|
460
|
+
/* @__PURE__ */ g(
|
|
461
|
+
M,
|
|
462
|
+
{
|
|
463
|
+
sx: {
|
|
464
|
+
fontSize: "15px",
|
|
465
|
+
fontWeight: 700,
|
|
466
|
+
position: "relative",
|
|
467
|
+
top: "5px",
|
|
468
|
+
fontVariantNumeric: "tabular-nums",
|
|
469
|
+
minWidth: "80px",
|
|
470
|
+
textAlign: "center",
|
|
471
|
+
color: s ? m.palette.action.disabled : m.palette.text.primary
|
|
472
|
+
},
|
|
473
|
+
children: n ? j(h) : x(h)
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
/* @__PURE__ */ g(
|
|
477
|
+
Qt,
|
|
478
|
+
{
|
|
479
|
+
disabled: !0,
|
|
480
|
+
"aria-label": "Joint position",
|
|
481
|
+
min: n ? f(e) : e,
|
|
482
|
+
max: n ? f(i) : i,
|
|
483
|
+
value: h || 0,
|
|
484
|
+
track: !1,
|
|
485
|
+
sx: {
|
|
486
|
+
"& .MuiSlider-mark": {
|
|
487
|
+
display: "none"
|
|
488
|
+
},
|
|
489
|
+
"& .MuiSlider-thumb": {
|
|
490
|
+
width: "5px",
|
|
491
|
+
height: "12px",
|
|
492
|
+
borderRadius: "2px",
|
|
493
|
+
color: s ? m.palette.action.disabled : m.palette.text.primary
|
|
494
|
+
},
|
|
495
|
+
"& .MuiSlider-markLabel": {
|
|
496
|
+
top: "20px",
|
|
497
|
+
fontSize: "12px",
|
|
498
|
+
color: s ? m.palette.action.disabled : m.palette.text.secondary
|
|
499
|
+
},
|
|
500
|
+
"& .MuiSlider-rail": {
|
|
501
|
+
backgroundColor: (nt = m.palette.backgroundPaperElevation) == null ? void 0 : nt[5],
|
|
502
|
+
opacity: 1
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
marks: e !== void 0 && i !== void 0 && [
|
|
506
|
+
{
|
|
507
|
+
value: n ? f(e) : e,
|
|
508
|
+
label: n ? j(f(e), 0) : x(e)
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
value: n ? f(i) : i,
|
|
512
|
+
label: n ? j(f(i), 0) : x(i)
|
|
513
|
+
}
|
|
514
|
+
]
|
|
515
|
+
}
|
|
516
|
+
)
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
/* @__PURE__ */ g(
|
|
521
|
+
ct,
|
|
522
|
+
{
|
|
523
|
+
onPointerDown: w,
|
|
524
|
+
onPointerUp: I,
|
|
525
|
+
onPointerOut: T,
|
|
526
|
+
disabled: s,
|
|
527
|
+
disableRipple: !0,
|
|
528
|
+
sx: {
|
|
529
|
+
borderRadius: "0px 16px 16px 0px",
|
|
530
|
+
...l.activeJoggingDir === "+" ? u : {}
|
|
531
|
+
},
|
|
532
|
+
children: /* @__PURE__ */ g(
|
|
533
|
+
ze,
|
|
534
|
+
{
|
|
535
|
+
sx: {
|
|
536
|
+
pointerEvents: "none",
|
|
537
|
+
color: jt
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
)
|
|
541
|
+
}
|
|
542
|
+
)
|
|
543
|
+
]
|
|
544
|
+
}
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
)
|
|
548
|
+
);
|
|
549
|
+
function so({
|
|
550
|
+
currentTcpPose: o,
|
|
551
|
+
axis: t,
|
|
552
|
+
direction: e,
|
|
553
|
+
motion: i,
|
|
554
|
+
useToolCoordinateSystem: n,
|
|
555
|
+
coordinateSystemRotation: r
|
|
556
|
+
}) {
|
|
557
|
+
const s = e === "-" ? -1 : 1;
|
|
558
|
+
if (i.type === "translate") {
|
|
559
|
+
if (!o.position)
|
|
560
|
+
throw new Error(
|
|
561
|
+
"Current pose has no position, cannot perform translation"
|
|
562
|
+
);
|
|
563
|
+
const m = i.distanceMm * s, u = new tt();
|
|
564
|
+
if (u[t] = m, n) {
|
|
565
|
+
if (!o.orientation)
|
|
566
|
+
throw new Error(
|
|
567
|
+
"Current pose has no orientation, cannot translate relative to tool"
|
|
568
|
+
);
|
|
569
|
+
u.applyQuaternion(
|
|
570
|
+
Tt(
|
|
571
|
+
o.orientation,
|
|
572
|
+
"ROTATION_VECTOR"
|
|
573
|
+
)
|
|
574
|
+
);
|
|
575
|
+
} else r && u.applyQuaternion(r);
|
|
576
|
+
const l = [...o.position];
|
|
577
|
+
return l[0] = (l[0] ?? 0) + u.x, l[1] = (l[1] ?? 0) + u.y, l[2] = (l[2] ?? 0) + u.z, {
|
|
578
|
+
position: l,
|
|
579
|
+
orientation: o.orientation
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
if (!o.orientation)
|
|
583
|
+
throw new Error("Current pose has no orientation, cannot perform rotation");
|
|
584
|
+
const a = Tt(
|
|
585
|
+
o.orientation,
|
|
586
|
+
"ROTATION_VECTOR"
|
|
587
|
+
), d = new tt();
|
|
588
|
+
d[t] = 1, !n && r && d.applyQuaternion(r);
|
|
589
|
+
const h = new qe().setFromAxisAngle(
|
|
590
|
+
d,
|
|
591
|
+
i.distanceRads * s
|
|
592
|
+
), c = n ? a.multiply(h) : h.multiply(a);
|
|
593
|
+
return {
|
|
594
|
+
position: o.position,
|
|
595
|
+
orientation: [...De(c)]
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function ht(o, t, e) {
|
|
599
|
+
return t.length !== o.length ? !1 : te(o, t, e);
|
|
600
|
+
}
|
|
601
|
+
function Xt(o, t, e) {
|
|
602
|
+
return t.length !== o.length ? !0 : te(o, t, e);
|
|
603
|
+
}
|
|
604
|
+
function te(o, t, e) {
|
|
605
|
+
for (let i = 0; i < t.length; i++)
|
|
606
|
+
if (Math.abs(
|
|
607
|
+
(t[i] ?? 0) - (o[i] ?? 0)
|
|
608
|
+
) > e)
|
|
609
|
+
return !1;
|
|
610
|
+
return !0;
|
|
611
|
+
}
|
|
612
|
+
function ao(o, t, e) {
|
|
613
|
+
if (o === void 0 && t || o && t === void 0 || (o == null ? void 0 : o.orientation) === void 0 || (t == null ? void 0 : t.orientation) === void 0 || (o == null ? void 0 : o.position) === void 0 || (t == null ? void 0 : t.position) === void 0)
|
|
614
|
+
return !1;
|
|
615
|
+
if (o === void 0 || t === void 0)
|
|
616
|
+
return !0;
|
|
617
|
+
let i = 0;
|
|
618
|
+
return i += Math.abs(o.orientation[0] - t.orientation[0]), i += Math.abs(o.orientation[1] - t.orientation[1]), i += Math.abs(o.orientation[2] - t.orientation[2]), i += Math.abs(o.position[0] - t.position[0]), i += Math.abs(o.position[1] - t.position[1]), i += Math.abs(o.position[2] - t.position[2]), i <= e;
|
|
619
|
+
}
|
|
620
|
+
function ee(o, t, e) {
|
|
621
|
+
return o.coordinate_system === t.coordinate_system && o.tcp === t.tcp && ao(
|
|
622
|
+
o.tcp_pose,
|
|
623
|
+
t.tcp_pose,
|
|
624
|
+
e
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
function oe(o, t) {
|
|
628
|
+
const e = new tt(
|
|
629
|
+
t[0],
|
|
630
|
+
t[1],
|
|
631
|
+
t[2]
|
|
632
|
+
), i = new tt(
|
|
633
|
+
o[0],
|
|
634
|
+
o[1],
|
|
635
|
+
o[2]
|
|
636
|
+
), n = e.length(), r = e.normalize();
|
|
637
|
+
let s = i.length(), a = i.normalize();
|
|
638
|
+
a.dot(r) < 0 && (s = -s, a = a.multiplyScalar(-1));
|
|
639
|
+
let d = s - n;
|
|
640
|
+
return d -= 2 * Math.PI * Math.floor((d + Math.PI) / (2 * Math.PI)), s = n + d, [...a.multiplyScalar(s)];
|
|
641
|
+
}
|
|
642
|
+
const lo = 2e-4;
|
|
643
|
+
function ie(o) {
|
|
644
|
+
const { joint_position: t, tcp_pose: e, tcp: i, coordinate_system: n } = o;
|
|
645
|
+
return { joint_position: t, tcp_pose: e, tcp: i, coordinate_system: n };
|
|
646
|
+
}
|
|
647
|
+
function ne(o, t) {
|
|
648
|
+
return o.tcp === t.tcp && o.coordinate_system === t.coordinate_system && o.tcp_pose === void 0 == (t.tcp_pose === void 0) && ht(
|
|
649
|
+
o.joint_position,
|
|
650
|
+
t.joint_position,
|
|
651
|
+
lo
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
const At = 1e-4;
|
|
655
|
+
class ut {
|
|
656
|
+
constructor(t, e, i, n, r, s, a = "cell", d = {}) {
|
|
657
|
+
this.controller = e, this.motionGroup = i, this.description = n, this.initialMotionState = r, this.motionStateSocket = s, this.cellId = a, this.nova = U(t), this.logger = d.logger ?? console, this.rapidlyChangingMotionState = r, s.addEventListener("message", (h) => {
|
|
658
|
+
var l;
|
|
659
|
+
const c = (l = J(h.data)) == null ? void 0 : l.result;
|
|
660
|
+
if (!c)
|
|
661
|
+
throw new Error(
|
|
662
|
+
`Failed to get motion state for ${this.motionGroupId}: ${h.data}`
|
|
663
|
+
);
|
|
664
|
+
ee(
|
|
665
|
+
this.rapidlyChangingMotionState,
|
|
666
|
+
c,
|
|
667
|
+
At
|
|
668
|
+
) || S(() => {
|
|
669
|
+
var p, f, v;
|
|
670
|
+
this.rapidlyChangingMotionState.tcp_pose == null ? this.rapidlyChangingMotionState.tcp_pose = c.tcp_pose : (p = c.tcp_pose) != null && p.orientation && ((f = c.tcp_pose) != null && f.position) && ((v = this.rapidlyChangingMotionState.tcp_pose) != null && v.orientation) ? this.rapidlyChangingMotionState.tcp_pose = {
|
|
671
|
+
position: c.tcp_pose.position,
|
|
672
|
+
orientation: oe(
|
|
673
|
+
c.tcp_pose.orientation,
|
|
674
|
+
this.rapidlyChangingMotionState.tcp_pose.orientation
|
|
675
|
+
)
|
|
676
|
+
} : this.logger.debug("Received incomplete tcp_pose, ignoring", {
|
|
677
|
+
tcpPose: c.tcp_pose
|
|
678
|
+
});
|
|
679
|
+
}), Xt(
|
|
680
|
+
this.rapidlyChangingMotionState.joint_position,
|
|
681
|
+
c.joint_position,
|
|
682
|
+
At
|
|
683
|
+
) || S(() => {
|
|
684
|
+
this.rapidlyChangingMotionState.joint_position = c.joint_position;
|
|
685
|
+
}), c.tcp !== void 0 && this.rapidlyChangingMotionState.tcp !== c.tcp && S(() => {
|
|
686
|
+
this.rapidlyChangingMotionState.tcp = c.tcp;
|
|
687
|
+
}), this.rapidlyChangingMotionState.standstill !== c.standstill && S(() => {
|
|
688
|
+
this.rapidlyChangingMotionState.standstill = c.standstill;
|
|
689
|
+
});
|
|
690
|
+
const m = this.rapidlyChangingMotionState.joint_limit_reached.limit_reached, u = c.joint_limit_reached.limit_reached;
|
|
691
|
+
m.some((p, f) => p !== u[f]) && S(() => {
|
|
692
|
+
this.rapidlyChangingMotionState.joint_limit_reached = c.joint_limit_reached;
|
|
693
|
+
}), this.rapidlyChangingMotionState.execute !== c.execute && S(() => {
|
|
694
|
+
this.rapidlyChangingMotionState.execute = c.execute;
|
|
695
|
+
});
|
|
696
|
+
}), D(this, {
|
|
697
|
+
logger: !1,
|
|
698
|
+
// keepAlive: pose readouts poll it from requestAnimationFrame, which
|
|
699
|
+
// MobX does not track, and a computed nobody observes is recomputed on
|
|
700
|
+
// every read without consulting `equals`
|
|
701
|
+
readoutState: zt({ equals: ne, keepAlive: !0 })
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
static async open(t, e, i = {}) {
|
|
705
|
+
var f;
|
|
706
|
+
const n = U(t), r = i.cellId ?? X(t) ?? "cell", [s, a] = e.split("@"), d = await n.api.controller.getCurrentRobotControllerState(
|
|
707
|
+
r,
|
|
708
|
+
a
|
|
709
|
+
), h = d == null ? void 0 : d.motion_groups.find(
|
|
710
|
+
(v) => v.motion_group === e
|
|
711
|
+
);
|
|
712
|
+
if (!d || !h)
|
|
713
|
+
throw new Error(
|
|
714
|
+
`Controller ${a} or motion group ${e} not found`
|
|
715
|
+
);
|
|
716
|
+
const c = n.openReconnectingWebsocket(
|
|
717
|
+
`/cells/${r}/controllers/${a}/motion-groups/${e}/state-stream`
|
|
718
|
+
), m = await c.firstMessage(), u = (f = J(m.data)) == null ? void 0 : f.result;
|
|
719
|
+
if (!u)
|
|
720
|
+
throw new Error(
|
|
721
|
+
`Unable to parse initial motion state message ${m.data}`
|
|
722
|
+
);
|
|
723
|
+
const l = i.logger ?? console;
|
|
724
|
+
l.info("Connected motion state websocket to motion group", {
|
|
725
|
+
motionGroup: h.motion_group,
|
|
726
|
+
initialMotionState: u
|
|
727
|
+
});
|
|
728
|
+
const p = await n.api.motionGroup.getMotionGroupDescription(
|
|
729
|
+
r,
|
|
730
|
+
a,
|
|
731
|
+
h.motion_group
|
|
732
|
+
);
|
|
733
|
+
return new ut(
|
|
734
|
+
n,
|
|
735
|
+
d,
|
|
736
|
+
h,
|
|
737
|
+
p,
|
|
738
|
+
u,
|
|
739
|
+
c,
|
|
740
|
+
r,
|
|
741
|
+
{ logger: l }
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* What pose readouts show (joints, TCP pose): it holds the previous reading
|
|
746
|
+
* while the joints only jitter, see {@link readoutsEqual}. Kept alive, so it
|
|
747
|
+
* also holds for untracked reads, e.g. from requestAnimationFrame.
|
|
748
|
+
*/
|
|
749
|
+
get readoutState() {
|
|
750
|
+
return ie(this.rapidlyChangingMotionState);
|
|
751
|
+
}
|
|
752
|
+
get motionGroupId() {
|
|
753
|
+
return this.motionGroup.motion_group;
|
|
754
|
+
}
|
|
755
|
+
get controllerId() {
|
|
756
|
+
return this.controller.controller;
|
|
757
|
+
}
|
|
758
|
+
get joints() {
|
|
759
|
+
return this.initialMotionState.joint_position.map((t, e) => ({
|
|
760
|
+
index: e
|
|
761
|
+
}));
|
|
762
|
+
}
|
|
763
|
+
dispose() {
|
|
764
|
+
this.motionStateSocket.close();
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
const Pt = "Movement request rejected. Another client is currently executing a 'Jogging' motion!", co = 500, go = 5e3;
|
|
768
|
+
function ho(o) {
|
|
769
|
+
var e;
|
|
770
|
+
return (((e = o.times) == null ? void 0 : e[o.times.length - 1]) ?? 0) * 2e3 + go;
|
|
771
|
+
}
|
|
772
|
+
class mt {
|
|
773
|
+
constructor(t, e = {}) {
|
|
774
|
+
this.motionStream = t, this.options = e, 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.incrementalMotionInFlight = !1, this.ownsMotionStream = !1, this.tcp = (e == null ? void 0 : e.tcp) || t.motionGroup.tcp || this.getDefaultTcp(t), this.coordinateSystem = e == null ? void 0 : e.coordinateSystem, this.orientation = (e == null ? void 0 : e.orientation) || this.DEFAULT_ORIENTATION, this.timeout = (e == null ? void 0 : e.timeout) || this.DEFAULT_INIT_TIMEOUT, this.mode = (e == null ? void 0 : e.mode) || this.DEFAULT_MODE, this.onError = e == null ? void 0 : e.onError, this.logger = (e == null ? void 0 : e.logger) ?? console;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Initialize the jogging connection using jogging endpoint or trajectory endpoint depending on the selected mode.
|
|
778
|
+
*
|
|
779
|
+
* @param connection - The base URL of a NOVA instance, or a NOVA client of the app (see `NovaConnection`)
|
|
780
|
+
* @param motionGroupId - The ID of the motion group to connect to
|
|
781
|
+
* @param options - Configuration options for the jogger connection
|
|
782
|
+
* @param options.mode - The jogging mode to initialize:
|
|
783
|
+
* - "jogging": Continuous jogging mode with persistent websocket for real-time velocity commands
|
|
784
|
+
* - "trajectory": Incremental jogging mode for fixed-distance motions via trajectory planning
|
|
785
|
+
* - "off": No jogging enabled, all websockets closed (default)
|
|
786
|
+
* @param options.timeout - Timeout in milliseconds for websocket initialization (default: 5000ms)
|
|
787
|
+
* @param options.tcp - TCP frame to use for motions (default: from motion group)
|
|
788
|
+
* @param options.coordinateSystem - Coordinate system whose axes cartesian jogging moves along, relative to world (default: world)
|
|
789
|
+
* @param options.orientation - If set to "tool", jogging TcpVelocityRequest will use `use_tool_coordinate_system` option (default: "coordsys")
|
|
790
|
+
* @param options.onError - Error handler for websocket errors and step jogs
|
|
791
|
+
* @param options.motionGroupModel - Model name for planning step jogs (default: from the motion group description)
|
|
792
|
+
* @param options.logger - Where the jogger and its motion stream log (default: the console)
|
|
793
|
+
* @returns Promise resolving to initialized JoggerConnection instance. Its
|
|
794
|
+
* `dispose()` also closes the motion stream that this function opens.
|
|
795
|
+
*/
|
|
796
|
+
static async open(t, e, i = {}) {
|
|
797
|
+
const n = await ut.open(
|
|
798
|
+
t,
|
|
799
|
+
e,
|
|
800
|
+
{
|
|
801
|
+
cellId: i.cellId,
|
|
802
|
+
logger: i.logger
|
|
803
|
+
}
|
|
804
|
+
), r = new mt(n, i);
|
|
805
|
+
r.ownsMotionStream = !0;
|
|
806
|
+
try {
|
|
807
|
+
await r.setJoggingMode(r.mode);
|
|
808
|
+
} catch (s) {
|
|
809
|
+
throw r.dispose(), s;
|
|
810
|
+
}
|
|
811
|
+
return r;
|
|
812
|
+
}
|
|
813
|
+
getDefaultTcp(t) {
|
|
814
|
+
var i, n;
|
|
815
|
+
const e = (n = (i = t.description.dh_parameters) == null ? void 0 : i[0]) == null ? void 0 : n.type;
|
|
816
|
+
return t.joints.length < 6 && (e === N.RevoluteJoint || e === N.PrismaticJoint) ? this.NO_TCP : this.DEFAULT_TCP;
|
|
817
|
+
}
|
|
818
|
+
// Set a new tcp or other options. If current mode is jogging, will reinitialize the jogging websocket
|
|
819
|
+
async setOptions(t) {
|
|
820
|
+
return t.tcp && (this.tcp = t.tcp), t.orientation && (this.orientation = t.orientation), "coordinateSystem" in t && (this.coordinateSystem = t.coordinateSystem), t.timeout && (this.timeout = t.timeout), t.mode && (this.mode = t.mode), t.onError && (this.onError = t.onError), this.setJoggingMode(this.mode, !1);
|
|
821
|
+
}
|
|
822
|
+
get motionGroupId() {
|
|
823
|
+
return this.motionStream.motionGroupId;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* The library's own NOVA client of the motion stream
|
|
827
|
+
* @internal
|
|
828
|
+
*/
|
|
829
|
+
get nova() {
|
|
830
|
+
return this.motionStream.nova;
|
|
831
|
+
}
|
|
832
|
+
get cellId() {
|
|
833
|
+
return this.motionStream.cellId;
|
|
834
|
+
}
|
|
835
|
+
get numJoints() {
|
|
836
|
+
return this.motionStream.joints.length;
|
|
837
|
+
}
|
|
838
|
+
// get activeJoggingMode() {
|
|
839
|
+
// return this.mode
|
|
840
|
+
// }
|
|
841
|
+
// get activeWebsocket() {
|
|
842
|
+
// return this.mode === "jogging" ? this.joggingSocket : this.trajectorySocket;
|
|
843
|
+
// }
|
|
844
|
+
// Sends stop movement command to robot
|
|
845
|
+
async stop() {
|
|
846
|
+
if (this.joggingSocket) {
|
|
847
|
+
const t = new Array(this.numJoints).fill(0);
|
|
848
|
+
this.joggingSocket.sendJson({
|
|
849
|
+
message_type: "JointVelocityRequest",
|
|
850
|
+
velocity: t
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
this.trajectorySocket && this.trajectorySocket.sendJson({
|
|
854
|
+
message_type: "PauseMovementRequest"
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Dispose the jogger, closing all open websockets: the jogging websockets,
|
|
859
|
+
* and the motion stream if the jogger opened it (in `open()`). A motion
|
|
860
|
+
* stream given to the constructor stays open: its caller closes it.
|
|
861
|
+
*/
|
|
862
|
+
async dispose() {
|
|
863
|
+
const t = this.closeJoggingSockets();
|
|
864
|
+
return this.ownsMotionStream && this.motionStream.dispose(), t;
|
|
865
|
+
}
|
|
866
|
+
/** Closes the jogging and trajectory websockets */
|
|
867
|
+
closeJoggingSockets() {
|
|
868
|
+
var e, i;
|
|
869
|
+
(e = this.endJoggingInit) == null || e.call(this), (i = this.endIncrementalMotion) == null || i.call(this);
|
|
870
|
+
const t = [this.joggingSocket, this.trajectorySocket].filter(
|
|
871
|
+
(n) => n !== null
|
|
872
|
+
);
|
|
873
|
+
return t.forEach((n) => {
|
|
874
|
+
n.dispose();
|
|
875
|
+
}), this.joggingSocket = null, this.trajectorySocket = null, Promise.all(t.map((n) => n.closed()));
|
|
876
|
+
}
|
|
877
|
+
// Activate jogger in one of the supported modes
|
|
878
|
+
// Will iniitialize or close websockets as necessary
|
|
879
|
+
// If mode is unchanged, does nothing (unless skipReinitializeIfSameMode is false)
|
|
880
|
+
async setJoggingMode(t, e = !0) {
|
|
881
|
+
if (!(this.mode === t && e) && (this.closeJoggingSockets(), this.mode = t, this.mode === "jogging"))
|
|
882
|
+
return this.initializeJoggingWebsocket();
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Opens the continuous jogging websocket and initializes it; called by
|
|
886
|
+
* `setJoggingMode("jogging")`. The promise settles once:
|
|
887
|
+
* - it resolves when NOVA confirms the initialization (INITIALIZE_RECEIVED),
|
|
888
|
+
* when the jogger closes the websocket before that (`setJoggingMode`,
|
|
889
|
+
* `dispose`), or when an error message goes to `onBlocked` or `onError`;
|
|
890
|
+
* - it rejects on an error message without such a handler, and when NOVA
|
|
891
|
+
* does not confirm the initialization within `timeout` milliseconds.
|
|
892
|
+
*/
|
|
893
|
+
async initializeJoggingWebsocket() {
|
|
894
|
+
return new Promise((t, e) => {
|
|
895
|
+
const i = this.nova.openReconnectingWebsocket(
|
|
896
|
+
`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`
|
|
897
|
+
);
|
|
898
|
+
this.joggingSocket = i;
|
|
899
|
+
let n = !1;
|
|
900
|
+
const r = setTimeout(() => {
|
|
901
|
+
s(
|
|
902
|
+
new Error(`Jogging initialization timeout after ${this.timeout} ms`)
|
|
903
|
+
);
|
|
904
|
+
}, this.timeout), s = (h) => {
|
|
905
|
+
n || (n = !0, clearTimeout(r), i.removeEventListener("close", d), this.endJoggingInit === a && (this.endJoggingInit = void 0), h ? e(h) : t());
|
|
906
|
+
}, a = () => s(), d = () => {
|
|
907
|
+
i.disposed && s();
|
|
908
|
+
};
|
|
909
|
+
this.endJoggingInit = a, i.addEventListener("close", d), i.addEventListener("message", (h) => {
|
|
910
|
+
var m, u, l;
|
|
911
|
+
const c = J(h.data);
|
|
912
|
+
if (((m = c == null ? void 0 : c.result) == null ? void 0 : m.kind) === "INITIALIZE_RECEIVED") {
|
|
913
|
+
s();
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
if (((u = c == null ? void 0 : c.result) == null ? void 0 : u.kind) === "MOTION_ERROR")
|
|
917
|
+
if (this.onBlocked && ((l = c == null ? void 0 : c.result) != null && l.message.includes(Pt))) {
|
|
918
|
+
s(), i.dispose(), this.onBlocked();
|
|
919
|
+
return;
|
|
920
|
+
} else this.onError ? (s(), this.onError(h.data)) : s(new Error(h.data));
|
|
921
|
+
}), i.sendJson({
|
|
922
|
+
message_type: "InitializeJoggingRequest",
|
|
923
|
+
motion_group: this.motionGroupId,
|
|
924
|
+
...this.tcp ? { tcp: this.tcp } : {}
|
|
925
|
+
});
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Jogging: Start rotation of a single robot joint at the specified velocity
|
|
930
|
+
*/
|
|
931
|
+
async rotateJoints({
|
|
932
|
+
joint: t,
|
|
933
|
+
direction: e,
|
|
934
|
+
velocityValue: i,
|
|
935
|
+
velocityUnit: n
|
|
936
|
+
}) {
|
|
937
|
+
if (!this.joggingSocket || this.mode !== "jogging")
|
|
938
|
+
throw new Error(
|
|
939
|
+
"Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'"
|
|
940
|
+
);
|
|
941
|
+
const r = new Array(this.numJoints).fill(0);
|
|
942
|
+
r[t] = e === "-" ? -i : i, this.joggingSocket.sendJson({
|
|
943
|
+
message_type: "JointVelocityRequest",
|
|
944
|
+
velocity: r
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Jogging: Start the TCP moving along a specified axis at a given velocity
|
|
949
|
+
*/
|
|
950
|
+
async translateTCP({
|
|
951
|
+
axis: t,
|
|
952
|
+
direction: e,
|
|
953
|
+
velocityMmPerSec: i
|
|
954
|
+
}) {
|
|
955
|
+
if (!this.joggingSocket || this.mode !== "jogging")
|
|
956
|
+
throw new Error(
|
|
957
|
+
"Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'"
|
|
958
|
+
);
|
|
959
|
+
this.joggingSocket.sendJson({
|
|
960
|
+
message_type: "TcpVelocityRequest",
|
|
961
|
+
translation: this.velocityAlongAxis(
|
|
962
|
+
t,
|
|
963
|
+
e === "-" ? -i : i
|
|
964
|
+
),
|
|
965
|
+
rotation: [0, 0, 0],
|
|
966
|
+
use_tool_coordinate_system: this.orientation === "tool"
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Jogging: Start the TCP rotating around a specified axis at a given velocity
|
|
971
|
+
*/
|
|
972
|
+
async rotateTCP({
|
|
973
|
+
axis: t,
|
|
974
|
+
direction: e,
|
|
975
|
+
velocityRadsPerSec: i
|
|
976
|
+
}) {
|
|
977
|
+
if (!this.joggingSocket || this.mode !== "jogging")
|
|
978
|
+
throw new Error(
|
|
979
|
+
"Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'"
|
|
980
|
+
);
|
|
981
|
+
this.joggingSocket.sendJson({
|
|
982
|
+
message_type: "TcpVelocityRequest",
|
|
983
|
+
translation: [0, 0, 0],
|
|
984
|
+
rotation: this.velocityAlongAxis(
|
|
985
|
+
t,
|
|
986
|
+
e === "-" ? -i : i
|
|
987
|
+
),
|
|
988
|
+
use_tool_coordinate_system: this.orientation === "tool"
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Rotation from {@link JoggerConnection.coordinateSystem} into world,
|
|
993
|
+
* while jogging along its axes. Undefined when jogging along world or tool
|
|
994
|
+
* axes.
|
|
995
|
+
*/
|
|
996
|
+
get coordinateSystemRotation() {
|
|
997
|
+
if (!(this.orientation === "tool" || !this.coordinateSystem))
|
|
998
|
+
return V.fromCoordinateSystem(this.coordinateSystem).quaternion;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Velocity vector along one axis of the jogging frame. The API takes TCP
|
|
1002
|
+
* velocities in either the tool frame or world, so an axis of
|
|
1003
|
+
* {@link JoggerConnection.coordinateSystem} is rotated into world here.
|
|
1004
|
+
*/
|
|
1005
|
+
velocityAlongAxis(t, e) {
|
|
1006
|
+
const i = new tt();
|
|
1007
|
+
i[t] = e;
|
|
1008
|
+
const n = this.coordinateSystemRotation;
|
|
1009
|
+
return n && i.applyQuaternion(n), [i.x, i.y, i.z];
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Trajectory jogging:
|
|
1013
|
+
*
|
|
1014
|
+
* Move the robot by a fixed distance in a single cartesian
|
|
1015
|
+
* axis, either rotating or translating relative to the TCP.
|
|
1016
|
+
* The axis is one of the tool in tool orientation, else one of
|
|
1017
|
+
* {@link JoggerConnection.coordinateSystem} (default: world).
|
|
1018
|
+
*
|
|
1019
|
+
* Promise resolves only after the motion has completed: once the robot
|
|
1020
|
+
* stands still again, or after a watchdog of twice the planned duration
|
|
1021
|
+
* plus 5 s. A step requested while another one runs is dropped (resolves
|
|
1022
|
+
* at once). Every error (a refused or failed plan, a refused trajectory, an
|
|
1023
|
+
* error of the controller, the watchdog) goes to `onError`, or without it
|
|
1024
|
+
* rejects the promise.
|
|
1025
|
+
*/
|
|
1026
|
+
async runIncrementalCartesianMotion(t) {
|
|
1027
|
+
if (this.mode !== "trajectory")
|
|
1028
|
+
throw new Error(
|
|
1029
|
+
"Set jogging mode to 'trajectory' to run incremental cartesian motions"
|
|
1030
|
+
);
|
|
1031
|
+
if (!this.incrementalMotionInFlight) {
|
|
1032
|
+
this.incrementalMotionInFlight = !0;
|
|
1033
|
+
try {
|
|
1034
|
+
const e = await this.planIncrementalCartesianMotion(t);
|
|
1035
|
+
e && await this.executeTrajectory(e);
|
|
1036
|
+
} finally {
|
|
1037
|
+
this.incrementalMotionInFlight = !1;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Plan the trajectory for a single incremental jog. Returns undefined when
|
|
1043
|
+
* no trajectory could be produced; the reason (a planner rejection such as a
|
|
1044
|
+
* singularity, or a motion group without a cycle time) is reported through
|
|
1045
|
+
* {@link JoggerConnection.onError} or logged.
|
|
1046
|
+
*/
|
|
1047
|
+
async planIncrementalCartesianMotion({
|
|
1048
|
+
currentTcpPose: t,
|
|
1049
|
+
currentJoints: e,
|
|
1050
|
+
velocityInRelevantUnits: i,
|
|
1051
|
+
axis: n,
|
|
1052
|
+
direction: r,
|
|
1053
|
+
motion: s
|
|
1054
|
+
}) {
|
|
1055
|
+
var f, v, w;
|
|
1056
|
+
const a = [], d = so({
|
|
1057
|
+
currentTcpPose: t,
|
|
1058
|
+
axis: n,
|
|
1059
|
+
direction: r,
|
|
1060
|
+
motion: s,
|
|
1061
|
+
useToolCoordinateSystem: this.orientation === "tool",
|
|
1062
|
+
coordinateSystemRotation: this.coordinateSystemRotation
|
|
1063
|
+
});
|
|
1064
|
+
a.push({
|
|
1065
|
+
limits_override: s.type === "translate" ? { tcp_velocity_limit: i } : { tcp_orientation_velocity_limit: i },
|
|
1066
|
+
path: {
|
|
1067
|
+
path_definition_name: "PathLine",
|
|
1068
|
+
target_pose: {
|
|
1069
|
+
position: d.position,
|
|
1070
|
+
orientation: d.orientation
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
const h = this.motionStream.description;
|
|
1075
|
+
if (h.cycle_time === void 0) {
|
|
1076
|
+
this.logger.warn(
|
|
1077
|
+
"Current motion group has no cycle time, cannot plan jogging motion"
|
|
1078
|
+
);
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
const c = this.motionStream.rapidlyChangingMotionState.tcp, m = c ? (v = (f = h.tcps) == null ? void 0 : f[c]) == null ? void 0 : v.pose : void 0, u = {
|
|
1082
|
+
motion_group_model: ((w = this.options) == null ? void 0 : w.motionGroupModel) ?? h.motion_group_model,
|
|
1083
|
+
cycle_time: h.cycle_time,
|
|
1084
|
+
mounting: h.mounting,
|
|
1085
|
+
tcp_offset: m,
|
|
1086
|
+
// FIXME use proper mode's limits if set
|
|
1087
|
+
global: h.operation_limits.auto_limits
|
|
1088
|
+
}, l = await this.nova.api.trajectoryPlanning.planTrajectory(
|
|
1089
|
+
this.cellId,
|
|
1090
|
+
{
|
|
1091
|
+
motion_group_setup: u,
|
|
1092
|
+
start_joint_position: e,
|
|
1093
|
+
motion_commands: a
|
|
1094
|
+
}
|
|
1095
|
+
), p = l.response;
|
|
1096
|
+
if (!p)
|
|
1097
|
+
throw new Error(
|
|
1098
|
+
`Failed to plan jogging increment motion ${JSON.stringify(l)}`
|
|
1099
|
+
);
|
|
1100
|
+
if ("error_feedback" in p) {
|
|
1101
|
+
if (this.onError) {
|
|
1102
|
+
this.onError(p);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
throw new Error(
|
|
1106
|
+
`Failed to plan jogging increment motion: ${JSON.stringify(p.error_feedback)}`
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
return p;
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Execute a planned trajectory https://portal.wandelbots.io/docs/api/v2/ui/#/operations/executeTrajectory
|
|
1113
|
+
* and resolve once the robot has come to a standstill again, so that the
|
|
1114
|
+
* caller -- and with it the jogging UI's motion lock -- stays blocked for the
|
|
1115
|
+
* whole motion. It also resolves when the jogger closes the websocket
|
|
1116
|
+
* (`setJoggingMode`, `dispose`).
|
|
1117
|
+
*
|
|
1118
|
+
* Each call owns its own websocket. Sharing
|
|
1119
|
+
* {@link JoggerConnection.trajectorySocket} across motions meant a finishing
|
|
1120
|
+
* motion closed the socket of a later one.
|
|
1121
|
+
*/
|
|
1122
|
+
async executeTrajectory(t) {
|
|
1123
|
+
const e = this.nova.openReconnectingWebsocket(
|
|
1124
|
+
`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`
|
|
1125
|
+
);
|
|
1126
|
+
this.trajectorySocket = e;
|
|
1127
|
+
const i = new AbortController();
|
|
1128
|
+
let n, r;
|
|
1129
|
+
try {
|
|
1130
|
+
await new Promise((s, a) => {
|
|
1131
|
+
let d = !1;
|
|
1132
|
+
const h = () => {
|
|
1133
|
+
d || (d = !0, s());
|
|
1134
|
+
}, c = (u) => {
|
|
1135
|
+
if (!d) {
|
|
1136
|
+
if (d = !0, this.onError) {
|
|
1137
|
+
this.onError(u), s();
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
a(
|
|
1141
|
+
u instanceof Error ? u : new Error(
|
|
1142
|
+
`Failed to execute trajectory: ${JSON.stringify(u)}`
|
|
1143
|
+
)
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
|
+
r = h, this.endIncrementalMotion = h;
|
|
1148
|
+
const m = ho(t);
|
|
1149
|
+
n = setTimeout(() => {
|
|
1150
|
+
c(
|
|
1151
|
+
new Error(`Jogging motion did not complete within ${m}ms`)
|
|
1152
|
+
);
|
|
1153
|
+
}, m), e.addEventListener("message", (u) => {
|
|
1154
|
+
var p, f;
|
|
1155
|
+
const l = (p = J(u.data)) == null ? void 0 : p.result;
|
|
1156
|
+
if (!(l != null && l.kind)) {
|
|
1157
|
+
c(
|
|
1158
|
+
new Error(
|
|
1159
|
+
`Failed to execute trajectory: Received invalid message ${u.data}`
|
|
1160
|
+
)
|
|
1161
|
+
);
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
if (this.onBlocked && ((f = l.message) != null && f.includes(Pt))) {
|
|
1165
|
+
this.onBlocked(), h();
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
if (l.kind === "INITIALIZE_RECEIVED") {
|
|
1169
|
+
if (l.add_trajectory_error || l.message) {
|
|
1170
|
+
c(l);
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
e.sendJson({
|
|
1174
|
+
message_type: "StartMovementRequest",
|
|
1175
|
+
direction: "DIRECTION_FORWARD"
|
|
1176
|
+
});
|
|
1177
|
+
} else if (l.kind === "START_RECEIVED") {
|
|
1178
|
+
if (l.message) {
|
|
1179
|
+
c(l);
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
this.waitForMotionToFinish(i.signal).then(h, c);
|
|
1183
|
+
} else l.kind === "PAUSE_RECEIVED" || (l.kind === "MOTION_ERROR" && l.message ? c(l) : c(
|
|
1184
|
+
new Error(
|
|
1185
|
+
`Failed to execute trajectory, cannot handle message type "${l.kind}"`
|
|
1186
|
+
)
|
|
1187
|
+
));
|
|
1188
|
+
}), e.sendJson({
|
|
1189
|
+
message_type: "InitializeMovementRequest",
|
|
1190
|
+
trajectory: {
|
|
1191
|
+
message_type: "TrajectoryData",
|
|
1192
|
+
motion_group: this.motionGroupId,
|
|
1193
|
+
data: t,
|
|
1194
|
+
tcp: this.tcp
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
});
|
|
1198
|
+
} finally {
|
|
1199
|
+
clearTimeout(n), i.abort(), this.endIncrementalMotion === r && (this.endIncrementalMotion = void 0), e.dispose(), this.trajectorySocket === e && (this.trajectorySocket = null);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Resolve once the robot has finished executing a trajectory.
|
|
1204
|
+
*
|
|
1205
|
+
* `standstill` from the motion stream is the only completion signal we get.
|
|
1206
|
+
* The robot is still at standstill for a moment after the controller
|
|
1207
|
+
* acknowledges the start, and a short increment can be over before the stream
|
|
1208
|
+
* reports any movement at all -- so movement is waited for as a grace period,
|
|
1209
|
+
* never required.
|
|
1210
|
+
*/
|
|
1211
|
+
async waitForMotionToFinish(t) {
|
|
1212
|
+
const e = () => this.motionStream.rapidlyChangingMotionState.standstill;
|
|
1213
|
+
await lt(() => !e(), {
|
|
1214
|
+
timeout: co,
|
|
1215
|
+
signal: t
|
|
1216
|
+
}).catch(() => {
|
|
1217
|
+
}), await lt(e, { signal: t });
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
const uo = (o) => {
|
|
1221
|
+
const t = o.softTimeout || 3e3, [e, i] = ot(!1);
|
|
1222
|
+
return at(() => {
|
|
1223
|
+
const n = setTimeout(() => {
|
|
1224
|
+
i(!0);
|
|
1225
|
+
}, t);
|
|
1226
|
+
return () => clearTimeout(n);
|
|
1227
|
+
}), /* @__PURE__ */ g(
|
|
1228
|
+
C,
|
|
1229
|
+
{
|
|
1230
|
+
width: "100%",
|
|
1231
|
+
height: "100%",
|
|
1232
|
+
alignItems: "center",
|
|
1233
|
+
justifyContent: "center",
|
|
1234
|
+
sx: { color: "text.primary" },
|
|
1235
|
+
children: o.error ? /* @__PURE__ */ g(
|
|
1236
|
+
mo,
|
|
1237
|
+
{
|
|
1238
|
+
loadingMessage: o.message,
|
|
1239
|
+
error: o.error
|
|
1240
|
+
}
|
|
1241
|
+
) : /* @__PURE__ */ _(st, { children: [
|
|
1242
|
+
/* @__PURE__ */ g(Wt, { sx: { mb: 3 } }),
|
|
1243
|
+
!!o.message && /* @__PURE__ */ g(M, { variant: "body1", children: o.message }),
|
|
1244
|
+
/* @__PURE__ */ g(
|
|
1245
|
+
M,
|
|
1246
|
+
{
|
|
1247
|
+
variant: "body2",
|
|
1248
|
+
sx: {
|
|
1249
|
+
visibility: e ? "visible" : "hidden",
|
|
1250
|
+
mt: 2,
|
|
1251
|
+
color: "text.secondary"
|
|
1252
|
+
},
|
|
1253
|
+
children: "This is taking longer than expected..."
|
|
1254
|
+
}
|
|
1255
|
+
)
|
|
1256
|
+
] })
|
|
1257
|
+
}
|
|
1258
|
+
);
|
|
1259
|
+
}, mo = (o) => {
|
|
1260
|
+
const t = Re(o.error), e = o.error instanceof Error ? o.error.stack : null;
|
|
1261
|
+
return /* @__PURE__ */ _(
|
|
1262
|
+
C,
|
|
1263
|
+
{
|
|
1264
|
+
sx: {
|
|
1265
|
+
maxHeight: "100%",
|
|
1266
|
+
maxWidth: "min(100%, 800px)",
|
|
1267
|
+
p: 2,
|
|
1268
|
+
overflow: "auto",
|
|
1269
|
+
color: "error.main"
|
|
1270
|
+
},
|
|
1271
|
+
children: [
|
|
1272
|
+
/* @__PURE__ */ g(M, { variant: "body1", children: (o.loadingMessage ? `Error while ${Oe(xe(o.loadingMessage))} - ` : "") + t }),
|
|
1273
|
+
e && /* @__PURE__ */ g(
|
|
1274
|
+
B,
|
|
1275
|
+
{
|
|
1276
|
+
component: "pre",
|
|
1277
|
+
sx: {
|
|
1278
|
+
typography: "body2",
|
|
1279
|
+
fontFamily: "monospace",
|
|
1280
|
+
whiteSpace: "pre-wrap",
|
|
1281
|
+
wordBreak: "break-word",
|
|
1282
|
+
mt: 2,
|
|
1283
|
+
pb: 6
|
|
1284
|
+
},
|
|
1285
|
+
children: e
|
|
1286
|
+
}
|
|
1287
|
+
)
|
|
1288
|
+
]
|
|
1289
|
+
}
|
|
1290
|
+
);
|
|
1291
|
+
}, po = A(({ store: o }) => {
|
|
1292
|
+
const { t } = F();
|
|
1293
|
+
return /* @__PURE__ */ g(
|
|
1294
|
+
Gt,
|
|
1295
|
+
{
|
|
1296
|
+
"data-testid": "jogging-blocked",
|
|
1297
|
+
"aria-label": "jogging-blocked",
|
|
1298
|
+
open: !0,
|
|
1299
|
+
sx: {
|
|
1300
|
+
position: "absolute",
|
|
1301
|
+
zIndex: (e) => e.zIndex.drawer + 1,
|
|
1302
|
+
color: "#fff",
|
|
1303
|
+
background: "rgba(15, 15, 15, 0.88)",
|
|
1304
|
+
justifyContent: "flex-start",
|
|
1305
|
+
alignItems: "flex-start"
|
|
1306
|
+
},
|
|
1307
|
+
children: /* @__PURE__ */ _(C, { sx: { m: 2, width: "100%" }, children: [
|
|
1308
|
+
/* @__PURE__ */ _(Ae, { severity: "error", sx: { mb: 2 }, children: [
|
|
1309
|
+
/* @__PURE__ */ g(Pe, { children: t("Jogging.Blocked.ti") }),
|
|
1310
|
+
t("Jogging.Blocked.lb")
|
|
1311
|
+
] }),
|
|
1312
|
+
/* @__PURE__ */ g(
|
|
1313
|
+
St,
|
|
1314
|
+
{
|
|
1315
|
+
variant: "contained",
|
|
1316
|
+
color: "secondary",
|
|
1317
|
+
onClick: () => o.unblock(),
|
|
1318
|
+
children: t("Jogging.Blocked.Reenable.bt")
|
|
1319
|
+
}
|
|
1320
|
+
)
|
|
1321
|
+
] })
|
|
1322
|
+
}
|
|
1323
|
+
);
|
|
1324
|
+
}), fo = ({
|
|
1325
|
+
title: o,
|
|
1326
|
+
titleId: t,
|
|
1327
|
+
...e
|
|
1328
|
+
}, i) => /* @__PURE__ */ b.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 19, height: 10, fill: "none", ref: i, "aria-labelledby": t, ...e }, o ? /* @__PURE__ */ b.createElement("title", { id: t }, o) : null, /* @__PURE__ */ 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" })), yo = Y(fo), So = ({
|
|
1329
|
+
title: o,
|
|
1330
|
+
titleId: t,
|
|
1331
|
+
...e
|
|
1332
|
+
}, i) => /* @__PURE__ */ b.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 19, height: 10, fill: "none", ref: i, "aria-labelledby": t, ...e }, o ? /* @__PURE__ */ b.createElement("title", { id: t }, o) : null, /* @__PURE__ */ 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" })), vo = Y(So), _o = ({
|
|
1333
|
+
title: o,
|
|
1334
|
+
titleId: t,
|
|
1335
|
+
...e
|
|
1336
|
+
}, i) => /* @__PURE__ */ b.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 10, height: 19, fill: "none", ref: i, "aria-labelledby": t, ...e }, o ? /* @__PURE__ */ b.createElement("title", { id: t }, o) : null, /* @__PURE__ */ 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" })), bo = Y(_o), Co = ({
|
|
1337
|
+
title: o,
|
|
1338
|
+
titleId: t,
|
|
1339
|
+
...e
|
|
1340
|
+
}, i) => /* @__PURE__ */ 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, ...e }, o ? /* @__PURE__ */ b.createElement("title", { id: t }, o) : null, /* @__PURE__ */ 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" })), wo = Y(Co), re = A(
|
|
1341
|
+
({ store: o }) => {
|
|
1342
|
+
const { t } = F(), [e, i] = ot(
|
|
1343
|
+
o.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached
|
|
1344
|
+
), n = gt(e);
|
|
1345
|
+
wt(() => {
|
|
1346
|
+
const s = o.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;
|
|
1347
|
+
Kt(n.current, s) || (n.current = s, i(s));
|
|
1348
|
+
});
|
|
1349
|
+
const r = [];
|
|
1350
|
+
for (const [s, a] of e.entries())
|
|
1351
|
+
a && r.push(s);
|
|
1352
|
+
return /* @__PURE__ */ g(
|
|
1353
|
+
B,
|
|
1354
|
+
{
|
|
1355
|
+
sx: {
|
|
1356
|
+
display: "flex",
|
|
1357
|
+
flexDirection: "row",
|
|
1358
|
+
justifyContent: "center"
|
|
1359
|
+
},
|
|
1360
|
+
children: /* @__PURE__ */ g(
|
|
1361
|
+
M,
|
|
1362
|
+
{
|
|
1363
|
+
"data-testid": "jogging-joint-limit-detector",
|
|
1364
|
+
"aria-label": "jogging-joint-limit-detector",
|
|
1365
|
+
color: "error",
|
|
1366
|
+
variant: "body2",
|
|
1367
|
+
sx: {
|
|
1368
|
+
fontSize: "0.75rem",
|
|
1369
|
+
lineHeight: 1.2,
|
|
1370
|
+
visibility: r.length ? "visible" : "hidden"
|
|
1371
|
+
},
|
|
1372
|
+
children: t("Jogging.JointLimitsReached.lb", {
|
|
1373
|
+
jointNumbers: r.map((s) => s + 1).join(", ")
|
|
1374
|
+
})
|
|
1375
|
+
}
|
|
1376
|
+
)
|
|
1377
|
+
}
|
|
1378
|
+
);
|
|
1379
|
+
}
|
|
1380
|
+
), Eo = Ht(Ne)(({ theme: o }) => ({
|
|
1381
|
+
"&.MuiFormControl-root": {
|
|
1382
|
+
".MuiSelect-select": {
|
|
1383
|
+
paddingTop: "20px",
|
|
1384
|
+
paddingLeft: "12px"
|
|
1385
|
+
},
|
|
1386
|
+
label: {
|
|
1387
|
+
pointerEvents: "none",
|
|
1388
|
+
fontSize: "16px"
|
|
1389
|
+
},
|
|
1390
|
+
".MuiInputLabel-root": {
|
|
1391
|
+
"&.Mui-focused": {
|
|
1392
|
+
color: o.palette.text.primary
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
}));
|
|
1397
|
+
function rt({
|
|
1398
|
+
labelValue: o,
|
|
1399
|
+
...t
|
|
1400
|
+
}) {
|
|
1401
|
+
return /* @__PURE__ */ _(Eo, { fullWidth: !0, variant: "filled", children: [
|
|
1402
|
+
/* @__PURE__ */ g(Ve, { id: t.labelId, children: o }),
|
|
1403
|
+
/* @__PURE__ */ g(Fe, { ...t })
|
|
1404
|
+
] });
|
|
1405
|
+
}
|
|
1406
|
+
function Jt(o) {
|
|
1407
|
+
const t = o.lastIndexOf("On");
|
|
1408
|
+
return t > 0 ? o.slice(0, t) : o;
|
|
1409
|
+
}
|
|
1410
|
+
function se(o, t) {
|
|
1411
|
+
const e = o[t];
|
|
1412
|
+
if (e)
|
|
1413
|
+
return e;
|
|
1414
|
+
const i = Jt(t), n = o[i];
|
|
1415
|
+
if (n)
|
|
1416
|
+
return n;
|
|
1417
|
+
const r = Object.keys(o).filter(
|
|
1418
|
+
(a) => Jt(a) === i
|
|
1419
|
+
);
|
|
1420
|
+
if (r.length !== 1)
|
|
1421
|
+
return;
|
|
1422
|
+
const s = r[0];
|
|
1423
|
+
return s ? o[s] : void 0;
|
|
1424
|
+
}
|
|
1425
|
+
const Io = {
|
|
1426
|
+
coordinate_system: "world",
|
|
1427
|
+
name: "world",
|
|
1428
|
+
reference_coordinate_system: "",
|
|
1429
|
+
position: [0, 0, 0],
|
|
1430
|
+
orientation: [0, 0, 0],
|
|
1431
|
+
orientation_type: "ROTATION_VECTOR"
|
|
1432
|
+
};
|
|
1433
|
+
function ae(o) {
|
|
1434
|
+
const t = q(
|
|
1435
|
+
o.map((n) => ({
|
|
1436
|
+
...n,
|
|
1437
|
+
coordinate_system: n.coordinate_system || "world"
|
|
1438
|
+
})),
|
|
1439
|
+
"coordinate_system"
|
|
1440
|
+
);
|
|
1441
|
+
t.world ?? (t.world = Io);
|
|
1442
|
+
const e = {}, i = (n) => {
|
|
1443
|
+
const r = e[n];
|
|
1444
|
+
if (r)
|
|
1445
|
+
return r;
|
|
1446
|
+
const s = se(t, n);
|
|
1447
|
+
if (!s)
|
|
1448
|
+
throw new Error(
|
|
1449
|
+
`Unknown coordinate system ${n}. Known coordinate systems are: ${Object.keys(t).join(", ")}`
|
|
1450
|
+
);
|
|
1451
|
+
const a = s.reference_coordinate_system || "world";
|
|
1452
|
+
let d;
|
|
1453
|
+
if (a === "world")
|
|
1454
|
+
d = s;
|
|
1455
|
+
else {
|
|
1456
|
+
const h = i(a), c = V.fromCoordinateSystem(h).multiply(
|
|
1457
|
+
V.fromCoordinateSystem(s)
|
|
1458
|
+
);
|
|
1459
|
+
d = {
|
|
1460
|
+
...s,
|
|
1461
|
+
position: [
|
|
1462
|
+
c.position.x,
|
|
1463
|
+
c.position.y,
|
|
1464
|
+
c.position.z
|
|
1465
|
+
],
|
|
1466
|
+
orientation: [
|
|
1467
|
+
c.orientation.x,
|
|
1468
|
+
c.orientation.y,
|
|
1469
|
+
c.orientation.z
|
|
1470
|
+
],
|
|
1471
|
+
orientation_type: "ROTATION_VECTOR",
|
|
1472
|
+
reference_coordinate_system: h.reference_coordinate_system
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
return e[n] = d, d;
|
|
1476
|
+
};
|
|
1477
|
+
return Object.fromEntries(
|
|
1478
|
+
Object.keys(t).map((n) => [
|
|
1479
|
+
n,
|
|
1480
|
+
i(n)
|
|
1481
|
+
])
|
|
1482
|
+
);
|
|
1483
|
+
}
|
|
1484
|
+
function vt(o, t) {
|
|
1485
|
+
const e = se(
|
|
1486
|
+
o,
|
|
1487
|
+
t || "world"
|
|
1488
|
+
);
|
|
1489
|
+
if (!e)
|
|
1490
|
+
throw new Error(
|
|
1491
|
+
`Unknown coordinate system ${t}. Known coordinate systems are: ${Object.keys(o).join(", ")}`
|
|
1492
|
+
);
|
|
1493
|
+
return e;
|
|
1494
|
+
}
|
|
1495
|
+
function Mo(o, t) {
|
|
1496
|
+
return vt(
|
|
1497
|
+
ae(t),
|
|
1498
|
+
o
|
|
1499
|
+
);
|
|
1500
|
+
}
|
|
1501
|
+
function dt(o, t, e) {
|
|
1502
|
+
if (o.coordinateSystemId === t)
|
|
1503
|
+
return o;
|
|
1504
|
+
const i = ae(e), n = vt(
|
|
1505
|
+
i,
|
|
1506
|
+
o.coordinateSystemId || "world"
|
|
1507
|
+
), r = vt(
|
|
1508
|
+
i,
|
|
1509
|
+
t
|
|
1510
|
+
);
|
|
1511
|
+
if (n.coordinate_system === r.coordinate_system)
|
|
1512
|
+
return {
|
|
1513
|
+
...o,
|
|
1514
|
+
coordinateSystemId: r.coordinate_system
|
|
1515
|
+
};
|
|
1516
|
+
const s = V.fromCoordinateSystem(r).inverse().multiply(
|
|
1517
|
+
V.fromCoordinateSystem(n).multiply(
|
|
1518
|
+
V.fromPose(o.pose)
|
|
1519
|
+
)
|
|
1520
|
+
);
|
|
1521
|
+
return {
|
|
1522
|
+
...o,
|
|
1523
|
+
pose: {
|
|
1524
|
+
position: [
|
|
1525
|
+
s.position.x,
|
|
1526
|
+
s.position.y,
|
|
1527
|
+
s.position.z
|
|
1528
|
+
],
|
|
1529
|
+
orientation: [
|
|
1530
|
+
s.orientation.x,
|
|
1531
|
+
s.orientation.y,
|
|
1532
|
+
s.orientation.z
|
|
1533
|
+
]
|
|
1534
|
+
},
|
|
1535
|
+
coordinateSystemId: r.coordinate_system
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
function le(o, t, e) {
|
|
1539
|
+
const i = V.fromPose(o).multiply(V.fromRobotTcp(t).inverse()).multiply(V.fromRobotTcp(e)), { position: n, orientation: r } = i;
|
|
1540
|
+
return {
|
|
1541
|
+
position: [n.x, n.y, n.z],
|
|
1542
|
+
orientation: [r.x, r.y, r.z]
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
function Dt(o, t) {
|
|
1546
|
+
const e = o == null ? void 0 : o[t];
|
|
1547
|
+
if (!e)
|
|
1548
|
+
throw new Error(
|
|
1549
|
+
`Unknown TCP ${t}. Known TCPs are: ${Object.keys(o ?? {}).join(", ")}`
|
|
1550
|
+
);
|
|
1551
|
+
return {
|
|
1552
|
+
position: e.pose.position ?? [0, 0, 0],
|
|
1553
|
+
orientation: e.pose.orientation ?? [0, 0, 0],
|
|
1554
|
+
orientation_type: "ROTATION_VECTOR"
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
function $t({
|
|
1558
|
+
inputPose: o,
|
|
1559
|
+
selectedTcpId: t,
|
|
1560
|
+
selectedCoordinateSystemId: e,
|
|
1561
|
+
tcpOffsetsById: i,
|
|
1562
|
+
coordinateSystems: n
|
|
1563
|
+
}) {
|
|
1564
|
+
const r = t && t !== o.tcpId ? {
|
|
1565
|
+
...o,
|
|
1566
|
+
pose: le(
|
|
1567
|
+
o.pose,
|
|
1568
|
+
Dt(i, o.tcpId),
|
|
1569
|
+
Dt(i, t)
|
|
1570
|
+
),
|
|
1571
|
+
tcpId: t
|
|
1572
|
+
} : o;
|
|
1573
|
+
return e ? dt(
|
|
1574
|
+
r,
|
|
1575
|
+
e,
|
|
1576
|
+
n
|
|
1577
|
+
) : r;
|
|
1578
|
+
}
|
|
1579
|
+
function ce(o) {
|
|
1580
|
+
var t, e, i, n, r;
|
|
1581
|
+
if (typeof o == "string") {
|
|
1582
|
+
const s = J(o);
|
|
1583
|
+
return s ? ce(s) : o;
|
|
1584
|
+
}
|
|
1585
|
+
if (o && typeof o == "object") {
|
|
1586
|
+
const s = o;
|
|
1587
|
+
return (
|
|
1588
|
+
// PlanTrajectoryFailedResponse: the feedback name identifies the
|
|
1589
|
+
// failure cause (e.g. "FeedbackSingularity") and is translated to a
|
|
1590
|
+
// friendly message by getJogErrorTranslationKey
|
|
1591
|
+
((t = s.error_feedback) == null ? void 0 : t.error_feedback_name) || ((e = s.add_trajectory_error) == null ? void 0 : e.message) || s.message || ((n = (i = s.result) == null ? void 0 : i.add_trajectory_error) == null ? void 0 : n.message) || ((r = s.result) == null ? void 0 : r.message) || "Jogging motion failed"
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
return "Jogging motion failed";
|
|
1595
|
+
}
|
|
1596
|
+
const To = [
|
|
1597
|
+
// Trajectory-planning failure causes, identified by the error_feedback_name
|
|
1598
|
+
// of a PlanTrajectoryFailedResponse (see extractJogErrorMessage)
|
|
1599
|
+
{
|
|
1600
|
+
pattern: /^FeedbackSingularity$/,
|
|
1601
|
+
translationKey: "Jogging.StreamStateSection.Error.Singularity.lb"
|
|
1602
|
+
},
|
|
1603
|
+
{
|
|
1604
|
+
pattern: /^FeedbackJointLimitExceeded$/,
|
|
1605
|
+
translationKey: "Jogging.StreamStateSection.Error.JointLimit.lb"
|
|
1606
|
+
},
|
|
1607
|
+
{
|
|
1608
|
+
pattern: /^FeedbackOutOfWorkspace$/,
|
|
1609
|
+
translationKey: "Jogging.StreamStateSection.Error.OutOfWorkspace.lb"
|
|
1610
|
+
},
|
|
1611
|
+
{
|
|
1612
|
+
pattern: /^FeedbackCollision$/,
|
|
1613
|
+
translationKey: "Jogging.StreamStateSection.Error.Collision.lb"
|
|
1614
|
+
},
|
|
1615
|
+
{
|
|
1616
|
+
pattern: /^FeedbackNoSolutionInCurrentConfiguration$/,
|
|
1617
|
+
translationKey: "Jogging.StreamStateSection.Error.NoSolutionInConfiguration.lb"
|
|
1618
|
+
},
|
|
1619
|
+
{
|
|
1620
|
+
// Catch-all for the remaining Feedback* causes we have no specific
|
|
1621
|
+
// message for -- must stay after the specific patterns above
|
|
1622
|
+
pattern: /^Feedback\w+$/,
|
|
1623
|
+
translationKey: "Jogging.StreamStateSection.Error.PlanningFailed.lb"
|
|
1624
|
+
}
|
|
1625
|
+
];
|
|
1626
|
+
function jo(o) {
|
|
1627
|
+
var t;
|
|
1628
|
+
return ((t = To.find(({ pattern: e }) => e.test(o))) == null ? void 0 : t.translationKey) ?? null;
|
|
1629
|
+
}
|
|
1630
|
+
const xo = 5, Oo = 250;
|
|
1631
|
+
function ko(o) {
|
|
1632
|
+
var i, n, r, s;
|
|
1633
|
+
const t = [
|
|
1634
|
+
(n = (i = o == null ? void 0 : o.manual_t1_limits) == null ? void 0 : i.tcp) == null ? void 0 : n.velocity,
|
|
1635
|
+
(s = (r = o == null ? void 0 : o.manual_limits) == null ? void 0 : r.tcp) == null ? void 0 : s.velocity
|
|
1636
|
+
].filter(
|
|
1637
|
+
(a) => typeof a == "number" && Number.isFinite(a) && a > 0
|
|
1638
|
+
);
|
|
1639
|
+
return Math.min(Oo, ...t) / 10;
|
|
1640
|
+
}
|
|
1641
|
+
const _t = [
|
|
1642
|
+
{ id: "0.1", mm: 0.1, degrees: 0.05 },
|
|
1643
|
+
{ id: "1", mm: 1, degrees: 0.5 },
|
|
1644
|
+
{ id: "5", mm: 5, degrees: 2.5 },
|
|
1645
|
+
{ id: "10", mm: 10, degrees: 5 }
|
|
1646
|
+
], Ro = [
|
|
1647
|
+
{ id: "continuous" },
|
|
1648
|
+
..._t
|
|
1649
|
+
], Ao = ["coordsys", "tool"], Lt = "joggingToolStore", Po = () => typeof localStorage > "u" ? void 0 : localStorage;
|
|
1650
|
+
class et {
|
|
1651
|
+
constructor(t, e, i, n, r, s = {}) {
|
|
1652
|
+
var d, h, c;
|
|
1653
|
+
this.jogger = t, this.coordSystems = e, this.motionGroupDescription = i, this.tcps = n, this.inverseSolverValue = r, this.selectedTabId = "cartesian", this.locks = /* @__PURE__ */ new Set(), this.blocked = !1, this.selectedCoordSystemId = "world", this.jogCoordSystemId = "world", this.selectedTcpId = "", this.tcpChangeInProgress = !1, this.selectedOrientation = "coordsys", this.selectedIncrementId = "continuous", this.selectedCartesianMotionType = "translate", this.incrementJogInProgress = null, this.lastJogError = null, this.onBeforeActivate = null, this.rotationVelocityDegPerSec = xo, this.minTranslationVelocityMmPerSec = 1, 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 = N.RevoluteJoint, this.storage = s.storage ?? Po();
|
|
1654
|
+
for (const m of e)
|
|
1655
|
+
if (m.coordinate_system === "") {
|
|
1656
|
+
m.coordinate_system = "world";
|
|
1657
|
+
break;
|
|
1658
|
+
}
|
|
1659
|
+
this.selectedCoordSystemId = ((d = e[0]) == null ? void 0 : d.coordinate_system) || "world", this.jogCoordSystemId = this.selectedCoordSystemId, this.selectedTcpId = t.motionStream.rapidlyChangingMotionState.tcp ?? "", this.tcpChangeInProgress = this.tcps.length > 0 && !this.selectedTcpId, this.inverseSolver = r, this.translationVelocityMmPerSec = ko(
|
|
1660
|
+
i == null ? void 0 : i.operation_limits
|
|
1661
|
+
), this.jointType = ((c = (h = i == null ? void 0 : i.dh_parameters) == null ? void 0 : h[0]) == null ? void 0 : c.type) ?? N.RevoluteJoint, D(
|
|
1662
|
+
this,
|
|
1663
|
+
{ storage: !1 },
|
|
1664
|
+
{ autoBind: !0 }
|
|
1665
|
+
), this.jogger.onBlocked = () => {
|
|
1666
|
+
this.block();
|
|
1667
|
+
};
|
|
1668
|
+
const a = this.jogger.onError;
|
|
1669
|
+
this.jogger.onError = (m) => {
|
|
1670
|
+
this.setLastJogError(ce(m)), a == null || a(m);
|
|
1671
|
+
}, this.loadFromLocalStorage(), this.disposers.push(Et(() => this.saveToLocalStorage())), this.disposers.push(
|
|
1672
|
+
Et(() => {
|
|
1673
|
+
const m = this.jogger.motionStream.rapidlyChangingMotionState.tcp;
|
|
1674
|
+
m && m !== this.selectedTcpId && S(() => {
|
|
1675
|
+
this.selectedTcpId = m, this.tcpChangeInProgress = !1;
|
|
1676
|
+
});
|
|
1677
|
+
})
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Load a jogging store with the relevant data it needs
|
|
1682
|
+
* from the backend
|
|
1683
|
+
*/
|
|
1684
|
+
static async loadFor(t, e = {}) {
|
|
1685
|
+
const { nova: i, cellId: n } = t, [r, s] = await Promise.all([
|
|
1686
|
+
// Fetch coord systems so user can select between them
|
|
1687
|
+
i.api.controller.listCoordinateSystems(
|
|
1688
|
+
n,
|
|
1689
|
+
t.motionStream.controllerId,
|
|
1690
|
+
"ROTATION_VECTOR"
|
|
1691
|
+
),
|
|
1692
|
+
// Same for TCPs and other info from description
|
|
1693
|
+
i.api.motionGroup.getMotionGroupDescription(
|
|
1694
|
+
n,
|
|
1695
|
+
t.motionStream.controllerId,
|
|
1696
|
+
t.motionGroupId
|
|
1697
|
+
)
|
|
1698
|
+
]), a = await i.api.motionGroupModels.getMotionGroupKinematicModel(
|
|
1699
|
+
s.motion_group_model
|
|
1700
|
+
);
|
|
1701
|
+
return et.create(
|
|
1702
|
+
t,
|
|
1703
|
+
{
|
|
1704
|
+
coordinateSystems: r || [],
|
|
1705
|
+
description: s,
|
|
1706
|
+
kinematicModel: a
|
|
1707
|
+
},
|
|
1708
|
+
e
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Make a jogging store from data that was loaded before: the coordinate
|
|
1713
|
+
* systems of the controller, the description and the kinematic model of the
|
|
1714
|
+
* motion group. An app that loads them once for several stores uses this
|
|
1715
|
+
* instead of {@link JoggingStore.loadFor}.
|
|
1716
|
+
*/
|
|
1717
|
+
static create(t, e, i = {}) {
|
|
1718
|
+
const { coordinateSystems: n, description: r, kinematicModel: s } = e, a = Object.entries(r.tcps || {}).map(([d, h]) => ({
|
|
1719
|
+
id: d,
|
|
1720
|
+
readable_name: h.name,
|
|
1721
|
+
position: h.pose.position,
|
|
1722
|
+
orientation: h.pose.orientation
|
|
1723
|
+
}));
|
|
1724
|
+
return new et(
|
|
1725
|
+
t,
|
|
1726
|
+
n,
|
|
1727
|
+
r,
|
|
1728
|
+
a,
|
|
1729
|
+
s.inverse_solver,
|
|
1730
|
+
i
|
|
1731
|
+
);
|
|
1732
|
+
}
|
|
1733
|
+
dispose() {
|
|
1734
|
+
for (const t of this.disposers)
|
|
1735
|
+
t();
|
|
1736
|
+
this.jogger.dispose();
|
|
1737
|
+
}
|
|
1738
|
+
get coordSystemCountByName() {
|
|
1739
|
+
return ke(this.coordSystems, (t) => t.name);
|
|
1740
|
+
}
|
|
1741
|
+
async deactivate() {
|
|
1742
|
+
this.jogger.mode === "jogging" && await this.jogger.setJoggingMode("off");
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Activate the jogger with current settings. Resolves when the jogging
|
|
1746
|
+
* websocket is initialized, or when the jogging was stopped before that
|
|
1747
|
+
* (`deactivate`).
|
|
1748
|
+
*/
|
|
1749
|
+
async activate() {
|
|
1750
|
+
var t;
|
|
1751
|
+
return this.lastJogError = null, await ((t = this.onBeforeActivate) == null ? void 0 : t.call(this)), this.currentTab.id === "cartesian" ? ((this.jogger.tcp !== this.selectedTcpId || this.jogger.orientation !== this.selectedOrientation) && await this.jogger.setOptions({
|
|
1752
|
+
tcp: this.selectedTcpId || void 0,
|
|
1753
|
+
orientation: this.selectedOrientation
|
|
1754
|
+
}), this.jogger.coordinateSystem = this.jogCoordSystem, this.activeDiscreteIncrement ? await this.jogger.setJoggingMode("trajectory") : await this.jogger.setJoggingMode("jogging")) : await this.jogger.setJoggingMode("jogging"), this.jogger;
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Takes the user's settings from the storage (see
|
|
1758
|
+
* {@link JoggingStoreOptions}), which is `localStorage` only by default
|
|
1759
|
+
*/
|
|
1760
|
+
loadFromLocalStorage() {
|
|
1761
|
+
var i;
|
|
1762
|
+
const t = (i = this.storage) == null ? void 0 : i.getItem(Lt), e = t ? J(t) : void 0;
|
|
1763
|
+
e && (this.tabsById[e.selectedTabId] && (this.selectedTabId = e.selectedTabId), this.coordSystemsById[e.selectedCoordSystemId] && (this.selectedCoordSystemId = e.selectedCoordSystemId), this.coordSystemsById[e.jogCoordSystemId] && (this.jogCoordSystemId = e.jogCoordSystemId), this.incrementOptionsById[e.selectedIncrementId] && (this.selectedIncrementId = e.selectedIncrementId), ["translate", "rotate"].includes(e.selectedCartesianMotionType) && (this.selectedCartesianMotionType = e.selectedCartesianMotionType), ["coordsys", "tool"].includes(e.selectedOrientation) && (this.selectedOrientation = e.selectedOrientation));
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Keeps the user's settings in the storage (see
|
|
1767
|
+
* {@link JoggingStoreOptions}), which is `localStorage` only by default
|
|
1768
|
+
*/
|
|
1769
|
+
saveToLocalStorage() {
|
|
1770
|
+
var t;
|
|
1771
|
+
(t = this.storage) == null || t.setItem(Lt, JSON.stringify(this.localStorageSave));
|
|
1772
|
+
}
|
|
1773
|
+
get isLocked() {
|
|
1774
|
+
return this.locks.size > 0;
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Translation key for a friendlier version of
|
|
1778
|
+
* {@link JoggingStore.lastJogError}, if the raw backend message is
|
|
1779
|
+
* recognized. `null` when there's no latched error or the message isn't one
|
|
1780
|
+
* we have a friendlier version for (in which case the raw message should be
|
|
1781
|
+
* shown as-is).
|
|
1782
|
+
*/
|
|
1783
|
+
get lastJogErrorTranslationKey() {
|
|
1784
|
+
return this.lastJogError ? jo(this.lastJogError) : null;
|
|
1785
|
+
}
|
|
1786
|
+
get localStorageSave() {
|
|
1787
|
+
return {
|
|
1788
|
+
selectedTabId: this.selectedTabId,
|
|
1789
|
+
selectedCoordSystemId: this.selectedCoordSystemId,
|
|
1790
|
+
jogCoordSystemId: this.jogCoordSystemId,
|
|
1791
|
+
selectedOrientation: this.selectedOrientation,
|
|
1792
|
+
selectedIncrementId: this.selectedIncrementId,
|
|
1793
|
+
selectedCartesianMotionType: this.selectedCartesianMotionType
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* Whether the robot can jog its TCP along axes (translate, rotate): with an
|
|
1798
|
+
* inverse solver, or when none could be loaded (as a default). A kinematic
|
|
1799
|
+
* model without a solver (null), e.g. a linear axis or a turntable, jogs
|
|
1800
|
+
* its joints only.
|
|
1801
|
+
*/
|
|
1802
|
+
get canJogCartesian() {
|
|
1803
|
+
return this.inverseSolver !== null;
|
|
1804
|
+
}
|
|
1805
|
+
get tabs() {
|
|
1806
|
+
const t = [
|
|
1807
|
+
{
|
|
1808
|
+
id: "joint",
|
|
1809
|
+
label: "Joints"
|
|
1810
|
+
}
|
|
1811
|
+
];
|
|
1812
|
+
return this.canJogCartesian && t.unshift({
|
|
1813
|
+
id: "cartesian",
|
|
1814
|
+
label: "Cartesian"
|
|
1815
|
+
}), t;
|
|
1816
|
+
}
|
|
1817
|
+
get incrementOptions() {
|
|
1818
|
+
return Ro;
|
|
1819
|
+
}
|
|
1820
|
+
get discreteIncrementOptions() {
|
|
1821
|
+
return _t;
|
|
1822
|
+
}
|
|
1823
|
+
get incrementOptionsById() {
|
|
1824
|
+
return q(this.incrementOptions, (t) => t.id);
|
|
1825
|
+
}
|
|
1826
|
+
get tabsById() {
|
|
1827
|
+
return q(this.tabs, (t) => t.id);
|
|
1828
|
+
}
|
|
1829
|
+
get currentTab() {
|
|
1830
|
+
return this.tabsById[this.selectedTabId] || this.tabs[0];
|
|
1831
|
+
}
|
|
1832
|
+
get tabIndex() {
|
|
1833
|
+
return this.tabs.indexOf(this.currentTab);
|
|
1834
|
+
}
|
|
1835
|
+
get coordSystemsById() {
|
|
1836
|
+
return q(this.coordSystems, (t) => t.coordinate_system);
|
|
1837
|
+
}
|
|
1838
|
+
/**
|
|
1839
|
+
* The id of the coordinate system to use for jogging.
|
|
1840
|
+
* If in tool orientation, this is set to "tool", not the
|
|
1841
|
+
* selected coordinate system.
|
|
1842
|
+
*/
|
|
1843
|
+
get activeCoordSystemId() {
|
|
1844
|
+
return this.selectedOrientation === "tool" ? "tool" : this.selectedCoordSystemId;
|
|
1845
|
+
}
|
|
1846
|
+
/** The coordinate system to jog along, resolved relative to world */
|
|
1847
|
+
get jogCoordSystem() {
|
|
1848
|
+
return Mo(
|
|
1849
|
+
this.jogCoordSystemId,
|
|
1850
|
+
this.coordSystems
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* The streamed TCP pose (its readout, see
|
|
1855
|
+
* {@link MotionStreamConnection.readoutState}) expressed in the selected
|
|
1856
|
+
* coordinate system, for values that show what a pose field in that
|
|
1857
|
+
* coordinate system shows.
|
|
1858
|
+
*/
|
|
1859
|
+
get tcpPoseInSelectedCoordSystem() {
|
|
1860
|
+
const { tcp_pose: t, coordinate_system: e } = this.jogger.motionStream.readoutState;
|
|
1861
|
+
return !(t != null && t.position) || !t.orientation ? t : dt(
|
|
1862
|
+
{
|
|
1863
|
+
pose: {
|
|
1864
|
+
position: t.position,
|
|
1865
|
+
orientation: t.orientation
|
|
1866
|
+
},
|
|
1867
|
+
coordinateSystemId: e || "world"
|
|
1868
|
+
},
|
|
1869
|
+
this.selectedCoordSystemId,
|
|
1870
|
+
this.coordSystems
|
|
1871
|
+
).pose;
|
|
1872
|
+
}
|
|
1873
|
+
get tcpsById() {
|
|
1874
|
+
return q(this.tcps, (t) => t.id);
|
|
1875
|
+
}
|
|
1876
|
+
/**
|
|
1877
|
+
* The streamed TCP pose (its readout) as the pose of a TCP, relative to a
|
|
1878
|
+
* coordinate system: for a pose display with a TCP and frame of its own,
|
|
1879
|
+
* like CurrentPoseBar. Undefined without a pose, or for an unknown TCP or
|
|
1880
|
+
* coordinate system.
|
|
1881
|
+
*/
|
|
1882
|
+
tcpPoseIn(t, e) {
|
|
1883
|
+
const { tcp_pose: i, tcp: n, coordinate_system: r } = this.jogger.motionStream.readoutState, s = this.tcpsById[n || this.selectedTcpId], a = this.tcpsById[t];
|
|
1884
|
+
if (!(!(i != null && i.position) || !i.orientation) && !(!s || !a))
|
|
1885
|
+
try {
|
|
1886
|
+
return dt(
|
|
1887
|
+
{
|
|
1888
|
+
pose: le(i, s, a),
|
|
1889
|
+
coordinateSystemId: r || "world"
|
|
1890
|
+
},
|
|
1891
|
+
e,
|
|
1892
|
+
this.coordSystems
|
|
1893
|
+
).pose;
|
|
1894
|
+
} catch {
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* The step of the selected increment, or undefined for continuous jogging.
|
|
1900
|
+
* In tool orientation, a step moves along the tool's axes.
|
|
1901
|
+
*/
|
|
1902
|
+
get activeDiscreteIncrement() {
|
|
1903
|
+
return _t.find(
|
|
1904
|
+
(t) => t.id === this.selectedIncrementId
|
|
1905
|
+
);
|
|
1906
|
+
}
|
|
1907
|
+
/** The selected rotation velocity converted to radians per second */
|
|
1908
|
+
get rotationVelocityRadsPerSec() {
|
|
1909
|
+
return this.rotationVelocityDegPerSec * Math.PI / 180;
|
|
1910
|
+
}
|
|
1911
|
+
/** Selected velocity in mm/sec or deg/sec */
|
|
1912
|
+
velocityInDisplayUnits(t) {
|
|
1913
|
+
return t ? this.rotationVelocityDegPerSec : this.translationVelocityMmPerSec;
|
|
1914
|
+
}
|
|
1915
|
+
/** Minimum selectable velocity in mm/sec or deg/sec */
|
|
1916
|
+
minVelocityInDisplayUnits(t) {
|
|
1917
|
+
return t ? this.minRotationVelocityDegPerSec : this.minTranslationVelocityMmPerSec;
|
|
1918
|
+
}
|
|
1919
|
+
/** Maximum selectable velocity in mm/sec or deg/sec */
|
|
1920
|
+
maxVelocityInDisplayUnits(t) {
|
|
1921
|
+
return t ? this.maxRotationVelocityDegPerSec : this.maxTranslationVelocityMmPerSec;
|
|
1922
|
+
}
|
|
1923
|
+
onTabChange(t, e) {
|
|
1924
|
+
const i = this.tabs[e] || this.tabs[0];
|
|
1925
|
+
this.selectedTabId = i.id;
|
|
1926
|
+
}
|
|
1927
|
+
setSelectedCoordSystemId(t) {
|
|
1928
|
+
this.selectedCoordSystemId = t;
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* @deprecated Use {@link JoggingStore.requestTcpChange} instead. This method now delegates
|
|
1932
|
+
* to `requestTcpChange` which properly communicates the TCP change to the server.
|
|
1933
|
+
*/
|
|
1934
|
+
setSelectedTcpId(t) {
|
|
1935
|
+
this.requestTcpChange(t).catch((e) => {
|
|
1936
|
+
console.error("Failed to change TCP:", e);
|
|
1937
|
+
});
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Request a TCP change on the server. Sends an InitializeJoggingRequest
|
|
1941
|
+
* with the new TCP to the backend via the jogging websocket.
|
|
1942
|
+
*
|
|
1943
|
+
* If the jogger is actively jogging, the websocket is reinitialised with the new TCP.
|
|
1944
|
+
* If the jogger is idle, a jogging websocket is briefly opened to communicate the
|
|
1945
|
+
* TCP change. The websocket is kept open until the state-stream confirms the
|
|
1946
|
+
* change (or a 1s timeout), to ensure the backend has time to process it.
|
|
1947
|
+
*/
|
|
1948
|
+
async requestTcpChange(t) {
|
|
1949
|
+
if (t === this.selectedTcpId) return;
|
|
1950
|
+
this.tcpChangeInProgress = !0;
|
|
1951
|
+
const e = this.jogger.tcp, i = this.jogger.mode !== "jogging";
|
|
1952
|
+
try {
|
|
1953
|
+
this.jogger.tcp = t, i ? await this.jogger.setJoggingMode("jogging") : await this.jogger.setJoggingMode("jogging", !1);
|
|
1954
|
+
let n = await this.waitForTcpConfirmation(t, 1e3);
|
|
1955
|
+
i && await this.jogger.setJoggingMode("off"), n || (n = await this.waitForTcpConfirmation(t, 2e3)), S(() => {
|
|
1956
|
+
n ? this.selectedTcpId = t : (this.jogger.tcp = e, this.selectedTcpId = this.jogger.motionStream.rapidlyChangingMotionState.tcp ?? "");
|
|
1957
|
+
});
|
|
1958
|
+
} catch (n) {
|
|
1959
|
+
throw i && await this.jogger.setJoggingMode("off").catch(() => {
|
|
1960
|
+
}), S(() => {
|
|
1961
|
+
this.jogger.tcp = e, this.selectedTcpId = this.jogger.motionStream.rapidlyChangingMotionState.tcp ?? "";
|
|
1962
|
+
}), n;
|
|
1963
|
+
} finally {
|
|
1964
|
+
S(() => {
|
|
1965
|
+
this.tcpChangeInProgress = !1;
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
waitForTcpConfirmation(t, e) {
|
|
1970
|
+
return new Promise((i) => {
|
|
1971
|
+
const n = setTimeout(() => {
|
|
1972
|
+
r(), i(!1);
|
|
1973
|
+
}, e), r = lt(
|
|
1974
|
+
() => this.jogger.motionStream.rapidlyChangingMotionState.tcp === t,
|
|
1975
|
+
() => {
|
|
1976
|
+
clearTimeout(n), i(!0);
|
|
1977
|
+
}
|
|
1978
|
+
);
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
setSelectedOrientation(t) {
|
|
1982
|
+
this.selectedOrientation = t;
|
|
1983
|
+
}
|
|
1984
|
+
/** "Move relative to" the selected TCP: jog along its own axes */
|
|
1985
|
+
setMoveRelativeToSelectedTcp() {
|
|
1986
|
+
this.selectedOrientation = "tool";
|
|
1987
|
+
}
|
|
1988
|
+
/** "Move relative to" a coordinate system: jog along its axes */
|
|
1989
|
+
setMoveRelativeToCoordSystem(t) {
|
|
1990
|
+
this.selectedOrientation = "coordsys", this.jogCoordSystemId = t;
|
|
1991
|
+
}
|
|
1992
|
+
setSelectedIncrementId(t) {
|
|
1993
|
+
this.selectedIncrementId = t;
|
|
1994
|
+
}
|
|
1995
|
+
setCurrentIncrementJog(t) {
|
|
1996
|
+
this.incrementJogInProgress = t;
|
|
1997
|
+
}
|
|
1998
|
+
setLastJogError(t) {
|
|
1999
|
+
this.lastJogError = t;
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Set the selected velocity in mm/s or °/s, from the slider or a velocity
|
|
2003
|
+
* text field. Values outside the slider range (and values that are not a
|
|
2004
|
+
* finite number) are ignored; a text field reports them to the user
|
|
2005
|
+
* instead of applying them.
|
|
2006
|
+
*/
|
|
2007
|
+
setVelocityFromSlider(t, e) {
|
|
2008
|
+
!Number.isFinite(t) || t < this.minVelocityInDisplayUnits(e) || t > this.maxVelocityInDisplayUnits(e) || (e ? this.rotationVelocityDegPerSec = t : this.translationVelocityMmPerSec = t);
|
|
2009
|
+
}
|
|
2010
|
+
setSelectedCartesianMotionType(t) {
|
|
2011
|
+
this.selectedCartesianMotionType = t;
|
|
2012
|
+
}
|
|
2013
|
+
lock(t) {
|
|
2014
|
+
this.locks.add(t);
|
|
2015
|
+
}
|
|
2016
|
+
unlock(t) {
|
|
2017
|
+
this.locks.delete(t);
|
|
2018
|
+
}
|
|
2019
|
+
block() {
|
|
2020
|
+
this.blocked = !0;
|
|
2021
|
+
}
|
|
2022
|
+
unblock() {
|
|
2023
|
+
this.blocked = !1, this.jogger.mode === "jogging" && this.jogger.initializeJoggingWebsocket().catch((t) => {
|
|
2024
|
+
console.error("Failed to initialize jogging:", t);
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
/** Lock the UI until the given async callback resolves */
|
|
2028
|
+
async withMotionLock(t) {
|
|
2029
|
+
const e = Ze();
|
|
2030
|
+
this.lock(e);
|
|
2031
|
+
try {
|
|
2032
|
+
return await t();
|
|
2033
|
+
} finally {
|
|
2034
|
+
this.unlock(e);
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
const Jo = A(
|
|
2039
|
+
({ store: o, useDegree: t }) => {
|
|
2040
|
+
var s;
|
|
2041
|
+
const { t: e } = F(), i = Ee(), n = [];
|
|
2042
|
+
function r(a) {
|
|
2043
|
+
switch (a) {
|
|
2044
|
+
case "coordsys":
|
|
2045
|
+
return e("Jogging.Orientation.coordsys");
|
|
2046
|
+
case "tool":
|
|
2047
|
+
return e("Jogging.Orientation.tool");
|
|
2048
|
+
default:
|
|
2049
|
+
return a;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
return o.showCoordSystemSelect && n.push(
|
|
2053
|
+
/* @__PURE__ */ g(
|
|
2054
|
+
rt,
|
|
2055
|
+
{
|
|
2056
|
+
labelId: `jogging-coord-select-${i}`,
|
|
2057
|
+
labelValue: e("Jogging.CoordinateSystem.hlb"),
|
|
2058
|
+
value: o.selectedCoordSystemId,
|
|
2059
|
+
size: "small",
|
|
2060
|
+
variant: "filled",
|
|
2061
|
+
displayEmpty: !0,
|
|
2062
|
+
onChange: (a) => o.setSelectedCoordSystemId(a.target.value),
|
|
2063
|
+
children: o.coordSystems.map((a) => /* @__PURE__ */ g(W, { value: a.coordinate_system, children: a.name && o.coordSystemCountByName[a.name] > 1 ? `${a.name} / ${a.coordinate_system}` : a.name || a.coordinate_system }, a.coordinate_system))
|
|
2064
|
+
},
|
|
2065
|
+
"coord"
|
|
2066
|
+
)
|
|
2067
|
+
), o.showTcpSelect && n.push(
|
|
2068
|
+
/* @__PURE__ */ g(
|
|
2069
|
+
rt,
|
|
2070
|
+
{
|
|
2071
|
+
labelId: `jogging-tcp-select-${i}`,
|
|
2072
|
+
labelValue: "TCP",
|
|
2073
|
+
value: o.selectedTcpId,
|
|
2074
|
+
size: "small",
|
|
2075
|
+
variant: "filled",
|
|
2076
|
+
displayEmpty: o.tcpChangeInProgress,
|
|
2077
|
+
onChange: (a) => {
|
|
2078
|
+
o.requestTcpChange(a.target.value).catch((d) => {
|
|
2079
|
+
console.error("Failed to change TCP:", d);
|
|
2080
|
+
});
|
|
2081
|
+
},
|
|
2082
|
+
disabled: o.tcpChangeInProgress,
|
|
2083
|
+
endAdornment: o.tcpChangeInProgress ? /* @__PURE__ */ g(Le, { position: "end", children: /* @__PURE__ */ g(Wt, { size: 16 }) }) : void 0,
|
|
2084
|
+
children: o.tcps.map((a) => /* @__PURE__ */ g(W, { value: a.id, children: a.id }, a.id))
|
|
2085
|
+
},
|
|
2086
|
+
"tcp"
|
|
2087
|
+
)
|
|
2088
|
+
), o.showOrientationSelect && n.push(
|
|
2089
|
+
/* @__PURE__ */ g(
|
|
2090
|
+
rt,
|
|
2091
|
+
{
|
|
2092
|
+
labelValue: e("Jogging.Cartesian.Orientation.lb"),
|
|
2093
|
+
labelId: `orientation-select-${i}`,
|
|
2094
|
+
value: o.selectedOrientation,
|
|
2095
|
+
onChange: (a) => o.setSelectedOrientation(a.target.value),
|
|
2096
|
+
children: Ao.map((a) => /* @__PURE__ */ g(W, { value: a, children: r(a) }, a))
|
|
2097
|
+
},
|
|
2098
|
+
"orientation"
|
|
2099
|
+
)
|
|
2100
|
+
), o.showIncrementSelect && n.push(
|
|
2101
|
+
/* @__PURE__ */ _(
|
|
2102
|
+
rt,
|
|
2103
|
+
{
|
|
2104
|
+
labelValue: e("Jogging.Increment.hlb"),
|
|
2105
|
+
labelId: `jogging-increment-select-${i}`,
|
|
2106
|
+
size: "small",
|
|
2107
|
+
variant: "filled",
|
|
2108
|
+
value: ((s = o.activeDiscreteIncrement) == null ? void 0 : s.id) || "continuous",
|
|
2109
|
+
onChange: (a) => o.setSelectedIncrementId(
|
|
2110
|
+
a.target.value
|
|
2111
|
+
),
|
|
2112
|
+
children: [
|
|
2113
|
+
/* @__PURE__ */ g(W, { value: "continuous", children: e("Jogging.Increment.Continuous.dd") }, "continuous"),
|
|
2114
|
+
o.discreteIncrementOptions.map((a) => /* @__PURE__ */ g(W, { value: a.id, children: t ? `${a.degrees}°` : `${a.mm}mm` }, a.id))
|
|
2115
|
+
]
|
|
2116
|
+
},
|
|
2117
|
+
"increment"
|
|
2118
|
+
)
|
|
2119
|
+
), /* @__PURE__ */ g(
|
|
2120
|
+
B,
|
|
2121
|
+
{
|
|
2122
|
+
component: "div",
|
|
2123
|
+
"data-testid": "jogging-options",
|
|
2124
|
+
"aria-label": "jogging-options",
|
|
2125
|
+
sx: {
|
|
2126
|
+
display: "grid",
|
|
2127
|
+
gap: "16px",
|
|
2128
|
+
gridTemplateColumns: "1fr 1fr",
|
|
2129
|
+
gridAutoRows: "min-content",
|
|
2130
|
+
"& label": { opacity: 0.7, fontSize: "12px", marginBottom: "4px" }
|
|
2131
|
+
},
|
|
2132
|
+
children: n.map((a, d) => /* @__PURE__ */ g(
|
|
2133
|
+
B,
|
|
2134
|
+
{
|
|
2135
|
+
sx: {
|
|
2136
|
+
gridColumn: n.length % 2 === 1 && d === n.length - 1 ? "span 2" : "auto"
|
|
2137
|
+
},
|
|
2138
|
+
children: a
|
|
2139
|
+
},
|
|
2140
|
+
d
|
|
2141
|
+
))
|
|
2142
|
+
}
|
|
2143
|
+
);
|
|
2144
|
+
}
|
|
2145
|
+
), Do = Ht(Be)(({ theme: o }) => {
|
|
2146
|
+
var t;
|
|
2147
|
+
return {
|
|
2148
|
+
"&.MuiToggleButtonGroup-root": {
|
|
2149
|
+
background: (t = o.palette.backgroundPaperElevation) == null ? void 0 : t[8],
|
|
2150
|
+
borderRadius: "8px",
|
|
2151
|
+
padding: "4px",
|
|
2152
|
+
gap: "4px",
|
|
2153
|
+
button: {
|
|
2154
|
+
border: "none",
|
|
2155
|
+
borderRadius: "4px",
|
|
2156
|
+
flex: "1 1 0px",
|
|
2157
|
+
minWidth: 0,
|
|
2158
|
+
"&.MuiToggleButtonGroup-firstButton": {
|
|
2159
|
+
borderRadius: "8px 4px 4px 8px"
|
|
2160
|
+
},
|
|
2161
|
+
"&.MuiToggleButtonGroup-lastButton": {
|
|
2162
|
+
borderRadius: "4px 8px 8px 4px"
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
};
|
|
2167
|
+
}), $o = it(
|
|
2168
|
+
A((o) => {
|
|
2169
|
+
const { store: t } = o, { t: e } = F();
|
|
2170
|
+
function i(n, r) {
|
|
2171
|
+
r === o.velocity || !Ge(r) || o.onVelocityChange(r, o.useDegree);
|
|
2172
|
+
}
|
|
2173
|
+
return /* @__PURE__ */ _(
|
|
2174
|
+
C,
|
|
2175
|
+
{
|
|
2176
|
+
direction: "row",
|
|
2177
|
+
gap: 2,
|
|
2178
|
+
alignItems: "center",
|
|
2179
|
+
"data-testid": "velocity-slider",
|
|
2180
|
+
"aria-label": "velocity-slider",
|
|
2181
|
+
children: [
|
|
2182
|
+
t.showVelocityLegend && /* @__PURE__ */ g(
|
|
2183
|
+
M,
|
|
2184
|
+
{
|
|
2185
|
+
sx: {
|
|
2186
|
+
color: $e,
|
|
2187
|
+
fontSize: "14px"
|
|
2188
|
+
},
|
|
2189
|
+
children: e("Jogging.Velocity.bt")
|
|
2190
|
+
}
|
|
2191
|
+
),
|
|
2192
|
+
/* @__PURE__ */ g(
|
|
2193
|
+
Qt,
|
|
2194
|
+
{
|
|
2195
|
+
value: o.velocity,
|
|
2196
|
+
color: "secondary",
|
|
2197
|
+
onChange: i,
|
|
2198
|
+
min: o.min,
|
|
2199
|
+
max: o.max,
|
|
2200
|
+
"aria-labelledby": "input-slider",
|
|
2201
|
+
disabled: o.disabled,
|
|
2202
|
+
sx: {
|
|
2203
|
+
"& .MuiSlider-valueLabelOpen": {
|
|
2204
|
+
zIndex: 100,
|
|
2205
|
+
backgroundColor: "transparent",
|
|
2206
|
+
top: "0px"
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
),
|
|
2211
|
+
t.showVelocitySliderLabel && (o.renderValue ? o.renderValue(o.velocity) : /* @__PURE__ */ g(de, { value: o.velocity.toString() }))
|
|
2212
|
+
]
|
|
2213
|
+
}
|
|
2214
|
+
);
|
|
2215
|
+
})
|
|
2216
|
+
);
|
|
2217
|
+
function de({ value: o, sx: t }) {
|
|
2218
|
+
var i;
|
|
2219
|
+
const e = K();
|
|
2220
|
+
return /* @__PURE__ */ g(
|
|
2221
|
+
C,
|
|
2222
|
+
{
|
|
2223
|
+
direction: "row",
|
|
2224
|
+
justifyContent: "center",
|
|
2225
|
+
alignItems: "center",
|
|
2226
|
+
gap: "5px",
|
|
2227
|
+
sx: {
|
|
2228
|
+
padding: "6px 12px",
|
|
2229
|
+
background: (i = e.palette.backgroundPaperElevation) == null ? void 0 : i[8],
|
|
2230
|
+
borderRadius: "10px",
|
|
2231
|
+
minWidth: "111px",
|
|
2232
|
+
...t
|
|
2233
|
+
},
|
|
2234
|
+
children: /* @__PURE__ */ g(
|
|
2235
|
+
M,
|
|
2236
|
+
{
|
|
2237
|
+
component: "span",
|
|
2238
|
+
sx: {
|
|
2239
|
+
textAlign: "right",
|
|
2240
|
+
fontSize: "14px",
|
|
2241
|
+
opacity: 0.8,
|
|
2242
|
+
color: e.palette.text.primary,
|
|
2243
|
+
whiteSpace: "nowrap"
|
|
2244
|
+
},
|
|
2245
|
+
children: o
|
|
2246
|
+
}
|
|
2247
|
+
)
|
|
2248
|
+
}
|
|
2249
|
+
);
|
|
2250
|
+
}
|
|
2251
|
+
const ge = A(
|
|
2252
|
+
({ store: o, useDegree: t }) => {
|
|
2253
|
+
const { t: e } = F();
|
|
2254
|
+
function i(n, r) {
|
|
2255
|
+
return r ? `ω = ${e("Jogging.Cartesian.Rotation.velocityDegPerSec.lb", { amount: n })}` : `v = ${e("Jogging.Cartesian.Translation.velocityMmPerSec.lb", { amount: n })}`;
|
|
2256
|
+
}
|
|
2257
|
+
return /* @__PURE__ */ g(
|
|
2258
|
+
$o,
|
|
2259
|
+
{
|
|
2260
|
+
store: o,
|
|
2261
|
+
velocity: o.velocityInDisplayUnits(t),
|
|
2262
|
+
min: o.minVelocityInDisplayUnits(t),
|
|
2263
|
+
max: o.maxVelocityInDisplayUnits(t),
|
|
2264
|
+
onVelocityChange: o.setVelocityFromSlider,
|
|
2265
|
+
useDegree: t,
|
|
2266
|
+
disabled: o.isLocked,
|
|
2267
|
+
renderValue: (n) => /* @__PURE__ */ g(
|
|
2268
|
+
de,
|
|
2269
|
+
{
|
|
2270
|
+
value: i(n, t),
|
|
2271
|
+
sx: {
|
|
2272
|
+
minWidth: "111px",
|
|
2273
|
+
span: {
|
|
2274
|
+
transform: "translateY(-1.5px)"
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
)
|
|
2279
|
+
}
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
), he = A(({ store: o }) => {
|
|
2283
|
+
var s, a, d;
|
|
2284
|
+
const { t } = F(), e = K(), i = ((d = (a = (s = o.jogger.motionStream.rapidlyChangingMotionState.execute) == null ? void 0 : s.details) == null ? void 0 : a.state) == null ? void 0 : d.kind) ?? "KIND_UNKNOWN", n = o.lastJogError, r = o.lastJogErrorTranslationKey;
|
|
2285
|
+
return /* @__PURE__ */ _(
|
|
2286
|
+
B,
|
|
2287
|
+
{
|
|
2288
|
+
sx: {
|
|
2289
|
+
display: "flex",
|
|
2290
|
+
flexDirection: "row",
|
|
2291
|
+
justifyContent: "space-between",
|
|
2292
|
+
color: e.palette.text.primary
|
|
2293
|
+
},
|
|
2294
|
+
children: [
|
|
2295
|
+
/* @__PURE__ */ g(
|
|
2296
|
+
M,
|
|
2297
|
+
{
|
|
2298
|
+
variant: "body2",
|
|
2299
|
+
sx: {
|
|
2300
|
+
fontSize: "0.75rem",
|
|
2301
|
+
// Smaller than body2
|
|
2302
|
+
lineHeight: 1.2
|
|
2303
|
+
},
|
|
2304
|
+
children: t("Jogging.StreamStateSection.lb")
|
|
2305
|
+
}
|
|
2306
|
+
),
|
|
2307
|
+
/* @__PURE__ */ g(
|
|
2308
|
+
M,
|
|
2309
|
+
{
|
|
2310
|
+
variant: "body2",
|
|
2311
|
+
color: n ? "error" : void 0,
|
|
2312
|
+
sx: {
|
|
2313
|
+
fontSize: "0.75rem",
|
|
2314
|
+
// Smaller than body2
|
|
2315
|
+
lineHeight: 1.2,
|
|
2316
|
+
textAlign: "right"
|
|
2317
|
+
},
|
|
2318
|
+
"data-testid": n ? "JOG_ERROR" : i,
|
|
2319
|
+
children: n ? r ? t(r) : n : t(`Jogging.StreamStateSection.${i}.lb`)
|
|
2320
|
+
}
|
|
2321
|
+
)
|
|
2322
|
+
]
|
|
2323
|
+
}
|
|
2324
|
+
);
|
|
2325
|
+
}), Lo = A(
|
|
2326
|
+
({
|
|
2327
|
+
store: o,
|
|
2328
|
+
children: t
|
|
2329
|
+
}) => {
|
|
2330
|
+
const { t: e } = F(), i = K(), n = gt(0);
|
|
2331
|
+
function r(u, l) {
|
|
2332
|
+
(l === "translate" || l === "rotate") && o.setSelectedCartesianMotionType(l);
|
|
2333
|
+
}
|
|
2334
|
+
async function s(u, l) {
|
|
2335
|
+
const p = await o.activate(), f = p.motionStream.rapidlyChangingMotionState.tcp_pose, v = p.motionStream.rapidlyChangingMotionState.joint_position;
|
|
2336
|
+
f && await o.withMotionLock(async () => {
|
|
2337
|
+
try {
|
|
2338
|
+
o.setCurrentIncrementJog({
|
|
2339
|
+
axis: u.axis,
|
|
2340
|
+
direction: u.direction
|
|
2341
|
+
}), await o.jogger.runIncrementalCartesianMotion({
|
|
2342
|
+
currentTcpPose: f,
|
|
2343
|
+
currentJoints: v,
|
|
2344
|
+
coordSystemId: o.activeCoordSystemId,
|
|
2345
|
+
velocityInRelevantUnits: o.selectedCartesianMotionType === "translate" ? o.translationVelocityMmPerSec : o.rotationVelocityRadsPerSec,
|
|
2346
|
+
axis: u.axis,
|
|
2347
|
+
direction: u.direction,
|
|
2348
|
+
motion: o.selectedCartesianMotionType === "translate" ? {
|
|
2349
|
+
type: "translate",
|
|
2350
|
+
distanceMm: l.mm
|
|
2351
|
+
} : {
|
|
2352
|
+
type: "rotate",
|
|
2353
|
+
distanceRads: Je(l.degrees)
|
|
2354
|
+
}
|
|
2355
|
+
});
|
|
2356
|
+
} finally {
|
|
2357
|
+
o.setCurrentIncrementJog(null), await o.deactivate();
|
|
2358
|
+
}
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
async function a(u) {
|
|
2362
|
+
if (o.isLocked) return;
|
|
2363
|
+
const l = ++n.current;
|
|
2364
|
+
try {
|
|
2365
|
+
if (await o.activate(), l !== n.current) return;
|
|
2366
|
+
if (o.activeDiscreteIncrement)
|
|
2367
|
+
return await s(
|
|
2368
|
+
u,
|
|
2369
|
+
o.activeDiscreteIncrement
|
|
2370
|
+
);
|
|
2371
|
+
u.motionType === "translate" ? await o.jogger.translateTCP({
|
|
2372
|
+
axis: u.axis,
|
|
2373
|
+
direction: u.direction,
|
|
2374
|
+
velocityMmPerSec: o.translationVelocityMmPerSec
|
|
2375
|
+
}) : await o.jogger.rotateTCP({
|
|
2376
|
+
axis: u.axis,
|
|
2377
|
+
direction: u.direction,
|
|
2378
|
+
velocityRadsPerSec: o.rotationVelocityRadsPerSec
|
|
2379
|
+
});
|
|
2380
|
+
} catch (p) {
|
|
2381
|
+
console.error("Jogging failed:", p);
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
async function d() {
|
|
2385
|
+
o.isLocked || o.activeDiscreteIncrement || (n.current++, await o.deactivate());
|
|
2386
|
+
}
|
|
2387
|
+
const h = [
|
|
2388
|
+
{
|
|
2389
|
+
id: "x",
|
|
2390
|
+
icon: /* @__PURE__ */ g(yo, {}),
|
|
2391
|
+
colors: pt.X
|
|
2392
|
+
},
|
|
2393
|
+
{
|
|
2394
|
+
id: "y",
|
|
2395
|
+
icon: /* @__PURE__ */ g(vo, {}),
|
|
2396
|
+
colors: pt.Y
|
|
2397
|
+
},
|
|
2398
|
+
{
|
|
2399
|
+
id: "z",
|
|
2400
|
+
icon: /* @__PURE__ */ g(bo, {}),
|
|
2401
|
+
colors: pt.Z
|
|
2402
|
+
}
|
|
2403
|
+
];
|
|
2404
|
+
function c(u) {
|
|
2405
|
+
return e("General.mm.variable", { amount: u.toFixed(1) });
|
|
2406
|
+
}
|
|
2407
|
+
function m(u) {
|
|
2408
|
+
return e("General.degree.variable", {
|
|
2409
|
+
amount: Yt(u).toFixed(1)
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
return /* @__PURE__ */ _(
|
|
2413
|
+
C,
|
|
2414
|
+
{
|
|
2415
|
+
"data-testid": "jogging-cartesian-tab",
|
|
2416
|
+
"aria-label": "jogging-cartesian-tab",
|
|
2417
|
+
flexGrow: 1,
|
|
2418
|
+
gap: 2,
|
|
2419
|
+
sx: { padding: "18px 24px" },
|
|
2420
|
+
children: [
|
|
2421
|
+
/* @__PURE__ */ _(C, { gap: 2, children: [
|
|
2422
|
+
/* @__PURE__ */ g(
|
|
2423
|
+
Jo,
|
|
2424
|
+
{
|
|
2425
|
+
store: o,
|
|
2426
|
+
useDegree: o.selectedCartesianMotionType === "rotate"
|
|
2427
|
+
}
|
|
2428
|
+
),
|
|
2429
|
+
/* @__PURE__ */ g(
|
|
2430
|
+
ge,
|
|
2431
|
+
{
|
|
2432
|
+
store: o,
|
|
2433
|
+
useDegree: o.selectedCartesianMotionType === "rotate"
|
|
2434
|
+
}
|
|
2435
|
+
),
|
|
2436
|
+
/* @__PURE__ */ g(H, {})
|
|
2437
|
+
] }),
|
|
2438
|
+
/* @__PURE__ */ g(
|
|
2439
|
+
C,
|
|
2440
|
+
{
|
|
2441
|
+
marginLeft: "auto",
|
|
2442
|
+
marginRight: "auto",
|
|
2443
|
+
gap: "24px",
|
|
2444
|
+
justifyContent: "center",
|
|
2445
|
+
sx: { flexGrow: "1" },
|
|
2446
|
+
children: /* @__PURE__ */ _(
|
|
2447
|
+
C,
|
|
2448
|
+
{
|
|
2449
|
+
alignItems: "center",
|
|
2450
|
+
justifyContent: "center",
|
|
2451
|
+
gap: "24px",
|
|
2452
|
+
sx: { flexGrow: 1 },
|
|
2453
|
+
children: [
|
|
2454
|
+
/* @__PURE__ */ _(
|
|
2455
|
+
Do,
|
|
2456
|
+
{
|
|
2457
|
+
value: o.selectedCartesianMotionType,
|
|
2458
|
+
onChange: r,
|
|
2459
|
+
exclusive: !0,
|
|
2460
|
+
"aria-label": e("Jogging.Cartesian.MotionType.lb"),
|
|
2461
|
+
sx: { justifyContent: "center" },
|
|
2462
|
+
children: [
|
|
2463
|
+
/* @__PURE__ */ g(It, { value: "translate", children: e("Jogging.Cartesian.Translation.bt") }),
|
|
2464
|
+
/* @__PURE__ */ g(It, { value: "rotate", children: e("Jogging.Cartesian.Rotation.bt") })
|
|
2465
|
+
]
|
|
2466
|
+
}
|
|
2467
|
+
),
|
|
2468
|
+
o.selectedCartesianMotionType === "translate" && h.map((u) => {
|
|
2469
|
+
var l, p;
|
|
2470
|
+
return /* @__PURE__ */ g(
|
|
2471
|
+
Rt,
|
|
2472
|
+
{
|
|
2473
|
+
"data-testid": `jogging-cartesian-axis-control-${u.id}`,
|
|
2474
|
+
"aria-label": `jogging-cartesian-axis-control-${u.id}`,
|
|
2475
|
+
colors: u.colors,
|
|
2476
|
+
disabled: o.isLocked,
|
|
2477
|
+
activeJoggingDirection: ((l = o.incrementJogInProgress) == null ? void 0 : l.axis) === u.id ? o.incrementJogInProgress.direction : void 0,
|
|
2478
|
+
label: /* @__PURE__ */ _(st, { children: [
|
|
2479
|
+
u.icon,
|
|
2480
|
+
/* @__PURE__ */ g(
|
|
2481
|
+
M,
|
|
2482
|
+
{
|
|
2483
|
+
sx: {
|
|
2484
|
+
fontSize: "24px",
|
|
2485
|
+
color: ((p = u.colors) == null ? void 0 : p.labelColor) ?? i.palette.text.primary
|
|
2486
|
+
},
|
|
2487
|
+
children: u.id.toUpperCase()
|
|
2488
|
+
}
|
|
2489
|
+
)
|
|
2490
|
+
] }),
|
|
2491
|
+
getDisplayedValue: () => {
|
|
2492
|
+
var f, v;
|
|
2493
|
+
return c(
|
|
2494
|
+
((v = (f = o.jogger.motionStream.rapidlyChangingMotionState.tcp_pose) == null ? void 0 : f.position) == null ? void 0 : v[Mt[u.id]]) || 0
|
|
2495
|
+
);
|
|
2496
|
+
},
|
|
2497
|
+
startJogging: (f) => a({
|
|
2498
|
+
axis: u.id,
|
|
2499
|
+
motionType: "translate",
|
|
2500
|
+
direction: f
|
|
2501
|
+
}),
|
|
2502
|
+
stopJogging: d
|
|
2503
|
+
},
|
|
2504
|
+
u.id
|
|
2505
|
+
);
|
|
2506
|
+
}),
|
|
2507
|
+
o.selectedCartesianMotionType === "rotate" && h.map((u) => {
|
|
2508
|
+
var l, p;
|
|
2509
|
+
return /* @__PURE__ */ g(
|
|
2510
|
+
Rt,
|
|
2511
|
+
{
|
|
2512
|
+
"data-testid": `jogging-cartesian-axis-control-${u.id}`,
|
|
2513
|
+
"aria-label": `jogging-cartesian-axis-control-${u.id}`,
|
|
2514
|
+
colors: u.colors,
|
|
2515
|
+
disabled: o.isLocked,
|
|
2516
|
+
activeJoggingDirection: ((l = o.incrementJogInProgress) == null ? void 0 : l.axis) === u.id ? o.incrementJogInProgress.direction : void 0,
|
|
2517
|
+
label: /* @__PURE__ */ _(st, { children: [
|
|
2518
|
+
/* @__PURE__ */ g(wo, {}),
|
|
2519
|
+
/* @__PURE__ */ g(
|
|
2520
|
+
M,
|
|
2521
|
+
{
|
|
2522
|
+
sx: {
|
|
2523
|
+
fontSize: "24px",
|
|
2524
|
+
color: ((p = u.colors) == null ? void 0 : p.labelColor) ?? i.palette.text.primary
|
|
2525
|
+
},
|
|
2526
|
+
children: u.id.toUpperCase()
|
|
2527
|
+
}
|
|
2528
|
+
)
|
|
2529
|
+
] }),
|
|
2530
|
+
getDisplayedValue: () => {
|
|
2531
|
+
var f, v;
|
|
2532
|
+
return m(
|
|
2533
|
+
((v = (f = o.jogger.motionStream.rapidlyChangingMotionState.tcp_pose) == null ? void 0 : f.orientation) == null ? void 0 : v[Mt[u.id]]) || 0
|
|
2534
|
+
);
|
|
2535
|
+
},
|
|
2536
|
+
startJogging: (f) => a({
|
|
2537
|
+
axis: u.id,
|
|
2538
|
+
motionType: "rotate",
|
|
2539
|
+
direction: f
|
|
2540
|
+
}),
|
|
2541
|
+
stopJogging: d
|
|
2542
|
+
},
|
|
2543
|
+
u.id
|
|
2544
|
+
);
|
|
2545
|
+
})
|
|
2546
|
+
]
|
|
2547
|
+
}
|
|
2548
|
+
)
|
|
2549
|
+
}
|
|
2550
|
+
),
|
|
2551
|
+
/* @__PURE__ */ g(re, { store: o }),
|
|
2552
|
+
/* @__PURE__ */ g(H, {}),
|
|
2553
|
+
/* @__PURE__ */ g(he, { store: o }),
|
|
2554
|
+
t && /* @__PURE__ */ g(H, {}),
|
|
2555
|
+
t
|
|
2556
|
+
]
|
|
2557
|
+
}
|
|
2558
|
+
);
|
|
2559
|
+
}
|
|
2560
|
+
), No = A(
|
|
2561
|
+
({ store: o, children: t }) => {
|
|
2562
|
+
const e = K(), i = gt(0);
|
|
2563
|
+
async function n(s) {
|
|
2564
|
+
const a = ++i.current;
|
|
2565
|
+
try {
|
|
2566
|
+
if (await o.activate(), a !== i.current) return;
|
|
2567
|
+
await o.jogger.rotateJoints({
|
|
2568
|
+
joint: s.joint,
|
|
2569
|
+
direction: s.direction,
|
|
2570
|
+
velocityUnit: o.jointType === N.PrismaticJoint ? "mm/s" : "rad/s",
|
|
2571
|
+
velocityValue: o.jointType === N.PrismaticJoint ? o.translationVelocityMmPerSec : o.rotationVelocityRadsPerSec
|
|
2572
|
+
});
|
|
2573
|
+
} catch (d) {
|
|
2574
|
+
console.error("Jogging failed:", d);
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
async function r() {
|
|
2578
|
+
i.current++, await o.jogger.stop(), await o.deactivate();
|
|
2579
|
+
}
|
|
2580
|
+
return /* @__PURE__ */ _(
|
|
2581
|
+
C,
|
|
2582
|
+
{
|
|
2583
|
+
"data-testid": "jogging-joint-tab",
|
|
2584
|
+
"aria-label": "jogging-joint-tab",
|
|
2585
|
+
flexGrow: 1,
|
|
2586
|
+
gap: 2,
|
|
2587
|
+
sx: { padding: "18px 24px" },
|
|
2588
|
+
children: [
|
|
2589
|
+
/* @__PURE__ */ g(
|
|
2590
|
+
ge,
|
|
2591
|
+
{
|
|
2592
|
+
store: o,
|
|
2593
|
+
useDegree: o.jointType === N.RevoluteJoint
|
|
2594
|
+
}
|
|
2595
|
+
),
|
|
2596
|
+
/* @__PURE__ */ g(H, {}),
|
|
2597
|
+
/* @__PURE__ */ g(
|
|
2598
|
+
C,
|
|
2599
|
+
{
|
|
2600
|
+
justifyContent: "center",
|
|
2601
|
+
alignItems: "stretch",
|
|
2602
|
+
sx: { flexGrow: "1" },
|
|
2603
|
+
children: /* @__PURE__ */ g(
|
|
2604
|
+
C,
|
|
2605
|
+
{
|
|
2606
|
+
"data-testid": "jogging-joint-value-controls-wrapper",
|
|
2607
|
+
"aria-label": "jogging-joint-value-controls-wrapper",
|
|
2608
|
+
alignItems: "center",
|
|
2609
|
+
gap: "24px",
|
|
2610
|
+
children: o.jogger.motionStream.joints.map((s) => {
|
|
2611
|
+
var d, h, c;
|
|
2612
|
+
const a = (c = (h = (d = o.motionGroupDescription.operation_limits.auto_limits) == null ? void 0 : d.joints) == null ? void 0 : h[s.index]) == null ? void 0 : c.position;
|
|
2613
|
+
return /* @__PURE__ */ _(
|
|
2614
|
+
C,
|
|
2615
|
+
{
|
|
2616
|
+
"data-testid": `jogging-joint-value-control-${s.index}`,
|
|
2617
|
+
"aria-label": `jogging-joint-value-control-${s.index}`,
|
|
2618
|
+
direction: "row",
|
|
2619
|
+
alignItems: "center",
|
|
2620
|
+
justifyContent: "center",
|
|
2621
|
+
spacing: 1.5,
|
|
2622
|
+
width: "100%",
|
|
2623
|
+
children: [
|
|
2624
|
+
o.showJointsLegend && /* @__PURE__ */ g(
|
|
2625
|
+
M,
|
|
2626
|
+
{
|
|
2627
|
+
color: o.isLocked ? e.palette.text.disabled : e.palette.text.secondary,
|
|
2628
|
+
children: `G${s.index + 1}`
|
|
2629
|
+
}
|
|
2630
|
+
),
|
|
2631
|
+
/* @__PURE__ */ g(
|
|
2632
|
+
ro,
|
|
2633
|
+
{
|
|
2634
|
+
disabled: o.isLocked,
|
|
2635
|
+
lowerLimit: a == null ? void 0 : a.lower_limit,
|
|
2636
|
+
upperLimit: a == null ? void 0 : a.upper_limit,
|
|
2637
|
+
useDegree: o.jointType === N.RevoluteJoint,
|
|
2638
|
+
getValue: () => {
|
|
2639
|
+
const m = o.jogger.motionStream.rapidlyChangingMotionState.joint_position[s.index];
|
|
2640
|
+
return m !== void 0 ? m : void 0;
|
|
2641
|
+
},
|
|
2642
|
+
startJogging: (m) => n({
|
|
2643
|
+
joint: s.index,
|
|
2644
|
+
direction: m
|
|
2645
|
+
}),
|
|
2646
|
+
stopJogging: r
|
|
2647
|
+
}
|
|
2648
|
+
)
|
|
2649
|
+
]
|
|
2650
|
+
},
|
|
2651
|
+
`joint-${s.index}`
|
|
2652
|
+
);
|
|
2653
|
+
})
|
|
2654
|
+
}
|
|
2655
|
+
)
|
|
2656
|
+
}
|
|
2657
|
+
),
|
|
2658
|
+
/* @__PURE__ */ g(re, { store: o }),
|
|
2659
|
+
/* @__PURE__ */ g(H, {}),
|
|
2660
|
+
/* @__PURE__ */ g(he, { store: o }),
|
|
2661
|
+
t && /* @__PURE__ */ g(H, {}),
|
|
2662
|
+
t
|
|
2663
|
+
]
|
|
2664
|
+
}
|
|
2665
|
+
);
|
|
2666
|
+
}
|
|
2667
|
+
), jn = it(
|
|
2668
|
+
A((o) => {
|
|
2669
|
+
const t = Ut(() => ({
|
|
2670
|
+
joggingStore: null,
|
|
2671
|
+
loadingError: null
|
|
2672
|
+
}));
|
|
2673
|
+
return at(() => {
|
|
2674
|
+
let e = !1, i;
|
|
2675
|
+
async function n() {
|
|
2676
|
+
S(() => {
|
|
2677
|
+
t.loadingError = null, t.joggingStore = null;
|
|
2678
|
+
});
|
|
2679
|
+
try {
|
|
2680
|
+
let r = o.store;
|
|
2681
|
+
if (!r) {
|
|
2682
|
+
const s = await mt.open(
|
|
2683
|
+
o.nova,
|
|
2684
|
+
o.motionGroupId,
|
|
2685
|
+
{
|
|
2686
|
+
cellId: o.cellId
|
|
2687
|
+
}
|
|
2688
|
+
);
|
|
2689
|
+
if (e) {
|
|
2690
|
+
s.dispose();
|
|
2691
|
+
return;
|
|
2692
|
+
}
|
|
2693
|
+
try {
|
|
2694
|
+
r = await et.loadFor(s);
|
|
2695
|
+
} catch (a) {
|
|
2696
|
+
throw s.dispose(), a;
|
|
2697
|
+
}
|
|
2698
|
+
if (i = r, e) {
|
|
2699
|
+
r.dispose();
|
|
2700
|
+
return;
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
S(() => {
|
|
2704
|
+
t.joggingStore = r;
|
|
2705
|
+
}), o.onSetup && o.onSetup(r);
|
|
2706
|
+
} catch (r) {
|
|
2707
|
+
if (e) return;
|
|
2708
|
+
S(() => {
|
|
2709
|
+
t.loadingError = r;
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
return n(), () => {
|
|
2714
|
+
e = !0, i == null || i.dispose();
|
|
2715
|
+
};
|
|
2716
|
+
}, [o.store, o.nova, o.motionGroupId, o.cellId]), at(() => {
|
|
2717
|
+
const e = t.joggingStore;
|
|
2718
|
+
e && (o.locked ? e.lock("external") : e.unlock("external"));
|
|
2719
|
+
}, [t.joggingStore, o.locked]), /* @__PURE__ */ g(
|
|
2720
|
+
C,
|
|
2721
|
+
{
|
|
2722
|
+
"data-testid": "jogging-panel",
|
|
2723
|
+
"aria-label": "jogging-panel",
|
|
2724
|
+
sx: {
|
|
2725
|
+
maxWidth: "460px",
|
|
2726
|
+
minWidth: "320px",
|
|
2727
|
+
position: "relative",
|
|
2728
|
+
...o.sx
|
|
2729
|
+
},
|
|
2730
|
+
children: t.joggingStore ? /* @__PURE__ */ g(Vo, { store: t.joggingStore, children: o.children }) : /* @__PURE__ */ g(uo, { message: "Loading jogging", error: t.loadingError })
|
|
2731
|
+
}
|
|
2732
|
+
);
|
|
2733
|
+
})
|
|
2734
|
+
), Vo = A(
|
|
2735
|
+
({
|
|
2736
|
+
store: o,
|
|
2737
|
+
children: t
|
|
2738
|
+
}) => {
|
|
2739
|
+
const { t: e } = F();
|
|
2740
|
+
function i() {
|
|
2741
|
+
if (o.currentTab.id === "cartesian")
|
|
2742
|
+
return /* @__PURE__ */ g(Lo, { store: o, children: t });
|
|
2743
|
+
if (o.currentTab.id === "joint")
|
|
2744
|
+
return /* @__PURE__ */ g(No, { store: o, children: t });
|
|
2745
|
+
}
|
|
2746
|
+
return /* @__PURE__ */ _(C, { flexGrow: 1, sx: { overflow: "hidden" }, children: [
|
|
2747
|
+
/* @__PURE__ */ g(
|
|
2748
|
+
je,
|
|
2749
|
+
{
|
|
2750
|
+
"data-testid": "jogging-tabs",
|
|
2751
|
+
"aria-label": "jogging-tabs",
|
|
2752
|
+
value: o.tabIndex,
|
|
2753
|
+
onChange: o.onTabChange,
|
|
2754
|
+
variant: "fullWidth",
|
|
2755
|
+
children: o.tabs.map((n) => {
|
|
2756
|
+
const r = n.label === "Cartesian" ? e("Jogging.Cartesian.bt") : e("Jogging.Joints.bt"), s = n.label === "cartesian" ? /* @__PURE__ */ g(Ie, { fontSize: "small", sx: { mr: 1 } }) : /* @__PURE__ */ g(Me, { fontSize: "small", sx: { mr: 1 } });
|
|
2757
|
+
return /* @__PURE__ */ g(
|
|
2758
|
+
Te,
|
|
2759
|
+
{
|
|
2760
|
+
"data-testid": `jogging-tab-${n.id}`,
|
|
2761
|
+
"aria-label": `jogging-tab-${n.id}`,
|
|
2762
|
+
label: o.showTabIcons ? /* @__PURE__ */ _(C, { direction: "row", alignItems: "center", children: [
|
|
2763
|
+
s,
|
|
2764
|
+
r
|
|
2765
|
+
] }) : r,
|
|
2766
|
+
id: `jogging-tab-${n.id}`,
|
|
2767
|
+
"aria-controls": `jogging-tab-${n.id}`
|
|
2768
|
+
},
|
|
2769
|
+
n.id
|
|
2770
|
+
);
|
|
2771
|
+
})
|
|
2772
|
+
}
|
|
2773
|
+
),
|
|
2774
|
+
/* @__PURE__ */ g(
|
|
2775
|
+
C,
|
|
2776
|
+
{
|
|
2777
|
+
flexGrow: 1,
|
|
2778
|
+
position: "relative",
|
|
2779
|
+
sx: { overflowY: "auto", overflowX: "hidden" },
|
|
2780
|
+
children: i()
|
|
2781
|
+
}
|
|
2782
|
+
),
|
|
2783
|
+
o.blocked && /* @__PURE__ */ g(po, { store: o })
|
|
2784
|
+
] });
|
|
2785
|
+
}
|
|
2786
|
+
);
|
|
2787
|
+
function Fo() {
|
|
2788
|
+
const o = window.location.href;
|
|
2789
|
+
return o.substring(
|
|
2790
|
+
0,
|
|
2791
|
+
o.indexOf("/", o.indexOf("//") + 2)
|
|
2792
|
+
);
|
|
2793
|
+
}
|
|
2794
|
+
function xn({
|
|
2795
|
+
baseUrl: o = Fo(),
|
|
2796
|
+
...t
|
|
2797
|
+
}) {
|
|
2798
|
+
return /* @__PURE__ */ _(
|
|
2799
|
+
He,
|
|
2800
|
+
{
|
|
2801
|
+
"aria-labelledby": "no-motion-group-modal-title",
|
|
2802
|
+
open: !0,
|
|
2803
|
+
fullWidth: !0,
|
|
2804
|
+
sx: {
|
|
2805
|
+
"& .MuiModal-backdrop": {
|
|
2806
|
+
backdropFilter: "blur(10px)"
|
|
2807
|
+
},
|
|
2808
|
+
"& .MuiDialog-paper": {
|
|
2809
|
+
"::before": {
|
|
2810
|
+
content: '""',
|
|
2811
|
+
height: "8px",
|
|
2812
|
+
width: "100%",
|
|
2813
|
+
background: "linear-gradient(90deg, #FF0E65 0%, #47D3FF 100%)"
|
|
2814
|
+
},
|
|
2815
|
+
background: "#101629"
|
|
2816
|
+
}
|
|
2817
|
+
},
|
|
2818
|
+
children: [
|
|
2819
|
+
/* @__PURE__ */ g(Qe, { id: "no-motion-group-modal-title", children: "No motion group found" }),
|
|
2820
|
+
/* @__PURE__ */ _(
|
|
2821
|
+
Ke,
|
|
2822
|
+
{
|
|
2823
|
+
sx: {
|
|
2824
|
+
marginTop: "3rem",
|
|
2825
|
+
marginBottom: "1.5rem",
|
|
2826
|
+
textAlign: "center"
|
|
2827
|
+
},
|
|
2828
|
+
children: [
|
|
2829
|
+
/* @__PURE__ */ g(M, { color: "#fff", children: "Found no devices to connect to." }),
|
|
2830
|
+
/* @__PURE__ */ g(M, { color: "#fff", children: "Please ensure a motion group has been created." })
|
|
2831
|
+
]
|
|
2832
|
+
}
|
|
2833
|
+
),
|
|
2834
|
+
/* @__PURE__ */ g(Ye, { children: /* @__PURE__ */ _(C, { width: "100%", maxWidth: "300px", margin: "auto", marginBottom: "2rem", children: [
|
|
2835
|
+
/* @__PURE__ */ g(
|
|
2836
|
+
St,
|
|
2837
|
+
{
|
|
2838
|
+
href: `${o}/settings`,
|
|
2839
|
+
variant: "contained",
|
|
2840
|
+
sx: {
|
|
2841
|
+
borderRadius: "8px",
|
|
2842
|
+
width: "100%"
|
|
2843
|
+
},
|
|
2844
|
+
children: "Go to settings app"
|
|
2845
|
+
}
|
|
2846
|
+
),
|
|
2847
|
+
/* @__PURE__ */ g(
|
|
2848
|
+
St,
|
|
2849
|
+
{
|
|
2850
|
+
href: `${o}`,
|
|
2851
|
+
variant: "text",
|
|
2852
|
+
sx: {
|
|
2853
|
+
marginTop: "1rem",
|
|
2854
|
+
color: "#fff",
|
|
2855
|
+
textDecoration: "underline",
|
|
2856
|
+
fontSize: "0.75rem"
|
|
2857
|
+
},
|
|
2858
|
+
children: "Back to Homescreen"
|
|
2859
|
+
}
|
|
2860
|
+
)
|
|
2861
|
+
] }) })
|
|
2862
|
+
]
|
|
2863
|
+
}
|
|
2864
|
+
);
|
|
2865
|
+
}
|
|
2866
|
+
const Nt = 1e-4, Bo = {
|
|
2867
|
+
a: 0,
|
|
2868
|
+
d: 0,
|
|
2869
|
+
alpha: 0,
|
|
2870
|
+
theta: 0,
|
|
2871
|
+
reverse_rotation_direction: !1
|
|
2872
|
+
};
|
|
2873
|
+
class bt {
|
|
2874
|
+
constructor(t, e, i, n, r, s, a, d, h, c, m = "cell") {
|
|
2875
|
+
this.controller = e, this.motionGroup = i, this.initialMotionState = n, this.motionStateSocket = r, this.isVirtual = s, this.tcps = a, this.description = d, this.initialControllerState = h, this.controllerStateSocket = c, this.cellId = m, this.connectedJoggingSocket = null, this.joggingVelocity = 10, this.activationState = "inactive", this.nova = U(t), this.rapidlyChangingMotionState = n, this.controllerState = h, c.addEventListener("message", (u) => {
|
|
2876
|
+
var p;
|
|
2877
|
+
const l = (p = J(u.data)) == null ? void 0 : p.result;
|
|
2878
|
+
l && S(() => {
|
|
2879
|
+
this.controllerState = l;
|
|
2880
|
+
});
|
|
2881
|
+
}), r.addEventListener("message", (u) => {
|
|
2882
|
+
var p;
|
|
2883
|
+
const l = (p = J(u.data)) == null ? void 0 : p.result;
|
|
2884
|
+
if (!l)
|
|
2885
|
+
throw new Error(
|
|
2886
|
+
`Failed to get motion state for ${this.motionGroupId}: ${u.data}`
|
|
2887
|
+
);
|
|
2888
|
+
Xt(
|
|
2889
|
+
this.rapidlyChangingMotionState.joint_position,
|
|
2890
|
+
l.joint_position,
|
|
2891
|
+
Nt
|
|
2892
|
+
) || S(() => {
|
|
2893
|
+
this.rapidlyChangingMotionState.joint_position = l.joint_position;
|
|
2894
|
+
}), ee(
|
|
2895
|
+
this.rapidlyChangingMotionState,
|
|
2896
|
+
l,
|
|
2897
|
+
Nt
|
|
2898
|
+
) || S(() => {
|
|
2899
|
+
this.rapidlyChangingMotionState.tcp_pose = l.tcp_pose;
|
|
2900
|
+
}), l.tcp !== void 0 && this.rapidlyChangingMotionState.tcp !== l.tcp && S(() => {
|
|
2901
|
+
this.rapidlyChangingMotionState.tcp = l.tcp;
|
|
2902
|
+
}), this.rapidlyChangingMotionState.standstill !== l.standstill && S(() => {
|
|
2903
|
+
this.rapidlyChangingMotionState.standstill = l.standstill;
|
|
2904
|
+
});
|
|
2905
|
+
}), D(this);
|
|
2906
|
+
}
|
|
2907
|
+
static async connectMultiple(t, e, i = {}) {
|
|
2908
|
+
const n = U(t), r = i.cellId ?? X(t);
|
|
2909
|
+
return Promise.all(
|
|
2910
|
+
e.map(
|
|
2911
|
+
(s) => bt.connect(n, s, {
|
|
2912
|
+
...i,
|
|
2913
|
+
cellId: r
|
|
2914
|
+
})
|
|
2915
|
+
)
|
|
2916
|
+
);
|
|
2917
|
+
}
|
|
2918
|
+
static async connect(t, e, i = {}) {
|
|
2919
|
+
var j, x;
|
|
2920
|
+
const n = U(t), r = i.cellId ?? X(t) ?? "cell", [s, a] = e.split("@"), d = await n.api.controller.getCurrentRobotControllerState(
|
|
2921
|
+
r,
|
|
2922
|
+
a
|
|
2923
|
+
), h = d == null ? void 0 : d.motion_groups.find(
|
|
2924
|
+
(E) => E.motion_group === e
|
|
2925
|
+
);
|
|
2926
|
+
if (!d || !h)
|
|
2927
|
+
throw new Error(
|
|
2928
|
+
`Controller ${a} or motion group ${e} not found`
|
|
2929
|
+
);
|
|
2930
|
+
const c = n.openReconnectingWebsocket(
|
|
2931
|
+
`/cells/${r}/controllers/${a}/motion-groups/${e}/state-stream`
|
|
2932
|
+
), m = await c.firstMessage(), u = (j = J(m.data)) == null ? void 0 : j.result;
|
|
2933
|
+
if (!u)
|
|
2934
|
+
throw new Error(
|
|
2935
|
+
`Unable to parse initial motion state message ${m.data}`
|
|
2936
|
+
);
|
|
2937
|
+
console.log(
|
|
2938
|
+
`Connected motion state websocket to motion group ${h.motion_group}. Initial state:
|
|
2939
|
+
`,
|
|
2940
|
+
u
|
|
2941
|
+
);
|
|
2942
|
+
const p = (await n.api.controller.getRobotController(
|
|
2943
|
+
r,
|
|
2944
|
+
d.controller
|
|
2945
|
+
)).configuration.kind === "VirtualController", f = await n.api.motionGroup.getMotionGroupDescription(
|
|
2946
|
+
r,
|
|
2947
|
+
a,
|
|
2948
|
+
h.motion_group
|
|
2949
|
+
), v = Object.entries(f.tcps || {}).map(
|
|
2950
|
+
([E, O]) => ({
|
|
2951
|
+
id: E,
|
|
2952
|
+
readable_name: O.name,
|
|
2953
|
+
position: O.pose.position,
|
|
2954
|
+
orientation: O.pose.orientation
|
|
2955
|
+
})
|
|
2956
|
+
), w = n.openReconnectingWebsocket(
|
|
2957
|
+
`/cells/${r}/controllers/${d.controller}/state-stream?response_rate=1000`
|
|
2958
|
+
), I = await w.firstMessage(), T = (x = J(I.data)) == null ? void 0 : x.result;
|
|
2959
|
+
if (!T)
|
|
2960
|
+
throw new Error(
|
|
2961
|
+
`Unable to parse initial controller state message ${I.data}`
|
|
2962
|
+
);
|
|
2963
|
+
return console.log(
|
|
2964
|
+
`Connected controller state websocket to controller ${d.controller}. Initial state:
|
|
2965
|
+
`,
|
|
2966
|
+
T
|
|
2967
|
+
), new bt(
|
|
2968
|
+
n,
|
|
2969
|
+
d,
|
|
2970
|
+
h,
|
|
2971
|
+
u,
|
|
2972
|
+
c,
|
|
2973
|
+
p,
|
|
2974
|
+
v,
|
|
2975
|
+
f,
|
|
2976
|
+
T,
|
|
2977
|
+
w,
|
|
2978
|
+
r
|
|
2979
|
+
);
|
|
2980
|
+
}
|
|
2981
|
+
get motionGroupId() {
|
|
2982
|
+
return this.motionGroup.motion_group;
|
|
2983
|
+
}
|
|
2984
|
+
get controllerId() {
|
|
2985
|
+
return this.controller.controller;
|
|
2986
|
+
}
|
|
2987
|
+
get modelFromController() {
|
|
2988
|
+
return this.description.motion_group_model;
|
|
2989
|
+
}
|
|
2990
|
+
/** Jogging velocity in radians for rotation and joint movement */
|
|
2991
|
+
get joggingVelocityRads() {
|
|
2992
|
+
return this.joggingVelocity * Math.PI / 180;
|
|
2993
|
+
}
|
|
2994
|
+
get joints() {
|
|
2995
|
+
return this.initialMotionState.joint_position.map((t, e) => ({
|
|
2996
|
+
index: e
|
|
2997
|
+
}));
|
|
2998
|
+
}
|
|
2999
|
+
// Please note that API v2 omits 0 values
|
|
3000
|
+
get dhParameters() {
|
|
3001
|
+
if (this.description.dh_parameters !== void 0)
|
|
3002
|
+
return this.description.dh_parameters.map((t) => ({
|
|
3003
|
+
...Bo,
|
|
3004
|
+
...t
|
|
3005
|
+
}));
|
|
3006
|
+
}
|
|
3007
|
+
get safetyZones() {
|
|
3008
|
+
return this.description.safety_zones;
|
|
3009
|
+
}
|
|
3010
|
+
/** Gets the robot mounting position offset in 3D viz coordinates */
|
|
3011
|
+
get mountingPosition() {
|
|
3012
|
+
var t, e, i;
|
|
3013
|
+
return this.description.mounting ? [
|
|
3014
|
+
(((t = this.description.mounting.position) == null ? void 0 : t[0]) || 0) / 1e3,
|
|
3015
|
+
(((e = this.description.mounting.position) == null ? void 0 : e[1]) || 0) / 1e3,
|
|
3016
|
+
(((i = this.description.mounting.position) == null ? void 0 : i[2]) || 0) / 1e3
|
|
3017
|
+
] : [0, 0, 0];
|
|
3018
|
+
}
|
|
3019
|
+
/** Gets the robot mounting position rotation in 3D viz coordinates */
|
|
3020
|
+
get mountingQuaternion() {
|
|
3021
|
+
var n, r, s, a, d, h;
|
|
3022
|
+
const t = new xt.Vector3(
|
|
3023
|
+
((r = (n = this.description.mounting) == null ? void 0 : n.orientation) == null ? void 0 : r[0]) || 0,
|
|
3024
|
+
((a = (s = this.description.mounting) == null ? void 0 : s.orientation) == null ? void 0 : a[1]) || 0,
|
|
3025
|
+
((h = (d = this.description.mounting) == null ? void 0 : d.orientation) == null ? void 0 : h[2]) || 0
|
|
3026
|
+
), e = t.length(), i = t.normalize();
|
|
3027
|
+
return new xt.Quaternion().setFromAxisAngle(i, e);
|
|
3028
|
+
}
|
|
3029
|
+
/**
|
|
3030
|
+
* Whether the controller is currently in a safety state
|
|
3031
|
+
* corresponding to an emergency stop
|
|
3032
|
+
*/
|
|
3033
|
+
get isEstopActive() {
|
|
3034
|
+
return [
|
|
3035
|
+
"SAFETY_STATE_ROBOT_EMERGENCY_STOP",
|
|
3036
|
+
"SAFETY_STATE_DEVICE_EMERGENCY_STOP"
|
|
3037
|
+
].includes(this.controllerState.safety_state);
|
|
3038
|
+
}
|
|
3039
|
+
/**
|
|
3040
|
+
* Whether the controller is in a safety state
|
|
3041
|
+
* that may be non-functional for robot pad purposes
|
|
3042
|
+
*/
|
|
3043
|
+
get isMoveableSafetyState() {
|
|
3044
|
+
return [
|
|
3045
|
+
"SAFETY_STATE_NORMAL",
|
|
3046
|
+
"SAFETY_STATE_REDUCED"
|
|
3047
|
+
].includes(this.controllerState.safety_state);
|
|
3048
|
+
}
|
|
3049
|
+
/**
|
|
3050
|
+
* Whether the controller is in an operation mode that allows movement
|
|
3051
|
+
*/
|
|
3052
|
+
get isMoveableOperationMode() {
|
|
3053
|
+
return [
|
|
3054
|
+
"OPERATION_MODE_AUTO",
|
|
3055
|
+
"OPERATION_MODE_MANUAL",
|
|
3056
|
+
"OPERATION_MODE_MANUAL_T1",
|
|
3057
|
+
"OPERATION_MODE_MANUAL_T2"
|
|
3058
|
+
].includes(this.controllerState.operation_mode);
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Whether the robot is currently active and can be moved, based on the
|
|
3062
|
+
* safety state, operation mode and servo toggle activation state.
|
|
3063
|
+
*/
|
|
3064
|
+
get canBeMoved() {
|
|
3065
|
+
return this.isMoveableSafetyState && this.isMoveableOperationMode && this.activationState === "active";
|
|
3066
|
+
}
|
|
3067
|
+
async deactivate() {
|
|
3068
|
+
if (this.activationState !== "active") {
|
|
3069
|
+
console.error("Tried to deactivate while already deactivating");
|
|
3070
|
+
return;
|
|
3071
|
+
}
|
|
3072
|
+
S(() => {
|
|
3073
|
+
this.activationState = "deactivating";
|
|
3074
|
+
});
|
|
3075
|
+
try {
|
|
3076
|
+
await this.nova.api.controller.setDefaultMode(
|
|
3077
|
+
this.cellId,
|
|
3078
|
+
this.controllerId,
|
|
3079
|
+
"ROBOT_SYSTEM_MODE_MONITOR"
|
|
3080
|
+
), S(() => {
|
|
3081
|
+
this.activationState = "inactive";
|
|
3082
|
+
});
|
|
3083
|
+
} catch (t) {
|
|
3084
|
+
throw S(() => {
|
|
3085
|
+
this.activationState = "active";
|
|
3086
|
+
}), t;
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
async activate() {
|
|
3090
|
+
if (this.activationState !== "inactive") {
|
|
3091
|
+
console.error("Tried to activate while already activating");
|
|
3092
|
+
return;
|
|
3093
|
+
}
|
|
3094
|
+
S(() => {
|
|
3095
|
+
this.activationState = "activating";
|
|
3096
|
+
});
|
|
3097
|
+
try {
|
|
3098
|
+
await this.nova.api.controller.setDefaultMode(
|
|
3099
|
+
this.cellId,
|
|
3100
|
+
this.controllerId,
|
|
3101
|
+
"ROBOT_SYSTEM_MODE_CONTROL"
|
|
3102
|
+
), S(() => {
|
|
3103
|
+
this.activationState = "active";
|
|
3104
|
+
});
|
|
3105
|
+
} catch (t) {
|
|
3106
|
+
throw S(() => {
|
|
3107
|
+
this.activationState = "inactive";
|
|
3108
|
+
}), t;
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
toggleActivation() {
|
|
3112
|
+
this.activationState === "inactive" ? this.activate() : this.activationState === "active" && this.deactivate();
|
|
3113
|
+
}
|
|
3114
|
+
dispose() {
|
|
3115
|
+
this.motionStateSocket.close(), this.controllerStateSocket.close(), this.connectedJoggingSocket && this.connectedJoggingSocket.close();
|
|
3116
|
+
}
|
|
3117
|
+
setJoggingVelocity(t) {
|
|
3118
|
+
this.joggingVelocity = t;
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
const ue = 1e-4, Go = /* @__PURE__ */ new Set([
|
|
3122
|
+
"timestamp",
|
|
3123
|
+
"sequence_number",
|
|
3124
|
+
"joint_position",
|
|
3125
|
+
"joint_torque",
|
|
3126
|
+
"joint_current",
|
|
3127
|
+
"flange_pose",
|
|
3128
|
+
"tcp_pose",
|
|
3129
|
+
"flange_velocity",
|
|
3130
|
+
"tcp_velocity"
|
|
3131
|
+
]), Uo = 1, Vt = (o) => Array.isArray(o) && o.length === 3 && o.every((t) => typeof t == "number");
|
|
3132
|
+
class zo {
|
|
3133
|
+
constructor(t, e, i, n = {}) {
|
|
3134
|
+
this.source = t, this.motionGroupId = e, this.lastMessageReceivedAt = Date.now(), this.lastInvalidStateMessage = null, this.connectionQuality = "good";
|
|
3135
|
+
const r = i.motion_groups.find(
|
|
3136
|
+
(s) => s.motion_group === e
|
|
3137
|
+
);
|
|
3138
|
+
if (!r)
|
|
3139
|
+
throw new Error(
|
|
3140
|
+
`Motion group ${e} not found in initial controller state`
|
|
3141
|
+
);
|
|
3142
|
+
this.isVirtual = n.isVirtual ?? !1, this.onError = n.onError, this.reconnectsOnFocus = (n.reconnectOnFocus ?? !0) && typeof window < "u", this.rapidlyChangingMotionState = r, this.lastValidStateMessage = {
|
|
3143
|
+
receivedAt: Date.now(),
|
|
3144
|
+
data: i
|
|
3145
|
+
}, D(
|
|
3146
|
+
this,
|
|
3147
|
+
{
|
|
3148
|
+
source: !1,
|
|
3149
|
+
lastMessageReceivedAt: !1,
|
|
3150
|
+
connectionQualityInterval: !1,
|
|
3151
|
+
isVirtual: !1,
|
|
3152
|
+
onError: !1,
|
|
3153
|
+
reconnectsOnFocus: !1,
|
|
3154
|
+
// keepAlive: a computed nobody observes is recomputed on every read
|
|
3155
|
+
// without consulting `equals`, so the hold would depend on a component
|
|
3156
|
+
// happening to observe the readout at the time.
|
|
3157
|
+
readoutState: zt({ equals: ne, keepAlive: !0 })
|
|
3158
|
+
},
|
|
3159
|
+
{ autoBind: !0 }
|
|
3160
|
+
), this.source.addEventListener("message", this.handleMessage), this.connectionQualityInterval = setInterval(
|
|
3161
|
+
this.updateConnectionQuality,
|
|
3162
|
+
500
|
|
3163
|
+
), this.reconnectsOnFocus && window.addEventListener("focus", this.handleWindowFocus);
|
|
3164
|
+
}
|
|
3165
|
+
/** The controller's state as of the last message that changed it */
|
|
3166
|
+
get controllerState() {
|
|
3167
|
+
return this.lastValidStateMessage.data;
|
|
3168
|
+
}
|
|
3169
|
+
/**
|
|
3170
|
+
* What pose and joint readouts show. Holds the previous reading while the
|
|
3171
|
+
* joints only jitter, see {@link readoutsEqual}; kept alive so it also holds
|
|
3172
|
+
* for untracked reads.
|
|
3173
|
+
*/
|
|
3174
|
+
get readoutState() {
|
|
3175
|
+
return ie(this.rapidlyChangingMotionState);
|
|
3176
|
+
}
|
|
3177
|
+
/** The motion group's state in the next message of the source */
|
|
3178
|
+
async nextMotionState() {
|
|
3179
|
+
var i, n;
|
|
3180
|
+
const t = await this.source.nextMessage(), e = (n = (i = this.source.parse(t.data)) == null ? void 0 : i.motion_groups) == null ? void 0 : n.find((r) => r.motion_group === this.motionGroupId);
|
|
3181
|
+
if (!e)
|
|
3182
|
+
throw new Error(
|
|
3183
|
+
`Failed to get motion state for ${this.motionGroupId}: ${t.data}`
|
|
3184
|
+
);
|
|
3185
|
+
return e;
|
|
3186
|
+
}
|
|
3187
|
+
setLastInvalidStateMessage(t) {
|
|
3188
|
+
this.lastInvalidStateMessage = {
|
|
3189
|
+
receivedAt: Date.now(),
|
|
3190
|
+
data: t
|
|
3191
|
+
};
|
|
3192
|
+
}
|
|
3193
|
+
setLastValidStateMessage(t) {
|
|
3194
|
+
this.lastValidStateMessage = {
|
|
3195
|
+
receivedAt: Date.now(),
|
|
3196
|
+
data: t
|
|
3197
|
+
};
|
|
3198
|
+
}
|
|
3199
|
+
/**
|
|
3200
|
+
* Merge the latest motion state onto the existing object instead of replacing
|
|
3201
|
+
* it, so this stream owns exactly one live motion state object for the whole
|
|
3202
|
+
* time it is connected.
|
|
3203
|
+
*
|
|
3204
|
+
* Consumers subscribe to *properties* of the object they are holding — the 3D
|
|
3205
|
+
* animators keep it in a ref and read `joint_position` inside a MobX
|
|
3206
|
+
* reaction. Replacing the object leaves those reactions subscribed to an
|
|
3207
|
+
* orphan that never changes again, so the robot model stopped getting joint
|
|
3208
|
+
* targets from the stream and only moved when React happened to re-render it
|
|
3209
|
+
* (~5 updates/s against a ~134/s stream).
|
|
3210
|
+
*
|
|
3211
|
+
* Only fields whose value actually changed are written. A blanket
|
|
3212
|
+
* `Object.assign` puts a fresh object into every nested field, and MobX
|
|
3213
|
+
* compares with `===`, so each of `flange_pose`, `tcp_pose` and
|
|
3214
|
+
* `joint_limit_reached` would notify its observers on every message of a
|
|
3215
|
+
* ~134/s stream even while standing still. This mirrors how
|
|
3216
|
+
* MotionStreamConnection guards each of its own field writes.
|
|
3217
|
+
*
|
|
3218
|
+
* Fields the message does not carry are removed rather than left behind: a
|
|
3219
|
+
* merge must not make a stale pose read as the current one, which replacing
|
|
3220
|
+
* the whole object never did.
|
|
3221
|
+
*
|
|
3222
|
+
* Runs as a MobX action (see `makeAutoObservable` with `autoBind` above), so
|
|
3223
|
+
* the per-field writes notify observers once, as a single batch.
|
|
3224
|
+
*
|
|
3225
|
+
* `skipFields` leaves the named fields exactly as they are — neither updated
|
|
3226
|
+
* nor removed — which is how a standstill message updates the discrete state
|
|
3227
|
+
* without churning the jittery pose readings.
|
|
3228
|
+
*/
|
|
3229
|
+
updateRapidlyChangingMotionState(t, e) {
|
|
3230
|
+
const i = this.rapidlyChangingMotionState, n = t;
|
|
3231
|
+
for (const r of Object.keys(n))
|
|
3232
|
+
e != null && e.has(r) || Kt(i[r], n[r]) || (i[r] = n[r]);
|
|
3233
|
+
for (const r of Object.keys(i))
|
|
3234
|
+
e != null && e.has(r) || r in n || delete i[r];
|
|
3235
|
+
}
|
|
3236
|
+
setConnectionQuality(t) {
|
|
3237
|
+
this.connectionQuality = t;
|
|
3238
|
+
}
|
|
3239
|
+
handleWindowFocus() {
|
|
3240
|
+
this.source.reconnect();
|
|
3241
|
+
}
|
|
3242
|
+
updateConnectionQuality() {
|
|
3243
|
+
const t = Date.now() - this.lastMessageReceivedAt, e = this.isVirtual ? 3e3 : 1e3, i = this.isVirtual ? 6e3 : 3e3;
|
|
3244
|
+
if (t > i) {
|
|
3245
|
+
this.source.readyState === Uo && this.source.reconnect(), this.setConnectionQuality("critical");
|
|
3246
|
+
return;
|
|
3247
|
+
}
|
|
3248
|
+
if (t > e) {
|
|
3249
|
+
this.setConnectionQuality("struggling");
|
|
3250
|
+
return;
|
|
3251
|
+
}
|
|
3252
|
+
this.setConnectionQuality("good");
|
|
3253
|
+
}
|
|
3254
|
+
/** Stops listening to the source; the source's owner closes it */
|
|
3255
|
+
dispose() {
|
|
3256
|
+
this.source.removeEventListener("message", this.handleMessage), clearInterval(this.connectionQualityInterval), this.reconnectsOnFocus && window.removeEventListener("focus", this.handleWindowFocus);
|
|
3257
|
+
}
|
|
3258
|
+
handleMessage(t) {
|
|
3259
|
+
var h, c;
|
|
3260
|
+
const e = this.source.parse(t.data);
|
|
3261
|
+
if (!(e != null && e.motion_groups)) {
|
|
3262
|
+
(h = this.onError) == null || h.call(this, {
|
|
3263
|
+
message: z(t.data),
|
|
3264
|
+
url: this.source.url
|
|
3265
|
+
}), this.setLastInvalidStateMessage(t.data);
|
|
3266
|
+
return;
|
|
3267
|
+
}
|
|
3268
|
+
this.lastMessageReceivedAt = Date.now();
|
|
3269
|
+
const i = this.lastValidStateMessage.data;
|
|
3270
|
+
(i.safety_state !== e.safety_state || i.operation_mode !== e.operation_mode || i.mode !== e.mode) && this.setLastValidStateMessage(e);
|
|
3271
|
+
const n = e.motion_groups.find(
|
|
3272
|
+
(m) => m.motion_group === this.motionGroupId
|
|
3273
|
+
);
|
|
3274
|
+
if (!n) {
|
|
3275
|
+
(c = this.onError) == null || c.call(this, {
|
|
3276
|
+
message: `Motion group ${this.motionGroupId} not found in controller state: ${JSON.stringify(t.data)}`,
|
|
3277
|
+
url: this.source.url
|
|
3278
|
+
}), this.setLastInvalidStateMessage(t.data);
|
|
3279
|
+
return;
|
|
3280
|
+
}
|
|
3281
|
+
const r = !ht(
|
|
3282
|
+
this.rapidlyChangingMotionState.joint_position,
|
|
3283
|
+
n.joint_position,
|
|
3284
|
+
ue
|
|
3285
|
+
), s = this.rapidlyChangingMotionState.tcp !== n.tcp;
|
|
3286
|
+
if (!r && !s) {
|
|
3287
|
+
this.updateRapidlyChangingMotionState(
|
|
3288
|
+
n,
|
|
3289
|
+
Go
|
|
3290
|
+
);
|
|
3291
|
+
return;
|
|
3292
|
+
}
|
|
3293
|
+
const a = this.rapidlyChangingMotionState.flange_pose, d = n.flange_pose;
|
|
3294
|
+
if ((d == null ? void 0 : d.orientation) == null || !Vt(d.orientation)) {
|
|
3295
|
+
const m = d == null ? void 0 : d.orientation;
|
|
3296
|
+
throw new Error(
|
|
3297
|
+
`Invalid newFlangePose.orientation: expected [number, number, number] (got ${m == null ? "null" : m.length})`
|
|
3298
|
+
);
|
|
3299
|
+
}
|
|
3300
|
+
if ((a == null ? void 0 : a.orientation) == null || !Vt(a.orientation)) {
|
|
3301
|
+
const m = a == null ? void 0 : a.orientation;
|
|
3302
|
+
throw new Error(
|
|
3303
|
+
`Invalid oldFlangePose.orientation: expected [number, number, number] (got ${m == null ? "null" : m.length})`
|
|
3304
|
+
);
|
|
3305
|
+
}
|
|
3306
|
+
d.orientation = oe(
|
|
3307
|
+
d.orientation,
|
|
3308
|
+
a.orientation
|
|
3309
|
+
), this.updateRapidlyChangingMotionState(n);
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
function Wo(o) {
|
|
3313
|
+
return {
|
|
3314
|
+
get url() {
|
|
3315
|
+
return o.url;
|
|
3316
|
+
},
|
|
3317
|
+
get readyState() {
|
|
3318
|
+
return o.readyState;
|
|
3319
|
+
},
|
|
3320
|
+
addEventListener: (t, e) => o.addEventListener(t, e),
|
|
3321
|
+
removeEventListener: (t, e) => o.removeEventListener(t, e),
|
|
3322
|
+
firstMessage: () => o.firstMessage(),
|
|
3323
|
+
nextMessage: () => o.nextMessage(),
|
|
3324
|
+
reconnect: () => o.reconnect(),
|
|
3325
|
+
close: () => o.close(),
|
|
3326
|
+
parse: (t) => {
|
|
3327
|
+
var e;
|
|
3328
|
+
return (e = qt(t)) == null ? void 0 : e.result;
|
|
3329
|
+
}
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
function Ho(o, {
|
|
3333
|
+
controllerId: t,
|
|
3334
|
+
cellId: e,
|
|
3335
|
+
responseRateMs: i
|
|
3336
|
+
}) {
|
|
3337
|
+
const n = U(o), r = e ?? X(o) ?? "cell", s = i === void 0 ? "" : `?response_rate=${i}`;
|
|
3338
|
+
return Wo(
|
|
3339
|
+
n.openReconnectingWebsocket(
|
|
3340
|
+
`/cells/${r}/controllers/${t}/state-stream${s}`
|
|
3341
|
+
)
|
|
3342
|
+
);
|
|
3343
|
+
}
|
|
3344
|
+
const Yo = [
|
|
3345
|
+
"FeedbackOutOfWorkspace",
|
|
3346
|
+
"FeedbackJointLimitExceeded",
|
|
3347
|
+
"FeedbackAxisRangeExceeded",
|
|
3348
|
+
"FeedbackNoSolutionInCurrentConfiguration"
|
|
3349
|
+
];
|
|
3350
|
+
function Ko(o) {
|
|
3351
|
+
return o === "FeedbackSingularity" ? "Jogging.TargetPose.Error.Singularity.lb" : o === "FeedbackCollision" ? "Jogging.TargetPose.Error.Collision.lb" : Yo.includes(o) ? "Jogging.TargetPose.Error.NotReachable.lb" : "Jogging.TargetPose.Error.PlanningFailed.lb";
|
|
3352
|
+
}
|
|
3353
|
+
function me(o) {
|
|
3354
|
+
const t = o.api.opts.axiosInstance;
|
|
3355
|
+
if (!t)
|
|
3356
|
+
throw new Error("Nova API client has no configured HTTP transport");
|
|
3357
|
+
return t;
|
|
3358
|
+
}
|
|
3359
|
+
function Ct(o, t) {
|
|
3360
|
+
const e = o.api.opts.baseOptions ?? {}, i = { ...e, ...t };
|
|
3361
|
+
return (e.headers || t.headers) && (i.headers = {
|
|
3362
|
+
...e.headers,
|
|
3363
|
+
...t.headers
|
|
3364
|
+
}), (e.params || t.params) && (i.params = {
|
|
3365
|
+
...e.params,
|
|
3366
|
+
...t.params
|
|
3367
|
+
}), i;
|
|
3368
|
+
}
|
|
3369
|
+
async function Qo(o, t, e, i) {
|
|
3370
|
+
var r;
|
|
3371
|
+
if (!e) return t;
|
|
3372
|
+
const n = `/experimental/motion-group-models/${encodeURIComponent(t)}/description`;
|
|
3373
|
+
i == null || i(`${n}?serial_number=${encodeURIComponent(e)}`);
|
|
3374
|
+
try {
|
|
3375
|
+
return (await me(o).get(
|
|
3376
|
+
n,
|
|
3377
|
+
Ct(o, { params: { serial_number: e } })
|
|
3378
|
+
)).data.name;
|
|
3379
|
+
} catch (s) {
|
|
3380
|
+
if (!Zt(s) || ((r = s.response) == null ? void 0 : r.status) !== 404)
|
|
3381
|
+
throw s;
|
|
3382
|
+
return t;
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
async function qo(o, t, e, i, n) {
|
|
3386
|
+
var h;
|
|
3387
|
+
const r = me(o), s = `/motion-group-models/${encodeURIComponent(t)}/${i}`, a = {};
|
|
3388
|
+
if (e) {
|
|
3389
|
+
const c = `/experimental${s}`;
|
|
3390
|
+
n == null || n(
|
|
3391
|
+
`${c}?serial_number=${encodeURIComponent(e)}`
|
|
3392
|
+
);
|
|
3393
|
+
try {
|
|
3394
|
+
return (await r.get(
|
|
3395
|
+
c,
|
|
3396
|
+
Ct(o, {
|
|
3397
|
+
...a,
|
|
3398
|
+
params: { serial_number: e }
|
|
3399
|
+
})
|
|
3400
|
+
)).data;
|
|
3401
|
+
} catch (m) {
|
|
3402
|
+
if (!Zt(m) || ((h = m.response) == null ? void 0 : h.status) !== 404)
|
|
3403
|
+
throw m;
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
return n == null || n(s), (await r.get(
|
|
3407
|
+
s,
|
|
3408
|
+
Ct(o, a)
|
|
3409
|
+
)).data;
|
|
3410
|
+
}
|
|
3411
|
+
const Zo = [
|
|
3412
|
+
"motionGroupDescription",
|
|
3413
|
+
"controllerConfiguration",
|
|
3414
|
+
"kinematicModel",
|
|
3415
|
+
"motionGroupModel",
|
|
3416
|
+
"coordinateSystems",
|
|
3417
|
+
"controllerState",
|
|
3418
|
+
"motionStateStream",
|
|
3419
|
+
"controllerStateStream"
|
|
3420
|
+
];
|
|
3421
|
+
class pe extends Error {
|
|
3422
|
+
constructor(t, e, i) {
|
|
3423
|
+
super(i), this.stepId = t, this.cause = e, this.name = "RobotLoadStepError";
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
function ft(o) {
|
|
3427
|
+
return o instanceof pe;
|
|
3428
|
+
}
|
|
3429
|
+
class Xo {
|
|
3430
|
+
/**
|
|
3431
|
+
* One instance tracks one load. Concurrent loads must not share one — a load
|
|
3432
|
+
* that has been superseded keeps reporting for a step or two before it
|
|
3433
|
+
* notices, and those reports would otherwise overwrite the state of the load
|
|
3434
|
+
* that replaced it (clearing a recorded failure, for instance).
|
|
3435
|
+
*/
|
|
3436
|
+
constructor(t = null, e = null) {
|
|
3437
|
+
this.motionGroupId = null, this.controllerId = null, this.steps = [], this.retryAttempt = 0, this.fatalError = null, this.currentStepStartedAt = null, this.motionGroupId = t, this.controllerId = e, this.steps = Zo.map((i) => ({
|
|
3438
|
+
id: i,
|
|
3439
|
+
status: "pending",
|
|
3440
|
+
url: null,
|
|
3441
|
+
error: null
|
|
3442
|
+
})), D(this, {}, { autoBind: !0 });
|
|
3443
|
+
}
|
|
3444
|
+
/** Reset the step states for another attempt at the same robot */
|
|
3445
|
+
beginRetry(t) {
|
|
3446
|
+
for (const e of this.steps)
|
|
3447
|
+
e.status = "pending", e.url = null, e.error = null;
|
|
3448
|
+
this.retryAttempt = t, this.fatalError = null, this.currentStepStartedAt = null;
|
|
3449
|
+
}
|
|
3450
|
+
stepById(t) {
|
|
3451
|
+
return this.steps.find((e) => e.id === t);
|
|
3452
|
+
}
|
|
3453
|
+
startStep(t, e) {
|
|
3454
|
+
const i = this.stepById(t);
|
|
3455
|
+
i && (i.status = "running", i.url = e, i.error = null, this.currentStepStartedAt = Date.now());
|
|
3456
|
+
}
|
|
3457
|
+
updateStepUrl(t, e) {
|
|
3458
|
+
const i = this.stepById(t);
|
|
3459
|
+
i && (i.url = e);
|
|
3460
|
+
}
|
|
3461
|
+
succeedStep(t) {
|
|
3462
|
+
const e = this.stepById(t);
|
|
3463
|
+
e && (e.status = "succeeded", this.currentStepStartedAt = null);
|
|
3464
|
+
}
|
|
3465
|
+
failStep(t, e) {
|
|
3466
|
+
const i = this.stepById(t);
|
|
3467
|
+
i && (i.status = "failed", i.error = e, this.currentStepStartedAt = null);
|
|
3468
|
+
}
|
|
3469
|
+
/** A failure that is not tied to a specific step (e.g. an invalid selection) */
|
|
3470
|
+
failWith(t) {
|
|
3471
|
+
this.fatalError = t, this.currentStepStartedAt = null;
|
|
3472
|
+
}
|
|
3473
|
+
get totalCount() {
|
|
3474
|
+
return this.steps.length;
|
|
3475
|
+
}
|
|
3476
|
+
get succeededCount() {
|
|
3477
|
+
return this.steps.filter((t) => t.status === "succeeded").length;
|
|
3478
|
+
}
|
|
3479
|
+
get runningStep() {
|
|
3480
|
+
return this.steps.find((t) => t.status === "running");
|
|
3481
|
+
}
|
|
3482
|
+
get failedStep() {
|
|
3483
|
+
return this.steps.find((t) => t.status === "failed");
|
|
3484
|
+
}
|
|
3485
|
+
get isFailed() {
|
|
3486
|
+
return this.fatalError !== null || this.failedStep !== void 0;
|
|
3487
|
+
}
|
|
3488
|
+
get isComplete() {
|
|
3489
|
+
return this.steps.length > 0 && this.steps.every((t) => t.status === "succeeded");
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
const ti = 1e4;
|
|
3493
|
+
async function Ft(o, t, e) {
|
|
3494
|
+
let i;
|
|
3495
|
+
o.catch(() => {
|
|
3496
|
+
});
|
|
3497
|
+
try {
|
|
3498
|
+
return await Promise.race([
|
|
3499
|
+
o,
|
|
3500
|
+
new Promise((n, r) => {
|
|
3501
|
+
i = setTimeout(() => r(new Error(e)), t);
|
|
3502
|
+
})
|
|
3503
|
+
]);
|
|
3504
|
+
} finally {
|
|
3505
|
+
clearTimeout(i);
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
async function ei({
|
|
3509
|
+
nova: o,
|
|
3510
|
+
cellId: t,
|
|
3511
|
+
controllerId: e,
|
|
3512
|
+
motionGroupId: i,
|
|
3513
|
+
progress: n,
|
|
3514
|
+
createStateSource: r,
|
|
3515
|
+
isStale: s = () => !1,
|
|
3516
|
+
socketTimeoutMs: a = ti
|
|
3517
|
+
}) {
|
|
3518
|
+
let d, h, c = !1;
|
|
3519
|
+
function m() {
|
|
3520
|
+
d == null || d.dispose(), h == null || h.close();
|
|
3521
|
+
}
|
|
3522
|
+
async function u(l, p, f) {
|
|
3523
|
+
n.startStep(l, p);
|
|
3524
|
+
try {
|
|
3525
|
+
const v = await f();
|
|
3526
|
+
return n.succeedStep(l), v;
|
|
3527
|
+
} catch (v) {
|
|
3528
|
+
throw n.failStep(l, v), new pe(l, v, z(v));
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
try {
|
|
3532
|
+
if (s()) return null;
|
|
3533
|
+
const l = `/cells/${t}/controllers/${e}/motion-groups/${i}`, p = `/cells/${t}/controllers/${e}`, f = await u(
|
|
3534
|
+
"motionGroupDescription",
|
|
3535
|
+
`${l}/description`,
|
|
3536
|
+
() => o.api.motionGroup.getMotionGroupDescription(
|
|
3537
|
+
t,
|
|
3538
|
+
e,
|
|
3539
|
+
i
|
|
3540
|
+
)
|
|
3541
|
+
);
|
|
3542
|
+
if (s()) return null;
|
|
3543
|
+
const { configuration: v } = await u(
|
|
3544
|
+
"controllerConfiguration",
|
|
3545
|
+
p,
|
|
3546
|
+
() => o.api.controller.getRobotController(t, e)
|
|
3547
|
+
);
|
|
3548
|
+
if (s()) return null;
|
|
3549
|
+
const w = {
|
|
3550
|
+
model: f.motion_group_model,
|
|
3551
|
+
serialNumber: f.serial_number
|
|
3552
|
+
}, I = w.serialNumber ? `?serial_number=${encodeURIComponent(w.serialNumber)}` : "", T = await u(
|
|
3553
|
+
"kinematicModel",
|
|
3554
|
+
`/experimental/motion-group-models/${encodeURIComponent(w.model)}/kinematic${I}`,
|
|
3555
|
+
() => qo(
|
|
3556
|
+
o,
|
|
3557
|
+
w.model,
|
|
3558
|
+
w.serialNumber,
|
|
3559
|
+
"kinematic",
|
|
3560
|
+
(y) => n.updateStepUrl("kinematicModel", y)
|
|
3561
|
+
)
|
|
3562
|
+
);
|
|
3563
|
+
if (s()) return null;
|
|
3564
|
+
const j = await u(
|
|
3565
|
+
"motionGroupModel",
|
|
3566
|
+
`/experimental/motion-group-models/${encodeURIComponent(w.model)}/description${I}`,
|
|
3567
|
+
() => Qo(
|
|
3568
|
+
o,
|
|
3569
|
+
w.model,
|
|
3570
|
+
w.serialNumber,
|
|
3571
|
+
(y) => n.updateStepUrl("motionGroupModel", y)
|
|
3572
|
+
)
|
|
3573
|
+
);
|
|
3574
|
+
if (s()) return null;
|
|
3575
|
+
const x = await u(
|
|
3576
|
+
"coordinateSystems",
|
|
3577
|
+
`${p}/coordinate-systems?orientation_type=ROTATION_VECTOR`,
|
|
3578
|
+
async () => await o.api.controller.listCoordinateSystems(
|
|
3579
|
+
t,
|
|
3580
|
+
e,
|
|
3581
|
+
"ROTATION_VECTOR"
|
|
3582
|
+
) ?? []
|
|
3583
|
+
);
|
|
3584
|
+
if (s()) return null;
|
|
3585
|
+
const { controllerState: E, motionGroupState: O } = await u(
|
|
3586
|
+
"controllerState",
|
|
3587
|
+
`${p}/state`,
|
|
3588
|
+
async () => {
|
|
3589
|
+
const y = await o.api.controller.getCurrentRobotControllerState(
|
|
3590
|
+
t,
|
|
3591
|
+
e
|
|
3592
|
+
), k = y == null ? void 0 : y.motion_groups.find(
|
|
3593
|
+
(R) => R.motion_group === i
|
|
3594
|
+
);
|
|
3595
|
+
if (!y || !k)
|
|
3596
|
+
throw new Error(
|
|
3597
|
+
`Controller ${e} or motion group ${i} not found`
|
|
3598
|
+
);
|
|
3599
|
+
return { controllerState: y, motionGroupState: k };
|
|
3600
|
+
}
|
|
3601
|
+
);
|
|
3602
|
+
if (s()) return null;
|
|
3603
|
+
const L = `${l}/state-stream`, { socket: G, initialMotionState: P } = await u(
|
|
3604
|
+
"motionStateStream",
|
|
3605
|
+
L,
|
|
3606
|
+
async () => {
|
|
3607
|
+
var Q;
|
|
3608
|
+
const y = o.openReconnectingWebsocket(L);
|
|
3609
|
+
d = y;
|
|
3610
|
+
const k = await Ft(
|
|
3611
|
+
y.firstMessage(),
|
|
3612
|
+
a,
|
|
3613
|
+
`No motion state received from ${L} within ${a / 1e3}s`
|
|
3614
|
+
), R = (Q = qt(k.data)) == null ? void 0 : Q.result;
|
|
3615
|
+
if (!R)
|
|
3616
|
+
throw new Error(
|
|
3617
|
+
`Unable to parse initial motion state message ${k.data}`
|
|
3618
|
+
);
|
|
3619
|
+
return { socket: y, initialMotionState: R };
|
|
3620
|
+
}
|
|
3621
|
+
);
|
|
3622
|
+
if (s()) return null;
|
|
3623
|
+
const { source: $, initialControllerState: nt } = await u(
|
|
3624
|
+
"controllerStateStream",
|
|
3625
|
+
`${p}/state`,
|
|
3626
|
+
async () => {
|
|
3627
|
+
var Q;
|
|
3628
|
+
const y = r({ cellId: t, controllerId: e });
|
|
3629
|
+
h = y, n.updateStepUrl("controllerStateStream", y.url);
|
|
3630
|
+
const k = await Ft(
|
|
3631
|
+
y.firstMessage(),
|
|
3632
|
+
a,
|
|
3633
|
+
`No controller state received from ${y.url} within ${a / 1e3}s`
|
|
3634
|
+
), R = y.parse(k.data);
|
|
3635
|
+
if (!R)
|
|
3636
|
+
throw new Error(
|
|
3637
|
+
`Unable to parse initial controller state message ${k.data}`
|
|
3638
|
+
);
|
|
3639
|
+
if (!((Q = R.motion_groups) != null && Q.some((ye) => ye.motion_group === i)))
|
|
3640
|
+
throw new Error(
|
|
3641
|
+
`Controller state from ${y.url} does not list motion group ${i} yet`
|
|
3642
|
+
);
|
|
3643
|
+
return { source: y, initialControllerState: R };
|
|
3644
|
+
}
|
|
3645
|
+
);
|
|
3646
|
+
return s() ? null : (c = !0, {
|
|
3647
|
+
motionGroupDescription: f,
|
|
3648
|
+
controllerConfiguration: v,
|
|
3649
|
+
kinematicModel: T,
|
|
3650
|
+
motionGroupModelName: j,
|
|
3651
|
+
coordinateSystems: x,
|
|
3652
|
+
controllerState: E,
|
|
3653
|
+
motionGroupState: O,
|
|
3654
|
+
initialMotionState: P,
|
|
3655
|
+
motionStateSocket: G,
|
|
3656
|
+
stateSource: $,
|
|
3657
|
+
initialControllerState: nt,
|
|
3658
|
+
dispose: m
|
|
3659
|
+
});
|
|
3660
|
+
} finally {
|
|
3661
|
+
c || m();
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
class oi {
|
|
3665
|
+
constructor(t) {
|
|
3666
|
+
this.options = t, this.plannedTrajectory = null, this.trajectoryState = "idle", this.lastError = null, this.disposers = [], this.logger = t.logger ?? console, D(
|
|
3667
|
+
this,
|
|
3668
|
+
{ socket: !1, disposers: !1, logger: !1, options: !1 },
|
|
3669
|
+
{ autoBind: !0 }
|
|
3670
|
+
), this.socket = this.openSocket(), this.disposers.push(
|
|
3671
|
+
Z(
|
|
3672
|
+
() => this.executionState,
|
|
3673
|
+
(e) => {
|
|
3674
|
+
e === "END_OF_TRAJECTORY" && this.reset();
|
|
3675
|
+
}
|
|
3676
|
+
)
|
|
3677
|
+
);
|
|
3678
|
+
}
|
|
3679
|
+
get joggingStore() {
|
|
3680
|
+
return this.options.joggingStore;
|
|
3681
|
+
}
|
|
3682
|
+
get jogger() {
|
|
3683
|
+
return this.options.joggingStore.jogger;
|
|
3684
|
+
}
|
|
3685
|
+
get motionStream() {
|
|
3686
|
+
return this.options.joggingStore.jogger.motionStream;
|
|
3687
|
+
}
|
|
3688
|
+
/** The execution state that the motion stream reports, e.g. "RUNNING" */
|
|
3689
|
+
get executionState() {
|
|
3690
|
+
var t, e;
|
|
3691
|
+
return (e = (t = this.motionStream.rapidlyChangingMotionState.execute) == null ? void 0 : t.details) == null ? void 0 : e.state.kind;
|
|
3692
|
+
}
|
|
3693
|
+
/**
|
|
3694
|
+
* Plans a trajectory from the current joints to the target and initializes
|
|
3695
|
+
* it on the execution websocket. The store is "planned" once NOVA accepted
|
|
3696
|
+
* it. Returns a planner rejection as a value; throws while the app locks
|
|
3697
|
+
* the robot and when the planner cannot be reached.
|
|
3698
|
+
*/
|
|
3699
|
+
async planTrajectory(t) {
|
|
3700
|
+
var w, I, T, j, x;
|
|
3701
|
+
if ((I = (w = this.options).isLocked) != null && I.call(w))
|
|
3702
|
+
throw this.reset(), new Error("Cannot plan trajectory: the robot is locked");
|
|
3703
|
+
await this.ensureMovementOwnership();
|
|
3704
|
+
const e = this.motionStream.rapidlyChangingMotionState.joint_position ?? [], { cycle_time: i, mounting: n, motion_group_model: r, tcps: s } = this.motionStream.description, a = this.joggingStore.selectedTcpId, d = a ? (T = s == null ? void 0 : s[a]) == null ? void 0 : T.pose : void 0, h = {
|
|
3705
|
+
// The model the jogger plans step jogs with: the custom copy that holds
|
|
3706
|
+
// this robot's data, if the app gave one
|
|
3707
|
+
motion_group_model: ((j = this.jogger.options) == null ? void 0 : j.motionGroupModel) ?? r,
|
|
3708
|
+
cycle_time: i ?? 0,
|
|
3709
|
+
mounting: n,
|
|
3710
|
+
...d && { tcp_offset: d }
|
|
3711
|
+
};
|
|
3712
|
+
let c;
|
|
3713
|
+
if (t.type === "cartesian") {
|
|
3714
|
+
let E = t.pose;
|
|
3715
|
+
const O = t.coordinateSystemId || "world";
|
|
3716
|
+
if (O !== "world")
|
|
3717
|
+
try {
|
|
3718
|
+
E = dt(
|
|
3719
|
+
{
|
|
3720
|
+
pose: {
|
|
3721
|
+
position: E.position ?? [0, 0, 0],
|
|
3722
|
+
orientation: E.orientation ?? [0, 0, 0]
|
|
3723
|
+
},
|
|
3724
|
+
coordinateSystemId: O
|
|
3725
|
+
},
|
|
3726
|
+
"world",
|
|
3727
|
+
this.joggingStore.coordSystems
|
|
3728
|
+
).pose;
|
|
3729
|
+
} catch {
|
|
3730
|
+
return this.reset(), { ok: !1, errorFeedbackName: "FeedbackUnknown" };
|
|
3731
|
+
}
|
|
3732
|
+
c = {
|
|
3733
|
+
limits_override: {
|
|
3734
|
+
tcp_velocity_limit: this.joggingStore.translationVelocityMmPerSec
|
|
3735
|
+
},
|
|
3736
|
+
path: {
|
|
3737
|
+
target_pose: E,
|
|
3738
|
+
path_definition_name: "PathCartesianPTP"
|
|
3739
|
+
}
|
|
3740
|
+
};
|
|
3741
|
+
} else
|
|
3742
|
+
c = {
|
|
3743
|
+
limits_override: {
|
|
3744
|
+
joint_velocity_limits: Array(e.length).fill(
|
|
3745
|
+
this.joggingStore.rotationVelocityRadsPerSec
|
|
3746
|
+
)
|
|
3747
|
+
},
|
|
3748
|
+
path: {
|
|
3749
|
+
target_joint_position: t.joints,
|
|
3750
|
+
path_definition_name: "PathJointPTP"
|
|
3751
|
+
}
|
|
3752
|
+
};
|
|
3753
|
+
S(() => {
|
|
3754
|
+
this.lastError = null, this.trajectoryState = "planning";
|
|
3755
|
+
});
|
|
3756
|
+
let m;
|
|
3757
|
+
try {
|
|
3758
|
+
m = await this.jogger.nova.api.trajectoryPlanning.planTrajectory(
|
|
3759
|
+
this.jogger.cellId,
|
|
3760
|
+
{
|
|
3761
|
+
motion_group_setup: h,
|
|
3762
|
+
start_joint_position: e,
|
|
3763
|
+
motion_commands: [c]
|
|
3764
|
+
}
|
|
3765
|
+
);
|
|
3766
|
+
} catch (E) {
|
|
3767
|
+
throw this.reset(), E;
|
|
3768
|
+
}
|
|
3769
|
+
const u = m.response;
|
|
3770
|
+
if ("error_feedback" in u) {
|
|
3771
|
+
const E = ((x = u.error_feedback) == null ? void 0 : x.error_feedback_name) ?? "FeedbackUnknown";
|
|
3772
|
+
return this.reset(), { ok: !1, errorFeedbackName: E };
|
|
3773
|
+
}
|
|
3774
|
+
const l = u.joint_positions, p = l[0], f = l[l.length - 1];
|
|
3775
|
+
if (!p || !f)
|
|
3776
|
+
throw this.reset(), new Error("Trajectory returned invalid joint positions");
|
|
3777
|
+
const v = {
|
|
3778
|
+
message_type: "InitializeMovementRequest",
|
|
3779
|
+
trajectory: {
|
|
3780
|
+
message_type: "TrajectoryData",
|
|
3781
|
+
motion_group: this.jogger.motionGroupId,
|
|
3782
|
+
tcp: a || void 0,
|
|
3783
|
+
data: u
|
|
3784
|
+
}
|
|
3785
|
+
};
|
|
3786
|
+
return this.socket.sendJson(v), S(() => {
|
|
3787
|
+
this.plannedTrajectory = { startJoints: p, endJoints: f };
|
|
3788
|
+
}), { ok: !0 };
|
|
3789
|
+
}
|
|
3790
|
+
/** Starts the motion along the planned trajectory */
|
|
3791
|
+
start() {
|
|
3792
|
+
if (!this.plannedTrajectory)
|
|
3793
|
+
throw new Error("Cannot start trajectory: no planned trajectory exists");
|
|
3794
|
+
if (this.trajectoryState !== "planned")
|
|
3795
|
+
throw new Error(
|
|
3796
|
+
`Cannot start trajectory: expected state "planned", got "${this.trajectoryState}"`
|
|
3797
|
+
);
|
|
3798
|
+
if (this.executionState === "RUNNING")
|
|
3799
|
+
throw new Error("Cannot start trajectory: robot is already running");
|
|
3800
|
+
const t = {
|
|
3801
|
+
message_type: "StartMovementRequest",
|
|
3802
|
+
direction: "DIRECTION_FORWARD"
|
|
3803
|
+
};
|
|
3804
|
+
this.socket.sendJson(t);
|
|
3805
|
+
}
|
|
3806
|
+
/**
|
|
3807
|
+
* Pauses the motion. Resolves once the robot stands still; the trajectory
|
|
3808
|
+
* stays planned, so `start` goes on from there.
|
|
3809
|
+
*/
|
|
3810
|
+
async pause() {
|
|
3811
|
+
if (this.trajectoryState !== "moving")
|
|
3812
|
+
throw new Error(
|
|
3813
|
+
`Cannot pause trajectory: expected state "moving", got "${this.trajectoryState}"`
|
|
3814
|
+
);
|
|
3815
|
+
if (this.executionState === "PAUSED_BY_USER")
|
|
3816
|
+
throw new Error("Cannot pause trajectory: robot is already paused");
|
|
3817
|
+
const t = {
|
|
3818
|
+
message_type: "PauseMovementRequest"
|
|
3819
|
+
};
|
|
3820
|
+
this.socket.sendJson(t), await this.waitUntilStopped(), S(() => {
|
|
3821
|
+
this.trajectoryState = this.plannedTrajectory ? "planned" : "idle";
|
|
3822
|
+
});
|
|
3823
|
+
}
|
|
3824
|
+
/**
|
|
3825
|
+
* Stops a moving robot, drops the trajectory and hands the controller's
|
|
3826
|
+
* execution session back: closes the execution websocket and opens a new
|
|
3827
|
+
* one for the next plan
|
|
3828
|
+
*/
|
|
3829
|
+
async stopAndReset() {
|
|
3830
|
+
try {
|
|
3831
|
+
if (this.executionState === "RUNNING" || this.trajectoryState === "moving") {
|
|
3832
|
+
const t = {
|
|
3833
|
+
message_type: "PauseMovementRequest"
|
|
3834
|
+
};
|
|
3835
|
+
this.socket.sendJson(t), await this.waitUntilStopped();
|
|
3836
|
+
}
|
|
3837
|
+
} catch (t) {
|
|
3838
|
+
this.logger.warn("Failed to stop trajectory execution cleanly", t);
|
|
3839
|
+
} finally {
|
|
3840
|
+
this.reset(), this.closeSocket(), this.socket = this.openSocket();
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
/** Drops the planned trajectory, without telling NOVA */
|
|
3844
|
+
reset() {
|
|
3845
|
+
this.plannedTrajectory = null, this.trajectoryState = "idle";
|
|
3846
|
+
}
|
|
3847
|
+
/** Removes {@link TrajectoryExecutionStore.lastError} */
|
|
3848
|
+
clearError() {
|
|
3849
|
+
this.lastError = null;
|
|
3850
|
+
}
|
|
3851
|
+
/** Closes the execution websocket and stops following the motion stream */
|
|
3852
|
+
dispose() {
|
|
3853
|
+
for (const t of this.disposers)
|
|
3854
|
+
t();
|
|
3855
|
+
this.closeSocket();
|
|
3856
|
+
}
|
|
3857
|
+
/** Ends continuous jogging, unless the app has its own way */
|
|
3858
|
+
async ensureMovementOwnership() {
|
|
3859
|
+
if (this.options.ensureMovementOwnership) {
|
|
3860
|
+
await this.options.ensureMovementOwnership();
|
|
3861
|
+
return;
|
|
3862
|
+
}
|
|
3863
|
+
this.jogger.mode !== "trajectory" && (await this.joggingStore.deactivate(), await this.jogger.setJoggingMode("trajectory"));
|
|
3864
|
+
}
|
|
3865
|
+
/** Resolves once the motion stream reports that the robot stands still */
|
|
3866
|
+
async waitUntilStopped() {
|
|
3867
|
+
await lt(() => this.motionStream.rapidlyChangingMotionState.standstill);
|
|
3868
|
+
}
|
|
3869
|
+
handleMessage(t) {
|
|
3870
|
+
var i, n;
|
|
3871
|
+
const e = (i = J(t.data)) == null ? void 0 : i.result;
|
|
3872
|
+
if (e)
|
|
3873
|
+
switch (e.kind) {
|
|
3874
|
+
case "INITIALIZE_RECEIVED":
|
|
3875
|
+
e.add_trajectory_error || e.message ? (this.lastError = ((n = e.add_trajectory_error) == null ? void 0 : n.message) ?? e.message ?? "NOVA refused the trajectory", this.reset()) : this.trajectoryState = "planned";
|
|
3876
|
+
break;
|
|
3877
|
+
case "START_RECEIVED":
|
|
3878
|
+
this.trajectoryState = "moving";
|
|
3879
|
+
break;
|
|
3880
|
+
case "PAUSE_RECEIVED":
|
|
3881
|
+
this.trajectoryState === "moving" && (this.trajectoryState = "stopping");
|
|
3882
|
+
break;
|
|
3883
|
+
case "MOTION_ERROR":
|
|
3884
|
+
this.lastError = e.message, this.reset();
|
|
3885
|
+
break;
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
openSocket() {
|
|
3889
|
+
const t = this.jogger.nova.openReconnectingWebsocket(
|
|
3890
|
+
`/cells/${this.jogger.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`
|
|
3891
|
+
);
|
|
3892
|
+
return t.addEventListener("message", this.handleMessage), t;
|
|
3893
|
+
}
|
|
3894
|
+
closeSocket() {
|
|
3895
|
+
this.socket.removeEventListener("message", this.handleMessage), this.socket.dispose();
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
class fe extends Error {
|
|
3899
|
+
/** @internal The session makes it, see RobotSession */
|
|
3900
|
+
constructor(t, e, i) {
|
|
3901
|
+
super(t), this.url = e, this.cause = i, this.name = "RobotModeChangeError";
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
class ii {
|
|
3905
|
+
constructor(t, e, i, n, r) {
|
|
3906
|
+
this.nova = t, this.ids = e, this.live = i, this.safety = n, this.logger = r, this.state = "inactive", this.disposers = [], i.controllerState.mode === "MODE_CONTROL" && (this.state = "active"), D(
|
|
3907
|
+
this,
|
|
3908
|
+
{
|
|
3909
|
+
nova: !1,
|
|
3910
|
+
ids: !1,
|
|
3911
|
+
live: !1,
|
|
3912
|
+
safety: !1,
|
|
3913
|
+
logger: !1,
|
|
3914
|
+
disposers: !1
|
|
3915
|
+
},
|
|
3916
|
+
{ autoBind: !0 }
|
|
3917
|
+
), this.disposers.push(
|
|
3918
|
+
Z(
|
|
3919
|
+
() => this.live.controllerState.mode,
|
|
3920
|
+
(s) => {
|
|
3921
|
+
this.state = s === "MODE_CONTROL" ? "active" : "inactive";
|
|
3922
|
+
}
|
|
3923
|
+
)
|
|
3924
|
+
), this.disposers.push(
|
|
3925
|
+
Z(
|
|
3926
|
+
() => this.live.connectionQuality,
|
|
3927
|
+
(s) => {
|
|
3928
|
+
s === "critical" && (this.state = "inactive");
|
|
3929
|
+
}
|
|
3930
|
+
)
|
|
3931
|
+
);
|
|
3932
|
+
}
|
|
3933
|
+
/**
|
|
3934
|
+
* Switches the controller to control mode. Does nothing while a mode change
|
|
3935
|
+
* is in progress, or when the safety state or operation mode would make
|
|
3936
|
+
* NOVA refuse it (see {@link RobotSafety.activationBlockedReason}). Rejects
|
|
3937
|
+
* with a {@link RobotModeChangeError} when NOVA refuses it.
|
|
3938
|
+
*/
|
|
3939
|
+
async activate() {
|
|
3940
|
+
if (this.state !== "inactive") {
|
|
3941
|
+
this.logger.warn("Tried to activate while already activating");
|
|
3942
|
+
return;
|
|
3943
|
+
}
|
|
3944
|
+
const t = this.safety().activationBlockedReason;
|
|
3945
|
+
if (t) {
|
|
3946
|
+
this.logger.warn(
|
|
3947
|
+
`Not enabling control mode for controller "${this.ids.controllerId}" because ${t}`
|
|
3948
|
+
);
|
|
3949
|
+
return;
|
|
3950
|
+
}
|
|
3951
|
+
this.state = "activating";
|
|
3952
|
+
try {
|
|
3953
|
+
await this.setMode("ROBOT_SYSTEM_MODE_CONTROL"), S(() => {
|
|
3954
|
+
this.live.controllerState.mode === "MODE_CONTROL" && (this.state = "active");
|
|
3955
|
+
});
|
|
3956
|
+
} catch (e) {
|
|
3957
|
+
throw S(() => {
|
|
3958
|
+
this.state = "inactive";
|
|
3959
|
+
}), e;
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
/**
|
|
3963
|
+
* Switches the controller to monitor mode. Rejects with a
|
|
3964
|
+
* {@link RobotModeChangeError} when NOVA refuses it.
|
|
3965
|
+
*/
|
|
3966
|
+
async deactivate() {
|
|
3967
|
+
if (this.state !== "active") {
|
|
3968
|
+
this.logger.warn("Tried to deactivate while already deactivating");
|
|
3969
|
+
return;
|
|
3970
|
+
}
|
|
3971
|
+
this.state = "deactivating";
|
|
3972
|
+
try {
|
|
3973
|
+
await this.setMode("ROBOT_SYSTEM_MODE_MONITOR"), S(() => {
|
|
3974
|
+
this.live.controllerState.mode !== "MODE_CONTROL" && (this.state = "inactive");
|
|
3975
|
+
});
|
|
3976
|
+
} catch (t) {
|
|
3977
|
+
throw S(() => {
|
|
3978
|
+
this.state = "active";
|
|
3979
|
+
}), t;
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
/** Activates an inactive robot, deactivates an active one */
|
|
3983
|
+
async toggle() {
|
|
3984
|
+
this.state === "inactive" ? await this.activate() : this.state === "active" && await this.deactivate();
|
|
3985
|
+
}
|
|
3986
|
+
dispose() {
|
|
3987
|
+
for (const t of this.disposers)
|
|
3988
|
+
t();
|
|
3989
|
+
}
|
|
3990
|
+
async setMode(t) {
|
|
3991
|
+
const { cellId: e, controllerId: i } = this.ids;
|
|
3992
|
+
try {
|
|
3993
|
+
await this.nova.api.controller.setDefaultMode(e, i, t);
|
|
3994
|
+
} catch (n) {
|
|
3995
|
+
const r = (typeof n == "object" && n !== null && "url" in n && typeof n.url == "string" ? n.url : void 0) ?? `/cells/${e}/controllers/${i}/mode`;
|
|
3996
|
+
throw new fe(
|
|
3997
|
+
`Failed to set controller "${i}" to ${t}: ${z(n)}`,
|
|
3998
|
+
r,
|
|
3999
|
+
n
|
|
4000
|
+
);
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
const ni = {
|
|
4005
|
+
a: 0,
|
|
4006
|
+
d: 0,
|
|
4007
|
+
alpha: 0,
|
|
4008
|
+
theta: 0,
|
|
4009
|
+
reverse_rotation_direction: !1
|
|
4010
|
+
};
|
|
4011
|
+
class ri {
|
|
4012
|
+
/** @internal The session makes it, see RobotSession */
|
|
4013
|
+
constructor(t, e, i, n, r) {
|
|
4014
|
+
this.motionGroupDescription = t, this.controllerConfiguration = e, this.kinematicModel = i, this.resolvedMotionGroupModel = n, this.coordinateSystems = r, this.dhParameters = (t.dh_parameters ?? []).map(
|
|
4015
|
+
(s) => ({ ...ni, ...s })
|
|
4016
|
+
);
|
|
4017
|
+
}
|
|
4018
|
+
/** A virtual robot of NOVA's simulation, not a physical one */
|
|
4019
|
+
get isVirtual() {
|
|
4020
|
+
return this.controllerConfiguration.kind === "VirtualController";
|
|
4021
|
+
}
|
|
4022
|
+
/** The model the controller reports */
|
|
4023
|
+
get motionGroupModel() {
|
|
4024
|
+
return this.motionGroupDescription.motion_group_model;
|
|
4025
|
+
}
|
|
4026
|
+
get serialNumber() {
|
|
4027
|
+
return this.motionGroupDescription.serial_number;
|
|
4028
|
+
}
|
|
4029
|
+
/**
|
|
4030
|
+
* The inverse solver of the model; null for a model without one, such as a
|
|
4031
|
+
* linear axis or a turntable, which jogs its joints only
|
|
4032
|
+
*/
|
|
4033
|
+
get inverseSolver() {
|
|
4034
|
+
return this.kinematicModel.inverse_solver;
|
|
4035
|
+
}
|
|
4036
|
+
/** Revolute, or prismatic for a linear axis */
|
|
4037
|
+
get jointType() {
|
|
4038
|
+
var t, e;
|
|
4039
|
+
return ((e = (t = this.motionGroupDescription.dh_parameters) == null ? void 0 : t[0]) == null ? void 0 : e.type) ?? N.RevoluteJoint;
|
|
4040
|
+
}
|
|
4041
|
+
/** The joints' limits in automatic mode, one per joint */
|
|
4042
|
+
get jointLimits() {
|
|
4043
|
+
var t;
|
|
4044
|
+
return ((t = this.motionGroupDescription.operation_limits.auto_limits) == null ? void 0 : t.joints) ?? [];
|
|
4045
|
+
}
|
|
4046
|
+
get safetyZones() {
|
|
4047
|
+
return this.motionGroupDescription.safety_zones;
|
|
4048
|
+
}
|
|
4049
|
+
/**
|
|
4050
|
+
* Per-link safety colliders (`safety_link_colliders`): entry k is in the
|
|
4051
|
+
* frame after k DH transforms (entry 0 = the static base). Not every
|
|
4052
|
+
* controller gives them.
|
|
4053
|
+
*/
|
|
4054
|
+
get safetyLinkColliders() {
|
|
4055
|
+
return this.motionGroupDescription.safety_link_colliders;
|
|
4056
|
+
}
|
|
4057
|
+
/** The collision shapes of each tool (TCP), at the flange */
|
|
4058
|
+
get safetyToolColliders() {
|
|
4059
|
+
return this.motionGroupDescription.safety_tool_colliders;
|
|
4060
|
+
}
|
|
4061
|
+
/**
|
|
4062
|
+
* Constant transformation between the motion group base frame and the start
|
|
4063
|
+
* of the DH chain. From the kinematic model, which always reflects the
|
|
4064
|
+
* current robot data; the motion group description is only the fallback, as
|
|
4065
|
+
* controllers snapshot the offset when they are created. Null means
|
|
4066
|
+
* identity.
|
|
4067
|
+
*/
|
|
4068
|
+
get kinematicChainOffset() {
|
|
4069
|
+
return this.kinematicModel.kinematic_chain_offset ?? this.motionGroupDescription.kinematic_chain_offset ?? null;
|
|
4070
|
+
}
|
|
4071
|
+
/**
|
|
4072
|
+
* Constant transformation between the end of the DH chain and the flange
|
|
4073
|
+
* frame, sourced as {@link RobotDescription.kinematicChainOffset}
|
|
4074
|
+
*/
|
|
4075
|
+
get flangeOffset() {
|
|
4076
|
+
return this.kinematicModel.flange_offset ?? this.motionGroupDescription.flange_offset ?? null;
|
|
4077
|
+
}
|
|
4078
|
+
/** Where the robot is mounted in the cell (mm, rotation vector), if set */
|
|
4079
|
+
get mounting() {
|
|
4080
|
+
return this.motionGroupDescription.mounting ?? null;
|
|
4081
|
+
}
|
|
4082
|
+
/** The robot's TCPs, by id and name */
|
|
4083
|
+
get tcps() {
|
|
4084
|
+
return Object.entries(this.motionGroupDescription.tcps ?? {}).map(
|
|
4085
|
+
([t, e]) => ({ id: t, name: e.name })
|
|
4086
|
+
);
|
|
4087
|
+
}
|
|
4088
|
+
/** The TCPs' offsets from the flange, by TCP id */
|
|
4089
|
+
get tcpOffsetsById() {
|
|
4090
|
+
return this.motionGroupDescription.tcps ?? {};
|
|
4091
|
+
}
|
|
4092
|
+
}
|
|
4093
|
+
const Bt = (o) => Array.isArray(o) && o.length === 3 && o.every((t) => typeof t == "number"), si = 1e-3, ai = 0.5, li = 0.01, yt = (o, t, e) => !!(o && t && ht([...o], [...t], e));
|
|
4094
|
+
class ci {
|
|
4095
|
+
/** @internal The session makes it, see RobotSession */
|
|
4096
|
+
constructor(t, e, i) {
|
|
4097
|
+
this.stream = t, this.description = e, this.jogging = i, D(
|
|
4098
|
+
this,
|
|
4099
|
+
{ stream: !1, description: !1, jogging: !1 },
|
|
4100
|
+
{ autoBind: !0 }
|
|
4101
|
+
);
|
|
4102
|
+
}
|
|
4103
|
+
/** Safety state, operation mode and mode of the controller */
|
|
4104
|
+
get controllerState() {
|
|
4105
|
+
return this.stream.controllerState;
|
|
4106
|
+
}
|
|
4107
|
+
/**
|
|
4108
|
+
* The motion state as the last message had it: one object for the whole
|
|
4109
|
+
* session, updated in place (see {@link ControllerStateStream})
|
|
4110
|
+
*/
|
|
4111
|
+
get rapidlyChangingMotionState() {
|
|
4112
|
+
return this.stream.rapidlyChangingMotionState;
|
|
4113
|
+
}
|
|
4114
|
+
/** What readouts show: it holds while the joints only jitter */
|
|
4115
|
+
get readoutState() {
|
|
4116
|
+
return this.stream.readoutState;
|
|
4117
|
+
}
|
|
4118
|
+
/** The joints readouts show, from {@link RobotLiveState.readoutState} */
|
|
4119
|
+
get jointPose() {
|
|
4120
|
+
return this.stream.readoutState.joint_position;
|
|
4121
|
+
}
|
|
4122
|
+
get connectionQuality() {
|
|
4123
|
+
return this.stream.connectionQuality;
|
|
4124
|
+
}
|
|
4125
|
+
get lastValidStateMessage() {
|
|
4126
|
+
return this.stream.lastValidStateMessage;
|
|
4127
|
+
}
|
|
4128
|
+
get lastInvalidStateMessage() {
|
|
4129
|
+
return this.stream.lastInvalidStateMessage;
|
|
4130
|
+
}
|
|
4131
|
+
/** The TCP pose as NOVA reports it, in its own TCP and coordinate system */
|
|
4132
|
+
get measuredTcpPoseReference() {
|
|
4133
|
+
return this.tcpPoseReferenceOf(this.rapidlyChangingMotionState);
|
|
4134
|
+
}
|
|
4135
|
+
/**
|
|
4136
|
+
* The measured TCP pose in the TCP and coordinate system that the jogging
|
|
4137
|
+
* store has selected: what a stored or typed pose uses
|
|
4138
|
+
*/
|
|
4139
|
+
get displayedTcpPoseReference() {
|
|
4140
|
+
return this.inSelectedFrame(this.measuredTcpPoseReference);
|
|
4141
|
+
}
|
|
4142
|
+
/** The pose readouts show, from {@link RobotLiveState.readoutState}, in the selected frame */
|
|
4143
|
+
get displayedTcpPose() {
|
|
4144
|
+
return this.inSelectedFrame(this.tcpPoseReferenceOf(this.readoutState)).pose;
|
|
4145
|
+
}
|
|
4146
|
+
/**
|
|
4147
|
+
* Whether the robot stands at a pose: its joints within 0.001, or its TCP
|
|
4148
|
+
* within 0.5 mm and 0.01 rad of the pose in the pose's TCP and coordinate
|
|
4149
|
+
* system. Not at a pose of a TCP or coordinate system it does not know.
|
|
4150
|
+
*/
|
|
4151
|
+
isAt(t) {
|
|
4152
|
+
if (t.type === "joint")
|
|
4153
|
+
return yt(
|
|
4154
|
+
t.joints,
|
|
4155
|
+
this.rapidlyChangingMotionState.joint_position,
|
|
4156
|
+
si
|
|
4157
|
+
);
|
|
4158
|
+
try {
|
|
4159
|
+
const e = $t({
|
|
4160
|
+
inputPose: this.measuredTcpPoseReference,
|
|
4161
|
+
selectedTcpId: t.tcpPose.tcpId,
|
|
4162
|
+
selectedCoordinateSystemId: t.tcpPose.coordSystemId,
|
|
4163
|
+
tcpOffsetsById: this.description.tcpOffsetsById,
|
|
4164
|
+
coordinateSystems: this.jogging.coordSystems
|
|
4165
|
+
});
|
|
4166
|
+
return yt(
|
|
4167
|
+
t.tcpPose.pose.position,
|
|
4168
|
+
e.pose.position,
|
|
4169
|
+
ai
|
|
4170
|
+
) && yt(
|
|
4171
|
+
t.tcpPose.pose.orientation,
|
|
4172
|
+
e.pose.orientation,
|
|
4173
|
+
li
|
|
4174
|
+
);
|
|
4175
|
+
} catch {
|
|
4176
|
+
return !1;
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
4179
|
+
/** The motion state in the stream's next message */
|
|
4180
|
+
nextMotionState() {
|
|
4181
|
+
return this.stream.nextMotionState();
|
|
4182
|
+
}
|
|
4183
|
+
/** Resolves once two messages in a row show the joints standing still */
|
|
4184
|
+
async waitUntilStopped() {
|
|
4185
|
+
let t = await this.stream.nextMotionState(), e = await this.stream.nextMotionState();
|
|
4186
|
+
for (; !ht(
|
|
4187
|
+
t.joint_position,
|
|
4188
|
+
e.joint_position,
|
|
4189
|
+
ue
|
|
4190
|
+
); )
|
|
4191
|
+
t = e, e = await this.stream.nextMotionState();
|
|
4192
|
+
}
|
|
4193
|
+
tcpPoseReferenceOf(t) {
|
|
4194
|
+
var n, r;
|
|
4195
|
+
const e = (n = t.tcp_pose) == null ? void 0 : n.position, i = (r = t.tcp_pose) == null ? void 0 : r.orientation;
|
|
4196
|
+
if (!e || !Bt(e))
|
|
4197
|
+
throw new Error(
|
|
4198
|
+
`Invalid current TCP pose position for motion group ${this.stream.motionGroupId}`
|
|
4199
|
+
);
|
|
4200
|
+
if (!i || !Bt(i))
|
|
4201
|
+
throw new Error(
|
|
4202
|
+
`Invalid current TCP pose orientation for motion group ${this.stream.motionGroupId}`
|
|
4203
|
+
);
|
|
4204
|
+
return {
|
|
4205
|
+
pose: { position: e, orientation: i },
|
|
4206
|
+
tcpId: t.tcp ?? "",
|
|
4207
|
+
coordinateSystemId: t.coordinate_system ?? "world"
|
|
4208
|
+
};
|
|
4209
|
+
}
|
|
4210
|
+
inSelectedFrame(t) {
|
|
4211
|
+
return $t({
|
|
4212
|
+
inputPose: t,
|
|
4213
|
+
selectedTcpId: this.jogging.selectedTcpId,
|
|
4214
|
+
selectedCoordinateSystemId: this.jogging.selectedCoordSystemId,
|
|
4215
|
+
tcpOffsetsById: this.description.tcpOffsetsById,
|
|
4216
|
+
coordinateSystems: this.jogging.coordSystems
|
|
4217
|
+
});
|
|
4218
|
+
}
|
|
4219
|
+
}
|
|
4220
|
+
const di = [
|
|
4221
|
+
"SAFETY_STATE_ROBOT_EMERGENCY_STOP",
|
|
4222
|
+
"SAFETY_STATE_DEVICE_EMERGENCY_STOP"
|
|
4223
|
+
], gi = ["SAFETY_STATE_NORMAL", "SAFETY_STATE_REDUCED"], hi = [
|
|
4224
|
+
"SAFETY_STATE_STOP",
|
|
4225
|
+
"SAFETY_STATE_STOP_0",
|
|
4226
|
+
"SAFETY_STATE_STOP_1",
|
|
4227
|
+
"SAFETY_STATE_STOP_2"
|
|
4228
|
+
], ui = [
|
|
4229
|
+
"OPERATION_MODE_AUTO",
|
|
4230
|
+
"OPERATION_MODE_MANUAL",
|
|
4231
|
+
"OPERATION_MODE_MANUAL_T1",
|
|
4232
|
+
"OPERATION_MODE_MANUAL_T2"
|
|
4233
|
+
];
|
|
4234
|
+
class mi {
|
|
4235
|
+
/** @internal The session makes it, see RobotSession */
|
|
4236
|
+
constructor(t, e) {
|
|
4237
|
+
this.state = t, this.activationState = e, D(
|
|
4238
|
+
this,
|
|
4239
|
+
{ state: !1, activationState: !1 },
|
|
4240
|
+
{ autoBind: !0 }
|
|
4241
|
+
);
|
|
4242
|
+
}
|
|
4243
|
+
get safetyState() {
|
|
4244
|
+
return this.state.controllerState.safety_state;
|
|
4245
|
+
}
|
|
4246
|
+
get operationMode() {
|
|
4247
|
+
return this.state.controllerState.operation_mode;
|
|
4248
|
+
}
|
|
4249
|
+
/** Whether an emergency stop is active */
|
|
4250
|
+
get isEstopActive() {
|
|
4251
|
+
return di.includes(this.safetyState);
|
|
4252
|
+
}
|
|
4253
|
+
/** Whether the safety state allows movement */
|
|
4254
|
+
get isMoveableSafetyState() {
|
|
4255
|
+
return gi.includes(this.safetyState);
|
|
4256
|
+
}
|
|
4257
|
+
/** Whether the operation mode allows movement */
|
|
4258
|
+
get isMoveableOperationMode() {
|
|
4259
|
+
return ui.includes(this.operationMode);
|
|
4260
|
+
}
|
|
4261
|
+
/**
|
|
4262
|
+
* Whether the safety state allows switching to control mode: the moveable
|
|
4263
|
+
* ones and the stop states (RPS-1296)
|
|
4264
|
+
*/
|
|
4265
|
+
get isActivatableSafetyState() {
|
|
4266
|
+
return this.isMoveableSafetyState || hi.includes(this.safetyState);
|
|
4267
|
+
}
|
|
4268
|
+
/**
|
|
4269
|
+
* Why the controller cannot be switched to control mode now, or null. NOVA
|
|
4270
|
+
* refuses the mode change then (an emergency stop needs a hand on the
|
|
4271
|
+
* physical controller), so it is not even requested.
|
|
4272
|
+
*/
|
|
4273
|
+
get activationBlockedReason() {
|
|
4274
|
+
return this.isEstopActive ? `an emergency stop is active (${this.safetyState})` : this.isActivatableSafetyState ? this.isMoveableOperationMode ? null : `the operation mode is ${this.operationMode}` : `the safety state is ${this.safetyState}`;
|
|
4275
|
+
}
|
|
4276
|
+
/** Whether the robot may be activated now */
|
|
4277
|
+
get canBeActive() {
|
|
4278
|
+
return this.activationBlockedReason === null;
|
|
4279
|
+
}
|
|
4280
|
+
/** Why the robot cannot move now, or null when it can */
|
|
4281
|
+
get notMoveableReason() {
|
|
4282
|
+
return this.state.connectionQuality === "critical" ? { code: "disconnected" } : this.isMoveableSafetyState ? this.isMoveableOperationMode ? this.activationState() === "inactive" ? { code: "deactivated" } : null : { code: "operation_mode", value: this.operationMode } : { code: "safety_state", value: this.safetyState };
|
|
4283
|
+
}
|
|
4284
|
+
/**
|
|
4285
|
+
* Whether the robot can move now: a moveable safety state and operation
|
|
4286
|
+
* mode, activated, and its live state coming
|
|
4287
|
+
*/
|
|
4288
|
+
get canBeMoved() {
|
|
4289
|
+
return this.isMoveableSafetyState && this.isMoveableOperationMode && this.activationState() === "active" && this.state.connectionQuality !== "critical";
|
|
4290
|
+
}
|
|
4291
|
+
}
|
|
4292
|
+
function pi(o) {
|
|
4293
|
+
return o.type === "joint" ? { type: "joint", joints: o.joints } : {
|
|
4294
|
+
type: "cartesian",
|
|
4295
|
+
pose: o.tcpPose.pose,
|
|
4296
|
+
coordinateSystemId: o.tcpPose.coordSystemId
|
|
4297
|
+
};
|
|
4298
|
+
}
|
|
4299
|
+
class fi {
|
|
4300
|
+
/** @internal The session makes it, see RobotSession */
|
|
4301
|
+
constructor(t, e) {
|
|
4302
|
+
this.robot = t, this.logger = e, this.editing = !1, this.draft = "", this.confirming = !1, this.staged = null, this.moveStarted = !1, this.disposers = [], D(
|
|
4303
|
+
this,
|
|
4304
|
+
{ robot: !1, logger: !1, disposers: !1, onBeforePlan: !1 },
|
|
4305
|
+
{ autoBind: !0 }
|
|
4306
|
+
), this.disposers.push(
|
|
4307
|
+
Z(
|
|
4308
|
+
() => this.robot.jogging.selectedTabId,
|
|
4309
|
+
() => {
|
|
4310
|
+
(this.editing || this.staged) && this.resetToLive();
|
|
4311
|
+
}
|
|
4312
|
+
)
|
|
4313
|
+
), this.disposers.push(
|
|
4314
|
+
Z(
|
|
4315
|
+
() => ({
|
|
4316
|
+
trajectoryState: this.robot.trajectory.trajectoryState,
|
|
4317
|
+
executionState: this.robot.trajectory.executionState,
|
|
4318
|
+
isRobotAtStagedPose: this.isRobotAtStagedPose
|
|
4319
|
+
}),
|
|
4320
|
+
({ trajectoryState: i, executionState: n, isRobotAtStagedPose: r }) => {
|
|
4321
|
+
if (!this.stagedPose) return;
|
|
4322
|
+
if (i === "moving") {
|
|
4323
|
+
this.moveStarted = !0;
|
|
4324
|
+
return;
|
|
4325
|
+
}
|
|
4326
|
+
(n === "END_OF_TRAJECTORY" || this.moveStarted && r && i !== "stopping") && this.resetToLive();
|
|
4327
|
+
}
|
|
4328
|
+
)
|
|
4329
|
+
);
|
|
4330
|
+
}
|
|
4331
|
+
dispose() {
|
|
4332
|
+
for (const t of this.disposers)
|
|
4333
|
+
t();
|
|
4334
|
+
}
|
|
4335
|
+
get phase() {
|
|
4336
|
+
return this.editing ? "editing" : this.staged ? this.staged.errorKey ? "error" : "staged" : "view";
|
|
4337
|
+
}
|
|
4338
|
+
get isJointTab() {
|
|
4339
|
+
return this.robot.jogging.selectedTabId === "joint";
|
|
4340
|
+
}
|
|
4341
|
+
/** The live pose as text: the joints on the joint tab, else the TCP pose */
|
|
4342
|
+
get liveDisplayString() {
|
|
4343
|
+
return this.isJointTab ? Ot(this.robot.state.jointPose) : kt(this.robot.state.displayedTcpPose);
|
|
4344
|
+
}
|
|
4345
|
+
/** What the field shows outside of edit mode: staged value or live pose */
|
|
4346
|
+
get displayString() {
|
|
4347
|
+
var t;
|
|
4348
|
+
return ((t = this.staged) == null ? void 0 : t.displayString) ?? this.liveDisplayString;
|
|
4349
|
+
}
|
|
4350
|
+
/** Parsed form of the draft, or null while it is not a valid pose */
|
|
4351
|
+
get parsedDraft() {
|
|
4352
|
+
const { state: t, motionGroupId: e } = this.robot;
|
|
4353
|
+
if (this.isJointTab) {
|
|
4354
|
+
const r = Xe(this.draft, t.jointPose.length);
|
|
4355
|
+
return r ? { type: "joint", motionGroupId: e, joints: r } : null;
|
|
4356
|
+
}
|
|
4357
|
+
const i = to(this.draft);
|
|
4358
|
+
if (!i) return null;
|
|
4359
|
+
const n = t.displayedTcpPoseReference;
|
|
4360
|
+
return {
|
|
4361
|
+
type: "cartesian",
|
|
4362
|
+
motionGroupId: e,
|
|
4363
|
+
tcpPose: {
|
|
4364
|
+
pose: { position: i.position, orientation: i.orientation },
|
|
4365
|
+
coordSystemId: n.coordinateSystemId,
|
|
4366
|
+
tcpId: n.tcpId
|
|
4367
|
+
}
|
|
4368
|
+
};
|
|
4369
|
+
}
|
|
4370
|
+
get draftValid() {
|
|
4371
|
+
return this.parsedDraft !== null;
|
|
4372
|
+
}
|
|
4373
|
+
beginEdit() {
|
|
4374
|
+
this.draft = this.displayString, this.editing = !0;
|
|
4375
|
+
}
|
|
4376
|
+
setDraft(t) {
|
|
4377
|
+
this.draft = t;
|
|
4378
|
+
}
|
|
4379
|
+
cancelEdit() {
|
|
4380
|
+
this.editing = !1, this.draft = "";
|
|
4381
|
+
}
|
|
4382
|
+
/**
|
|
4383
|
+
* Validates the typed pose against the backend by planning a trajectory to
|
|
4384
|
+
* it. On success the trajectory is left initialized on the execution
|
|
4385
|
+
* socket, so Move to is armed immediately; on a planner rejection the pose
|
|
4386
|
+
* stays staged with the failure explanation. Does nothing while the robot
|
|
4387
|
+
* may not move.
|
|
4388
|
+
*/
|
|
4389
|
+
async confirmEdit() {
|
|
4390
|
+
var i;
|
|
4391
|
+
const t = this.parsedDraft;
|
|
4392
|
+
if (!t || this.confirming || this.robot.notMoveableReason()) return;
|
|
4393
|
+
const e = t.type === "joint" ? Ot(t.joints) : kt(t.tcpPose.pose);
|
|
4394
|
+
this.confirming = !0;
|
|
4395
|
+
try {
|
|
4396
|
+
await ((i = this.onBeforePlan) == null ? void 0 : i.call(this));
|
|
4397
|
+
const n = await this.robot.trajectory.planTrajectory(
|
|
4398
|
+
pi(t)
|
|
4399
|
+
);
|
|
4400
|
+
S(() => {
|
|
4401
|
+
this.staged = {
|
|
4402
|
+
pose: t,
|
|
4403
|
+
displayString: e,
|
|
4404
|
+
errorKey: n.ok ? null : Ko(n.errorFeedbackName)
|
|
4405
|
+
}, this.editing = !1, this.draft = "";
|
|
4406
|
+
});
|
|
4407
|
+
} catch (n) {
|
|
4408
|
+
this.logger.warn("Failed to plan trajectory to typed pose", n), S(() => {
|
|
4409
|
+
this.staged = {
|
|
4410
|
+
pose: t,
|
|
4411
|
+
displayString: e,
|
|
4412
|
+
errorKey: "Jogging.TargetPose.Error.PlanningFailed.lb"
|
|
4413
|
+
}, this.editing = !1, this.draft = "";
|
|
4414
|
+
});
|
|
4415
|
+
} finally {
|
|
4416
|
+
S(() => {
|
|
4417
|
+
this.confirming = !1;
|
|
4418
|
+
});
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
/** Discards the staged pose and shows the live pose again */
|
|
4422
|
+
async resetToLive() {
|
|
4423
|
+
const t = this.staged !== null && !this.staged.errorKey;
|
|
4424
|
+
this.staged = null, this.moveStarted = !1, this.editing = !1, this.draft = "", t && await this.robot.trajectory.stopAndReset();
|
|
4425
|
+
}
|
|
4426
|
+
/**
|
|
4427
|
+
* Drops the staged pose and the edit without touching the trajectory: for
|
|
4428
|
+
* when another flow has just planned its own (RobotPad: a saved pose that
|
|
4429
|
+
* the user selected)
|
|
4430
|
+
*/
|
|
4431
|
+
clear() {
|
|
4432
|
+
this.editing = !1, this.staged = null;
|
|
4433
|
+
}
|
|
4434
|
+
/** The staged pose, if it is valid to store or move to */
|
|
4435
|
+
get stagedPose() {
|
|
4436
|
+
return !this.staged || this.staged.errorKey ? null : this.staged.pose;
|
|
4437
|
+
}
|
|
4438
|
+
/** True when the robot has arrived at (or already was at) the staged pose */
|
|
4439
|
+
get isRobotAtStagedPose() {
|
|
4440
|
+
return this.stagedPose ? this.robot.state.isAt(this.stagedPose) : !1;
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4443
|
+
const yi = {
|
|
4444
|
+
getItem: () => null,
|
|
4445
|
+
setItem: () => {
|
|
4446
|
+
}
|
|
4447
|
+
};
|
|
4448
|
+
class Si {
|
|
4449
|
+
/**
|
|
4450
|
+
* @internal Use {@link loadRobotSession}, which loads the resources and
|
|
4451
|
+
* makes the session
|
|
4452
|
+
*/
|
|
4453
|
+
constructor(t, e, i, n = {}) {
|
|
4454
|
+
const r = n.logger ?? console;
|
|
4455
|
+
this.onError = n.onError ?? (() => {
|
|
4456
|
+
}), this.nova = t, this.motionGroupId = e.motionGroupId, this.controllerId = e.controllerId, this.cellId = e.cellId, this.stateSource = i.stateSource, this.motionStateSocket = i.motionStateSocket;
|
|
4457
|
+
const s = new ut(
|
|
4458
|
+
t,
|
|
4459
|
+
i.controllerState,
|
|
4460
|
+
i.motionGroupState,
|
|
4461
|
+
i.motionGroupDescription,
|
|
4462
|
+
i.initialMotionState,
|
|
4463
|
+
i.motionStateSocket,
|
|
4464
|
+
e.cellId,
|
|
4465
|
+
{ logger: r }
|
|
4466
|
+
), a = new mt(s, {
|
|
4467
|
+
cellId: e.cellId,
|
|
4468
|
+
motionGroupModel: i.motionGroupModelName,
|
|
4469
|
+
logger: r,
|
|
4470
|
+
onError: (h) => this.onError({
|
|
4471
|
+
kind: "jog",
|
|
4472
|
+
message: z(h),
|
|
4473
|
+
url: a.motionStream.motionStateSocket.url,
|
|
4474
|
+
cause: h
|
|
4475
|
+
})
|
|
4476
|
+
});
|
|
4477
|
+
this.jogging = et.create(
|
|
4478
|
+
a,
|
|
4479
|
+
{
|
|
4480
|
+
coordinateSystems: i.coordinateSystems,
|
|
4481
|
+
description: i.motionGroupDescription,
|
|
4482
|
+
kinematicModel: i.kinematicModel
|
|
4483
|
+
},
|
|
4484
|
+
{ storage: n.storage ?? yi }
|
|
4485
|
+
), this.description = new ri(
|
|
4486
|
+
i.motionGroupDescription,
|
|
4487
|
+
i.controllerConfiguration,
|
|
4488
|
+
i.kinematicModel,
|
|
4489
|
+
i.motionGroupModelName,
|
|
4490
|
+
this.jogging.coordSystems
|
|
4491
|
+
);
|
|
4492
|
+
const d = new zo(
|
|
4493
|
+
i.stateSource,
|
|
4494
|
+
e.motionGroupId,
|
|
4495
|
+
i.initialControllerState,
|
|
4496
|
+
{
|
|
4497
|
+
isVirtual: this.description.isVirtual,
|
|
4498
|
+
onError: (h) => this.onError({ kind: "stream", ...h })
|
|
4499
|
+
}
|
|
4500
|
+
);
|
|
4501
|
+
this.state = new ci(d, this.description, this.jogging), this.activation = new ii(
|
|
4502
|
+
t,
|
|
4503
|
+
e,
|
|
4504
|
+
this.state,
|
|
4505
|
+
() => this.safety,
|
|
4506
|
+
r
|
|
4507
|
+
), this.safety = new mi(this.state, () => this.activation.state), this.trajectory = new oi({
|
|
4508
|
+
joggingStore: this.jogging,
|
|
4509
|
+
isLocked: n.isLocked,
|
|
4510
|
+
ensureMovementOwnership: () => this.ensureMovementOwnership("trajectory"),
|
|
4511
|
+
logger: r
|
|
4512
|
+
}), this.targetPose = new fi(
|
|
4513
|
+
{
|
|
4514
|
+
motionGroupId: e.motionGroupId,
|
|
4515
|
+
state: this.state,
|
|
4516
|
+
jogging: this.jogging,
|
|
4517
|
+
trajectory: this.trajectory,
|
|
4518
|
+
// A typed pose plans nothing while the robot may not move, or while
|
|
4519
|
+
// the app is locked
|
|
4520
|
+
notMoveableReason: () => {
|
|
4521
|
+
var h;
|
|
4522
|
+
return this.safety.notMoveableReason ?? ((h = n.isLocked) != null && h.call(n) ? { code: "locked" } : null);
|
|
4523
|
+
}
|
|
4524
|
+
},
|
|
4525
|
+
r
|
|
4526
|
+
), this.jogging.onBeforeActivate = async () => {
|
|
4527
|
+
this.targetPose.staged && await this.targetPose.resetToLive();
|
|
4528
|
+
}, n.autoActivateVirtual && this.description.isVirtual && this.activation.state === "inactive" && this.activation.activate().catch((h) => {
|
|
4529
|
+
this.onError({
|
|
4530
|
+
kind: "mode",
|
|
4531
|
+
message: z(h),
|
|
4532
|
+
url: h instanceof fe ? h.url : void 0,
|
|
4533
|
+
cause: h
|
|
4534
|
+
});
|
|
4535
|
+
});
|
|
4536
|
+
}
|
|
4537
|
+
/** Which motion owns the robot: jogging, a trajectory, or none ("off") */
|
|
4538
|
+
get movementOwner() {
|
|
4539
|
+
return this.jogging.jogger.mode;
|
|
4540
|
+
}
|
|
4541
|
+
/**
|
|
4542
|
+
* Hands the robot to jogging or to a trajectory: the controller runs only
|
|
4543
|
+
* one of them at a time
|
|
4544
|
+
*/
|
|
4545
|
+
async ensureMovementOwnership(t) {
|
|
4546
|
+
this.movementOwner !== t && (await this.jogging.deactivate(), await this.jogging.jogger.setJoggingMode(t));
|
|
4547
|
+
}
|
|
4548
|
+
/** Closes the session's connections and stops following the robot */
|
|
4549
|
+
dispose() {
|
|
4550
|
+
this.activation.dispose(), this.targetPose.dispose(), this.state.stream.dispose(), this.trajectory.dispose(), this.stateSource.close(), this.jogging.dispose(), this.motionStateSocket.dispose();
|
|
4551
|
+
}
|
|
4552
|
+
}
|
|
4553
|
+
const vi = [1e3, 2e3], _i = (o) => new Promise((t) => setTimeout(t, o));
|
|
4554
|
+
class bi {
|
|
4555
|
+
/** @internal Use {@link loadRobotSession} */
|
|
4556
|
+
constructor(t, e, i, n) {
|
|
4557
|
+
this.nova = t, this.motionGroupId = e, this.ids = i, this.options = n, this.state = "loading", this.session = null, this.error = null, this.attempt = 0, this.disposed = !1, this.progress = new Xo(e, i.controllerId), D(
|
|
4558
|
+
this,
|
|
4559
|
+
{
|
|
4560
|
+
nova: !1,
|
|
4561
|
+
ids: !1,
|
|
4562
|
+
options: !1,
|
|
4563
|
+
attempt: !1,
|
|
4564
|
+
disposed: !1,
|
|
4565
|
+
readyPromise: !1,
|
|
4566
|
+
settle: !1,
|
|
4567
|
+
progress: !1
|
|
4568
|
+
},
|
|
4569
|
+
{ autoBind: !0 }
|
|
4570
|
+
), this.start();
|
|
4571
|
+
}
|
|
4572
|
+
/**
|
|
4573
|
+
* Resolves with the session once it is ready; rejects when the load fails
|
|
4574
|
+
* or is disposed. After {@link RobotSessionLoad.retry}, a new promise for the new load.
|
|
4575
|
+
*/
|
|
4576
|
+
get ready() {
|
|
4577
|
+
return this.readyPromise;
|
|
4578
|
+
}
|
|
4579
|
+
/** Loads the robot again after a failure */
|
|
4580
|
+
retry() {
|
|
4581
|
+
this.disposed || this.state !== "failed" || this.start();
|
|
4582
|
+
}
|
|
4583
|
+
/** Stops a running load and closes the session */
|
|
4584
|
+
dispose() {
|
|
4585
|
+
var t;
|
|
4586
|
+
this.disposed || (this.disposed = !0, this.attempt++, (t = this.session) == null || t.dispose(), this.session = null, this.settle.reject(new Error("The robot session load was disposed")));
|
|
4587
|
+
}
|
|
4588
|
+
start() {
|
|
4589
|
+
this.attempt++;
|
|
4590
|
+
const t = this.attempt;
|
|
4591
|
+
this.readyPromise = new Promise((e, i) => {
|
|
4592
|
+
this.settle = { resolve: e, reject: i };
|
|
4593
|
+
}), this.readyPromise.catch(() => {
|
|
4594
|
+
}), S(() => {
|
|
4595
|
+
this.state = "loading", this.error = null;
|
|
4596
|
+
}), this.run(t);
|
|
4597
|
+
}
|
|
4598
|
+
isStale(t) {
|
|
4599
|
+
return this.disposed || t !== this.attempt;
|
|
4600
|
+
}
|
|
4601
|
+
async run(t) {
|
|
4602
|
+
var a, d;
|
|
4603
|
+
const { cellId: e, controllerId: i } = this.ids, n = this.options.retryDelaysMs ?? vi, r = this.options.logger ?? console, s = this.options.stateSource ?? ((h) => Ho(this.nova, h));
|
|
4604
|
+
for (let h = 0; ; h++)
|
|
4605
|
+
try {
|
|
4606
|
+
const c = await ei({
|
|
4607
|
+
nova: this.nova,
|
|
4608
|
+
cellId: e,
|
|
4609
|
+
controllerId: i,
|
|
4610
|
+
motionGroupId: this.motionGroupId,
|
|
4611
|
+
progress: this.progress,
|
|
4612
|
+
createStateSource: s,
|
|
4613
|
+
isStale: () => this.isStale(t),
|
|
4614
|
+
socketTimeoutMs: this.options.socketTimeoutMs
|
|
4615
|
+
});
|
|
4616
|
+
if (!c) return;
|
|
4617
|
+
if (this.isStale(t)) {
|
|
4618
|
+
c.dispose();
|
|
4619
|
+
return;
|
|
4620
|
+
}
|
|
4621
|
+
let m;
|
|
4622
|
+
try {
|
|
4623
|
+
m = new Si(
|
|
4624
|
+
this.nova,
|
|
4625
|
+
{ cellId: e, controllerId: i, motionGroupId: this.motionGroupId },
|
|
4626
|
+
c,
|
|
4627
|
+
this.options
|
|
4628
|
+
);
|
|
4629
|
+
} catch (u) {
|
|
4630
|
+
throw c.dispose(), u;
|
|
4631
|
+
}
|
|
4632
|
+
if (this.isStale(t)) {
|
|
4633
|
+
m.dispose();
|
|
4634
|
+
return;
|
|
4635
|
+
}
|
|
4636
|
+
S(() => {
|
|
4637
|
+
this.session = m, this.state = "ready";
|
|
4638
|
+
}), this.settle.resolve(m);
|
|
4639
|
+
return;
|
|
4640
|
+
} catch (c) {
|
|
4641
|
+
if (this.isStale(t)) return;
|
|
4642
|
+
const m = ft(c) ? n[h] : void 0;
|
|
4643
|
+
if (m === void 0) {
|
|
4644
|
+
S(() => {
|
|
4645
|
+
ft(c) ? this.progress.failStep(c.stepId, c.cause) : this.progress.failWith(c), this.state = "failed", this.error = c;
|
|
4646
|
+
}), (d = (a = this.options).onEvent) == null || d.call(a, {
|
|
4647
|
+
type: "loadFailed",
|
|
4648
|
+
motionGroupId: this.motionGroupId,
|
|
4649
|
+
step: ft(c) ? c.stepId : "unknown",
|
|
4650
|
+
message: z(c),
|
|
4651
|
+
attempts: h + 1
|
|
4652
|
+
}), this.settle.reject(c);
|
|
4653
|
+
return;
|
|
4654
|
+
}
|
|
4655
|
+
if (r.warn(
|
|
4656
|
+
`Retrying load of robot "${this.motionGroupId}" after: ${z(c)}`
|
|
4657
|
+
), S(() => {
|
|
4658
|
+
this.progress.beginRetry(h + 1);
|
|
4659
|
+
}), await _i(m), this.isStale(t)) return;
|
|
4660
|
+
}
|
|
4661
|
+
}
|
|
4662
|
+
}
|
|
4663
|
+
function On(o, t, e = {}) {
|
|
4664
|
+
return Ci(U(o), t, {
|
|
4665
|
+
...e,
|
|
4666
|
+
cellId: e.cellId ?? X(o)
|
|
4667
|
+
});
|
|
4668
|
+
}
|
|
4669
|
+
function Ci(o, t, e = {}) {
|
|
4670
|
+
const i = e.cellId ?? "cell", n = e.controllerId ?? t.split("@")[1] ?? "";
|
|
4671
|
+
return new bi(
|
|
4672
|
+
o,
|
|
4673
|
+
t,
|
|
4674
|
+
{ cellId: i, controllerId: n },
|
|
4675
|
+
e
|
|
4676
|
+
);
|
|
4677
|
+
}
|
|
4678
|
+
export {
|
|
4679
|
+
Tn as A,
|
|
4680
|
+
ie as B,
|
|
4681
|
+
bt as C,
|
|
4682
|
+
ne as D,
|
|
4683
|
+
Mo as E,
|
|
4684
|
+
ee as F,
|
|
4685
|
+
pi as G,
|
|
4686
|
+
dt as H,
|
|
4687
|
+
oe as I,
|
|
4688
|
+
mt as J,
|
|
4689
|
+
uo as L,
|
|
4690
|
+
ue as M,
|
|
4691
|
+
xn as N,
|
|
4692
|
+
Zo as R,
|
|
4693
|
+
oi as T,
|
|
4694
|
+
$o as V,
|
|
4695
|
+
zo as a,
|
|
4696
|
+
Rt as b,
|
|
4697
|
+
ro as c,
|
|
4698
|
+
jn as d,
|
|
4699
|
+
et as e,
|
|
4700
|
+
mo as f,
|
|
4701
|
+
ut as g,
|
|
4702
|
+
ii as h,
|
|
4703
|
+
ri as i,
|
|
4704
|
+
ci as j,
|
|
4705
|
+
Xo as k,
|
|
4706
|
+
pe as l,
|
|
4707
|
+
fe as m,
|
|
4708
|
+
mi as n,
|
|
4709
|
+
Si as o,
|
|
4710
|
+
bi as p,
|
|
4711
|
+
fi as q,
|
|
4712
|
+
de as r,
|
|
4713
|
+
Ho as s,
|
|
4714
|
+
$t as t,
|
|
4715
|
+
ft as u,
|
|
4716
|
+
ht as v,
|
|
4717
|
+
Xt as w,
|
|
4718
|
+
On as x,
|
|
4719
|
+
Ko as y,
|
|
4720
|
+
ao as z
|
|
4721
|
+
};
|