@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.bd2ec84 → 6.4.0-pr.revamp.667.ca77f09
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -40
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +3 -4
- package/dist/3d.js +35 -38
- package/dist/CurrentPose/index.cjs +1 -1
- package/dist/CurrentPose/index.js +2 -2
- package/dist/CurrentPoseBar/index.cjs +1 -1
- package/dist/CurrentPoseBar/index.js +1 -1
- package/dist/JoggingButtons/index.cjs +1 -1
- package/dist/JoggingButtons/index.js +1 -1
- package/dist/JoggingGizmo/index.cjs +1 -1
- package/dist/JoggingGizmo/index.js +2 -2
- package/dist/JoggingJointSlider/index.cjs +1 -1
- package/dist/JoggingJointSlider/index.js +1 -1
- package/dist/RobotControl/index.cjs +1 -1
- package/dist/RobotControl/index.js +2 -2
- package/dist/RobotControlPanel/index.cjs +1 -1
- package/dist/RobotControlPanel/index.d.ts +1 -1
- package/dist/RobotControlPanel/index.js +1 -1
- package/dist/RobotHeader/index.cjs +1 -1
- package/dist/RobotHeader/index.d.ts +3 -5
- package/dist/RobotHeader/index.js +6 -7
- package/dist/RobotScene/index.cjs +1 -1
- package/dist/RobotScene/index.js +3 -3
- package/dist/RobotView/index.cjs +1 -1
- package/dist/RobotView/index.js +2 -2
- package/dist/SafetyBar/IndicatorWithExplanation.d.ts +12 -1
- package/dist/SafetyBar/SafetyBar.d.ts +15 -1
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.d.ts +0 -1
- package/dist/SafetyBar/index.js +3 -4
- package/dist/SafetyBar/robotSafetyOf.d.ts +1 -0
- package/dist/chunks/{ConnectedMotionGroup-BifrgwV1.js → ConnectedMotionGroup-DNYakgxy.js} +6 -5
- package/dist/chunks/ConnectedMotionGroup-IRTsTxwB.cjs +3 -0
- package/dist/chunks/{CurrentPose-CMqO8oqX.cjs → CurrentPose-CAq9e9JY.cjs} +1 -1
- package/dist/chunks/{CurrentPose-CdD2ZB7B.js → CurrentPose-CgdINEh2.js} +3 -3
- package/dist/chunks/{CurrentPoseBar-CX1xFBtm.js → CurrentPoseBar--HkZBGnN.js} +11 -11
- package/dist/chunks/{CurrentPoseBar-BTBAwIO4.cjs → CurrentPoseBar-DoOUfRRs.cjs} +1 -1
- package/dist/chunks/{JoggingButtons-aijK-3g6.js → JoggingButtons-BNOnpcTH.js} +1 -1
- package/dist/chunks/{JoggingButtons-BOHl7hVq.cjs → JoggingButtons-Boaym2hQ.cjs} +1 -1
- package/dist/chunks/{JoggingGizmo-CoKYUtXq.cjs → JoggingGizmo-CNFjpWDv.cjs} +1 -1
- package/dist/chunks/{JoggingGizmo-DHvrJouR.js → JoggingGizmo-RDiEVQes.js} +1 -1
- package/dist/chunks/{JoggingGizmoOrientation-CIvIAIeO.js → JoggingGizmoOrientation-Dzzz2gEz.js} +1 -1
- package/dist/chunks/{JoggingGizmoOrientation-DVcagPRJ.cjs → JoggingGizmoOrientation-laUrgY0N.cjs} +1 -1
- package/dist/chunks/{JoggingJointSlider-DQtt4-pa.js → JoggingJointSlider-BY-Tof8G.js} +1 -1
- package/dist/chunks/{JoggingJointSlider-CTFYKzsU.cjs → JoggingJointSlider-Dm3vILd3.cjs} +1 -1
- package/dist/chunks/{JoggingRefusedError-BIkUM6-g.js → JoggingRefusedError-C4D8_YR_.js} +5 -3
- package/dist/chunks/JoggingRefusedError-DqyrfUcc.cjs +1 -0
- package/dist/chunks/Pose3-BfBNPRDM.cjs +1 -0
- package/dist/chunks/{Pose3-B_fLR-Wv.js → Pose3-DWxfC6Dj.js} +1 -2
- package/dist/chunks/{Robot-C-IWfxP9.js → Robot-B-VAYuAr.js} +5 -5
- package/dist/chunks/{Robot-Cfhjv9Z8.cjs → Robot-DRf8T9Zf.cjs} +1 -1
- package/dist/chunks/RobotActivation-CRVxXvlx.cjs +1 -0
- package/dist/chunks/RobotActivation-oR-8Y0iq.js +143 -0
- package/dist/chunks/RobotControl-Dbe50ZKM.cjs +1 -0
- package/dist/chunks/RobotControl-Ms1F7fFe.js +332 -0
- package/dist/chunks/RobotControlPanel-B7NxoHsO.cjs +1 -0
- package/dist/chunks/RobotControlPanel-CkQlkq8x.js +1029 -0
- package/dist/chunks/RobotHeader-CjOaf9s6.cjs +1 -0
- package/dist/chunks/RobotHeader-LSuRTDFB.js +395 -0
- package/dist/chunks/RobotScene-Au6zpHH1.cjs +1 -0
- package/dist/chunks/RobotScene-C6XEgaVR.js +1284 -0
- package/dist/chunks/RobotSessionProvider-CoF_tX0O.cjs +1 -0
- package/dist/chunks/RobotSessionProvider-DuHi-dtw.js +30 -0
- package/dist/chunks/{RobotView-BGYlAWj-.cjs → RobotView-Cg6JfGiY.cjs} +1 -1
- package/dist/chunks/{RobotView-D-v8jCM7.js → RobotView-CrAxNkyG.js} +3 -3
- package/dist/chunks/{robotSafetyOf-DuKKma1_.js → SafetyBar-C85BAKsL.js} +244 -215
- package/dist/chunks/SafetyBar-D2l81Omq.cjs +1 -0
- package/dist/chunks/externalizeComponent-CA_sHzyH.cjs +2 -0
- package/dist/chunks/{externalizeComponent-4juwPKL5.js → externalizeComponent-CChY_1bN.js} +34 -8
- package/dist/chunks/{useSmoothedMotionState-BSSV8aZN.js → hooks-BWoeBWLV.js} +43 -87
- package/dist/chunks/hooks-BXe2bNMo.cjs +1 -0
- package/dist/chunks/loadRobotSession-BzY9H3F8.cjs +1 -0
- package/dist/chunks/{loadRobotSession-GHHtv5dv.js → loadRobotSession-Ts2MumBB.js} +1065 -679
- package/dist/chunks/poseText-BxG4Caa-.js +48 -0
- package/dist/chunks/poseText-CwplkbDM.cjs +1 -0
- package/dist/chunks/useSmoothedMotionState-CCXmMZ0S.cjs +1 -0
- package/dist/chunks/useSmoothedMotionState-CELh-YJa.js +50 -0
- package/dist/components/VelocitySlider.d.ts +14 -1
- package/dist/components/connectionWarning/ConnectionWarning.d.ts +18 -4
- package/dist/components/connectionWarning/connectionWarningOf.d.ts +1 -11
- package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +7 -1
- package/dist/components/jogging/JoggingCartesianTab.d.ts +6 -0
- package/dist/components/jogging/JoggingJointTab.d.ts +5 -0
- package/dist/components/jogging/JoggingJointValueControl.d.ts +7 -1
- package/dist/components/jogging/JoggingPanel.d.ts +11 -0
- package/dist/components/jogging/JoggingRefusedError.d.ts +8 -3
- package/dist/components/jogging/JoggingStore.d.ts +206 -17
- package/dist/components/jogging/joggingColors.d.ts +6 -0
- package/dist/components/robotControl/CartesianJogTab.d.ts +14 -3
- package/dist/components/robotControl/JogArea.d.ts +6 -3
- package/dist/components/robotControl/JogDisabledReason.d.ts +15 -0
- package/dist/components/robotControl/JointJogTab.d.ts +10 -2
- package/dist/components/robotControl/MoveToTab.d.ts +24 -3
- package/dist/components/robotControl/PoseField.d.ts +3 -1
- package/dist/components/robotControl/RobotControl.d.ts +3 -0
- package/dist/components/robotControl/RobotControlPanel.d.ts +91 -22
- package/dist/components/robotControl/VelocityRow.d.ts +8 -2
- package/dist/components/robotControl/atPose.d.ts +6 -0
- package/dist/components/robotControl/poseText.d.ts +13 -1
- package/dist/components/robotControl/units.d.ts +10 -2
- package/dist/components/robotControl/useRobotControlProps.d.ts +7 -4
- package/dist/components/robotControl/velocityText.d.ts +18 -0
- package/dist/components/robotHeader/ActivationSwitch.d.ts +13 -2
- package/dist/components/robotHeader/RobotHeader.d.ts +25 -4
- package/dist/components/robotHeader/robotActivationOf.d.ts +1 -8
- package/dist/components/robotScene/RobotScene.d.ts +7 -1
- package/dist/components/robots/MotionGroupVisualizer.d.ts +6 -4
- package/dist/components/robots/SupportedLinearAxis.d.ts +6 -4
- package/dist/components/robots/SupportedRobot.d.ts +7 -5
- package/dist/components/robots/useFrameSmoothedMotionState.d.ts +25 -0
- package/dist/components/utils/useSmoothedMotionState.d.ts +11 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +8 -10
- package/dist/core.js +60 -69
- package/dist/index.cjs +1 -1
- package/dist/index.js +100 -113
- package/dist/lib/ConnectedMotionGroup.d.ts +11 -0
- package/dist/lib/ControllerStateStream.d.ts +9 -9
- package/dist/lib/JoggerConnection.d.ts +48 -13
- package/dist/lib/MotionStreamConnection.d.ts +3 -2
- package/dist/lib/TrajectoryExecutionStore.d.ts +58 -20
- package/dist/lib/controllerStateSource.d.ts +6 -5
- package/dist/lib/robotSession/RobotActivation.d.ts +52 -21
- package/dist/lib/robotSession/RobotSession.d.ts +27 -8
- package/dist/lib/robotSession/RobotTargetPose.d.ts +4 -2
- package/dist/lib/robotSession/loadRobotSession.d.ts +1 -1
- package/dist/lib/robotSession/robotPose.d.ts +0 -6
- package/dist/session.cjs +1 -1
- package/dist/session.d.ts +6 -6
- package/dist/session.js +30 -38
- package/package.json +22 -1
- package/dist/chunks/ConnectedMotionGroup-CybwJHkh.cjs +0 -3
- package/dist/chunks/JoggingRefusedError-BuCGsVsa.cjs +0 -1
- package/dist/chunks/Pose3-Ch4xVeXV.cjs +0 -1
- package/dist/chunks/RobotActivation-Bb0oNSBN.cjs +0 -1
- package/dist/chunks/RobotActivation-C0rrwpQZ.js +0 -115
- package/dist/chunks/RobotControl-Cv6Sr1Ni.js +0 -289
- package/dist/chunks/RobotControl-DFnOYMAa.cjs +0 -1
- package/dist/chunks/RobotControlPanel-B1_9g9D-.js +0 -850
- package/dist/chunks/RobotControlPanel-BpTpRBgy.cjs +0 -1
- package/dist/chunks/RobotScene-0ZJzXL50.cjs +0 -1
- package/dist/chunks/RobotScene-DpFeFpnx.js +0 -1255
- package/dist/chunks/RobotSessionProvider--AekyPqD.cjs +0 -1
- package/dist/chunks/RobotSessionProvider-TVaKGzqa.js +0 -25
- package/dist/chunks/externalizeComponent-Br_U-QAr.cjs +0 -2
- package/dist/chunks/loadRobotSession-DYbeNnTI.cjs +0 -1
- package/dist/chunks/poseText-BXUaQWnK.cjs +0 -1
- package/dist/chunks/poseText-pg4cxE8R.js +0 -41
- package/dist/chunks/robotActivationOf-B4oV10Za.cjs +0 -1
- package/dist/chunks/robotActivationOf-EzcT9g07.js +0 -368
- package/dist/chunks/robotSafetyOf-Dxm6s7Pp.cjs +0 -1
- package/dist/chunks/useSmoothedMotionState-B9WO73k0.cjs +0 -1
- package/dist/components/robotHeader/robotSafetyOf.d.ts +0 -11
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { jsx as K } from "react/jsx-runtime";
|
|
2
|
+
import { observer as W } from "mobx-react-lite";
|
|
3
|
+
import { useEffect as B, useState as V, useRef as P, useMemo as ro } from "react";
|
|
4
|
+
import { a as ao } from "./RobotSessionProvider-DuHi-dtw.js";
|
|
5
|
+
import { R as io } from "./RobotControlPanel-CkQlkq8x.js";
|
|
6
|
+
import { degreesToRadians as l, radiansToDegrees as co } from "@wandelbots/nova-js";
|
|
7
|
+
import { JointTypeEnum as so } from "@wandelbots/nova-js/v2";
|
|
8
|
+
import { reaction as lo, runInAction as mo } from "mobx";
|
|
9
|
+
import { useTranslation as go } from "react-i18next";
|
|
10
|
+
import { Quaternion as uo } from "three";
|
|
11
|
+
import { i as po } from "./externalizeComponent-CChY_1bN.js";
|
|
12
|
+
import { P as G, p as fo } from "./Pose3-DWxfC6Dj.js";
|
|
13
|
+
import { s as bo, J as vo } from "./JoggingRefusedError-C4D8_YR_.js";
|
|
14
|
+
import { c as q } from "./coordSystemLabel-Bfy9MUsV.js";
|
|
15
|
+
import { u as yo } from "./useEveryFrame-D04ygIe7.js";
|
|
16
|
+
function So(t) {
|
|
17
|
+
return [
|
|
18
|
+
t("RobotControl.Joint.Base.lb"),
|
|
19
|
+
t("RobotControl.Joint.Shoulder.lb"),
|
|
20
|
+
t("RobotControl.Joint.Elbow.lb"),
|
|
21
|
+
t("RobotControl.Joint.Forearm.lb"),
|
|
22
|
+
t("RobotControl.Joint.Wrist.lb"),
|
|
23
|
+
t("RobotControl.Joint.Flange.lb")
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
const h = "selected-tcp", O = "coordinate-system:", A = (t) => Math.round(co(t) * 1e6) / 1e6;
|
|
27
|
+
function D(t, r) {
|
|
28
|
+
return "joints" in r ? {
|
|
29
|
+
type: "joint",
|
|
30
|
+
motionGroupId: t.motionGroupId,
|
|
31
|
+
joints: r.joints
|
|
32
|
+
} : {
|
|
33
|
+
type: "cartesian",
|
|
34
|
+
motionGroupId: t.motionGroupId,
|
|
35
|
+
tcpPose: {
|
|
36
|
+
pose: r,
|
|
37
|
+
coordSystemId: t.jogging.selectedCoordSystemId,
|
|
38
|
+
tcpId: t.jogging.selectedTcpId
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function Q(t, r) {
|
|
43
|
+
t.targetPose.plan(D(t, r));
|
|
44
|
+
}
|
|
45
|
+
function z(t, r) {
|
|
46
|
+
switch (t.code) {
|
|
47
|
+
case "disconnected":
|
|
48
|
+
return r("RobotControl.MoveTo.NotMoveable.Disconnected.lb");
|
|
49
|
+
case "safety_state":
|
|
50
|
+
return r("RobotControl.MoveTo.NotMoveable.SafetyState.lb", {
|
|
51
|
+
value: t.value
|
|
52
|
+
});
|
|
53
|
+
case "operation_mode":
|
|
54
|
+
return r("RobotControl.MoveTo.NotMoveable.OperationMode.lb", {
|
|
55
|
+
value: t.value
|
|
56
|
+
});
|
|
57
|
+
case "deactivated":
|
|
58
|
+
return r("RobotControl.MoveTo.NotMoveable.Deactivated.lb");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function To(t) {
|
|
62
|
+
const r = yo(
|
|
63
|
+
() => t.jogger.motionStream.rapidlyChangingMotionState.joint_position.join(
|
|
64
|
+
" "
|
|
65
|
+
),
|
|
66
|
+
!0
|
|
67
|
+
);
|
|
68
|
+
return ro(() => r ? r.split(" ").map(Number) : [], [r]);
|
|
69
|
+
}
|
|
70
|
+
function Co(t, r = {}) {
|
|
71
|
+
var N;
|
|
72
|
+
const { disabled: g = !1, gizmoOrientation: c } = r, { t: i } = go(void 0, { i18n: po }), o = t.jogging, { trajectory: u, targetPose: m } = t, _ = To(o), S = o.jointType === so.PrismaticJoint, p = (N = o.motionGroupDescription.operation_limits.auto_limits) == null ? void 0 : N.joints, C = _.length === 6 && !S ? So(i) : void 0, E = u.trajectoryState === "moving" || u.trajectoryState === "stopping", M = t.safety.canBeMoved, k = g || E || !M, T = M ? E ? "trajectory" : o.blocked ? "blocked" : null : "robot", Y = {
|
|
73
|
+
// A robot that is activating or deactivating has no reason of its own
|
|
74
|
+
// (see RobotSession): it is not activated yet, or no longer
|
|
75
|
+
robot: () => z(
|
|
76
|
+
t.safety.notMoveableReason ?? { code: "deactivated" },
|
|
77
|
+
i
|
|
78
|
+
),
|
|
79
|
+
trajectory: () => i("RobotControl.JogDisabled.Moving.lb"),
|
|
80
|
+
// NOVA gave the jogging connection to another client
|
|
81
|
+
blocked: () => i("Jogging.Blocked.lb")
|
|
82
|
+
};
|
|
83
|
+
B(() => {
|
|
84
|
+
if (k)
|
|
85
|
+
return o.lock("external"), () => o.unlock("external");
|
|
86
|
+
}, [o, k]);
|
|
87
|
+
const [H, L] = V(!1), U = H ? "moveTo" : o.currentTab.id === "joint" ? "joint" : o.selectedCartesianMotionType;
|
|
88
|
+
function X(e) {
|
|
89
|
+
L(e === "moveTo"), mo(() => {
|
|
90
|
+
o.selectedTabId = e === "joint" ? "joint" : "cartesian";
|
|
91
|
+
}), (e === "translate" || e === "rotate") && o.setSelectedCartesianMotionType(e);
|
|
92
|
+
}
|
|
93
|
+
const Z = o.selectedIncrementId === "continuous" ? "continuous" : "increment", R = P(
|
|
94
|
+
o.activeDiscreteIncrement ?? o.discreteIncrementOptions[0]
|
|
95
|
+
);
|
|
96
|
+
o.activeDiscreteIncrement && (R.current = o.activeDiscreteIncrement);
|
|
97
|
+
const I = R.current, j = P(0);
|
|
98
|
+
function $(e, n) {
|
|
99
|
+
return o.discreteIncrementOptions.find(
|
|
100
|
+
(a) => e === "translate" ? Math.abs(a.mm - n) < 1e-9 : Math.abs(l(a.degrees) - n) < 1e-9
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
function oo() {
|
|
104
|
+
if (o.selectedOrientation === "tool") {
|
|
105
|
+
const e = t.state.rapidlyChangingMotionState.flange_pose, n = e ? G.fromPose(e).quaternion.clone() : new uo(), a = o.selectedTcpId ? t.description.tcpOffsetsById[o.selectedTcpId] : void 0;
|
|
106
|
+
return a != null && a.pose.orientation && n.multiply(
|
|
107
|
+
fo(a.pose.orientation, "ROTATION_VECTOR")
|
|
108
|
+
), n;
|
|
109
|
+
}
|
|
110
|
+
return G.fromCoordinateSystem(o.jogCoordSystem).quaternion;
|
|
111
|
+
}
|
|
112
|
+
function x(e) {
|
|
113
|
+
t.reportError({
|
|
114
|
+
kind: "jog",
|
|
115
|
+
message: e instanceof Error ? e.message : String(e),
|
|
116
|
+
cause: e
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function d(e) {
|
|
120
|
+
e.catch((n) => {
|
|
121
|
+
n instanceof vo || x(n);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const [f, eo] = V(null), F = P(f);
|
|
125
|
+
F.current = f;
|
|
126
|
+
function to(e) {
|
|
127
|
+
if (eo(e), !e) {
|
|
128
|
+
m.resetToLive();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
Q(t, e);
|
|
132
|
+
}
|
|
133
|
+
B(
|
|
134
|
+
() => (
|
|
135
|
+
// Once the robot can move: while it is activating, there is no reason
|
|
136
|
+
// not to, but an app may still lock it, and the session plans nothing
|
|
137
|
+
lo(
|
|
138
|
+
() => t.safety.canBeMoved,
|
|
139
|
+
(e) => {
|
|
140
|
+
const n = F.current, { staged: a, confirming: s } = t.targetPose;
|
|
141
|
+
e && n && !a && !s && Q(t, n);
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
),
|
|
145
|
+
[t]
|
|
146
|
+
);
|
|
147
|
+
const w = t.safety.notMoveableReason, J = w ? z(w, i) : M ? null : i("RobotControl.MoveTo.NotMoveable.Deactivated.lb"), b = m.staged, no = f !== null && m.stagedPose !== null && bo(m.stagedPose, D(t, f));
|
|
148
|
+
return {
|
|
149
|
+
disabled: g,
|
|
150
|
+
// Jogging waits for a trajectory, for another client's jogging, and for
|
|
151
|
+
// a robot that may move
|
|
152
|
+
jogDisabled: T !== null,
|
|
153
|
+
jogDisabledReason: T ? Y[T]() : void 0,
|
|
154
|
+
// The store stays blocked until it is told to try again: the next jog
|
|
155
|
+
// asks NOVA for the jogging connection anew
|
|
156
|
+
onJogRetry: T === "blocked" ? () => o.unblock() : void 0,
|
|
157
|
+
// A linear axis or a turntable jogs its joints only
|
|
158
|
+
cartesian: o.canJogCartesian,
|
|
159
|
+
tab: U,
|
|
160
|
+
onTabChange: X,
|
|
161
|
+
jogMode: Z,
|
|
162
|
+
onJogModeChange: (e) => {
|
|
163
|
+
var n;
|
|
164
|
+
return o.setSelectedIncrementId(
|
|
165
|
+
e === "continuous" ? "continuous" : ((n = R.current) == null ? void 0 : n.id) ?? "continuous"
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
gizmoOrientation: c,
|
|
169
|
+
gizmoFrameQuaternion: oo,
|
|
170
|
+
tcp: o.tcps.length > 0 ? {
|
|
171
|
+
options: o.tcps.map((e) => ({ id: e.id, label: e.id })),
|
|
172
|
+
value: o.selectedTcpId,
|
|
173
|
+
onChange: (e) => {
|
|
174
|
+
d(o.requestTcpChange(e));
|
|
175
|
+
}
|
|
176
|
+
} : void 0,
|
|
177
|
+
jogFrame: {
|
|
178
|
+
options: [
|
|
179
|
+
{
|
|
180
|
+
id: h,
|
|
181
|
+
label: i("Jogging.MoveRelativeTo.SelectedTcp.dd")
|
|
182
|
+
},
|
|
183
|
+
...o.coordSystems.map((e) => ({
|
|
184
|
+
id: O + e.coordinate_system,
|
|
185
|
+
label: q(o, e)
|
|
186
|
+
}))
|
|
187
|
+
],
|
|
188
|
+
value: o.selectedOrientation === "tool" ? h : O + o.jogCoordSystemId,
|
|
189
|
+
onChange: (e) => e === h ? o.setMoveRelativeToSelectedTcp() : o.setMoveRelativeToCoordSystem(e.slice(O.length))
|
|
190
|
+
},
|
|
191
|
+
velocity: {
|
|
192
|
+
translate: {
|
|
193
|
+
value: o.translationVelocityMmPerSec,
|
|
194
|
+
min: o.minTranslationVelocityMmPerSec,
|
|
195
|
+
max: o.maxTranslationVelocityMmPerSec
|
|
196
|
+
},
|
|
197
|
+
rotate: {
|
|
198
|
+
value: o.rotationVelocityRadsPerSec,
|
|
199
|
+
min: l(o.minRotationVelocityDegPerSec),
|
|
200
|
+
max: l(o.maxRotationVelocityDegPerSec)
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
onVelocityChange: (e, n) => e === "rotate" ? o.setVelocityFromSlider(A(n), !0) : o.setVelocityFromSlider(n, !1),
|
|
204
|
+
// The store jogs: it makes a press that ends before the jogging
|
|
205
|
+
// connection is ready move nothing, and runs one step at a time
|
|
206
|
+
onJogStart: (e, n, a) => d(o.startCartesianJogging(e, n, a)),
|
|
207
|
+
onJogStop: () => d(o.stopJogging()),
|
|
208
|
+
increments: {
|
|
209
|
+
steps: {
|
|
210
|
+
translate: o.discreteIncrementOptions.map((e) => e.mm),
|
|
211
|
+
rotate: o.discreteIncrementOptions.map(
|
|
212
|
+
(e) => l(e.degrees)
|
|
213
|
+
)
|
|
214
|
+
},
|
|
215
|
+
onStep: (e, n, a, s) => {
|
|
216
|
+
const v = $(e, s);
|
|
217
|
+
if (!v) return;
|
|
218
|
+
j.current++;
|
|
219
|
+
const y = o.runIncrementalCartesianJog(
|
|
220
|
+
e,
|
|
221
|
+
n,
|
|
222
|
+
a,
|
|
223
|
+
v
|
|
224
|
+
);
|
|
225
|
+
d(y), y.finally(() => {
|
|
226
|
+
j.current--;
|
|
227
|
+
}).catch(() => {
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
running: o.incrementJogInProgress,
|
|
231
|
+
// The panel goes away: a step of the panel stops, as by its starter;
|
|
232
|
+
// one of another part of the app goes on
|
|
233
|
+
onStepStop: () => {
|
|
234
|
+
j.current > 0 && d(o.stopIncrementalJog());
|
|
235
|
+
},
|
|
236
|
+
// The store's increments pair a distance with an angle
|
|
237
|
+
step: I && {
|
|
238
|
+
translate: I.mm,
|
|
239
|
+
rotate: l(I.degrees)
|
|
240
|
+
},
|
|
241
|
+
onStepChange: (e, n) => {
|
|
242
|
+
const a = o.discreteIncrementOptions.find(
|
|
243
|
+
(s) => e === "translate" ? s.mm === n : Math.abs(l(s.degrees) - n) < 1e-9
|
|
244
|
+
);
|
|
245
|
+
a && o.setSelectedIncrementId(a.id);
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
joints: {
|
|
249
|
+
joints: _.map((e, n) => {
|
|
250
|
+
var a, s, v, y;
|
|
251
|
+
return {
|
|
252
|
+
value: e,
|
|
253
|
+
min: (s = (a = p == null ? void 0 : p[n]) == null ? void 0 : a.position) == null ? void 0 : s.lower_limit,
|
|
254
|
+
max: (y = (v = p == null ? void 0 : p[n]) == null ? void 0 : v.position) == null ? void 0 : y.upper_limit,
|
|
255
|
+
name: C == null ? void 0 : C[n]
|
|
256
|
+
};
|
|
257
|
+
}),
|
|
258
|
+
linear: S,
|
|
259
|
+
velocity: S ? {
|
|
260
|
+
value: o.translationVelocityMmPerSec,
|
|
261
|
+
min: o.minTranslationVelocityMmPerSec,
|
|
262
|
+
max: o.maxTranslationVelocityMmPerSec
|
|
263
|
+
} : {
|
|
264
|
+
value: o.rotationVelocityRadsPerSec,
|
|
265
|
+
min: l(o.minRotationVelocityDegPerSec),
|
|
266
|
+
max: l(o.maxRotationVelocityDegPerSec)
|
|
267
|
+
},
|
|
268
|
+
onVelocityChange: (e) => S ? o.setVelocityFromSlider(e, !1) : o.setVelocityFromSlider(A(e), !0),
|
|
269
|
+
onJogStart: (e, n) => d(o.startJointJogging(e, n)),
|
|
270
|
+
onJogStop: () => d(o.stopJogging())
|
|
271
|
+
},
|
|
272
|
+
moveTo: {
|
|
273
|
+
getCurrentPose: () => {
|
|
274
|
+
const e = t.state.displayedTcpPose;
|
|
275
|
+
return !(e != null && e.position) || !e.orientation ? null : {
|
|
276
|
+
position: e.position,
|
|
277
|
+
orientation: e.orientation
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
// The joints as the readouts show them: joint values can be a target
|
|
281
|
+
getCurrentJoints: () => t.state.jointPose,
|
|
282
|
+
// The typed pose is read in the coordinate system of the displayed
|
|
283
|
+
// pose. A robot without TCP poses moves to joint values only, which
|
|
284
|
+
// are relative to nothing.
|
|
285
|
+
frame: o.canJogCartesian ? {
|
|
286
|
+
options: o.coordSystems.map((e) => ({
|
|
287
|
+
id: e.coordinate_system,
|
|
288
|
+
label: q(o, e)
|
|
289
|
+
})),
|
|
290
|
+
value: o.selectedCoordSystemId,
|
|
291
|
+
onChange: (e) => o.setSelectedCoordSystemId(e)
|
|
292
|
+
} : void 0,
|
|
293
|
+
onTargetChange: to,
|
|
294
|
+
// The trajectory's states are the panel's, while it is the target's
|
|
295
|
+
state: m.confirming ? "planning" : no ? u.trajectoryState : "idle",
|
|
296
|
+
error: f && J ? J : b != null && b.errorKey ? i(b.errorKey, {
|
|
297
|
+
// NOVA's reason for a failed move, as it is: React escapes it
|
|
298
|
+
message: b.errorMessage,
|
|
299
|
+
interpolation: { escapeValue: !1 }
|
|
300
|
+
}) : null,
|
|
301
|
+
// Also without a target: the panel says it while a pose is typed
|
|
302
|
+
notMoveableReason: J,
|
|
303
|
+
// The button is held and let go: the session sees to it that the
|
|
304
|
+
// robot moves only while it is held, and only to the target it shows
|
|
305
|
+
onMoveStart: (e) => {
|
|
306
|
+
m.holdMove(D(t, e));
|
|
307
|
+
},
|
|
308
|
+
onMoveStop: () => {
|
|
309
|
+
m.releaseMove().catch(x);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
const No = W(function({
|
|
315
|
+
session: r,
|
|
316
|
+
...g
|
|
317
|
+
}) {
|
|
318
|
+
const c = ao(r), [i, o] = V({ robot: c, panel: 0 }), u = i.robot === c ? i.panel : i.panel + 1;
|
|
319
|
+
return i.robot !== c && o({ robot: c, panel: u }), /* @__PURE__ */ K(Mo, { session: c, ...g }, u);
|
|
320
|
+
}), Mo = W(function({
|
|
321
|
+
session: r,
|
|
322
|
+
disabled: g,
|
|
323
|
+
gizmoOrientation: c,
|
|
324
|
+
...i
|
|
325
|
+
}) {
|
|
326
|
+
const o = Co(r, { disabled: g, gizmoOrientation: c });
|
|
327
|
+
return /* @__PURE__ */ K(io, { ...o, ...i });
|
|
328
|
+
});
|
|
329
|
+
export {
|
|
330
|
+
No as R,
|
|
331
|
+
Co as u
|
|
332
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),ot=require("@mui/material/IconButton"),M=require("@mui/material/Stack"),_=require("@mui/material/Tab"),at=require("@mui/material/Tabs"),G=require("@mui/material/Typography"),rt=require("@wandelbots/icons/CloseFilled"),b=require("react"),F=require("react-i18next"),st=require("./externalizeComponent-CA_sHzyH.cjs"),U=require("@mui/material/Divider"),z=require("@mui/material/Tooltip"),it=require("@wandelbots/icons/Jog"),ut=require("@wandelbots/icons/ViewModuleFilled"),ct=require("./JoggingGizmo-CNFjpWDv.cjs"),dt=require("./JoggingButtons-Boaym2hQ.cjs"),xt=require("./useWebGLRenderer-CtddVDDb.cjs"),gt=require("@mui/material/styles"),Z=require("@mui/material/ToggleButton"),pt=require("@mui/material/ToggleButtonGroup"),P=require("./useEveryFrame-NeKiPXY-.cjs"),bt=require("@mui/material/Box"),ft=require("@mui/material/FormHelperText"),ht=require("@mui/material/InputAdornment"),Ct=require("@mui/material/Slider"),J=require("@wandelbots/mui"),jt=require("./JoggingJointSlider-Dm3vILd3.cjs"),Rt=require("@wandelbots/icons/CachedFilled"),vt=require("@wandelbots/icons/Undo"),mt=require("@wandelbots/icons/NorthEastFilled"),yt=require("./joggingColors-Cqpfuw4G.cjs"),tt=require("@wandelbots/icons/CheckFilled"),Mt=require("@wandelbots/icons/ContentCopyFilled"),Tt=require("@wandelbots/icons/EditFilled"),D=require("./poseText-CwplkbDM.cjs");function St({view:t,onViewChange:n,mode:o,controls:l,disabledReason:u,gizmoOrientation:x,gizmoFrameQuaternion:f}){const{t:a}=F.useTranslation(),[C,s]=b.useState(xt.isWebGLAvailable),r=x!==void 0&&C,i=t==="gizmo"&&r,c=a(i?o==="increment"?"RobotControl.JogArea.Hint.ClickHandle.lb":"RobotControl.JogArea.Hint.HoldHandle.lb":o==="increment"?"RobotControl.JogArea.Hint.ClickButton.lb":"RobotControl.JogArea.Hint.HoldButton.lb"),g=a(i?"RobotControl.JogArea.ShowButtons.bt":"RobotControl.JogArea.ShowGizmo.bt");return e.jsxs(M,{"data-testid":"jog-area",sx:{position:"relative",alignItems:"center",gap:"16px"},children:[r&&e.jsx(z,{title:g,placement:"left",children:e.jsx(ot,{"aria-label":g,onClick:()=>n(i?"buttons":"gizmo"),size:"small",sx:j=>{var d;return{position:"absolute",top:0,right:0,zIndex:1,borderRadius:"8px",border:`1px solid ${j.palette.divider}`,background:(d=j.palette.backgroundPaperElevation)==null?void 0:d[11]}},children:i?e.jsx(ut.ViewModuleFilled,{}):e.jsx(it.Jog,{})})}),i?e.jsx(ct.JoggingGizmo,{...l,orientation:x,frameQuaternion:f,size:180,onWebGLUnavailable:()=>s(!1)}):e.jsx(dt.JoggingButtons,{...l}),u??e.jsx(G,{variant:"body2",color:"text.secondary",textAlign:"center",children:c})]})}const kt=gt.styled(pt)(({theme:t})=>{var n;return{gap:"4px","& .MuiToggleButton-root":{border:"none",borderRadius:"8px",padding:"6px 16px",textTransform:"none",fontSize:"14px",color:t.palette.text.secondary},"& .MuiToggleButton-root.Mui-selected":{color:t.palette.text.primary,background:(n=t.palette.backgroundPaperElevation)==null?void 0:n[11]}}});function It({value:t,onChange:n,disabled:o}){const{t:l}=F.useTranslation();return e.jsxs(kt,{exclusive:!0,value:t,disabled:o,"aria-label":l("RobotControl.JogMode.lb"),onChange:(u,x)=>{x!==null&&n(x)},children:[e.jsx(Z,{value:"continuous",children:l("RobotControl.JogMode.Continuous.bt")}),e.jsx(Z,{value:"increment",children:l("RobotControl.JogMode.Increment.bt")})]})}function V({children:t}){return e.jsx(M,{sx:{padding:"16px 20px",gap:"16px"},children:t})}function Et(t){return t*180/Math.PI}function Jt(t){return t*Math.PI/180}function lt(t,n){return t==="rotate"?Et(n):n}function qt(t,n){return t==="rotate"?Jt(n):n}function wt(t,n){const o=String(Number(lt(t,n).toFixed(2)));return t==="rotate"?`${o}°`:`${o} mm`}function X(t,n){return Number(lt(t,n).toFixed(2))}function At(t){return t==="rotate"?"°/s":"mm/s"}function et(t,n){return t==="rotate"?`${n}°/s`:`${n} mm/s`}const Ft=/^[+-]?(\d+([.,]\d*)?|[.,]\d+)$/;function Bt(t,n,o){const l=t.trim();if(l==="")return{kind:"empty"};if(!Ft.test(l))return{kind:"notANumber"};const u=Number(l.replace(",","."));return Number.isFinite(u)?u<n||u>o?{kind:"outOfRange"}:{kind:"valid",value:u}:{kind:"notANumber"}}function K({motion:t,velocity:n,onChange:o,disabled:l}){const{t:u}=F.useTranslation(),x=b.useId(),f=b.useId(),[a,C]=b.useState(null),s=(a==null?void 0:a.motion)===t?a.text:null,r=X(t,n.value),i=X(t,n.min),c=X(t,n.max),g=s===null?null:Bt(s,i,c),j=g===null||g.kind==="valid"?null:g.kind==="outOfRange"?u("RobotControl.Velocity.OutOfRange.lb",{min:et(t,i),max:et(t,c),interpolation:{escapeValue:!1}}):u("RobotControl.Velocity.NotANumber.lb");function d(p){o(Math.min(n.max,Math.max(n.min,qt(t,p)))),C(null)}function v(){(g==null?void 0:g.kind)==="valid"&&d(g.value)}return e.jsxs(M,{gap:"4px",children:[e.jsxs(M,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",gap:2},children:[e.jsx(G,{id:x,variant:"body2",color:"text.secondary",children:u("RobotControl.Velocity.lb")}),e.jsx(bt,{sx:{width:"calc((100% - 12px) / 2)",flexShrink:0},children:e.jsx(J.AdornedTextField,{adornedSize:"small",fullWidth:!0,value:s??String(r),error:j!==null,disabled:l,autoComplete:"off",onChange:p=>C({motion:t,text:p.target.value}),onFocus:p=>p.target.select(),onBlur:v,onKeyDown:p=>{p.key==="Enter"?v():p.key==="Escape"&&C(null)},slotProps:{input:{endAdornment:e.jsx(ht,{position:"end",children:At(t)})},htmlInput:{inputMode:"decimal","aria-labelledby":x,"aria-describedby":j===null?void 0:f}},sx:{"& input":{textAlign:"right",fontVariantNumeric:"tabular-nums"}}})})]}),j!==null&&e.jsx(ft,{error:!0,id:f,sx:{margin:0,textAlign:"right"},children:j}),e.jsx(Ct,{"aria-labelledby":x,size:"small",value:Math.round(r),min:Math.ceil(i),max:Math.floor(c),disabled:l,onChange:(p,m)=>{typeof m=="number"&&d(m)},sx:p=>{var m;return{height:4,"& .MuiSlider-rail":{opacity:.38},"& .MuiSlider-thumb":{width:16,height:16,border:`3px solid ${p.palette.primary.main}`,backgroundColor:(m=p.palette.backgroundPaperElevation)==null?void 0:m[5]}}}})]})}function Pt({motion:t,settings:n,onSettingsChange:o,disabled:l=!1,jogDisabled:u=!1,tcp:x,jogFrame:f,velocity:a,onVelocityChange:C,onJogStart:s,onJogStop:r,increments:i,jogDisabledReason:c,gizmoOrientation:g,gizmoFrameQuaternion:j}){const{t:d}=F.useTranslation(),v=i?n.mode:"continuous",p=(i==null?void 0:i.steps[t])??[],m=Math.min(n.step[t],p.length-1),T=p[m],q=!!(i!=null&&i.running),S=l||u||q,k=b.useRef(!1);function N(h,E){if(v==="increment"){i&&T!==void 0&&i.onStep(t,h,E,T);return}k.current=!0,s(t,h,E)}function w(){k.current&&(k.current=!1,r())}return e.jsxs(e.Fragment,{children:[(x||f)&&e.jsxs(e.Fragment,{children:[e.jsx(V,{children:e.jsxs(M,{direction:"row",sx:{gap:"12px"},children:[x&&e.jsx(P.PanelSelect,{label:d("RobotControl.Tcp.lb"),...x,disabled:S}),f&&e.jsx(P.PanelSelect,{label:d("RobotControl.JogFrame.lb"),...f,disabled:l})]})}),e.jsx(U,{sx:{marginX:"20px"}})]}),e.jsxs(V,{children:[i&&e.jsx(It,{value:v,onChange:h=>o({...n,mode:h}),disabled:l}),e.jsx(K,{motion:t,velocity:a[t],onChange:h=>C(t,h),disabled:l}),v==="increment"&&T!==void 0&&e.jsx(P.InlineSelect,{label:d("RobotControl.StepSize.lb"),value:String(m),options:p.map((h,E)=>({id:String(E),label:wt(t,h)})),onChange:h=>o({...n,step:{...n.step,[t]:Number(h)}}),disabled:l})]}),e.jsx(U,{sx:{marginX:"20px"}}),e.jsx(V,{children:e.jsx(St,{view:n.view,onViewChange:h=>o({...n,view:h}),mode:v,controls:{motion:t,onJogStart:N,onJogStop:w,activeHandle:v==="increment"?i==null?void 0:i.running:null,disabled:S},disabledReason:c,gizmoOrientation:g,gizmoFrameQuaternion:j},v)})]})}function Nt({text:t,onRetry:n,disabled:o}){const{t:l}=F.useTranslation();return e.jsxs(M,{"data-testid":"jog-disabled-reason",sx:{alignItems:"center",gap:"8px"},children:[e.jsx(G,{role:"status",variant:"body2",color:"text.secondary",textAlign:"center",children:t}),n&&e.jsx(J.SecondaryButton,{size:"small",onClick:n,disabled:o,children:l("RobotControl.JogDisabled.Retry.bt")})]})}function Vt({joints:t,disabled:n,jogDisabled:o,disabledReason:l}){const u=b.useRef(null),[x,f]=b.useState(null);function a(s,r){u.current!==null&&u.current!==s||(u.current=s,f(s),t.onJogStart(s,r))}function C(s){u.current===s&&(u.current=null,f(null),t.onJogStop())}return e.jsxs(e.Fragment,{children:[e.jsxs(V,{children:[e.jsx(M,{sx:{gap:"8px",paddingX:"4px"},children:t.joints.map((s,r)=>e.jsx(jt.JoggingJointSlider,{label:`J${r+1}`,name:s.name,value:s.value,min:s.min,max:s.max,linear:t.linear,onJogStart:i=>a(r,i),onJogStop:()=>C(r),disabled:n||o||x!==null&&x!==r},r))}),l]}),e.jsx(U,{sx:{marginX:"20px"}}),e.jsx(V,{children:e.jsx(K,{motion:t.linear?"translate":"rotate",velocity:t.velocity,onChange:t.onVelocityChange,disabled:n})})]})}const zt=.5,Ot=.01,Lt=.001;function Dt(t,n){return t!==null&&t.length===n.length&&n.every((o,l)=>Math.abs(o-(t[l]??0))<=Lt)}function Gt(t,n){return t?Math.hypot(t.position[0]-n.position[0],t.position[1]-n.position[1],t.position[2]-n.position[2])<=zt&&Ht(t.orientation,n.orientation)<=Ot:!1}function nt(t){const n=Math.hypot(...t);if(n<1e-12)return[1,0,0,0];const o=Math.sin(n/2)/n;return[Math.cos(n/2),t[0]*o,t[1]*o,t[2]*o]}function Ht(t,n){const o=nt(t),l=nt(n),u=Math.abs(o[0]*l[0]+o[1]*l[1]+o[2]*l[2]+o[3]*l[3]);return 2*Math.acos(Math.min(1,u))}const _t="move",Wt=200;function Xt({state:t,ready:n,atPose:o,disabled:l,onMoveStart:u,onMoveStop:x,stopRef:f}){const{t:a}=F.useTranslation(),[C,s]=b.useState(!1),r=b.useRef(void 0),i=b.useRef(!1),c=b.useRef({onMoveStart:u,onMoveStop:x});c.current={onMoveStart:u,onMoveStop:x};const g=t==="planned",j=g||t==="moving",{handlersFor:d,stop:v}=yt.useHold({onStart:()=>{s(!0),r.current=setTimeout(()=>{r.current=void 0,i.current=!0,c.current.onMoveStart()},Wt)},onStop:()=>{s(!1),clearTimeout(r.current),r.current=void 0,i.current&&(i.current=!1,c.current.onMoveStop())},disabled:C?l||!n||!j:l||!n||o||!g,isSame:()=>!0});f&&(f.current=v),b.useEffect(()=>()=>clearTimeout(r.current),[]);const p=a(t==="moving"?"RobotControl.MoveTo.Moving.bt":t==="stopping"?"RobotControl.MoveTo.Stopping.bt":"RobotControl.MoveTo.MoveTo.bt");return e.jsx(z,{title:a(o?"RobotControl.MoveTo.AtPose.lb":"RobotControl.MoveTo.HoldToMove.lb"),placement:"top",children:e.jsx("span",{...d(_t),style:{display:"block",flexGrow:1,touchAction:"none",userSelect:"none"},children:e.jsx(J.PrimaryButton,{fullWidth:!0,disabled:l||!n||o||!j,loading:t==="planning"||t==="stopping",loadingPosition:"start",startIcon:e.jsx(mt.NorthEastFilled,{}),"aria-pressed":C,children:p})})})}function $t({label:t,text:n,editing:o,onEdit:l,onDraftChange:u,onCancel:x,onConfirm:f,canConfirm:a,error:C,disabled:s}){const{t:r}=F.useTranslation(),i=b.useRef(null),{copied:c,copy:g}=P.useCopyText();b.useEffect(()=>{const d=i.current;d&&(o?(d.focus(),d.setSelectionRange(d.value.length,d.value.length)):document.activeElement===d&&(d.blur(),d.scrollLeft=0))},[o]);function j(){return g(n,()=>{var d;return(d=i.current)==null?void 0:d.select()})}return e.jsxs(M,{direction:"row",sx:{gap:"8px",alignItems:"flex-start"},children:[e.jsx(J.AdornedTextField,{label:t,value:n,inputRef:i,onChange:d=>u(d.target.value),onClick:()=>{!o&&!s&&l()},onKeyDown:d=>{o&&(d.key==="Enter"&&a?f():d.key==="Escape"&&x())},error:!!C,helperText:C??void 0,fullWidth:!0,autoComplete:"off",slotProps:{htmlInput:{readOnly:!o,spellCheck:!1}},sx:{"& input":{fontVariantNumeric:"tabular-nums",cursor:o||s?void 0:"text"}}}),e.jsx(M,{direction:"row",sx:{gap:"8px",height:"56px",alignItems:"center"},children:o?e.jsxs(e.Fragment,{children:[e.jsx(J.RoundedIconButton,{icon:e.jsx(rt.CloseFilled,{}),ariaLabel:r("RobotControl.MoveTo.Cancel.bt"),onClick:x}),e.jsx(z,{title:r("RobotControl.MoveTo.ConfirmEdit.lb"),placement:"top",disableInteractive:!0,children:e.jsx("span",{children:e.jsx(J.RoundedIconButton,{icon:e.jsx(tt.CheckFilled,{}),ariaLabel:r("RobotControl.MoveTo.ConfirmEdit.lb"),onClick:f,disabled:!a,sx:{color:"primary.main"}})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{title:r("RobotControl.MoveTo.Copied.lb"),open:c,disableHoverListener:!0,disableInteractive:!0,placement:"left",children:e.jsx(J.RoundedIconButton,{icon:c?e.jsx(tt.CheckFilled,{}):e.jsx(Mt.ContentCopyFilled,{}),ariaLabel:r("RobotControl.MoveTo.Copy.bt"),onClick:()=>void j()})}),e.jsx(J.RoundedIconButton,{icon:e.jsx(Tt.EditFilled,{}),ariaLabel:r("RobotControl.MoveTo.Edit.bt"),onClick:l,disabled:s})]})})]})}const $=t=>"joints"in t;function Ut({moveTo:t,tcp:n,cartesian:o,linear:l,velocity:u,onVelocityChange:x,jointVelocity:f,disabled:a,jogDisabled:C}){var O,B,L;const{t:s}=F.useTranslation(),[r,i]=b.useState(null),[c,g]=b.useState(null),j=P.useEveryFrame(()=>{var Q;if(!o){const Y=(Q=t.getCurrentJoints)==null?void 0:Q.call(t);return Y?D.jointsToText(Y):""}const I=t.getCurrentPose();return I?D.poseToText(I):""},r===null&&c===null),d=(r==null?void 0:r.text)??j,v=c!==null,p=c===null?null:D.parseTargetText(c,{poses:o,jointCount:((B=(O=t.getCurrentJoints)==null?void 0:O.call(t))==null?void 0:B.length)??null}),m=t.notMoveableReason||t.error||null,T=r!==null&&!m&&!v,q=P.useEveryFrame(()=>{var I;return r!==null&&($(r.target)?Dt(((I=t.getCurrentJoints)==null?void 0:I.call(t))??null,r.target.joints):Gt(t.getCurrentPose(),r.target))},T)&&T,S=r?$(r.target):!o,k=b.useRef(!1);r===null?k.current=!1:t.state!=="idle"&&(k.current=!0);const N=T&&k.current&&t.state==="idle"&&!q,w=b.useRef(!1),h=b.useRef(null);function E(){var I;(I=h.current)==null||I.call(h),w.current=!1,i(null),g(null),t.onTargetChange(null)}function W(){p===null||a||(w.current=!1,k.current=!1,i({target:p,text:$(p)?D.jointsToText(p.joints):D.poseToText(p)}),g(null),t.onTargetChange(p))}function H(){r&&t.onTargetChange(r.target)}b.useEffect(()=>{if(T){if(t.state==="moving"){w.current=!0;return}w.current&&q&&t.state!=="stopping"&&E()}},[T,t.state,q]);const R=[n==null?void 0:n.value,(L=t.frame)==null?void 0:L.value].join("\0");b.useEffect(()=>{r&&E()},[R]);const y=b.useRef({target:r,onTargetChange:t.onTargetChange});y.current={target:r,onTargetChange:t.onTargetChange},b.useEffect(()=>()=>{var I;(I=h.current)==null||I.call(h),y.current.target&&y.current.onTargetChange(null)},[]);const A=c!==null?p===null?s("RobotControl.MoveTo.InvalidPose.lb"):t.notMoveableReason||null:r?m??(N?s("RobotControl.MoveTo.PlanDropped.lb"):null):null;return e.jsxs(V,{children:[n&&e.jsx(P.PanelSelect,{label:s("RobotControl.Tcp.lb"),...n,disabled:a||C}),e.jsx(G,{variant:"body1",color:"text.primary",children:s("RobotControl.MoveTo.TargetPose.lb")}),e.jsxs(M,{sx:{gap:"8px"},children:[t.frame&&e.jsx(P.PanelSelect,{label:s("RobotControl.MoveTo.RelativeTo.lb"),...t.frame,disabled:a}),e.jsx($t,{label:o?s("RobotControl.MoveTo.Coordinates.lb"):s("RobotControl.MoveTo.JointPositions.lb",{unit:l?"mm":"rad"}),text:c??d,editing:v,onEdit:()=>{a||g(d)},onDraftChange:g,onCancel:()=>g(null),onConfirm:W,canConfirm:p!==null&&!a&&t.state!=="planning",error:A,disabled:a})]}),e.jsx(K,{motion:S&&!l?"rotate":"translate",velocity:S?f.velocity:u,onChange:S?f.onChange:x,disabled:a}),e.jsxs(M,{direction:"row",sx:{gap:"12px",alignItems:"center"},children:[r&&!v&&e.jsx(z,{title:s("RobotControl.MoveTo.Reset.lb"),placement:"top",children:e.jsx("span",{children:e.jsx(J.RoundedIconButton,{icon:e.jsx(vt.Undo,{}),ariaLabel:s("RobotControl.MoveTo.Reset.lb"),onClick:E})})}),r&&!v&&(m||N)&&e.jsx(z,{title:s("RobotControl.MoveTo.PlanAgain.lb"),placement:"top",children:e.jsx("span",{children:e.jsx(J.RoundedIconButton,{icon:e.jsx(Rt.CachedFilled,{}),ariaLabel:s("RobotControl.MoveTo.PlanAgain.lb"),onClick:H,disabled:a||t.state==="planning"})})}),e.jsx(Xt,{state:r?t.state:"idle",ready:T,atPose:q,disabled:a,onMoveStart:()=>{r&&t.onMoveStart(r.target)},onMoveStop:t.onMoveStop,stopRef:h})]})]})}const Kt=st.externalizeComponent(({onClose:t,sx:n,joints:o,moveTo:l,jogDisabled:u=!1,jogDisabledReason:x,onJogRetry:f,cartesian:a=!0,tab:C,onTabChange:s,jogMode:r,onJogModeChange:i,...c})=>{var H;const{t:g}=F.useTranslation(),j=c.disabled??!1,[d,v]=b.useState("translate"),[p,m]=b.useState({mode:"continuous",view:"gizmo",step:{translate:0,rotate:0}}),T=[...a?["translate","rotate"]:[],...o?["joint"]:[],...l?["moveTo"]:[]],q=C??d,S=T.includes(q)?q:T[0],k=Qt(p,r,c.increments),N=g("RobotControl.Title.ti"),w=x?e.jsx(Nt,{text:x,onRetry:f,disabled:j}):void 0,h=b.useRef(c.increments);h.current=c.increments,b.useEffect(()=>()=>{var R,y,A;(R=h.current)!=null&&R.running&&((A=(y=h.current).onStepStop)==null||A.call(y))},[]);function E(R){v(R),s==null||s(R)}function W(R){var y,A,O;m(R),R.mode!==k.mode&&(i==null||i(R.mode));for(const B of["translate","rotate"]){const L=(y=c.increments)==null?void 0:y.steps[B][R.step[B]];R.step[B]!==k.step[B]&&L!==void 0&&((O=(A=c.increments)==null?void 0:A.onStepChange)==null||O.call(A,B,L))}}return e.jsxs(M,{"data-testid":"robot-control-panel",sx:[R=>{var y;return{minHeight:0,overflow:"hidden",borderRadius:"16px",background:(y=R.palette.backgroundPaperElevation)==null?void 0:y[5]}},...Array.isArray(n)?n:[n]],children:[e.jsxs(M,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",padding:"20px 20px 8px"},children:[e.jsx(G,{component:"h2",color:"text.primary",sx:{fontSize:"20px"},children:N}),t&&e.jsx(ot,{"aria-label":g("RobotControl.Close.bt"),onClick:t,size:"small",children:e.jsx(rt.CloseFilled,{})})]}),e.jsxs(at,{value:S??!1,onChange:(R,y)=>E(y),"aria-label":N,variant:"scrollable",scrollButtons:!1,sx:{marginX:"20px",borderBottom:1,borderColor:"divider",background:"transparent"},children:[a&&e.jsx(_,{value:"translate",label:g("RobotControl.Tab.Translate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),a&&e.jsx(_,{value:"rotate",label:g("RobotControl.Tab.Rotate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),o&&e.jsx(_,{value:"joint",label:g("RobotControl.Tab.Joint.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),l&&e.jsx(_,{value:"moveTo",label:g("RobotControl.Tab.MoveTo.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}})]}),e.jsx(M,{sx:{flexGrow:1,overflowY:"auto",overflowX:"hidden"},children:S==="joint"&&o?e.jsx(Vt,{joints:o,disabled:j,jogDisabled:u||!!((H=c.increments)!=null&&H.running),disabledReason:w}):S==="moveTo"&&l?e.jsx(Ut,{moveTo:l,tcp:c.tcp,cartesian:a,velocity:c.velocity.translate,onVelocityChange:R=>c.onVelocityChange("translate",R),linear:(o==null?void 0:o.linear)??!1,jointVelocity:o?{velocity:o.velocity,onChange:o.onVelocityChange}:{velocity:c.velocity.rotate,onChange:R=>c.onVelocityChange("rotate",R)},disabled:j,jogDisabled:u}):S==="translate"||S==="rotate"?e.jsx(Pt,{...c,disabled:j,jogDisabled:u,jogDisabledReason:w,motion:S,settings:k,onSettingsChange:W}):null})]})});function Qt(t,n,o){const l=u=>{var a;const x=(a=o==null?void 0:o.step)==null?void 0:a[u];if(x===void 0)return t.step[u];const f=o==null?void 0:o.steps[u].findIndex(C=>Math.abs(C-x)<=1e-9*Math.max(1,Math.abs(C)));return f===void 0||f<0?t.step[u]:f};return{...t,mode:n??t.mode,step:{translate:l("translate"),rotate:l("rotate")}}}exports.RobotControlPanel=Kt;
|