@wandelbots/nova-js 1.17.1-pr.feat-added-v2-client.64.9ac2247
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/LICENSE +201 -0
- package/README.md +202 -0
- package/dist/LoginWithAuth0.d.ts +7 -0
- package/dist/LoginWithAuth0.d.ts.map +1 -0
- package/dist/chunk-V3NJLR6P.js +336 -0
- package/dist/chunk-V3NJLR6P.js.map +1 -0
- package/dist/index.cjs +390 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/AutoReconnectingWebsocket.d.ts +43 -0
- package/dist/lib/AutoReconnectingWebsocket.d.ts.map +1 -0
- package/dist/lib/availableStorage.d.ts +15 -0
- package/dist/lib/availableStorage.d.ts.map +1 -0
- package/dist/lib/converters.d.ts +26 -0
- package/dist/lib/converters.d.ts.map +1 -0
- package/dist/lib/errorHandling.d.ts +4 -0
- package/dist/lib/errorHandling.d.ts.map +1 -0
- package/dist/lib/v1/ConnectedMotionGroup.d.ts +77 -0
- package/dist/lib/v1/ConnectedMotionGroup.d.ts.map +1 -0
- package/dist/lib/v1/JoggerConnection.d.ts +94 -0
- package/dist/lib/v1/JoggerConnection.d.ts.map +1 -0
- package/dist/lib/v1/MotionStreamConnection.d.ts +25 -0
- package/dist/lib/v1/MotionStreamConnection.d.ts.map +1 -0
- package/dist/lib/v1/NovaCellAPIClient.d.ts +66 -0
- package/dist/lib/v1/NovaCellAPIClient.d.ts.map +1 -0
- package/dist/lib/v1/NovaClient.d.ts +67 -0
- package/dist/lib/v1/NovaClient.d.ts.map +1 -0
- package/dist/lib/v1/ProgramStateConnection.d.ts +53 -0
- package/dist/lib/v1/ProgramStateConnection.d.ts.map +1 -0
- package/dist/lib/v1/getLatestTrajectories.d.ts +4 -0
- package/dist/lib/v1/getLatestTrajectories.d.ts.map +1 -0
- package/dist/lib/v1/index.cjs +3957 -0
- package/dist/lib/v1/index.cjs.map +1 -0
- package/dist/lib/v1/index.d.ts +9 -0
- package/dist/lib/v1/index.d.ts.map +1 -0
- package/dist/lib/v1/index.js +3662 -0
- package/dist/lib/v1/index.js.map +1 -0
- package/dist/lib/v1/mock/MockNovaInstance.d.ts +13 -0
- package/dist/lib/v1/mock/MockNovaInstance.d.ts.map +1 -0
- package/dist/lib/v1/motionStateUpdate.d.ts +4 -0
- package/dist/lib/v1/motionStateUpdate.d.ts.map +1 -0
- package/dist/lib/v2/ConnectedMotionGroup.d.ts +41 -0
- package/dist/lib/v2/ConnectedMotionGroup.d.ts.map +1 -0
- package/dist/lib/v2/JoggerConnection.d.ts +53 -0
- package/dist/lib/v2/JoggerConnection.d.ts.map +1 -0
- package/dist/lib/v2/MotionStreamConnection.d.ts +25 -0
- package/dist/lib/v2/MotionStreamConnection.d.ts.map +1 -0
- package/dist/lib/v2/NovaCellAPIClient.d.ts +64 -0
- package/dist/lib/v2/NovaCellAPIClient.d.ts.map +1 -0
- package/dist/lib/v2/NovaClient.d.ts +67 -0
- package/dist/lib/v2/NovaClient.d.ts.map +1 -0
- package/dist/lib/v2/ProgramStateConnection.d.ts +53 -0
- package/dist/lib/v2/ProgramStateConnection.d.ts.map +1 -0
- package/dist/lib/v2/index.cjs +2239 -0
- package/dist/lib/v2/index.cjs.map +1 -0
- package/dist/lib/v2/index.d.ts +8 -0
- package/dist/lib/v2/index.d.ts.map +1 -0
- package/dist/lib/v2/index.js +1947 -0
- package/dist/lib/v2/index.js.map +1 -0
- package/dist/lib/v2/mock/MockNovaInstance.d.ts +13 -0
- package/dist/lib/v2/mock/MockNovaInstance.d.ts.map +1 -0
- package/dist/lib/v2/motionStateUpdate.d.ts +4 -0
- package/dist/lib/v2/motionStateUpdate.d.ts.map +1 -0
- package/dist/lib/v2/vectorUtils.d.ts +7 -0
- package/dist/lib/v2/vectorUtils.d.ts.map +1 -0
- package/package.json +67 -0
- package/src/LoginWithAuth0.ts +90 -0
- package/src/index.ts +5 -0
- package/src/lib/AutoReconnectingWebsocket.ts +163 -0
- package/src/lib/availableStorage.ts +46 -0
- package/src/lib/converters.ts +74 -0
- package/src/lib/errorHandling.ts +26 -0
- package/src/lib/v1/ConnectedMotionGroup.ts +419 -0
- package/src/lib/v1/JoggerConnection.ts +480 -0
- package/src/lib/v1/MotionStreamConnection.ts +202 -0
- package/src/lib/v1/NovaCellAPIClient.ts +180 -0
- package/src/lib/v1/NovaClient.ts +232 -0
- package/src/lib/v1/ProgramStateConnection.ts +267 -0
- package/src/lib/v1/getLatestTrajectories.ts +36 -0
- package/src/lib/v1/index.ts +8 -0
- package/src/lib/v1/mock/MockNovaInstance.ts +1302 -0
- package/src/lib/v1/motionStateUpdate.ts +55 -0
- package/src/lib/v2/ConnectedMotionGroup.ts +216 -0
- package/src/lib/v2/JoggerConnection.ts +207 -0
- package/src/lib/v2/MotionStreamConnection.ts +201 -0
- package/src/lib/v2/NovaCellAPIClient.ts +174 -0
- package/src/lib/v2/NovaClient.ts +230 -0
- package/src/lib/v2/ProgramStateConnection.ts +255 -0
- package/src/lib/v2/index.ts +7 -0
- package/src/lib/v2/mock/MockNovaInstance.ts +982 -0
- package/src/lib/v2/motionStateUpdate.ts +55 -0
- package/src/lib/v2/vectorUtils.ts +36 -0
|
@@ -0,0 +1,3957 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __copyProps = (to, from, except, desc) => {
|
|
30
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(from))
|
|
32
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
38
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
39
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
40
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
41
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
42
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
43
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
44
|
+
mod
|
|
45
|
+
));
|
|
46
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
47
|
+
var __async = (__this, __arguments, generator) => {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
var fulfilled = (value) => {
|
|
50
|
+
try {
|
|
51
|
+
step(generator.next(value));
|
|
52
|
+
} catch (e) {
|
|
53
|
+
reject(e);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var rejected = (value) => {
|
|
57
|
+
try {
|
|
58
|
+
step(generator.throw(value));
|
|
59
|
+
} catch (e) {
|
|
60
|
+
reject(e);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
64
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/lib/v1/index.ts
|
|
69
|
+
var v1_exports = {};
|
|
70
|
+
__export(v1_exports, {
|
|
71
|
+
ConnectedMotionGroup: () => ConnectedMotionGroup,
|
|
72
|
+
JoggerConnection: () => JoggerConnection,
|
|
73
|
+
MotionStreamConnection: () => MotionStreamConnection,
|
|
74
|
+
NovaCellAPIClient: () => NovaCellAPIClient,
|
|
75
|
+
NovaClient: () => NovaClient,
|
|
76
|
+
ProgramState: () => ProgramState,
|
|
77
|
+
ProgramStateConnection: () => ProgramStateConnection,
|
|
78
|
+
getLatestTrajectories: () => getLatestTrajectories
|
|
79
|
+
});
|
|
80
|
+
module.exports = __toCommonJS(v1_exports);
|
|
81
|
+
__reExport(v1_exports, require("@wandelbots/nova-api/v1"), module.exports);
|
|
82
|
+
|
|
83
|
+
// src/lib/v1/ConnectedMotionGroup.ts
|
|
84
|
+
var import_mobx = require("mobx");
|
|
85
|
+
var THREE = __toESM(require("three"), 1);
|
|
86
|
+
|
|
87
|
+
// src/lib/converters.ts
|
|
88
|
+
function tryParseJson(json) {
|
|
89
|
+
try {
|
|
90
|
+
return JSON.parse(json);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function isSameCoordinateSystem(firstCoordSystem, secondCoordSystem) {
|
|
96
|
+
if (!firstCoordSystem) firstCoordSystem = "world";
|
|
97
|
+
if (!secondCoordSystem) secondCoordSystem = "world";
|
|
98
|
+
return firstCoordSystem === secondCoordSystem;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/lib/v1/motionStateUpdate.ts
|
|
102
|
+
function jointValuesEqual(oldJointValues, newJointValues, changeDeltaThreshold) {
|
|
103
|
+
if (newJointValues.length !== oldJointValues.length) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
for (let jointIndex = 0; jointIndex < newJointValues.length; jointIndex++) {
|
|
107
|
+
if (Math.abs(newJointValues[jointIndex] - oldJointValues[jointIndex]) > changeDeltaThreshold) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
function tcpPoseEqual(oldTcp, newTcp, changeDeltaThreshold) {
|
|
114
|
+
if (oldTcp === void 0 && newTcp || oldTcp && newTcp === void 0) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (oldTcp === void 0 || newTcp === void 0) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
let changedDelta = 0;
|
|
121
|
+
changedDelta += Math.abs(oldTcp.orientation.x - newTcp.orientation.x);
|
|
122
|
+
changedDelta += Math.abs(oldTcp.orientation.y - newTcp.orientation.y);
|
|
123
|
+
changedDelta += Math.abs(oldTcp.orientation.z - newTcp.orientation.z);
|
|
124
|
+
changedDelta += Math.abs(oldTcp.position.x - newTcp.position.x);
|
|
125
|
+
changedDelta += Math.abs(oldTcp.position.y - newTcp.position.y);
|
|
126
|
+
changedDelta += Math.abs(oldTcp.position.z - newTcp.position.z);
|
|
127
|
+
if (changedDelta > changeDeltaThreshold) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return oldTcp.coordinate_system === newTcp.coordinate_system && oldTcp.tcp === newTcp.tcp;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/lib/v1/ConnectedMotionGroup.ts
|
|
134
|
+
var MOTION_DELTA_THRESHOLD = 1e-4;
|
|
135
|
+
var ConnectedMotionGroup = class _ConnectedMotionGroup {
|
|
136
|
+
constructor(nova, controller, motionGroup, initialMotionState, motionStateSocket, isVirtual, tcps, motionGroupSpecification, safetySetup, mounting, initialControllerState, controllerStateSocket) {
|
|
137
|
+
this.nova = nova;
|
|
138
|
+
this.controller = controller;
|
|
139
|
+
this.motionGroup = motionGroup;
|
|
140
|
+
this.initialMotionState = initialMotionState;
|
|
141
|
+
this.motionStateSocket = motionStateSocket;
|
|
142
|
+
this.isVirtual = isVirtual;
|
|
143
|
+
this.tcps = tcps;
|
|
144
|
+
this.motionGroupSpecification = motionGroupSpecification;
|
|
145
|
+
this.safetySetup = safetySetup;
|
|
146
|
+
this.mounting = mounting;
|
|
147
|
+
this.initialControllerState = initialControllerState;
|
|
148
|
+
this.controllerStateSocket = controllerStateSocket;
|
|
149
|
+
this.connectedJoggingCartesianSocket = null;
|
|
150
|
+
this.connectedJoggingJointsSocket = null;
|
|
151
|
+
// tmp
|
|
152
|
+
this.joggingVelocity = 10;
|
|
153
|
+
/**
|
|
154
|
+
* Reflects activation state of the motion group / robot servos. The
|
|
155
|
+
* movement controls in the UI should only be enabled in the "active" state
|
|
156
|
+
*/
|
|
157
|
+
this.activationState = "inactive";
|
|
158
|
+
this.rapidlyChangingMotionState = initialMotionState;
|
|
159
|
+
this.controllerState = initialControllerState;
|
|
160
|
+
controllerStateSocket.addEventListener("message", (event) => {
|
|
161
|
+
var _a;
|
|
162
|
+
const data = (_a = tryParseJson(event.data)) == null ? void 0 : _a.result;
|
|
163
|
+
if (!data) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
(0, import_mobx.runInAction)(() => {
|
|
167
|
+
this.controllerState = data;
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
motionStateSocket.addEventListener("message", (event) => {
|
|
171
|
+
var _a;
|
|
172
|
+
const motionStateResponse = (_a = tryParseJson(event.data)) == null ? void 0 : _a.result;
|
|
173
|
+
if (!motionStateResponse) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Failed to get motion state for ${this.motionGroupId}: ${event.data}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
if (!jointValuesEqual(
|
|
179
|
+
this.rapidlyChangingMotionState.state.joint_position.joints,
|
|
180
|
+
motionStateResponse.state.joint_position.joints,
|
|
181
|
+
MOTION_DELTA_THRESHOLD
|
|
182
|
+
)) {
|
|
183
|
+
(0, import_mobx.runInAction)(() => {
|
|
184
|
+
this.rapidlyChangingMotionState.state = motionStateResponse.state;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (!tcpPoseEqual(
|
|
188
|
+
this.rapidlyChangingMotionState.tcp_pose,
|
|
189
|
+
motionStateResponse.tcp_pose,
|
|
190
|
+
MOTION_DELTA_THRESHOLD
|
|
191
|
+
)) {
|
|
192
|
+
(0, import_mobx.runInAction)(() => {
|
|
193
|
+
this.rapidlyChangingMotionState.tcp_pose = motionStateResponse.tcp_pose;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
(0, import_mobx.makeAutoObservable)(this);
|
|
198
|
+
}
|
|
199
|
+
static connect(nova, motionGroupId, controllers) {
|
|
200
|
+
return __async(this, null, function* () {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
const [_motionGroupIndex, controllerId] = motionGroupId.split("@");
|
|
203
|
+
const controller = controllers.find((c) => c.controller === controllerId);
|
|
204
|
+
const motionGroup = controller == null ? void 0 : controller.physical_motion_groups.find(
|
|
205
|
+
(mg) => mg.motion_group === motionGroupId
|
|
206
|
+
);
|
|
207
|
+
if (!controller || !motionGroup) {
|
|
208
|
+
throw new Error(
|
|
209
|
+
`Controller ${controllerId} or motion group ${motionGroupId} not found`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
const motionStateSocket = nova.openReconnectingWebsocket(
|
|
213
|
+
`/motion-groups/${motionGroupId}/state-stream`
|
|
214
|
+
);
|
|
215
|
+
const firstMessage = yield motionStateSocket.firstMessage();
|
|
216
|
+
const initialMotionState = (_a = tryParseJson(firstMessage.data)) == null ? void 0 : _a.result;
|
|
217
|
+
if (!initialMotionState) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Unable to parse initial motion state message ${firstMessage.data}`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
console.log(
|
|
223
|
+
`Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:
|
|
224
|
+
`,
|
|
225
|
+
initialMotionState
|
|
226
|
+
);
|
|
227
|
+
const config = yield nova.api.controller.getRobotController(
|
|
228
|
+
controller.controller
|
|
229
|
+
);
|
|
230
|
+
const isVirtual = config.configuration.kind === "VirtualController";
|
|
231
|
+
const mounting = yield (() => __async(this, null, function* () {
|
|
232
|
+
try {
|
|
233
|
+
const mounting2 = yield nova.api.motionGroupInfos.getMounting(
|
|
234
|
+
motionGroup.motion_group
|
|
235
|
+
);
|
|
236
|
+
return mounting2;
|
|
237
|
+
} catch (err) {
|
|
238
|
+
console.error(
|
|
239
|
+
`Error fetching mounting for ${motionGroup.motion_group}`,
|
|
240
|
+
err
|
|
241
|
+
);
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
}))();
|
|
245
|
+
const controllerStateSocket = nova.openReconnectingWebsocket(
|
|
246
|
+
`/controllers/${controller.controller}/state-stream?response_rate=1000`
|
|
247
|
+
);
|
|
248
|
+
const firstControllerMessage = yield controllerStateSocket.firstMessage();
|
|
249
|
+
const initialControllerState = (_b = tryParseJson(firstControllerMessage.data)) == null ? void 0 : _b.result;
|
|
250
|
+
if (!initialControllerState) {
|
|
251
|
+
throw new Error(
|
|
252
|
+
`Unable to parse initial controller state message ${firstControllerMessage.data}`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
console.log(
|
|
256
|
+
`Connected controller state websocket to controller ${controller.controller}. Initial state:
|
|
257
|
+
`,
|
|
258
|
+
initialControllerState
|
|
259
|
+
);
|
|
260
|
+
const { tcps } = yield nova.api.motionGroupInfos.listTcps(motionGroupId);
|
|
261
|
+
const motionGroupSpecification = yield nova.api.motionGroupInfos.getMotionGroupSpecification(motionGroupId);
|
|
262
|
+
const safetySetup = yield nova.api.motionGroupInfos.getSafetySetup(motionGroupId);
|
|
263
|
+
return new _ConnectedMotionGroup(
|
|
264
|
+
nova,
|
|
265
|
+
controller,
|
|
266
|
+
motionGroup,
|
|
267
|
+
initialMotionState,
|
|
268
|
+
motionStateSocket,
|
|
269
|
+
isVirtual,
|
|
270
|
+
tcps,
|
|
271
|
+
motionGroupSpecification,
|
|
272
|
+
safetySetup,
|
|
273
|
+
mounting,
|
|
274
|
+
initialControllerState,
|
|
275
|
+
controllerStateSocket
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
get motionGroupId() {
|
|
280
|
+
return this.motionGroup.motion_group;
|
|
281
|
+
}
|
|
282
|
+
get controllerId() {
|
|
283
|
+
return this.controller.controller;
|
|
284
|
+
}
|
|
285
|
+
get modelFromController() {
|
|
286
|
+
return this.motionGroup.model_from_controller;
|
|
287
|
+
}
|
|
288
|
+
get wandelscriptIdentifier() {
|
|
289
|
+
const num = this.motionGroupId.split("@")[0];
|
|
290
|
+
return `${this.controllerId.replaceAll("-", "_")}_${num}`;
|
|
291
|
+
}
|
|
292
|
+
/** Jogging velocity in radians for rotation and joint movement */
|
|
293
|
+
get joggingVelocityRads() {
|
|
294
|
+
return this.joggingVelocity * Math.PI / 180;
|
|
295
|
+
}
|
|
296
|
+
get joints() {
|
|
297
|
+
return this.initialMotionState.state.joint_position.joints.map((_, i) => {
|
|
298
|
+
return {
|
|
299
|
+
index: i
|
|
300
|
+
};
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
get dhParameters() {
|
|
304
|
+
return this.motionGroupSpecification.dh_parameters;
|
|
305
|
+
}
|
|
306
|
+
get safetyZones() {
|
|
307
|
+
return this.safetySetup.safety_zones;
|
|
308
|
+
}
|
|
309
|
+
/** Gets the robot mounting position offset in 3D viz coordinates */
|
|
310
|
+
get mountingPosition() {
|
|
311
|
+
if (!this.mounting) {
|
|
312
|
+
return [0, 0, 0];
|
|
313
|
+
}
|
|
314
|
+
return [
|
|
315
|
+
this.mounting.pose.position.x / 1e3,
|
|
316
|
+
this.mounting.pose.position.y / 1e3,
|
|
317
|
+
this.mounting.pose.position.z / 1e3
|
|
318
|
+
];
|
|
319
|
+
}
|
|
320
|
+
/** Gets the robot mounting position rotation in 3D viz coordinates */
|
|
321
|
+
get mountingQuaternion() {
|
|
322
|
+
var _a, _b, _c, _d, _e, _f;
|
|
323
|
+
const rotationVector = new THREE.Vector3(
|
|
324
|
+
((_b = (_a = this.mounting) == null ? void 0 : _a.pose.orientation) == null ? void 0 : _b.x) || 0,
|
|
325
|
+
((_d = (_c = this.mounting) == null ? void 0 : _c.pose.orientation) == null ? void 0 : _d.y) || 0,
|
|
326
|
+
((_f = (_e = this.mounting) == null ? void 0 : _e.pose.orientation) == null ? void 0 : _f.z) || 0
|
|
327
|
+
);
|
|
328
|
+
const magnitude = rotationVector.length();
|
|
329
|
+
const axis = rotationVector.normalize();
|
|
330
|
+
return new THREE.Quaternion().setFromAxisAngle(axis, magnitude);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Whether the controller is currently in a safety state
|
|
334
|
+
* corresponding to an emergency stop
|
|
335
|
+
*/
|
|
336
|
+
get isEstopActive() {
|
|
337
|
+
const estopStates = [
|
|
338
|
+
"SAFETY_STATE_ROBOT_EMERGENCY_STOP",
|
|
339
|
+
"SAFETY_STATE_DEVICE_EMERGENCY_STOP"
|
|
340
|
+
];
|
|
341
|
+
return estopStates.includes(this.controllerState.safety_state);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Whether the controller is in a safety state
|
|
345
|
+
* that may be non-functional for robot pad purposes
|
|
346
|
+
*/
|
|
347
|
+
get isMoveableSafetyState() {
|
|
348
|
+
const goodSafetyStates = [
|
|
349
|
+
"SAFETY_STATE_NORMAL",
|
|
350
|
+
"SAFETY_STATE_REDUCED"
|
|
351
|
+
];
|
|
352
|
+
return goodSafetyStates.includes(this.controllerState.safety_state);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Whether the controller is in an operation mode that allows movement
|
|
356
|
+
*/
|
|
357
|
+
get isMoveableOperationMode() {
|
|
358
|
+
const goodOperationModes = [
|
|
359
|
+
"OPERATION_MODE_AUTO",
|
|
360
|
+
"OPERATION_MODE_MANUAL",
|
|
361
|
+
"OPERATION_MODE_MANUAL_T1",
|
|
362
|
+
"OPERATION_MODE_MANUAL_T2"
|
|
363
|
+
];
|
|
364
|
+
return goodOperationModes.includes(this.controllerState.operation_mode);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Whether the robot is currently active and can be moved, based on the
|
|
368
|
+
* safety state, operation mode and servo toggle activation state.
|
|
369
|
+
*/
|
|
370
|
+
get canBeMoved() {
|
|
371
|
+
return this.isMoveableSafetyState && this.isMoveableOperationMode && this.activationState === "active";
|
|
372
|
+
}
|
|
373
|
+
deactivate() {
|
|
374
|
+
return __async(this, null, function* () {
|
|
375
|
+
if (this.activationState !== "active") {
|
|
376
|
+
console.error("Tried to deactivate while already deactivating");
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
(0, import_mobx.runInAction)(() => {
|
|
380
|
+
this.activationState = "deactivating";
|
|
381
|
+
});
|
|
382
|
+
try {
|
|
383
|
+
yield this.nova.api.controller.setDefaultMode(
|
|
384
|
+
this.controllerId,
|
|
385
|
+
"MODE_MONITOR"
|
|
386
|
+
);
|
|
387
|
+
(0, import_mobx.runInAction)(() => {
|
|
388
|
+
this.activationState = "inactive";
|
|
389
|
+
});
|
|
390
|
+
} catch (err) {
|
|
391
|
+
(0, import_mobx.runInAction)(() => {
|
|
392
|
+
this.activationState = "active";
|
|
393
|
+
});
|
|
394
|
+
throw err;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
activate() {
|
|
399
|
+
return __async(this, null, function* () {
|
|
400
|
+
if (this.activationState !== "inactive") {
|
|
401
|
+
console.error("Tried to activate while already activating");
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
(0, import_mobx.runInAction)(() => {
|
|
405
|
+
this.activationState = "activating";
|
|
406
|
+
});
|
|
407
|
+
try {
|
|
408
|
+
yield this.nova.api.controller.setDefaultMode(
|
|
409
|
+
this.controllerId,
|
|
410
|
+
"MODE_CONTROL"
|
|
411
|
+
);
|
|
412
|
+
(0, import_mobx.runInAction)(() => {
|
|
413
|
+
this.activationState = "active";
|
|
414
|
+
});
|
|
415
|
+
} catch (err) {
|
|
416
|
+
(0, import_mobx.runInAction)(() => {
|
|
417
|
+
this.activationState = "inactive";
|
|
418
|
+
});
|
|
419
|
+
throw err;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
toggleActivation() {
|
|
424
|
+
if (this.activationState === "inactive") {
|
|
425
|
+
this.activate();
|
|
426
|
+
} else if (this.activationState === "active") {
|
|
427
|
+
this.deactivate();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
dispose() {
|
|
431
|
+
this.motionStateSocket.close();
|
|
432
|
+
if (this.connectedJoggingCartesianSocket)
|
|
433
|
+
this.connectedJoggingCartesianSocket.close();
|
|
434
|
+
if (this.connectedJoggingJointsSocket)
|
|
435
|
+
this.connectedJoggingJointsSocket.close();
|
|
436
|
+
}
|
|
437
|
+
setJoggingVelocity(velocity) {
|
|
438
|
+
this.joggingVelocity = velocity;
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// src/lib/v1/getLatestTrajectories.ts
|
|
443
|
+
var lastMotionIds = /* @__PURE__ */ new Set();
|
|
444
|
+
function getLatestTrajectories(apiClient, sampleTime = 50, responsesCoordinateSystem) {
|
|
445
|
+
return __async(this, null, function* () {
|
|
446
|
+
const newTrajectories = [];
|
|
447
|
+
try {
|
|
448
|
+
const motions = yield apiClient.motion.listMotions();
|
|
449
|
+
const currentMotionIds = new Set(motions.motions);
|
|
450
|
+
const newMotionIds = Array.from(currentMotionIds).filter(
|
|
451
|
+
(id) => !lastMotionIds.has(id)
|
|
452
|
+
);
|
|
453
|
+
for (const motionId of newMotionIds) {
|
|
454
|
+
const trajectory = yield apiClient.motion.getMotionTrajectory(
|
|
455
|
+
motionId,
|
|
456
|
+
sampleTime,
|
|
457
|
+
responsesCoordinateSystem
|
|
458
|
+
);
|
|
459
|
+
newTrajectories.push(trajectory);
|
|
460
|
+
}
|
|
461
|
+
lastMotionIds = currentMotionIds;
|
|
462
|
+
} catch (error) {
|
|
463
|
+
console.error("Failed to get latest trajectories:", error);
|
|
464
|
+
}
|
|
465
|
+
return newTrajectories;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// node_modules/lodash-es/_listCacheClear.js
|
|
470
|
+
function listCacheClear() {
|
|
471
|
+
this.__data__ = [];
|
|
472
|
+
this.size = 0;
|
|
473
|
+
}
|
|
474
|
+
var listCacheClear_default = listCacheClear;
|
|
475
|
+
|
|
476
|
+
// node_modules/lodash-es/eq.js
|
|
477
|
+
function eq(value, other) {
|
|
478
|
+
return value === other || value !== value && other !== other;
|
|
479
|
+
}
|
|
480
|
+
var eq_default = eq;
|
|
481
|
+
|
|
482
|
+
// node_modules/lodash-es/_assocIndexOf.js
|
|
483
|
+
function assocIndexOf(array, key) {
|
|
484
|
+
var length = array.length;
|
|
485
|
+
while (length--) {
|
|
486
|
+
if (eq_default(array[length][0], key)) {
|
|
487
|
+
return length;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return -1;
|
|
491
|
+
}
|
|
492
|
+
var assocIndexOf_default = assocIndexOf;
|
|
493
|
+
|
|
494
|
+
// node_modules/lodash-es/_listCacheDelete.js
|
|
495
|
+
var arrayProto = Array.prototype;
|
|
496
|
+
var splice = arrayProto.splice;
|
|
497
|
+
function listCacheDelete(key) {
|
|
498
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
499
|
+
if (index < 0) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
var lastIndex = data.length - 1;
|
|
503
|
+
if (index == lastIndex) {
|
|
504
|
+
data.pop();
|
|
505
|
+
} else {
|
|
506
|
+
splice.call(data, index, 1);
|
|
507
|
+
}
|
|
508
|
+
--this.size;
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
var listCacheDelete_default = listCacheDelete;
|
|
512
|
+
|
|
513
|
+
// node_modules/lodash-es/_listCacheGet.js
|
|
514
|
+
function listCacheGet(key) {
|
|
515
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
516
|
+
return index < 0 ? void 0 : data[index][1];
|
|
517
|
+
}
|
|
518
|
+
var listCacheGet_default = listCacheGet;
|
|
519
|
+
|
|
520
|
+
// node_modules/lodash-es/_listCacheHas.js
|
|
521
|
+
function listCacheHas(key) {
|
|
522
|
+
return assocIndexOf_default(this.__data__, key) > -1;
|
|
523
|
+
}
|
|
524
|
+
var listCacheHas_default = listCacheHas;
|
|
525
|
+
|
|
526
|
+
// node_modules/lodash-es/_listCacheSet.js
|
|
527
|
+
function listCacheSet(key, value) {
|
|
528
|
+
var data = this.__data__, index = assocIndexOf_default(data, key);
|
|
529
|
+
if (index < 0) {
|
|
530
|
+
++this.size;
|
|
531
|
+
data.push([key, value]);
|
|
532
|
+
} else {
|
|
533
|
+
data[index][1] = value;
|
|
534
|
+
}
|
|
535
|
+
return this;
|
|
536
|
+
}
|
|
537
|
+
var listCacheSet_default = listCacheSet;
|
|
538
|
+
|
|
539
|
+
// node_modules/lodash-es/_ListCache.js
|
|
540
|
+
function ListCache(entries) {
|
|
541
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
542
|
+
this.clear();
|
|
543
|
+
while (++index < length) {
|
|
544
|
+
var entry = entries[index];
|
|
545
|
+
this.set(entry[0], entry[1]);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
ListCache.prototype.clear = listCacheClear_default;
|
|
549
|
+
ListCache.prototype["delete"] = listCacheDelete_default;
|
|
550
|
+
ListCache.prototype.get = listCacheGet_default;
|
|
551
|
+
ListCache.prototype.has = listCacheHas_default;
|
|
552
|
+
ListCache.prototype.set = listCacheSet_default;
|
|
553
|
+
var ListCache_default = ListCache;
|
|
554
|
+
|
|
555
|
+
// node_modules/lodash-es/_stackClear.js
|
|
556
|
+
function stackClear() {
|
|
557
|
+
this.__data__ = new ListCache_default();
|
|
558
|
+
this.size = 0;
|
|
559
|
+
}
|
|
560
|
+
var stackClear_default = stackClear;
|
|
561
|
+
|
|
562
|
+
// node_modules/lodash-es/_stackDelete.js
|
|
563
|
+
function stackDelete(key) {
|
|
564
|
+
var data = this.__data__, result = data["delete"](key);
|
|
565
|
+
this.size = data.size;
|
|
566
|
+
return result;
|
|
567
|
+
}
|
|
568
|
+
var stackDelete_default = stackDelete;
|
|
569
|
+
|
|
570
|
+
// node_modules/lodash-es/_stackGet.js
|
|
571
|
+
function stackGet(key) {
|
|
572
|
+
return this.__data__.get(key);
|
|
573
|
+
}
|
|
574
|
+
var stackGet_default = stackGet;
|
|
575
|
+
|
|
576
|
+
// node_modules/lodash-es/_stackHas.js
|
|
577
|
+
function stackHas(key) {
|
|
578
|
+
return this.__data__.has(key);
|
|
579
|
+
}
|
|
580
|
+
var stackHas_default = stackHas;
|
|
581
|
+
|
|
582
|
+
// node_modules/lodash-es/_freeGlobal.js
|
|
583
|
+
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
584
|
+
var freeGlobal_default = freeGlobal;
|
|
585
|
+
|
|
586
|
+
// node_modules/lodash-es/_root.js
|
|
587
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
588
|
+
var root = freeGlobal_default || freeSelf || Function("return this")();
|
|
589
|
+
var root_default = root;
|
|
590
|
+
|
|
591
|
+
// node_modules/lodash-es/_Symbol.js
|
|
592
|
+
var Symbol2 = root_default.Symbol;
|
|
593
|
+
var Symbol_default = Symbol2;
|
|
594
|
+
|
|
595
|
+
// node_modules/lodash-es/_getRawTag.js
|
|
596
|
+
var objectProto = Object.prototype;
|
|
597
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
598
|
+
var nativeObjectToString = objectProto.toString;
|
|
599
|
+
var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
600
|
+
function getRawTag(value) {
|
|
601
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
|
|
602
|
+
try {
|
|
603
|
+
value[symToStringTag] = void 0;
|
|
604
|
+
var unmasked = true;
|
|
605
|
+
} catch (e) {
|
|
606
|
+
}
|
|
607
|
+
var result = nativeObjectToString.call(value);
|
|
608
|
+
if (unmasked) {
|
|
609
|
+
if (isOwn) {
|
|
610
|
+
value[symToStringTag] = tag;
|
|
611
|
+
} else {
|
|
612
|
+
delete value[symToStringTag];
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return result;
|
|
616
|
+
}
|
|
617
|
+
var getRawTag_default = getRawTag;
|
|
618
|
+
|
|
619
|
+
// node_modules/lodash-es/_objectToString.js
|
|
620
|
+
var objectProto2 = Object.prototype;
|
|
621
|
+
var nativeObjectToString2 = objectProto2.toString;
|
|
622
|
+
function objectToString(value) {
|
|
623
|
+
return nativeObjectToString2.call(value);
|
|
624
|
+
}
|
|
625
|
+
var objectToString_default = objectToString;
|
|
626
|
+
|
|
627
|
+
// node_modules/lodash-es/_baseGetTag.js
|
|
628
|
+
var nullTag = "[object Null]";
|
|
629
|
+
var undefinedTag = "[object Undefined]";
|
|
630
|
+
var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
631
|
+
function baseGetTag(value) {
|
|
632
|
+
if (value == null) {
|
|
633
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
634
|
+
}
|
|
635
|
+
return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
|
|
636
|
+
}
|
|
637
|
+
var baseGetTag_default = baseGetTag;
|
|
638
|
+
|
|
639
|
+
// node_modules/lodash-es/isObject.js
|
|
640
|
+
function isObject(value) {
|
|
641
|
+
var type = typeof value;
|
|
642
|
+
return value != null && (type == "object" || type == "function");
|
|
643
|
+
}
|
|
644
|
+
var isObject_default = isObject;
|
|
645
|
+
|
|
646
|
+
// node_modules/lodash-es/isFunction.js
|
|
647
|
+
var asyncTag = "[object AsyncFunction]";
|
|
648
|
+
var funcTag = "[object Function]";
|
|
649
|
+
var genTag = "[object GeneratorFunction]";
|
|
650
|
+
var proxyTag = "[object Proxy]";
|
|
651
|
+
function isFunction(value) {
|
|
652
|
+
if (!isObject_default(value)) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
var tag = baseGetTag_default(value);
|
|
656
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
657
|
+
}
|
|
658
|
+
var isFunction_default = isFunction;
|
|
659
|
+
|
|
660
|
+
// node_modules/lodash-es/_coreJsData.js
|
|
661
|
+
var coreJsData = root_default["__core-js_shared__"];
|
|
662
|
+
var coreJsData_default = coreJsData;
|
|
663
|
+
|
|
664
|
+
// node_modules/lodash-es/_isMasked.js
|
|
665
|
+
var maskSrcKey = function() {
|
|
666
|
+
var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
|
|
667
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
668
|
+
}();
|
|
669
|
+
function isMasked(func) {
|
|
670
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
671
|
+
}
|
|
672
|
+
var isMasked_default = isMasked;
|
|
673
|
+
|
|
674
|
+
// node_modules/lodash-es/_toSource.js
|
|
675
|
+
var funcProto = Function.prototype;
|
|
676
|
+
var funcToString = funcProto.toString;
|
|
677
|
+
function toSource(func) {
|
|
678
|
+
if (func != null) {
|
|
679
|
+
try {
|
|
680
|
+
return funcToString.call(func);
|
|
681
|
+
} catch (e) {
|
|
682
|
+
}
|
|
683
|
+
try {
|
|
684
|
+
return func + "";
|
|
685
|
+
} catch (e) {
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
return "";
|
|
689
|
+
}
|
|
690
|
+
var toSource_default = toSource;
|
|
691
|
+
|
|
692
|
+
// node_modules/lodash-es/_baseIsNative.js
|
|
693
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
694
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
695
|
+
var funcProto2 = Function.prototype;
|
|
696
|
+
var objectProto3 = Object.prototype;
|
|
697
|
+
var funcToString2 = funcProto2.toString;
|
|
698
|
+
var hasOwnProperty2 = objectProto3.hasOwnProperty;
|
|
699
|
+
var reIsNative = RegExp(
|
|
700
|
+
"^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
701
|
+
);
|
|
702
|
+
function baseIsNative(value) {
|
|
703
|
+
if (!isObject_default(value) || isMasked_default(value)) {
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
|
|
707
|
+
return pattern.test(toSource_default(value));
|
|
708
|
+
}
|
|
709
|
+
var baseIsNative_default = baseIsNative;
|
|
710
|
+
|
|
711
|
+
// node_modules/lodash-es/_getValue.js
|
|
712
|
+
function getValue(object, key) {
|
|
713
|
+
return object == null ? void 0 : object[key];
|
|
714
|
+
}
|
|
715
|
+
var getValue_default = getValue;
|
|
716
|
+
|
|
717
|
+
// node_modules/lodash-es/_getNative.js
|
|
718
|
+
function getNative(object, key) {
|
|
719
|
+
var value = getValue_default(object, key);
|
|
720
|
+
return baseIsNative_default(value) ? value : void 0;
|
|
721
|
+
}
|
|
722
|
+
var getNative_default = getNative;
|
|
723
|
+
|
|
724
|
+
// node_modules/lodash-es/_Map.js
|
|
725
|
+
var Map = getNative_default(root_default, "Map");
|
|
726
|
+
var Map_default = Map;
|
|
727
|
+
|
|
728
|
+
// node_modules/lodash-es/_nativeCreate.js
|
|
729
|
+
var nativeCreate = getNative_default(Object, "create");
|
|
730
|
+
var nativeCreate_default = nativeCreate;
|
|
731
|
+
|
|
732
|
+
// node_modules/lodash-es/_hashClear.js
|
|
733
|
+
function hashClear() {
|
|
734
|
+
this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
|
|
735
|
+
this.size = 0;
|
|
736
|
+
}
|
|
737
|
+
var hashClear_default = hashClear;
|
|
738
|
+
|
|
739
|
+
// node_modules/lodash-es/_hashDelete.js
|
|
740
|
+
function hashDelete(key) {
|
|
741
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
742
|
+
this.size -= result ? 1 : 0;
|
|
743
|
+
return result;
|
|
744
|
+
}
|
|
745
|
+
var hashDelete_default = hashDelete;
|
|
746
|
+
|
|
747
|
+
// node_modules/lodash-es/_hashGet.js
|
|
748
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
749
|
+
var objectProto4 = Object.prototype;
|
|
750
|
+
var hasOwnProperty3 = objectProto4.hasOwnProperty;
|
|
751
|
+
function hashGet(key) {
|
|
752
|
+
var data = this.__data__;
|
|
753
|
+
if (nativeCreate_default) {
|
|
754
|
+
var result = data[key];
|
|
755
|
+
return result === HASH_UNDEFINED ? void 0 : result;
|
|
756
|
+
}
|
|
757
|
+
return hasOwnProperty3.call(data, key) ? data[key] : void 0;
|
|
758
|
+
}
|
|
759
|
+
var hashGet_default = hashGet;
|
|
760
|
+
|
|
761
|
+
// node_modules/lodash-es/_hashHas.js
|
|
762
|
+
var objectProto5 = Object.prototype;
|
|
763
|
+
var hasOwnProperty4 = objectProto5.hasOwnProperty;
|
|
764
|
+
function hashHas(key) {
|
|
765
|
+
var data = this.__data__;
|
|
766
|
+
return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty4.call(data, key);
|
|
767
|
+
}
|
|
768
|
+
var hashHas_default = hashHas;
|
|
769
|
+
|
|
770
|
+
// node_modules/lodash-es/_hashSet.js
|
|
771
|
+
var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
|
|
772
|
+
function hashSet(key, value) {
|
|
773
|
+
var data = this.__data__;
|
|
774
|
+
this.size += this.has(key) ? 0 : 1;
|
|
775
|
+
data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
|
|
776
|
+
return this;
|
|
777
|
+
}
|
|
778
|
+
var hashSet_default = hashSet;
|
|
779
|
+
|
|
780
|
+
// node_modules/lodash-es/_Hash.js
|
|
781
|
+
function Hash(entries) {
|
|
782
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
783
|
+
this.clear();
|
|
784
|
+
while (++index < length) {
|
|
785
|
+
var entry = entries[index];
|
|
786
|
+
this.set(entry[0], entry[1]);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
Hash.prototype.clear = hashClear_default;
|
|
790
|
+
Hash.prototype["delete"] = hashDelete_default;
|
|
791
|
+
Hash.prototype.get = hashGet_default;
|
|
792
|
+
Hash.prototype.has = hashHas_default;
|
|
793
|
+
Hash.prototype.set = hashSet_default;
|
|
794
|
+
var Hash_default = Hash;
|
|
795
|
+
|
|
796
|
+
// node_modules/lodash-es/_mapCacheClear.js
|
|
797
|
+
function mapCacheClear() {
|
|
798
|
+
this.size = 0;
|
|
799
|
+
this.__data__ = {
|
|
800
|
+
"hash": new Hash_default(),
|
|
801
|
+
"map": new (Map_default || ListCache_default)(),
|
|
802
|
+
"string": new Hash_default()
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
var mapCacheClear_default = mapCacheClear;
|
|
806
|
+
|
|
807
|
+
// node_modules/lodash-es/_isKeyable.js
|
|
808
|
+
function isKeyable(value) {
|
|
809
|
+
var type = typeof value;
|
|
810
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
811
|
+
}
|
|
812
|
+
var isKeyable_default = isKeyable;
|
|
813
|
+
|
|
814
|
+
// node_modules/lodash-es/_getMapData.js
|
|
815
|
+
function getMapData(map, key) {
|
|
816
|
+
var data = map.__data__;
|
|
817
|
+
return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
818
|
+
}
|
|
819
|
+
var getMapData_default = getMapData;
|
|
820
|
+
|
|
821
|
+
// node_modules/lodash-es/_mapCacheDelete.js
|
|
822
|
+
function mapCacheDelete(key) {
|
|
823
|
+
var result = getMapData_default(this, key)["delete"](key);
|
|
824
|
+
this.size -= result ? 1 : 0;
|
|
825
|
+
return result;
|
|
826
|
+
}
|
|
827
|
+
var mapCacheDelete_default = mapCacheDelete;
|
|
828
|
+
|
|
829
|
+
// node_modules/lodash-es/_mapCacheGet.js
|
|
830
|
+
function mapCacheGet(key) {
|
|
831
|
+
return getMapData_default(this, key).get(key);
|
|
832
|
+
}
|
|
833
|
+
var mapCacheGet_default = mapCacheGet;
|
|
834
|
+
|
|
835
|
+
// node_modules/lodash-es/_mapCacheHas.js
|
|
836
|
+
function mapCacheHas(key) {
|
|
837
|
+
return getMapData_default(this, key).has(key);
|
|
838
|
+
}
|
|
839
|
+
var mapCacheHas_default = mapCacheHas;
|
|
840
|
+
|
|
841
|
+
// node_modules/lodash-es/_mapCacheSet.js
|
|
842
|
+
function mapCacheSet(key, value) {
|
|
843
|
+
var data = getMapData_default(this, key), size = data.size;
|
|
844
|
+
data.set(key, value);
|
|
845
|
+
this.size += data.size == size ? 0 : 1;
|
|
846
|
+
return this;
|
|
847
|
+
}
|
|
848
|
+
var mapCacheSet_default = mapCacheSet;
|
|
849
|
+
|
|
850
|
+
// node_modules/lodash-es/_MapCache.js
|
|
851
|
+
function MapCache(entries) {
|
|
852
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
853
|
+
this.clear();
|
|
854
|
+
while (++index < length) {
|
|
855
|
+
var entry = entries[index];
|
|
856
|
+
this.set(entry[0], entry[1]);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
MapCache.prototype.clear = mapCacheClear_default;
|
|
860
|
+
MapCache.prototype["delete"] = mapCacheDelete_default;
|
|
861
|
+
MapCache.prototype.get = mapCacheGet_default;
|
|
862
|
+
MapCache.prototype.has = mapCacheHas_default;
|
|
863
|
+
MapCache.prototype.set = mapCacheSet_default;
|
|
864
|
+
var MapCache_default = MapCache;
|
|
865
|
+
|
|
866
|
+
// node_modules/lodash-es/_stackSet.js
|
|
867
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
868
|
+
function stackSet(key, value) {
|
|
869
|
+
var data = this.__data__;
|
|
870
|
+
if (data instanceof ListCache_default) {
|
|
871
|
+
var pairs = data.__data__;
|
|
872
|
+
if (!Map_default || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
873
|
+
pairs.push([key, value]);
|
|
874
|
+
this.size = ++data.size;
|
|
875
|
+
return this;
|
|
876
|
+
}
|
|
877
|
+
data = this.__data__ = new MapCache_default(pairs);
|
|
878
|
+
}
|
|
879
|
+
data.set(key, value);
|
|
880
|
+
this.size = data.size;
|
|
881
|
+
return this;
|
|
882
|
+
}
|
|
883
|
+
var stackSet_default = stackSet;
|
|
884
|
+
|
|
885
|
+
// node_modules/lodash-es/_Stack.js
|
|
886
|
+
function Stack(entries) {
|
|
887
|
+
var data = this.__data__ = new ListCache_default(entries);
|
|
888
|
+
this.size = data.size;
|
|
889
|
+
}
|
|
890
|
+
Stack.prototype.clear = stackClear_default;
|
|
891
|
+
Stack.prototype["delete"] = stackDelete_default;
|
|
892
|
+
Stack.prototype.get = stackGet_default;
|
|
893
|
+
Stack.prototype.has = stackHas_default;
|
|
894
|
+
Stack.prototype.set = stackSet_default;
|
|
895
|
+
var Stack_default = Stack;
|
|
896
|
+
|
|
897
|
+
// node_modules/lodash-es/_setCacheAdd.js
|
|
898
|
+
var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
|
|
899
|
+
function setCacheAdd(value) {
|
|
900
|
+
this.__data__.set(value, HASH_UNDEFINED3);
|
|
901
|
+
return this;
|
|
902
|
+
}
|
|
903
|
+
var setCacheAdd_default = setCacheAdd;
|
|
904
|
+
|
|
905
|
+
// node_modules/lodash-es/_setCacheHas.js
|
|
906
|
+
function setCacheHas(value) {
|
|
907
|
+
return this.__data__.has(value);
|
|
908
|
+
}
|
|
909
|
+
var setCacheHas_default = setCacheHas;
|
|
910
|
+
|
|
911
|
+
// node_modules/lodash-es/_SetCache.js
|
|
912
|
+
function SetCache(values) {
|
|
913
|
+
var index = -1, length = values == null ? 0 : values.length;
|
|
914
|
+
this.__data__ = new MapCache_default();
|
|
915
|
+
while (++index < length) {
|
|
916
|
+
this.add(values[index]);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd_default;
|
|
920
|
+
SetCache.prototype.has = setCacheHas_default;
|
|
921
|
+
var SetCache_default = SetCache;
|
|
922
|
+
|
|
923
|
+
// node_modules/lodash-es/_arraySome.js
|
|
924
|
+
function arraySome(array, predicate) {
|
|
925
|
+
var index = -1, length = array == null ? 0 : array.length;
|
|
926
|
+
while (++index < length) {
|
|
927
|
+
if (predicate(array[index], index, array)) {
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return false;
|
|
932
|
+
}
|
|
933
|
+
var arraySome_default = arraySome;
|
|
934
|
+
|
|
935
|
+
// node_modules/lodash-es/_cacheHas.js
|
|
936
|
+
function cacheHas(cache, key) {
|
|
937
|
+
return cache.has(key);
|
|
938
|
+
}
|
|
939
|
+
var cacheHas_default = cacheHas;
|
|
940
|
+
|
|
941
|
+
// node_modules/lodash-es/_equalArrays.js
|
|
942
|
+
var COMPARE_PARTIAL_FLAG = 1;
|
|
943
|
+
var COMPARE_UNORDERED_FLAG = 2;
|
|
944
|
+
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
945
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
|
|
946
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
var arrStacked = stack.get(array);
|
|
950
|
+
var othStacked = stack.get(other);
|
|
951
|
+
if (arrStacked && othStacked) {
|
|
952
|
+
return arrStacked == other && othStacked == array;
|
|
953
|
+
}
|
|
954
|
+
var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
|
|
955
|
+
stack.set(array, other);
|
|
956
|
+
stack.set(other, array);
|
|
957
|
+
while (++index < arrLength) {
|
|
958
|
+
var arrValue = array[index], othValue = other[index];
|
|
959
|
+
if (customizer) {
|
|
960
|
+
var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
|
|
961
|
+
}
|
|
962
|
+
if (compared !== void 0) {
|
|
963
|
+
if (compared) {
|
|
964
|
+
continue;
|
|
965
|
+
}
|
|
966
|
+
result = false;
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
if (seen) {
|
|
970
|
+
if (!arraySome_default(other, function(othValue2, othIndex) {
|
|
971
|
+
if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
|
|
972
|
+
return seen.push(othIndex);
|
|
973
|
+
}
|
|
974
|
+
})) {
|
|
975
|
+
result = false;
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
979
|
+
result = false;
|
|
980
|
+
break;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
stack["delete"](array);
|
|
984
|
+
stack["delete"](other);
|
|
985
|
+
return result;
|
|
986
|
+
}
|
|
987
|
+
var equalArrays_default = equalArrays;
|
|
988
|
+
|
|
989
|
+
// node_modules/lodash-es/_Uint8Array.js
|
|
990
|
+
var Uint8Array2 = root_default.Uint8Array;
|
|
991
|
+
var Uint8Array_default = Uint8Array2;
|
|
992
|
+
|
|
993
|
+
// node_modules/lodash-es/_mapToArray.js
|
|
994
|
+
function mapToArray(map) {
|
|
995
|
+
var index = -1, result = Array(map.size);
|
|
996
|
+
map.forEach(function(value, key) {
|
|
997
|
+
result[++index] = [key, value];
|
|
998
|
+
});
|
|
999
|
+
return result;
|
|
1000
|
+
}
|
|
1001
|
+
var mapToArray_default = mapToArray;
|
|
1002
|
+
|
|
1003
|
+
// node_modules/lodash-es/_setToArray.js
|
|
1004
|
+
function setToArray(set) {
|
|
1005
|
+
var index = -1, result = Array(set.size);
|
|
1006
|
+
set.forEach(function(value) {
|
|
1007
|
+
result[++index] = value;
|
|
1008
|
+
});
|
|
1009
|
+
return result;
|
|
1010
|
+
}
|
|
1011
|
+
var setToArray_default = setToArray;
|
|
1012
|
+
|
|
1013
|
+
// node_modules/lodash-es/_equalByTag.js
|
|
1014
|
+
var COMPARE_PARTIAL_FLAG2 = 1;
|
|
1015
|
+
var COMPARE_UNORDERED_FLAG2 = 2;
|
|
1016
|
+
var boolTag = "[object Boolean]";
|
|
1017
|
+
var dateTag = "[object Date]";
|
|
1018
|
+
var errorTag = "[object Error]";
|
|
1019
|
+
var mapTag = "[object Map]";
|
|
1020
|
+
var numberTag = "[object Number]";
|
|
1021
|
+
var regexpTag = "[object RegExp]";
|
|
1022
|
+
var setTag = "[object Set]";
|
|
1023
|
+
var stringTag = "[object String]";
|
|
1024
|
+
var symbolTag = "[object Symbol]";
|
|
1025
|
+
var arrayBufferTag = "[object ArrayBuffer]";
|
|
1026
|
+
var dataViewTag = "[object DataView]";
|
|
1027
|
+
var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
|
|
1028
|
+
var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
1029
|
+
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
1030
|
+
switch (tag) {
|
|
1031
|
+
case dataViewTag:
|
|
1032
|
+
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
object = object.buffer;
|
|
1036
|
+
other = other.buffer;
|
|
1037
|
+
case arrayBufferTag:
|
|
1038
|
+
if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
return true;
|
|
1042
|
+
case boolTag:
|
|
1043
|
+
case dateTag:
|
|
1044
|
+
case numberTag:
|
|
1045
|
+
return eq_default(+object, +other);
|
|
1046
|
+
case errorTag:
|
|
1047
|
+
return object.name == other.name && object.message == other.message;
|
|
1048
|
+
case regexpTag:
|
|
1049
|
+
case stringTag:
|
|
1050
|
+
return object == other + "";
|
|
1051
|
+
case mapTag:
|
|
1052
|
+
var convert = mapToArray_default;
|
|
1053
|
+
case setTag:
|
|
1054
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
|
|
1055
|
+
convert || (convert = setToArray_default);
|
|
1056
|
+
if (object.size != other.size && !isPartial) {
|
|
1057
|
+
return false;
|
|
1058
|
+
}
|
|
1059
|
+
var stacked = stack.get(object);
|
|
1060
|
+
if (stacked) {
|
|
1061
|
+
return stacked == other;
|
|
1062
|
+
}
|
|
1063
|
+
bitmask |= COMPARE_UNORDERED_FLAG2;
|
|
1064
|
+
stack.set(object, other);
|
|
1065
|
+
var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
1066
|
+
stack["delete"](object);
|
|
1067
|
+
return result;
|
|
1068
|
+
case symbolTag:
|
|
1069
|
+
if (symbolValueOf) {
|
|
1070
|
+
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
var equalByTag_default = equalByTag;
|
|
1076
|
+
|
|
1077
|
+
// node_modules/lodash-es/_arrayPush.js
|
|
1078
|
+
function arrayPush(array, values) {
|
|
1079
|
+
var index = -1, length = values.length, offset = array.length;
|
|
1080
|
+
while (++index < length) {
|
|
1081
|
+
array[offset + index] = values[index];
|
|
1082
|
+
}
|
|
1083
|
+
return array;
|
|
1084
|
+
}
|
|
1085
|
+
var arrayPush_default = arrayPush;
|
|
1086
|
+
|
|
1087
|
+
// node_modules/lodash-es/isArray.js
|
|
1088
|
+
var isArray = Array.isArray;
|
|
1089
|
+
var isArray_default = isArray;
|
|
1090
|
+
|
|
1091
|
+
// node_modules/lodash-es/_baseGetAllKeys.js
|
|
1092
|
+
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
1093
|
+
var result = keysFunc(object);
|
|
1094
|
+
return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
|
|
1095
|
+
}
|
|
1096
|
+
var baseGetAllKeys_default = baseGetAllKeys;
|
|
1097
|
+
|
|
1098
|
+
// node_modules/lodash-es/_arrayFilter.js
|
|
1099
|
+
function arrayFilter(array, predicate) {
|
|
1100
|
+
var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
|
|
1101
|
+
while (++index < length) {
|
|
1102
|
+
var value = array[index];
|
|
1103
|
+
if (predicate(value, index, array)) {
|
|
1104
|
+
result[resIndex++] = value;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
return result;
|
|
1108
|
+
}
|
|
1109
|
+
var arrayFilter_default = arrayFilter;
|
|
1110
|
+
|
|
1111
|
+
// node_modules/lodash-es/stubArray.js
|
|
1112
|
+
function stubArray() {
|
|
1113
|
+
return [];
|
|
1114
|
+
}
|
|
1115
|
+
var stubArray_default = stubArray;
|
|
1116
|
+
|
|
1117
|
+
// node_modules/lodash-es/_getSymbols.js
|
|
1118
|
+
var objectProto6 = Object.prototype;
|
|
1119
|
+
var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
|
|
1120
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
1121
|
+
var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
|
|
1122
|
+
if (object == null) {
|
|
1123
|
+
return [];
|
|
1124
|
+
}
|
|
1125
|
+
object = Object(object);
|
|
1126
|
+
return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
|
|
1127
|
+
return propertyIsEnumerable.call(object, symbol);
|
|
1128
|
+
});
|
|
1129
|
+
};
|
|
1130
|
+
var getSymbols_default = getSymbols;
|
|
1131
|
+
|
|
1132
|
+
// node_modules/lodash-es/_baseTimes.js
|
|
1133
|
+
function baseTimes(n, iteratee) {
|
|
1134
|
+
var index = -1, result = Array(n);
|
|
1135
|
+
while (++index < n) {
|
|
1136
|
+
result[index] = iteratee(index);
|
|
1137
|
+
}
|
|
1138
|
+
return result;
|
|
1139
|
+
}
|
|
1140
|
+
var baseTimes_default = baseTimes;
|
|
1141
|
+
|
|
1142
|
+
// node_modules/lodash-es/isObjectLike.js
|
|
1143
|
+
function isObjectLike(value) {
|
|
1144
|
+
return value != null && typeof value == "object";
|
|
1145
|
+
}
|
|
1146
|
+
var isObjectLike_default = isObjectLike;
|
|
1147
|
+
|
|
1148
|
+
// node_modules/lodash-es/_baseIsArguments.js
|
|
1149
|
+
var argsTag = "[object Arguments]";
|
|
1150
|
+
function baseIsArguments(value) {
|
|
1151
|
+
return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
|
|
1152
|
+
}
|
|
1153
|
+
var baseIsArguments_default = baseIsArguments;
|
|
1154
|
+
|
|
1155
|
+
// node_modules/lodash-es/isArguments.js
|
|
1156
|
+
var objectProto7 = Object.prototype;
|
|
1157
|
+
var hasOwnProperty5 = objectProto7.hasOwnProperty;
|
|
1158
|
+
var propertyIsEnumerable2 = objectProto7.propertyIsEnumerable;
|
|
1159
|
+
var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
|
|
1160
|
+
return arguments;
|
|
1161
|
+
}()) ? baseIsArguments_default : function(value) {
|
|
1162
|
+
return isObjectLike_default(value) && hasOwnProperty5.call(value, "callee") && !propertyIsEnumerable2.call(value, "callee");
|
|
1163
|
+
};
|
|
1164
|
+
var isArguments_default = isArguments;
|
|
1165
|
+
|
|
1166
|
+
// node_modules/lodash-es/stubFalse.js
|
|
1167
|
+
function stubFalse() {
|
|
1168
|
+
return false;
|
|
1169
|
+
}
|
|
1170
|
+
var stubFalse_default = stubFalse;
|
|
1171
|
+
|
|
1172
|
+
// node_modules/lodash-es/isBuffer.js
|
|
1173
|
+
var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
1174
|
+
var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
|
|
1175
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1176
|
+
var Buffer2 = moduleExports ? root_default.Buffer : void 0;
|
|
1177
|
+
var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
|
|
1178
|
+
var isBuffer = nativeIsBuffer || stubFalse_default;
|
|
1179
|
+
var isBuffer_default = isBuffer;
|
|
1180
|
+
|
|
1181
|
+
// node_modules/lodash-es/_isIndex.js
|
|
1182
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
1183
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
1184
|
+
function isIndex(value, length) {
|
|
1185
|
+
var type = typeof value;
|
|
1186
|
+
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
1187
|
+
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
1188
|
+
}
|
|
1189
|
+
var isIndex_default = isIndex;
|
|
1190
|
+
|
|
1191
|
+
// node_modules/lodash-es/isLength.js
|
|
1192
|
+
var MAX_SAFE_INTEGER2 = 9007199254740991;
|
|
1193
|
+
function isLength(value) {
|
|
1194
|
+
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
|
|
1195
|
+
}
|
|
1196
|
+
var isLength_default = isLength;
|
|
1197
|
+
|
|
1198
|
+
// node_modules/lodash-es/_baseIsTypedArray.js
|
|
1199
|
+
var argsTag2 = "[object Arguments]";
|
|
1200
|
+
var arrayTag = "[object Array]";
|
|
1201
|
+
var boolTag2 = "[object Boolean]";
|
|
1202
|
+
var dateTag2 = "[object Date]";
|
|
1203
|
+
var errorTag2 = "[object Error]";
|
|
1204
|
+
var funcTag2 = "[object Function]";
|
|
1205
|
+
var mapTag2 = "[object Map]";
|
|
1206
|
+
var numberTag2 = "[object Number]";
|
|
1207
|
+
var objectTag = "[object Object]";
|
|
1208
|
+
var regexpTag2 = "[object RegExp]";
|
|
1209
|
+
var setTag2 = "[object Set]";
|
|
1210
|
+
var stringTag2 = "[object String]";
|
|
1211
|
+
var weakMapTag = "[object WeakMap]";
|
|
1212
|
+
var arrayBufferTag2 = "[object ArrayBuffer]";
|
|
1213
|
+
var dataViewTag2 = "[object DataView]";
|
|
1214
|
+
var float32Tag = "[object Float32Array]";
|
|
1215
|
+
var float64Tag = "[object Float64Array]";
|
|
1216
|
+
var int8Tag = "[object Int8Array]";
|
|
1217
|
+
var int16Tag = "[object Int16Array]";
|
|
1218
|
+
var int32Tag = "[object Int32Array]";
|
|
1219
|
+
var uint8Tag = "[object Uint8Array]";
|
|
1220
|
+
var uint8ClampedTag = "[object Uint8ClampedArray]";
|
|
1221
|
+
var uint16Tag = "[object Uint16Array]";
|
|
1222
|
+
var uint32Tag = "[object Uint32Array]";
|
|
1223
|
+
var typedArrayTags = {};
|
|
1224
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
|
|
1225
|
+
typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag2] = typedArrayTags[boolTag2] = typedArrayTags[dataViewTag2] = typedArrayTags[dateTag2] = typedArrayTags[errorTag2] = typedArrayTags[funcTag2] = typedArrayTags[mapTag2] = typedArrayTags[numberTag2] = typedArrayTags[objectTag] = typedArrayTags[regexpTag2] = typedArrayTags[setTag2] = typedArrayTags[stringTag2] = typedArrayTags[weakMapTag] = false;
|
|
1226
|
+
function baseIsTypedArray(value) {
|
|
1227
|
+
return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
|
|
1228
|
+
}
|
|
1229
|
+
var baseIsTypedArray_default = baseIsTypedArray;
|
|
1230
|
+
|
|
1231
|
+
// node_modules/lodash-es/_baseUnary.js
|
|
1232
|
+
function baseUnary(func) {
|
|
1233
|
+
return function(value) {
|
|
1234
|
+
return func(value);
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
var baseUnary_default = baseUnary;
|
|
1238
|
+
|
|
1239
|
+
// node_modules/lodash-es/_nodeUtil.js
|
|
1240
|
+
var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
1241
|
+
var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
|
|
1242
|
+
var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
|
|
1243
|
+
var freeProcess = moduleExports2 && freeGlobal_default.process;
|
|
1244
|
+
var nodeUtil = function() {
|
|
1245
|
+
try {
|
|
1246
|
+
var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
|
|
1247
|
+
if (types) {
|
|
1248
|
+
return types;
|
|
1249
|
+
}
|
|
1250
|
+
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
1251
|
+
} catch (e) {
|
|
1252
|
+
}
|
|
1253
|
+
}();
|
|
1254
|
+
var nodeUtil_default = nodeUtil;
|
|
1255
|
+
|
|
1256
|
+
// node_modules/lodash-es/isTypedArray.js
|
|
1257
|
+
var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
|
|
1258
|
+
var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
|
|
1259
|
+
var isTypedArray_default = isTypedArray;
|
|
1260
|
+
|
|
1261
|
+
// node_modules/lodash-es/_arrayLikeKeys.js
|
|
1262
|
+
var objectProto8 = Object.prototype;
|
|
1263
|
+
var hasOwnProperty6 = objectProto8.hasOwnProperty;
|
|
1264
|
+
function arrayLikeKeys(value, inherited) {
|
|
1265
|
+
var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
|
|
1266
|
+
for (var key in value) {
|
|
1267
|
+
if ((inherited || hasOwnProperty6.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
1268
|
+
(key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
1269
|
+
isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
1270
|
+
isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
|
|
1271
|
+
isIndex_default(key, length)))) {
|
|
1272
|
+
result.push(key);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return result;
|
|
1276
|
+
}
|
|
1277
|
+
var arrayLikeKeys_default = arrayLikeKeys;
|
|
1278
|
+
|
|
1279
|
+
// node_modules/lodash-es/_isPrototype.js
|
|
1280
|
+
var objectProto9 = Object.prototype;
|
|
1281
|
+
function isPrototype(value) {
|
|
1282
|
+
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto9;
|
|
1283
|
+
return value === proto;
|
|
1284
|
+
}
|
|
1285
|
+
var isPrototype_default = isPrototype;
|
|
1286
|
+
|
|
1287
|
+
// node_modules/lodash-es/_overArg.js
|
|
1288
|
+
function overArg(func, transform) {
|
|
1289
|
+
return function(arg) {
|
|
1290
|
+
return func(transform(arg));
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
var overArg_default = overArg;
|
|
1294
|
+
|
|
1295
|
+
// node_modules/lodash-es/_nativeKeys.js
|
|
1296
|
+
var nativeKeys = overArg_default(Object.keys, Object);
|
|
1297
|
+
var nativeKeys_default = nativeKeys;
|
|
1298
|
+
|
|
1299
|
+
// node_modules/lodash-es/_baseKeys.js
|
|
1300
|
+
var objectProto10 = Object.prototype;
|
|
1301
|
+
var hasOwnProperty7 = objectProto10.hasOwnProperty;
|
|
1302
|
+
function baseKeys(object) {
|
|
1303
|
+
if (!isPrototype_default(object)) {
|
|
1304
|
+
return nativeKeys_default(object);
|
|
1305
|
+
}
|
|
1306
|
+
var result = [];
|
|
1307
|
+
for (var key in Object(object)) {
|
|
1308
|
+
if (hasOwnProperty7.call(object, key) && key != "constructor") {
|
|
1309
|
+
result.push(key);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
return result;
|
|
1313
|
+
}
|
|
1314
|
+
var baseKeys_default = baseKeys;
|
|
1315
|
+
|
|
1316
|
+
// node_modules/lodash-es/isArrayLike.js
|
|
1317
|
+
function isArrayLike(value) {
|
|
1318
|
+
return value != null && isLength_default(value.length) && !isFunction_default(value);
|
|
1319
|
+
}
|
|
1320
|
+
var isArrayLike_default = isArrayLike;
|
|
1321
|
+
|
|
1322
|
+
// node_modules/lodash-es/keys.js
|
|
1323
|
+
function keys(object) {
|
|
1324
|
+
return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
|
|
1325
|
+
}
|
|
1326
|
+
var keys_default = keys;
|
|
1327
|
+
|
|
1328
|
+
// node_modules/lodash-es/_getAllKeys.js
|
|
1329
|
+
function getAllKeys(object) {
|
|
1330
|
+
return baseGetAllKeys_default(object, keys_default, getSymbols_default);
|
|
1331
|
+
}
|
|
1332
|
+
var getAllKeys_default = getAllKeys;
|
|
1333
|
+
|
|
1334
|
+
// node_modules/lodash-es/_equalObjects.js
|
|
1335
|
+
var COMPARE_PARTIAL_FLAG3 = 1;
|
|
1336
|
+
var objectProto11 = Object.prototype;
|
|
1337
|
+
var hasOwnProperty8 = objectProto11.hasOwnProperty;
|
|
1338
|
+
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
1339
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
|
|
1340
|
+
if (objLength != othLength && !isPartial) {
|
|
1341
|
+
return false;
|
|
1342
|
+
}
|
|
1343
|
+
var index = objLength;
|
|
1344
|
+
while (index--) {
|
|
1345
|
+
var key = objProps[index];
|
|
1346
|
+
if (!(isPartial ? key in other : hasOwnProperty8.call(other, key))) {
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
var objStacked = stack.get(object);
|
|
1351
|
+
var othStacked = stack.get(other);
|
|
1352
|
+
if (objStacked && othStacked) {
|
|
1353
|
+
return objStacked == other && othStacked == object;
|
|
1354
|
+
}
|
|
1355
|
+
var result = true;
|
|
1356
|
+
stack.set(object, other);
|
|
1357
|
+
stack.set(other, object);
|
|
1358
|
+
var skipCtor = isPartial;
|
|
1359
|
+
while (++index < objLength) {
|
|
1360
|
+
key = objProps[index];
|
|
1361
|
+
var objValue = object[key], othValue = other[key];
|
|
1362
|
+
if (customizer) {
|
|
1363
|
+
var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
|
|
1364
|
+
}
|
|
1365
|
+
if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
|
|
1366
|
+
result = false;
|
|
1367
|
+
break;
|
|
1368
|
+
}
|
|
1369
|
+
skipCtor || (skipCtor = key == "constructor");
|
|
1370
|
+
}
|
|
1371
|
+
if (result && !skipCtor) {
|
|
1372
|
+
var objCtor = object.constructor, othCtor = other.constructor;
|
|
1373
|
+
if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
|
|
1374
|
+
result = false;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
stack["delete"](object);
|
|
1378
|
+
stack["delete"](other);
|
|
1379
|
+
return result;
|
|
1380
|
+
}
|
|
1381
|
+
var equalObjects_default = equalObjects;
|
|
1382
|
+
|
|
1383
|
+
// node_modules/lodash-es/_DataView.js
|
|
1384
|
+
var DataView = getNative_default(root_default, "DataView");
|
|
1385
|
+
var DataView_default = DataView;
|
|
1386
|
+
|
|
1387
|
+
// node_modules/lodash-es/_Promise.js
|
|
1388
|
+
var Promise2 = getNative_default(root_default, "Promise");
|
|
1389
|
+
var Promise_default = Promise2;
|
|
1390
|
+
|
|
1391
|
+
// node_modules/lodash-es/_Set.js
|
|
1392
|
+
var Set2 = getNative_default(root_default, "Set");
|
|
1393
|
+
var Set_default = Set2;
|
|
1394
|
+
|
|
1395
|
+
// node_modules/lodash-es/_WeakMap.js
|
|
1396
|
+
var WeakMap = getNative_default(root_default, "WeakMap");
|
|
1397
|
+
var WeakMap_default = WeakMap;
|
|
1398
|
+
|
|
1399
|
+
// node_modules/lodash-es/_getTag.js
|
|
1400
|
+
var mapTag3 = "[object Map]";
|
|
1401
|
+
var objectTag2 = "[object Object]";
|
|
1402
|
+
var promiseTag = "[object Promise]";
|
|
1403
|
+
var setTag3 = "[object Set]";
|
|
1404
|
+
var weakMapTag2 = "[object WeakMap]";
|
|
1405
|
+
var dataViewTag3 = "[object DataView]";
|
|
1406
|
+
var dataViewCtorString = toSource_default(DataView_default);
|
|
1407
|
+
var mapCtorString = toSource_default(Map_default);
|
|
1408
|
+
var promiseCtorString = toSource_default(Promise_default);
|
|
1409
|
+
var setCtorString = toSource_default(Set_default);
|
|
1410
|
+
var weakMapCtorString = toSource_default(WeakMap_default);
|
|
1411
|
+
var getTag = baseGetTag_default;
|
|
1412
|
+
if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag3 || Map_default && getTag(new Map_default()) != mapTag3 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag3 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
|
|
1413
|
+
getTag = function(value) {
|
|
1414
|
+
var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
|
|
1415
|
+
if (ctorString) {
|
|
1416
|
+
switch (ctorString) {
|
|
1417
|
+
case dataViewCtorString:
|
|
1418
|
+
return dataViewTag3;
|
|
1419
|
+
case mapCtorString:
|
|
1420
|
+
return mapTag3;
|
|
1421
|
+
case promiseCtorString:
|
|
1422
|
+
return promiseTag;
|
|
1423
|
+
case setCtorString:
|
|
1424
|
+
return setTag3;
|
|
1425
|
+
case weakMapCtorString:
|
|
1426
|
+
return weakMapTag2;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
return result;
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
var getTag_default = getTag;
|
|
1433
|
+
|
|
1434
|
+
// node_modules/lodash-es/_baseIsEqualDeep.js
|
|
1435
|
+
var COMPARE_PARTIAL_FLAG4 = 1;
|
|
1436
|
+
var argsTag3 = "[object Arguments]";
|
|
1437
|
+
var arrayTag2 = "[object Array]";
|
|
1438
|
+
var objectTag3 = "[object Object]";
|
|
1439
|
+
var objectProto12 = Object.prototype;
|
|
1440
|
+
var hasOwnProperty9 = objectProto12.hasOwnProperty;
|
|
1441
|
+
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
1442
|
+
var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
|
|
1443
|
+
objTag = objTag == argsTag3 ? objectTag3 : objTag;
|
|
1444
|
+
othTag = othTag == argsTag3 ? objectTag3 : othTag;
|
|
1445
|
+
var objIsObj = objTag == objectTag3, othIsObj = othTag == objectTag3, isSameTag = objTag == othTag;
|
|
1446
|
+
if (isSameTag && isBuffer_default(object)) {
|
|
1447
|
+
if (!isBuffer_default(other)) {
|
|
1448
|
+
return false;
|
|
1449
|
+
}
|
|
1450
|
+
objIsArr = true;
|
|
1451
|
+
objIsObj = false;
|
|
1452
|
+
}
|
|
1453
|
+
if (isSameTag && !objIsObj) {
|
|
1454
|
+
stack || (stack = new Stack_default());
|
|
1455
|
+
return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
1456
|
+
}
|
|
1457
|
+
if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
|
|
1458
|
+
var objIsWrapped = objIsObj && hasOwnProperty9.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty9.call(other, "__wrapped__");
|
|
1459
|
+
if (objIsWrapped || othIsWrapped) {
|
|
1460
|
+
var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
|
|
1461
|
+
stack || (stack = new Stack_default());
|
|
1462
|
+
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
if (!isSameTag) {
|
|
1466
|
+
return false;
|
|
1467
|
+
}
|
|
1468
|
+
stack || (stack = new Stack_default());
|
|
1469
|
+
return equalObjects_default(object, other, bitmask, customizer, equalFunc, stack);
|
|
1470
|
+
}
|
|
1471
|
+
var baseIsEqualDeep_default = baseIsEqualDeep;
|
|
1472
|
+
|
|
1473
|
+
// node_modules/lodash-es/_baseIsEqual.js
|
|
1474
|
+
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
1475
|
+
if (value === other) {
|
|
1476
|
+
return true;
|
|
1477
|
+
}
|
|
1478
|
+
if (value == null || other == null || !isObjectLike_default(value) && !isObjectLike_default(other)) {
|
|
1479
|
+
return value !== value && other !== other;
|
|
1480
|
+
}
|
|
1481
|
+
return baseIsEqualDeep_default(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
1482
|
+
}
|
|
1483
|
+
var baseIsEqual_default = baseIsEqual;
|
|
1484
|
+
|
|
1485
|
+
// node_modules/lodash-es/isEqual.js
|
|
1486
|
+
function isEqual(value, other) {
|
|
1487
|
+
return baseIsEqual_default(value, other);
|
|
1488
|
+
}
|
|
1489
|
+
var isEqual_default = isEqual;
|
|
1490
|
+
|
|
1491
|
+
// src/lib/v1/JoggerConnection.ts
|
|
1492
|
+
var import_Vector3 = require("three/src/math/Vector3.js");
|
|
1493
|
+
var JoggerConnection = class _JoggerConnection {
|
|
1494
|
+
constructor(motionStream, opts = {}) {
|
|
1495
|
+
this.motionStream = motionStream;
|
|
1496
|
+
this.opts = opts;
|
|
1497
|
+
// Currently a separate websocket is needed for each mode, pester API people
|
|
1498
|
+
// to merge these for simplicity
|
|
1499
|
+
this.cartesianWebsocket = null;
|
|
1500
|
+
this.jointWebsocket = null;
|
|
1501
|
+
this.cartesianJoggingOpts = {};
|
|
1502
|
+
}
|
|
1503
|
+
static open(_0, _1) {
|
|
1504
|
+
return __async(this, arguments, function* (nova, motionGroupId, opts = {}) {
|
|
1505
|
+
const motionStream = yield nova.connectMotionStream(motionGroupId);
|
|
1506
|
+
return new _JoggerConnection(motionStream, opts);
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
get motionGroupId() {
|
|
1510
|
+
return this.motionStream.motionGroupId;
|
|
1511
|
+
}
|
|
1512
|
+
get nova() {
|
|
1513
|
+
return this.motionStream.nova;
|
|
1514
|
+
}
|
|
1515
|
+
get numJoints() {
|
|
1516
|
+
return this.motionStream.joints.length;
|
|
1517
|
+
}
|
|
1518
|
+
get activeJoggingMode() {
|
|
1519
|
+
if (this.cartesianWebsocket) return "cartesian";
|
|
1520
|
+
if (this.jointWebsocket) return "joint";
|
|
1521
|
+
return "increment";
|
|
1522
|
+
}
|
|
1523
|
+
get activeWebsocket() {
|
|
1524
|
+
return this.cartesianWebsocket || this.jointWebsocket;
|
|
1525
|
+
}
|
|
1526
|
+
stop() {
|
|
1527
|
+
return __async(this, null, function* () {
|
|
1528
|
+
if (this.cartesianWebsocket) {
|
|
1529
|
+
this.cartesianWebsocket.sendJson({
|
|
1530
|
+
motion_group: this.motionGroupId,
|
|
1531
|
+
position_direction: { x: 0, y: 0, z: 0 },
|
|
1532
|
+
rotation_direction: { x: 0, y: 0, z: 0 },
|
|
1533
|
+
position_velocity: 0,
|
|
1534
|
+
rotation_velocity: 0,
|
|
1535
|
+
tcp: this.cartesianJoggingOpts.tcpId,
|
|
1536
|
+
coordinate_system: this.cartesianJoggingOpts.coordSystemId
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
if (this.jointWebsocket) {
|
|
1540
|
+
this.jointWebsocket.sendJson({
|
|
1541
|
+
motion_group: this.motionGroupId,
|
|
1542
|
+
joint_velocities: new Array(this.numJoints).fill(0)
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
dispose() {
|
|
1548
|
+
if (this.cartesianWebsocket) {
|
|
1549
|
+
this.cartesianWebsocket.dispose();
|
|
1550
|
+
}
|
|
1551
|
+
if (this.jointWebsocket) {
|
|
1552
|
+
this.jointWebsocket.dispose();
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
setJoggingMode(mode, cartesianJoggingOpts) {
|
|
1556
|
+
console.log("Setting jogging mode to", mode);
|
|
1557
|
+
if (cartesianJoggingOpts) {
|
|
1558
|
+
if (!isEqual_default(this.cartesianJoggingOpts, cartesianJoggingOpts)) {
|
|
1559
|
+
if (this.cartesianWebsocket) {
|
|
1560
|
+
this.cartesianWebsocket.dispose();
|
|
1561
|
+
this.cartesianWebsocket = null;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
this.cartesianJoggingOpts = cartesianJoggingOpts;
|
|
1565
|
+
}
|
|
1566
|
+
if (mode !== "cartesian" && this.cartesianWebsocket) {
|
|
1567
|
+
this.cartesianWebsocket.dispose();
|
|
1568
|
+
this.cartesianWebsocket = null;
|
|
1569
|
+
}
|
|
1570
|
+
if (mode !== "joint" && this.jointWebsocket) {
|
|
1571
|
+
this.jointWebsocket.dispose();
|
|
1572
|
+
this.jointWebsocket = null;
|
|
1573
|
+
}
|
|
1574
|
+
if (mode === "cartesian" && !this.cartesianWebsocket) {
|
|
1575
|
+
this.cartesianWebsocket = this.nova.openReconnectingWebsocket(
|
|
1576
|
+
`/motion-groups/move-tcp`
|
|
1577
|
+
);
|
|
1578
|
+
this.cartesianWebsocket.addEventListener(
|
|
1579
|
+
"message",
|
|
1580
|
+
(ev) => {
|
|
1581
|
+
const data = tryParseJson(ev.data);
|
|
1582
|
+
if (data && "error" in data) {
|
|
1583
|
+
if (this.opts.onError) {
|
|
1584
|
+
this.opts.onError(ev.data);
|
|
1585
|
+
} else {
|
|
1586
|
+
throw new Error(ev.data);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
if (mode === "joint" && !this.jointWebsocket) {
|
|
1593
|
+
this.jointWebsocket = this.nova.openReconnectingWebsocket(
|
|
1594
|
+
`/motion-groups/move-joint`
|
|
1595
|
+
);
|
|
1596
|
+
this.jointWebsocket.addEventListener("message", (ev) => {
|
|
1597
|
+
const data = tryParseJson(ev.data);
|
|
1598
|
+
if (data && "error" in data) {
|
|
1599
|
+
if (this.opts.onError) {
|
|
1600
|
+
this.opts.onError(ev.data);
|
|
1601
|
+
} else {
|
|
1602
|
+
throw new Error(ev.data);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* Start rotation of a single robot joint at the specified velocity
|
|
1610
|
+
*/
|
|
1611
|
+
startJointRotation(_0) {
|
|
1612
|
+
return __async(this, arguments, function* ({
|
|
1613
|
+
joint,
|
|
1614
|
+
direction,
|
|
1615
|
+
velocityRadsPerSec
|
|
1616
|
+
}) {
|
|
1617
|
+
if (!this.jointWebsocket) {
|
|
1618
|
+
throw new Error(
|
|
1619
|
+
"Joint jogging websocket not connected; call setJoggingMode first"
|
|
1620
|
+
);
|
|
1621
|
+
}
|
|
1622
|
+
const jointVelocities = new Array(this.numJoints).fill(0);
|
|
1623
|
+
jointVelocities[joint] = direction === "-" ? -velocityRadsPerSec : velocityRadsPerSec;
|
|
1624
|
+
this.jointWebsocket.sendJson({
|
|
1625
|
+
motion_group: this.motionGroupId,
|
|
1626
|
+
joint_velocities: jointVelocities
|
|
1627
|
+
});
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Start the TCP moving along a specified axis at a given velocity
|
|
1632
|
+
*/
|
|
1633
|
+
startTCPTranslation(_0) {
|
|
1634
|
+
return __async(this, arguments, function* ({
|
|
1635
|
+
axis,
|
|
1636
|
+
direction,
|
|
1637
|
+
velocityMmPerSec
|
|
1638
|
+
}) {
|
|
1639
|
+
if (!this.cartesianWebsocket) {
|
|
1640
|
+
throw new Error(
|
|
1641
|
+
"Cartesian jogging websocket not connected; call setJoggingMode first"
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
const zeroVector = { x: 0, y: 0, z: 0 };
|
|
1645
|
+
const joggingVector = Object.assign({}, zeroVector);
|
|
1646
|
+
joggingVector[axis] = direction === "-" ? -1 : 1;
|
|
1647
|
+
this.cartesianWebsocket.sendJson({
|
|
1648
|
+
motion_group: this.motionGroupId,
|
|
1649
|
+
position_direction: joggingVector,
|
|
1650
|
+
rotation_direction: zeroVector,
|
|
1651
|
+
position_velocity: velocityMmPerSec,
|
|
1652
|
+
rotation_velocity: 0,
|
|
1653
|
+
tcp: this.cartesianJoggingOpts.tcpId,
|
|
1654
|
+
coordinate_system: this.cartesianJoggingOpts.coordSystemId
|
|
1655
|
+
});
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Start the TCP rotating around a specified axis at a given velocity
|
|
1660
|
+
*/
|
|
1661
|
+
startTCPRotation(_0) {
|
|
1662
|
+
return __async(this, arguments, function* ({
|
|
1663
|
+
axis,
|
|
1664
|
+
direction,
|
|
1665
|
+
velocityRadsPerSec
|
|
1666
|
+
}) {
|
|
1667
|
+
if (!this.cartesianWebsocket) {
|
|
1668
|
+
throw new Error(
|
|
1669
|
+
"Cartesian jogging websocket not connected; call setJoggingMode first"
|
|
1670
|
+
);
|
|
1671
|
+
}
|
|
1672
|
+
const zeroVector = { x: 0, y: 0, z: 0 };
|
|
1673
|
+
const joggingVector = Object.assign({}, zeroVector);
|
|
1674
|
+
joggingVector[axis] = direction === "-" ? -1 : 1;
|
|
1675
|
+
this.cartesianWebsocket.sendJson({
|
|
1676
|
+
motion_group: this.motionGroupId,
|
|
1677
|
+
position_direction: zeroVector,
|
|
1678
|
+
rotation_direction: joggingVector,
|
|
1679
|
+
position_velocity: 0,
|
|
1680
|
+
rotation_velocity: velocityRadsPerSec,
|
|
1681
|
+
tcp: this.cartesianJoggingOpts.tcpId,
|
|
1682
|
+
coordinate_system: this.cartesianJoggingOpts.coordSystemId
|
|
1683
|
+
});
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* Move the robot by a fixed distance in a single cartesian
|
|
1688
|
+
* axis, either rotating or translating relative to the TCP.
|
|
1689
|
+
* Promise resolves only after the motion has completed.
|
|
1690
|
+
*/
|
|
1691
|
+
runIncrementalCartesianMotion(_0) {
|
|
1692
|
+
return __async(this, arguments, function* ({
|
|
1693
|
+
currentTcpPose,
|
|
1694
|
+
currentJoints,
|
|
1695
|
+
coordSystemId,
|
|
1696
|
+
velocityInRelevantUnits,
|
|
1697
|
+
axis,
|
|
1698
|
+
direction,
|
|
1699
|
+
motion
|
|
1700
|
+
}) {
|
|
1701
|
+
var _a;
|
|
1702
|
+
const commands = [];
|
|
1703
|
+
if (!isSameCoordinateSystem(currentTcpPose.coordinate_system, coordSystemId)) {
|
|
1704
|
+
throw new Error(
|
|
1705
|
+
`Current TCP pose coordinate system ${currentTcpPose.coordinate_system} does not match target coordinate system ${coordSystemId}`
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
if (motion.type === "translate") {
|
|
1709
|
+
const targetTcpPosition = Object.assign({}, currentTcpPose.position);
|
|
1710
|
+
targetTcpPosition[axis] += motion.distanceMm * (direction === "-" ? -1 : 1);
|
|
1711
|
+
commands.push({
|
|
1712
|
+
settings: {
|
|
1713
|
+
limits_override: {
|
|
1714
|
+
tcp_velocity_limit: velocityInRelevantUnits
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
line: {
|
|
1718
|
+
position: targetTcpPosition,
|
|
1719
|
+
orientation: currentTcpPose.orientation,
|
|
1720
|
+
coordinate_system: coordSystemId
|
|
1721
|
+
}
|
|
1722
|
+
});
|
|
1723
|
+
} else if (motion.type === "rotate") {
|
|
1724
|
+
const currentRotationVector = new import_Vector3.Vector3(
|
|
1725
|
+
currentTcpPose.orientation["x"],
|
|
1726
|
+
currentTcpPose.orientation["y"],
|
|
1727
|
+
currentTcpPose.orientation["z"]
|
|
1728
|
+
);
|
|
1729
|
+
const currentRotationRad = currentRotationVector.length();
|
|
1730
|
+
const currentRotationDirection = currentRotationVector.clone().normalize();
|
|
1731
|
+
const differenceRotationRad = motion.distanceRads * (direction === "-" ? -1 : 1);
|
|
1732
|
+
const differenceRotationDirection = new import_Vector3.Vector3(0, 0, 0);
|
|
1733
|
+
differenceRotationDirection[axis] = 1;
|
|
1734
|
+
const f1 = Math.cos(0.5 * differenceRotationRad) * Math.cos(0.5 * currentRotationRad);
|
|
1735
|
+
const f2 = Math.sin(0.5 * differenceRotationRad) * Math.sin(0.5 * currentRotationRad);
|
|
1736
|
+
const f3 = Math.sin(0.5 * differenceRotationRad) * Math.cos(0.5 * currentRotationRad);
|
|
1737
|
+
const f4 = Math.cos(0.5 * differenceRotationRad) * Math.sin(0.5 * currentRotationRad);
|
|
1738
|
+
const dotProduct = differenceRotationDirection.dot(
|
|
1739
|
+
currentRotationDirection
|
|
1740
|
+
);
|
|
1741
|
+
const crossProduct = differenceRotationDirection.clone().cross(currentRotationDirection);
|
|
1742
|
+
const newRotationRad = 2 * Math.acos(f1 - f2 * dotProduct);
|
|
1743
|
+
const f5 = newRotationRad / Math.sin(0.5 * newRotationRad);
|
|
1744
|
+
const targetTcpOrientation = new import_Vector3.Vector3().addScaledVector(crossProduct, f2).addScaledVector(differenceRotationDirection, f3).addScaledVector(currentRotationDirection, f4).multiplyScalar(f5);
|
|
1745
|
+
commands.push({
|
|
1746
|
+
settings: {
|
|
1747
|
+
limits_override: {
|
|
1748
|
+
tcp_orientation_velocity_limit: velocityInRelevantUnits
|
|
1749
|
+
}
|
|
1750
|
+
},
|
|
1751
|
+
line: {
|
|
1752
|
+
position: currentTcpPose.position,
|
|
1753
|
+
orientation: targetTcpOrientation,
|
|
1754
|
+
coordinate_system: coordSystemId
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
const motionPlanRes = yield this.nova.api.motion.planMotion({
|
|
1759
|
+
motion_group: this.motionGroupId,
|
|
1760
|
+
start_joint_position: currentJoints,
|
|
1761
|
+
tcp: this.cartesianJoggingOpts.tcpId,
|
|
1762
|
+
commands
|
|
1763
|
+
});
|
|
1764
|
+
const plannedMotion = (_a = motionPlanRes.plan_successful_response) == null ? void 0 : _a.motion;
|
|
1765
|
+
if (!plannedMotion) {
|
|
1766
|
+
throw new Error(
|
|
1767
|
+
`Failed to plan jogging increment motion ${JSON.stringify(motionPlanRes)}`
|
|
1768
|
+
);
|
|
1769
|
+
}
|
|
1770
|
+
yield this.nova.api.motion.streamMoveForward(
|
|
1771
|
+
plannedMotion,
|
|
1772
|
+
100,
|
|
1773
|
+
void 0,
|
|
1774
|
+
void 0,
|
|
1775
|
+
void 0,
|
|
1776
|
+
{
|
|
1777
|
+
// Might take a while at low velocity
|
|
1778
|
+
timeout: 1e3 * 60
|
|
1779
|
+
}
|
|
1780
|
+
);
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Rotate a single robot joint by a fixed number of radians
|
|
1785
|
+
* Promise resolves only after the motion has completed.
|
|
1786
|
+
*/
|
|
1787
|
+
runIncrementalJointRotation(_0) {
|
|
1788
|
+
return __async(this, arguments, function* ({
|
|
1789
|
+
joint,
|
|
1790
|
+
currentJoints,
|
|
1791
|
+
velocityRadsPerSec,
|
|
1792
|
+
direction,
|
|
1793
|
+
distanceRads
|
|
1794
|
+
}) {
|
|
1795
|
+
var _a;
|
|
1796
|
+
const targetJoints = [...currentJoints.joints];
|
|
1797
|
+
targetJoints[joint] += distanceRads * (direction === "-" ? -1 : 1);
|
|
1798
|
+
const jointVelocityLimits = new Array(
|
|
1799
|
+
currentJoints.joints.length
|
|
1800
|
+
).fill(velocityRadsPerSec);
|
|
1801
|
+
const motionPlanRes = yield this.nova.api.motion.planMotion({
|
|
1802
|
+
motion_group: this.motionGroupId,
|
|
1803
|
+
start_joint_position: currentJoints,
|
|
1804
|
+
commands: [
|
|
1805
|
+
{
|
|
1806
|
+
settings: {
|
|
1807
|
+
limits_override: {
|
|
1808
|
+
joint_velocity_limits: {
|
|
1809
|
+
joints: jointVelocityLimits
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
},
|
|
1813
|
+
joint_ptp: {
|
|
1814
|
+
joints: targetJoints
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
]
|
|
1818
|
+
});
|
|
1819
|
+
const plannedMotion = (_a = motionPlanRes.plan_successful_response) == null ? void 0 : _a.motion;
|
|
1820
|
+
if (!plannedMotion) {
|
|
1821
|
+
console.error("Failed to plan jogging increment motion", motionPlanRes);
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
yield this.nova.api.motion.streamMoveForward(
|
|
1825
|
+
plannedMotion,
|
|
1826
|
+
100,
|
|
1827
|
+
void 0,
|
|
1828
|
+
void 0,
|
|
1829
|
+
void 0,
|
|
1830
|
+
{
|
|
1831
|
+
// Might take a while at low velocity
|
|
1832
|
+
timeout: 1e3 * 60
|
|
1833
|
+
}
|
|
1834
|
+
);
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
};
|
|
1838
|
+
|
|
1839
|
+
// src/lib/v1/MotionStreamConnection.ts
|
|
1840
|
+
var import_mobx2 = require("mobx");
|
|
1841
|
+
var import_three = require("three");
|
|
1842
|
+
var MOTION_DELTA_THRESHOLD2 = 1e-4;
|
|
1843
|
+
function unwrapRotationVector(newRotationVectorApi, currentRotationVectorApi) {
|
|
1844
|
+
const currentRotationVector = new import_three.Vector3(
|
|
1845
|
+
currentRotationVectorApi.x,
|
|
1846
|
+
currentRotationVectorApi.y,
|
|
1847
|
+
currentRotationVectorApi.z
|
|
1848
|
+
);
|
|
1849
|
+
const newRotationVector = new import_three.Vector3(
|
|
1850
|
+
newRotationVectorApi.x,
|
|
1851
|
+
newRotationVectorApi.y,
|
|
1852
|
+
newRotationVectorApi.z
|
|
1853
|
+
);
|
|
1854
|
+
const currentAngle = currentRotationVector.length();
|
|
1855
|
+
const currentAxis = currentRotationVector.normalize();
|
|
1856
|
+
let newAngle = newRotationVector.length();
|
|
1857
|
+
let newAxis = newRotationVector.normalize();
|
|
1858
|
+
if (newAxis.dot(currentAxis) < 0) {
|
|
1859
|
+
newAngle = -newAngle;
|
|
1860
|
+
newAxis = newAxis.multiplyScalar(-1);
|
|
1861
|
+
}
|
|
1862
|
+
let angleDifference = newAngle - currentAngle;
|
|
1863
|
+
angleDifference -= 2 * Math.PI * Math.floor((angleDifference + Math.PI) / (2 * Math.PI));
|
|
1864
|
+
newAngle = currentAngle + angleDifference;
|
|
1865
|
+
return newAxis.multiplyScalar(newAngle);
|
|
1866
|
+
}
|
|
1867
|
+
var MotionStreamConnection = class _MotionStreamConnection {
|
|
1868
|
+
constructor(nova, controller, motionGroup, initialMotionState, motionStateSocket) {
|
|
1869
|
+
this.nova = nova;
|
|
1870
|
+
this.controller = controller;
|
|
1871
|
+
this.motionGroup = motionGroup;
|
|
1872
|
+
this.initialMotionState = initialMotionState;
|
|
1873
|
+
this.motionStateSocket = motionStateSocket;
|
|
1874
|
+
this.rapidlyChangingMotionState = initialMotionState;
|
|
1875
|
+
motionStateSocket.addEventListener("message", (event) => {
|
|
1876
|
+
var _a;
|
|
1877
|
+
const motionStateResponse = (_a = tryParseJson(event.data)) == null ? void 0 : _a.result;
|
|
1878
|
+
if (!motionStateResponse) {
|
|
1879
|
+
throw new Error(
|
|
1880
|
+
`Failed to get motion state for ${this.motionGroupId}: ${event.data}`
|
|
1881
|
+
);
|
|
1882
|
+
}
|
|
1883
|
+
if (!jointValuesEqual(
|
|
1884
|
+
this.rapidlyChangingMotionState.state.joint_position.joints,
|
|
1885
|
+
motionStateResponse.state.joint_position.joints,
|
|
1886
|
+
MOTION_DELTA_THRESHOLD2
|
|
1887
|
+
)) {
|
|
1888
|
+
(0, import_mobx2.runInAction)(() => {
|
|
1889
|
+
this.rapidlyChangingMotionState.state = motionStateResponse.state;
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
if (!tcpPoseEqual(
|
|
1893
|
+
this.rapidlyChangingMotionState.tcp_pose,
|
|
1894
|
+
motionStateResponse.tcp_pose,
|
|
1895
|
+
MOTION_DELTA_THRESHOLD2
|
|
1896
|
+
)) {
|
|
1897
|
+
(0, import_mobx2.runInAction)(() => {
|
|
1898
|
+
if (this.rapidlyChangingMotionState.tcp_pose == void 0) {
|
|
1899
|
+
this.rapidlyChangingMotionState.tcp_pose = motionStateResponse.tcp_pose;
|
|
1900
|
+
} else {
|
|
1901
|
+
this.rapidlyChangingMotionState.tcp_pose = {
|
|
1902
|
+
position: motionStateResponse.tcp_pose.position,
|
|
1903
|
+
orientation: unwrapRotationVector(
|
|
1904
|
+
motionStateResponse.tcp_pose.orientation,
|
|
1905
|
+
this.rapidlyChangingMotionState.tcp_pose.orientation
|
|
1906
|
+
),
|
|
1907
|
+
tcp: motionStateResponse.tcp_pose.tcp,
|
|
1908
|
+
coordinate_system: motionStateResponse.tcp_pose.coordinate_system
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
});
|
|
1914
|
+
(0, import_mobx2.makeAutoObservable)(this);
|
|
1915
|
+
}
|
|
1916
|
+
static open(nova, motionGroupId) {
|
|
1917
|
+
return __async(this, null, function* () {
|
|
1918
|
+
var _a;
|
|
1919
|
+
const { instances: controllers } = yield nova.api.controller.listControllers();
|
|
1920
|
+
const [_motionGroupIndex, controllerId] = motionGroupId.split("@");
|
|
1921
|
+
const controller = controllers.find((c) => c.controller === controllerId);
|
|
1922
|
+
const motionGroup = controller == null ? void 0 : controller.physical_motion_groups.find(
|
|
1923
|
+
(mg) => mg.motion_group === motionGroupId
|
|
1924
|
+
);
|
|
1925
|
+
if (!controller || !motionGroup) {
|
|
1926
|
+
throw new Error(
|
|
1927
|
+
`Controller ${controllerId} or motion group ${motionGroupId} not found`
|
|
1928
|
+
);
|
|
1929
|
+
}
|
|
1930
|
+
const motionStateSocket = nova.openReconnectingWebsocket(
|
|
1931
|
+
`/motion-groups/${motionGroupId}/state-stream`
|
|
1932
|
+
);
|
|
1933
|
+
const firstMessage = yield motionStateSocket.firstMessage();
|
|
1934
|
+
console.log("got first message", firstMessage);
|
|
1935
|
+
const initialMotionState = (_a = tryParseJson(firstMessage.data)) == null ? void 0 : _a.result;
|
|
1936
|
+
if (!initialMotionState) {
|
|
1937
|
+
throw new Error(
|
|
1938
|
+
`Unable to parse initial motion state message ${firstMessage.data}`
|
|
1939
|
+
);
|
|
1940
|
+
}
|
|
1941
|
+
console.log(
|
|
1942
|
+
`Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:
|
|
1943
|
+
`,
|
|
1944
|
+
initialMotionState
|
|
1945
|
+
);
|
|
1946
|
+
return new _MotionStreamConnection(
|
|
1947
|
+
nova,
|
|
1948
|
+
controller,
|
|
1949
|
+
motionGroup,
|
|
1950
|
+
initialMotionState,
|
|
1951
|
+
motionStateSocket
|
|
1952
|
+
);
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
get motionGroupId() {
|
|
1956
|
+
return this.motionGroup.motion_group;
|
|
1957
|
+
}
|
|
1958
|
+
get controllerId() {
|
|
1959
|
+
return this.controller.controller;
|
|
1960
|
+
}
|
|
1961
|
+
get modelFromController() {
|
|
1962
|
+
return this.motionGroup.model_from_controller;
|
|
1963
|
+
}
|
|
1964
|
+
get wandelscriptIdentifier() {
|
|
1965
|
+
const num = this.motionGroupId.split("@")[0];
|
|
1966
|
+
return `${this.controllerId.replaceAll("-", "_")}_${num}`;
|
|
1967
|
+
}
|
|
1968
|
+
get joints() {
|
|
1969
|
+
return this.initialMotionState.state.joint_position.joints.map((_, i) => {
|
|
1970
|
+
return {
|
|
1971
|
+
index: i
|
|
1972
|
+
};
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
dispose() {
|
|
1976
|
+
this.motionStateSocket.close();
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
// src/lib/v1/NovaCellAPIClient.ts
|
|
1981
|
+
var import_v1 = require("@wandelbots/nova-api/v1");
|
|
1982
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
1983
|
+
var NovaCellAPIClient = class {
|
|
1984
|
+
constructor(cellId, opts) {
|
|
1985
|
+
this.cellId = cellId;
|
|
1986
|
+
this.opts = opts;
|
|
1987
|
+
this.system = this.withUnwrappedResponsesOnly(import_v1.SystemApi);
|
|
1988
|
+
this.cell = this.withUnwrappedResponsesOnly(import_v1.CellApi);
|
|
1989
|
+
this.deviceConfig = this.withCellId(import_v1.DeviceConfigurationApi);
|
|
1990
|
+
this.motionGroup = this.withCellId(import_v1.MotionGroupApi);
|
|
1991
|
+
this.motionGroupInfos = this.withCellId(import_v1.MotionGroupInfosApi);
|
|
1992
|
+
this.controller = this.withCellId(import_v1.ControllerApi);
|
|
1993
|
+
this.program = this.withCellId(import_v1.ProgramApi);
|
|
1994
|
+
this.programValues = this.withCellId(import_v1.ProgramValuesApi);
|
|
1995
|
+
this.controllerIOs = this.withCellId(import_v1.ControllerIOsApi);
|
|
1996
|
+
this.motionGroupKinematic = this.withCellId(import_v1.MotionGroupKinematicApi);
|
|
1997
|
+
this.motion = this.withCellId(import_v1.MotionApi);
|
|
1998
|
+
this.coordinateSystems = this.withCellId(import_v1.CoordinateSystemsApi);
|
|
1999
|
+
this.application = this.withCellId(import_v1.ApplicationApi);
|
|
2000
|
+
this.applicationGlobal = this.withUnwrappedResponsesOnly(import_v1.ApplicationApi);
|
|
2001
|
+
this.motionGroupJogging = this.withCellId(import_v1.MotionGroupJoggingApi);
|
|
2002
|
+
this.virtualRobot = this.withCellId(import_v1.VirtualRobotApi);
|
|
2003
|
+
this.virtualRobotSetup = this.withCellId(import_v1.VirtualRobotSetupApi);
|
|
2004
|
+
this.virtualRobotMode = this.withCellId(import_v1.VirtualRobotModeApi);
|
|
2005
|
+
this.virtualRobotBehavior = this.withCellId(import_v1.VirtualRobotBehaviorApi);
|
|
2006
|
+
this.libraryProgramMetadata = this.withCellId(import_v1.LibraryProgramMetadataApi);
|
|
2007
|
+
this.libraryProgram = this.withCellId(import_v1.LibraryProgramApi);
|
|
2008
|
+
this.libraryRecipeMetadata = this.withCellId(import_v1.LibraryRecipeMetadataApi);
|
|
2009
|
+
this.libraryRecipe = this.withCellId(import_v1.LibraryRecipeApi);
|
|
2010
|
+
this.storeObject = this.withCellId(import_v1.StoreObjectApi);
|
|
2011
|
+
this.storeCollisionComponents = this.withCellId(
|
|
2012
|
+
import_v1.StoreCollisionComponentsApi
|
|
2013
|
+
);
|
|
2014
|
+
this.storeCollisionScenes = this.withCellId(import_v1.StoreCollisionScenesApi);
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Some TypeScript sorcery which alters the API class methods so you don't
|
|
2018
|
+
* have to pass the cell id to every single one, and de-encapsulates the
|
|
2019
|
+
* response data
|
|
2020
|
+
*/
|
|
2021
|
+
withCellId(ApiConstructor) {
|
|
2022
|
+
var _a, _b;
|
|
2023
|
+
const apiClient = new ApiConstructor(
|
|
2024
|
+
__spreadProps(__spreadValues({}, this.opts), {
|
|
2025
|
+
isJsonMime: (mime) => {
|
|
2026
|
+
return mime === "application/json";
|
|
2027
|
+
}
|
|
2028
|
+
}),
|
|
2029
|
+
(_a = this.opts.basePath) != null ? _a : "",
|
|
2030
|
+
(_b = this.opts.axiosInstance) != null ? _b : import_axios.default.create()
|
|
2031
|
+
);
|
|
2032
|
+
for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) {
|
|
2033
|
+
if (key !== "constructor" && typeof apiClient[key] === "function") {
|
|
2034
|
+
const originalFunction = apiClient[key];
|
|
2035
|
+
apiClient[key] = (...args) => {
|
|
2036
|
+
return originalFunction.apply(apiClient, [this.cellId, ...args]).then((res) => res.data);
|
|
2037
|
+
};
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
return apiClient;
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* As withCellId, but only does the response unwrapping
|
|
2044
|
+
*/
|
|
2045
|
+
withUnwrappedResponsesOnly(ApiConstructor) {
|
|
2046
|
+
var _a, _b;
|
|
2047
|
+
const apiClient = new ApiConstructor(
|
|
2048
|
+
__spreadProps(__spreadValues({}, this.opts), {
|
|
2049
|
+
isJsonMime: (mime) => {
|
|
2050
|
+
return mime === "application/json";
|
|
2051
|
+
}
|
|
2052
|
+
}),
|
|
2053
|
+
(_a = this.opts.basePath) != null ? _a : "",
|
|
2054
|
+
(_b = this.opts.axiosInstance) != null ? _b : import_axios.default.create()
|
|
2055
|
+
);
|
|
2056
|
+
for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) {
|
|
2057
|
+
if (key !== "constructor" && typeof apiClient[key] === "function") {
|
|
2058
|
+
const originalFunction = apiClient[key];
|
|
2059
|
+
apiClient[key] = (...args) => {
|
|
2060
|
+
return originalFunction.apply(apiClient, args).then((res) => res.data);
|
|
2061
|
+
};
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
return apiClient;
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
// src/lib/v1/NovaClient.ts
|
|
2069
|
+
var import_axios3 = __toESM(require("axios"), 1);
|
|
2070
|
+
var import_url_join = __toESM(require("url-join"), 1);
|
|
2071
|
+
|
|
2072
|
+
// src/LoginWithAuth0.ts
|
|
2073
|
+
var DOMAIN_SUFFIX = "wandelbots.io";
|
|
2074
|
+
var auth0ConfigMap = {
|
|
2075
|
+
dev: {
|
|
2076
|
+
domain: `https://auth.portal.dev.${DOMAIN_SUFFIX}`,
|
|
2077
|
+
clientId: "fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha"
|
|
2078
|
+
},
|
|
2079
|
+
stg: {
|
|
2080
|
+
domain: `https://auth.portal.stg.${DOMAIN_SUFFIX}`,
|
|
2081
|
+
clientId: "joVDeD9e786WzFNSGCqoVq7HNkWt5j6s"
|
|
2082
|
+
},
|
|
2083
|
+
prod: {
|
|
2084
|
+
domain: `https://auth.portal.${DOMAIN_SUFFIX}`,
|
|
2085
|
+
clientId: "J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2"
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
var getAuth0Config = (instanceUrl) => {
|
|
2089
|
+
if (instanceUrl.includes(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev;
|
|
2090
|
+
if (instanceUrl.includes(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg;
|
|
2091
|
+
if (instanceUrl.includes(DOMAIN_SUFFIX)) return auth0ConfigMap.prod;
|
|
2092
|
+
throw new Error(
|
|
2093
|
+
"Unsupported instance URL. Cannot determine Auth0 configuration."
|
|
2094
|
+
);
|
|
2095
|
+
};
|
|
2096
|
+
var loginWithAuth0 = (instanceUrl) => __async(void 0, null, function* () {
|
|
2097
|
+
var _a;
|
|
2098
|
+
if (typeof window === "undefined") {
|
|
2099
|
+
throw new Error(
|
|
2100
|
+
`Access token must be set to use NovaClient when not in a browser environment.`
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
const auth0Config = getAuth0Config(instanceUrl);
|
|
2104
|
+
if (new URL(instanceUrl).origin === window.location.origin) {
|
|
2105
|
+
window.location.reload();
|
|
2106
|
+
throw new Error(
|
|
2107
|
+
"Failed to reload page to get auth details, please refresh manually"
|
|
2108
|
+
);
|
|
2109
|
+
}
|
|
2110
|
+
const { Auth0Client } = yield import("@auth0/auth0-spa-js");
|
|
2111
|
+
const auth0Client = new Auth0Client({
|
|
2112
|
+
domain: auth0Config.domain,
|
|
2113
|
+
clientId: (_a = auth0Config.clientId) != null ? _a : "",
|
|
2114
|
+
useRefreshTokens: false,
|
|
2115
|
+
authorizationParams: {
|
|
2116
|
+
audience: "nova-api",
|
|
2117
|
+
redirect_uri: window.location.origin
|
|
2118
|
+
}
|
|
2119
|
+
});
|
|
2120
|
+
if (window.location.search.includes("code=") && window.location.search.includes("state=")) {
|
|
2121
|
+
const { appState } = yield auth0Client.handleRedirectCallback();
|
|
2122
|
+
window.history.replaceState(
|
|
2123
|
+
{},
|
|
2124
|
+
document.title,
|
|
2125
|
+
(appState == null ? void 0 : appState.returnTo) || window.location.pathname
|
|
2126
|
+
);
|
|
2127
|
+
} else {
|
|
2128
|
+
yield auth0Client.loginWithRedirect();
|
|
2129
|
+
}
|
|
2130
|
+
const accessToken = yield auth0Client.getTokenSilently();
|
|
2131
|
+
return accessToken;
|
|
2132
|
+
});
|
|
2133
|
+
|
|
2134
|
+
// src/lib/AutoReconnectingWebsocket.ts
|
|
2135
|
+
var import_reconnecting_websocket = __toESM(require("reconnecting-websocket"), 1);
|
|
2136
|
+
var AutoReconnectingWebsocket = class extends import_reconnecting_websocket.default {
|
|
2137
|
+
constructor(targetUrl, opts = {}) {
|
|
2138
|
+
console.log("Opening websocket to", targetUrl);
|
|
2139
|
+
super(() => this.targetUrl || targetUrl, void 0, {
|
|
2140
|
+
startClosed: true
|
|
2141
|
+
});
|
|
2142
|
+
this.opts = opts;
|
|
2143
|
+
this.disposed = false;
|
|
2144
|
+
Object.defineProperty(this, "url", {
|
|
2145
|
+
get() {
|
|
2146
|
+
return this.targetUrl;
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
this.targetUrl = targetUrl;
|
|
2150
|
+
this.addEventListener("open", () => {
|
|
2151
|
+
console.log(`Websocket to ${this.url} opened`);
|
|
2152
|
+
});
|
|
2153
|
+
this.addEventListener("message", (ev) => {
|
|
2154
|
+
if (!this.receivedFirstMessage) {
|
|
2155
|
+
this.receivedFirstMessage = ev;
|
|
2156
|
+
}
|
|
2157
|
+
});
|
|
2158
|
+
this.addEventListener("close", () => {
|
|
2159
|
+
console.log(`Websocket to ${this.url} closed`);
|
|
2160
|
+
});
|
|
2161
|
+
const origReconnect = this.reconnect;
|
|
2162
|
+
this.reconnect = () => {
|
|
2163
|
+
if (this.opts.mock) {
|
|
2164
|
+
this.opts.mock.handleWebsocketConnection(this);
|
|
2165
|
+
} else {
|
|
2166
|
+
origReconnect.apply(this);
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
this.reconnect();
|
|
2170
|
+
}
|
|
2171
|
+
changeUrl(targetUrl) {
|
|
2172
|
+
this.receivedFirstMessage = void 0;
|
|
2173
|
+
this.targetUrl = targetUrl;
|
|
2174
|
+
this.reconnect();
|
|
2175
|
+
}
|
|
2176
|
+
sendJson(data) {
|
|
2177
|
+
if (this.opts.mock) {
|
|
2178
|
+
this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data));
|
|
2179
|
+
} else {
|
|
2180
|
+
this.send(JSON.stringify(data));
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Permanently close this websocket and indicate that
|
|
2185
|
+
* this object should not be used again.
|
|
2186
|
+
**/
|
|
2187
|
+
dispose() {
|
|
2188
|
+
this.close();
|
|
2189
|
+
this.disposed = true;
|
|
2190
|
+
if (this.opts.onDispose) {
|
|
2191
|
+
this.opts.onDispose();
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Returns a promise that resolves once the websocket
|
|
2196
|
+
* is in the OPEN state. */
|
|
2197
|
+
opened() {
|
|
2198
|
+
return __async(this, null, function* () {
|
|
2199
|
+
return new Promise((resolve, reject) => {
|
|
2200
|
+
if (this.readyState === WebSocket.OPEN) {
|
|
2201
|
+
resolve();
|
|
2202
|
+
} else {
|
|
2203
|
+
this.addEventListener("open", () => resolve());
|
|
2204
|
+
this.addEventListener("error", reject);
|
|
2205
|
+
}
|
|
2206
|
+
});
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Returns a promise that resolves once the websocket
|
|
2211
|
+
* is in the CLOSED state. */
|
|
2212
|
+
closed() {
|
|
2213
|
+
return __async(this, null, function* () {
|
|
2214
|
+
return new Promise((resolve, reject) => {
|
|
2215
|
+
if (this.readyState === WebSocket.CLOSED) {
|
|
2216
|
+
resolve();
|
|
2217
|
+
} else {
|
|
2218
|
+
this.addEventListener("close", () => resolve());
|
|
2219
|
+
this.addEventListener("error", reject);
|
|
2220
|
+
}
|
|
2221
|
+
});
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
/**
|
|
2225
|
+
* Returns a promise that resolves when the first message
|
|
2226
|
+
* is received from the websocket. Resolves immediately if
|
|
2227
|
+
* the first message has already been received.
|
|
2228
|
+
*/
|
|
2229
|
+
firstMessage() {
|
|
2230
|
+
return __async(this, null, function* () {
|
|
2231
|
+
if (this.receivedFirstMessage) {
|
|
2232
|
+
return this.receivedFirstMessage;
|
|
2233
|
+
}
|
|
2234
|
+
return new Promise((resolve, reject) => {
|
|
2235
|
+
const onMessage = (ev) => {
|
|
2236
|
+
this.receivedFirstMessage = ev;
|
|
2237
|
+
this.removeEventListener("message", onMessage);
|
|
2238
|
+
this.removeEventListener("error", onError);
|
|
2239
|
+
resolve(ev);
|
|
2240
|
+
};
|
|
2241
|
+
const onError = (ev) => {
|
|
2242
|
+
this.removeEventListener("message", onMessage);
|
|
2243
|
+
this.removeEventListener("error", onError);
|
|
2244
|
+
reject(ev);
|
|
2245
|
+
};
|
|
2246
|
+
this.addEventListener("message", onMessage);
|
|
2247
|
+
this.addEventListener("error", onError);
|
|
2248
|
+
});
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Returns a promise that resolves when the next message
|
|
2253
|
+
* is received from the websocket.
|
|
2254
|
+
*/
|
|
2255
|
+
nextMessage() {
|
|
2256
|
+
return __async(this, null, function* () {
|
|
2257
|
+
return new Promise((resolve, reject) => {
|
|
2258
|
+
const onMessage = (ev) => {
|
|
2259
|
+
this.removeEventListener("message", onMessage);
|
|
2260
|
+
this.removeEventListener("error", onError);
|
|
2261
|
+
resolve(ev);
|
|
2262
|
+
};
|
|
2263
|
+
const onError = (ev) => {
|
|
2264
|
+
this.removeEventListener("message", onMessage);
|
|
2265
|
+
this.removeEventListener("error", onError);
|
|
2266
|
+
reject(ev);
|
|
2267
|
+
};
|
|
2268
|
+
this.addEventListener("message", onMessage);
|
|
2269
|
+
this.addEventListener("error", onError);
|
|
2270
|
+
});
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
|
|
2275
|
+
// src/lib/availableStorage.ts
|
|
2276
|
+
var AvailableStorage = class {
|
|
2277
|
+
constructor() {
|
|
2278
|
+
this.available = typeof window !== "undefined" && !!window.localStorage;
|
|
2279
|
+
}
|
|
2280
|
+
getJSON(key) {
|
|
2281
|
+
if (!this.available) return null;
|
|
2282
|
+
const result = window.localStorage.getItem(key);
|
|
2283
|
+
if (result === null) return null;
|
|
2284
|
+
try {
|
|
2285
|
+
return JSON.parse(result);
|
|
2286
|
+
} catch (err) {
|
|
2287
|
+
return null;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
setJSON(key, obj) {
|
|
2291
|
+
if (!this.available) return null;
|
|
2292
|
+
window.localStorage.setItem(key, JSON.stringify(obj));
|
|
2293
|
+
}
|
|
2294
|
+
delete(key) {
|
|
2295
|
+
if (!this.available) return null;
|
|
2296
|
+
window.localStorage.removeItem(key);
|
|
2297
|
+
}
|
|
2298
|
+
setString(key, value) {
|
|
2299
|
+
if (!this.available) return null;
|
|
2300
|
+
window.localStorage.setItem(key, value);
|
|
2301
|
+
}
|
|
2302
|
+
getString(key) {
|
|
2303
|
+
if (!this.available) return null;
|
|
2304
|
+
return window.localStorage.getItem(key);
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2307
|
+
var availableStorage = new AvailableStorage();
|
|
2308
|
+
|
|
2309
|
+
// src/lib/v1/mock/MockNovaInstance.ts
|
|
2310
|
+
var import_axios2 = require("axios");
|
|
2311
|
+
var pathToRegexp = __toESM(require("path-to-regexp"), 1);
|
|
2312
|
+
var MockNovaInstance = class {
|
|
2313
|
+
constructor() {
|
|
2314
|
+
this.connections = [];
|
|
2315
|
+
}
|
|
2316
|
+
handleAPIRequest(config) {
|
|
2317
|
+
return __async(this, null, function* () {
|
|
2318
|
+
var _a, _b, _c;
|
|
2319
|
+
const apiHandlers = [
|
|
2320
|
+
{
|
|
2321
|
+
method: "GET",
|
|
2322
|
+
path: "/cells/:cellId/controllers",
|
|
2323
|
+
handle() {
|
|
2324
|
+
return {
|
|
2325
|
+
instances: [
|
|
2326
|
+
{
|
|
2327
|
+
controller: "mock-ur5e",
|
|
2328
|
+
model_name: "UniversalRobots::Controller",
|
|
2329
|
+
host: "mock-ur5e",
|
|
2330
|
+
allow_software_install_on_controller: true,
|
|
2331
|
+
physical_motion_groups: [
|
|
2332
|
+
{
|
|
2333
|
+
motion_group: "0@mock-ur5e",
|
|
2334
|
+
name_from_controller: "UR5e",
|
|
2335
|
+
active: false,
|
|
2336
|
+
model_from_controller: "UniversalRobots_UR5e"
|
|
2337
|
+
}
|
|
2338
|
+
],
|
|
2339
|
+
has_error: false,
|
|
2340
|
+
error_details: ""
|
|
2341
|
+
}
|
|
2342
|
+
]
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
2346
|
+
{
|
|
2347
|
+
method: "GET",
|
|
2348
|
+
path: "/cells/:cellId/controllers/:controllerId",
|
|
2349
|
+
handle() {
|
|
2350
|
+
return {
|
|
2351
|
+
configuration: {
|
|
2352
|
+
kind: "VirtualController",
|
|
2353
|
+
manufacturer: "universalrobots",
|
|
2354
|
+
position: "[0,-1.571,-1.571,-1.571,1.571,-1.571,0]",
|
|
2355
|
+
type: "universalrobots-ur5e"
|
|
2356
|
+
},
|
|
2357
|
+
name: "mock-ur5"
|
|
2358
|
+
};
|
|
2359
|
+
}
|
|
2360
|
+
},
|
|
2361
|
+
{
|
|
2362
|
+
method: "GET",
|
|
2363
|
+
path: "/cells/:cellId/motion-groups/:motionGroupId/specification",
|
|
2364
|
+
handle() {
|
|
2365
|
+
return {
|
|
2366
|
+
dh_parameters: [
|
|
2367
|
+
{
|
|
2368
|
+
alpha: 1.5707963267948966,
|
|
2369
|
+
theta: 0,
|
|
2370
|
+
a: 0,
|
|
2371
|
+
d: 162.25,
|
|
2372
|
+
reverse_rotation_direction: false
|
|
2373
|
+
},
|
|
2374
|
+
{
|
|
2375
|
+
alpha: 0,
|
|
2376
|
+
theta: 0,
|
|
2377
|
+
a: -425,
|
|
2378
|
+
d: 0,
|
|
2379
|
+
reverse_rotation_direction: false
|
|
2380
|
+
},
|
|
2381
|
+
{
|
|
2382
|
+
alpha: 0,
|
|
2383
|
+
theta: 0,
|
|
2384
|
+
a: -392.2,
|
|
2385
|
+
d: 0,
|
|
2386
|
+
reverse_rotation_direction: false
|
|
2387
|
+
},
|
|
2388
|
+
{
|
|
2389
|
+
alpha: 1.5707963267948966,
|
|
2390
|
+
theta: 0,
|
|
2391
|
+
a: 0,
|
|
2392
|
+
d: 133.3,
|
|
2393
|
+
reverse_rotation_direction: false
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
alpha: -1.5707963267948966,
|
|
2397
|
+
theta: 0,
|
|
2398
|
+
a: 0,
|
|
2399
|
+
d: 99.7,
|
|
2400
|
+
reverse_rotation_direction: false
|
|
2401
|
+
},
|
|
2402
|
+
{
|
|
2403
|
+
alpha: 0,
|
|
2404
|
+
theta: 0,
|
|
2405
|
+
a: 0,
|
|
2406
|
+
d: 99.6,
|
|
2407
|
+
reverse_rotation_direction: false
|
|
2408
|
+
}
|
|
2409
|
+
],
|
|
2410
|
+
mechanical_joint_limits: [
|
|
2411
|
+
{
|
|
2412
|
+
joint: "JOINTNAME_AXIS_1",
|
|
2413
|
+
lower_limit: -6.335545063018799,
|
|
2414
|
+
upper_limit: 6.335545063018799,
|
|
2415
|
+
unlimited: false
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
joint: "JOINTNAME_AXIS_2",
|
|
2419
|
+
lower_limit: -6.335545063018799,
|
|
2420
|
+
upper_limit: 6.335545063018799,
|
|
2421
|
+
unlimited: false
|
|
2422
|
+
},
|
|
2423
|
+
{
|
|
2424
|
+
joint: "JOINTNAME_AXIS_3",
|
|
2425
|
+
lower_limit: -6.335545063018799,
|
|
2426
|
+
upper_limit: 6.335545063018799,
|
|
2427
|
+
unlimited: false
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
joint: "JOINTNAME_AXIS_4",
|
|
2431
|
+
lower_limit: -6.335545063018799,
|
|
2432
|
+
upper_limit: 6.335545063018799,
|
|
2433
|
+
unlimited: false
|
|
2434
|
+
},
|
|
2435
|
+
{
|
|
2436
|
+
joint: "JOINTNAME_AXIS_5",
|
|
2437
|
+
lower_limit: -6.335545063018799,
|
|
2438
|
+
upper_limit: 6.335545063018799,
|
|
2439
|
+
unlimited: false
|
|
2440
|
+
},
|
|
2441
|
+
{
|
|
2442
|
+
joint: "JOINTNAME_AXIS_6",
|
|
2443
|
+
lower_limit: -6.335545063018799,
|
|
2444
|
+
upper_limit: 6.335545063018799,
|
|
2445
|
+
unlimited: false
|
|
2446
|
+
}
|
|
2447
|
+
]
|
|
2448
|
+
};
|
|
2449
|
+
}
|
|
2450
|
+
},
|
|
2451
|
+
{
|
|
2452
|
+
method: "GET",
|
|
2453
|
+
path: "/cells/:cellId/motion-groups/:motionGroupId/safety-setup",
|
|
2454
|
+
handle() {
|
|
2455
|
+
return {
|
|
2456
|
+
safety_settings: [
|
|
2457
|
+
{
|
|
2458
|
+
safety_state: "SAFETY_NORMAL",
|
|
2459
|
+
settings: {
|
|
2460
|
+
joint_position_limits: [
|
|
2461
|
+
{
|
|
2462
|
+
joint: "JOINTNAME_AXIS_1",
|
|
2463
|
+
lower_limit: -2.96705961227417,
|
|
2464
|
+
upper_limit: 2.96705961227417,
|
|
2465
|
+
unlimited: false
|
|
2466
|
+
},
|
|
2467
|
+
{
|
|
2468
|
+
joint: "JOINTNAME_AXIS_2",
|
|
2469
|
+
lower_limit: -1.7453292608261108,
|
|
2470
|
+
upper_limit: 2.7925267219543457,
|
|
2471
|
+
unlimited: false
|
|
2472
|
+
},
|
|
2473
|
+
{
|
|
2474
|
+
joint: "JOINTNAME_AXIS_3",
|
|
2475
|
+
lower_limit: -3.3161256313323975,
|
|
2476
|
+
upper_limit: 0.40142571926116943,
|
|
2477
|
+
unlimited: false
|
|
2478
|
+
},
|
|
2479
|
+
{
|
|
2480
|
+
joint: "JOINTNAME_AXIS_4",
|
|
2481
|
+
lower_limit: -3.4906585216522217,
|
|
2482
|
+
upper_limit: 3.4906585216522217,
|
|
2483
|
+
unlimited: false
|
|
2484
|
+
},
|
|
2485
|
+
{
|
|
2486
|
+
joint: "JOINTNAME_AXIS_5",
|
|
2487
|
+
lower_limit: -2.4434609413146973,
|
|
2488
|
+
upper_limit: 2.4434609413146973,
|
|
2489
|
+
unlimited: false
|
|
2490
|
+
},
|
|
2491
|
+
{
|
|
2492
|
+
joint: "JOINTNAME_AXIS_6",
|
|
2493
|
+
lower_limit: -4.71238899230957,
|
|
2494
|
+
upper_limit: 4.71238899230957,
|
|
2495
|
+
unlimited: false
|
|
2496
|
+
}
|
|
2497
|
+
],
|
|
2498
|
+
joint_velocity_limits: [
|
|
2499
|
+
{
|
|
2500
|
+
joint: "JOINTNAME_AXIS_1",
|
|
2501
|
+
limit: 3.1415927410125732
|
|
2502
|
+
},
|
|
2503
|
+
{
|
|
2504
|
+
joint: "JOINTNAME_AXIS_2",
|
|
2505
|
+
limit: 3.1415927410125732
|
|
2506
|
+
},
|
|
2507
|
+
{
|
|
2508
|
+
joint: "JOINTNAME_AXIS_3",
|
|
2509
|
+
limit: 3.4906585216522217
|
|
2510
|
+
},
|
|
2511
|
+
{
|
|
2512
|
+
joint: "JOINTNAME_AXIS_4",
|
|
2513
|
+
limit: 6.108652591705322
|
|
2514
|
+
},
|
|
2515
|
+
{
|
|
2516
|
+
joint: "JOINTNAME_AXIS_5",
|
|
2517
|
+
limit: 6.108652591705322
|
|
2518
|
+
},
|
|
2519
|
+
{
|
|
2520
|
+
joint: "JOINTNAME_AXIS_6",
|
|
2521
|
+
limit: 6.981317043304443
|
|
2522
|
+
}
|
|
2523
|
+
],
|
|
2524
|
+
joint_acceleration_limits: [],
|
|
2525
|
+
joint_torque_limits: [],
|
|
2526
|
+
tcp_velocity_limit: 1800
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
],
|
|
2530
|
+
safety_zones: [
|
|
2531
|
+
{
|
|
2532
|
+
id: 1,
|
|
2533
|
+
priority: 0,
|
|
2534
|
+
geometry: {
|
|
2535
|
+
compound: {
|
|
2536
|
+
child_geometries: [
|
|
2537
|
+
{
|
|
2538
|
+
convex_hull: {
|
|
2539
|
+
vertices: [
|
|
2540
|
+
{
|
|
2541
|
+
x: -800,
|
|
2542
|
+
y: -1330,
|
|
2543
|
+
z: -1820
|
|
2544
|
+
},
|
|
2545
|
+
{
|
|
2546
|
+
x: 1650,
|
|
2547
|
+
y: -1330,
|
|
2548
|
+
z: -1820
|
|
2549
|
+
},
|
|
2550
|
+
{
|
|
2551
|
+
x: 1650,
|
|
2552
|
+
y: 1330,
|
|
2553
|
+
z: -1820
|
|
2554
|
+
},
|
|
2555
|
+
{
|
|
2556
|
+
x: -800,
|
|
2557
|
+
y: 1330,
|
|
2558
|
+
z: -1820
|
|
2559
|
+
}
|
|
2560
|
+
]
|
|
2561
|
+
},
|
|
2562
|
+
init_pose: {
|
|
2563
|
+
position: {
|
|
2564
|
+
x: 0,
|
|
2565
|
+
y: 0,
|
|
2566
|
+
z: 0
|
|
2567
|
+
},
|
|
2568
|
+
orientation: {
|
|
2569
|
+
x: 0,
|
|
2570
|
+
y: 0,
|
|
2571
|
+
z: 0,
|
|
2572
|
+
w: 1
|
|
2573
|
+
}
|
|
2574
|
+
},
|
|
2575
|
+
id: "box"
|
|
2576
|
+
},
|
|
2577
|
+
{
|
|
2578
|
+
convex_hull: {
|
|
2579
|
+
vertices: [
|
|
2580
|
+
{
|
|
2581
|
+
x: -800,
|
|
2582
|
+
y: -1330,
|
|
2583
|
+
z: -1820
|
|
2584
|
+
},
|
|
2585
|
+
{
|
|
2586
|
+
x: 1650,
|
|
2587
|
+
y: -1330,
|
|
2588
|
+
z: -1820
|
|
2589
|
+
},
|
|
2590
|
+
{
|
|
2591
|
+
x: 1650,
|
|
2592
|
+
y: -1330,
|
|
2593
|
+
z: 1500
|
|
2594
|
+
},
|
|
2595
|
+
{
|
|
2596
|
+
x: -800,
|
|
2597
|
+
y: -1330,
|
|
2598
|
+
z: 1500
|
|
2599
|
+
}
|
|
2600
|
+
]
|
|
2601
|
+
},
|
|
2602
|
+
init_pose: {
|
|
2603
|
+
position: {
|
|
2604
|
+
x: 0,
|
|
2605
|
+
y: 0,
|
|
2606
|
+
z: 0
|
|
2607
|
+
},
|
|
2608
|
+
orientation: {
|
|
2609
|
+
x: 0,
|
|
2610
|
+
y: 0,
|
|
2611
|
+
z: 0,
|
|
2612
|
+
w: 1
|
|
2613
|
+
}
|
|
2614
|
+
},
|
|
2615
|
+
id: "box"
|
|
2616
|
+
},
|
|
2617
|
+
{
|
|
2618
|
+
convex_hull: {
|
|
2619
|
+
vertices: [
|
|
2620
|
+
{
|
|
2621
|
+
x: -800,
|
|
2622
|
+
y: -1330,
|
|
2623
|
+
z: -1820
|
|
2624
|
+
},
|
|
2625
|
+
{
|
|
2626
|
+
x: -800,
|
|
2627
|
+
y: 1330,
|
|
2628
|
+
z: -1820
|
|
2629
|
+
},
|
|
2630
|
+
{
|
|
2631
|
+
x: -800,
|
|
2632
|
+
y: 1330,
|
|
2633
|
+
z: 1500
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
x: -800,
|
|
2637
|
+
y: -1330,
|
|
2638
|
+
z: 1500
|
|
2639
|
+
}
|
|
2640
|
+
]
|
|
2641
|
+
},
|
|
2642
|
+
init_pose: {
|
|
2643
|
+
position: {
|
|
2644
|
+
x: 0,
|
|
2645
|
+
y: 0,
|
|
2646
|
+
z: 0
|
|
2647
|
+
},
|
|
2648
|
+
orientation: {
|
|
2649
|
+
x: 0,
|
|
2650
|
+
y: 0,
|
|
2651
|
+
z: 0,
|
|
2652
|
+
w: 1
|
|
2653
|
+
}
|
|
2654
|
+
},
|
|
2655
|
+
id: "box"
|
|
2656
|
+
},
|
|
2657
|
+
{
|
|
2658
|
+
convex_hull: {
|
|
2659
|
+
vertices: [
|
|
2660
|
+
{
|
|
2661
|
+
x: 1650,
|
|
2662
|
+
y: 1330,
|
|
2663
|
+
z: 1500
|
|
2664
|
+
},
|
|
2665
|
+
{
|
|
2666
|
+
x: -800,
|
|
2667
|
+
y: 1330,
|
|
2668
|
+
z: 1500
|
|
2669
|
+
},
|
|
2670
|
+
{
|
|
2671
|
+
x: -800,
|
|
2672
|
+
y: -1330,
|
|
2673
|
+
z: 1500
|
|
2674
|
+
},
|
|
2675
|
+
{
|
|
2676
|
+
x: 1650,
|
|
2677
|
+
y: -1330,
|
|
2678
|
+
z: 1500
|
|
2679
|
+
}
|
|
2680
|
+
]
|
|
2681
|
+
},
|
|
2682
|
+
init_pose: {
|
|
2683
|
+
position: {
|
|
2684
|
+
x: 0,
|
|
2685
|
+
y: 0,
|
|
2686
|
+
z: 0
|
|
2687
|
+
},
|
|
2688
|
+
orientation: {
|
|
2689
|
+
x: 0,
|
|
2690
|
+
y: 0,
|
|
2691
|
+
z: 0,
|
|
2692
|
+
w: 1
|
|
2693
|
+
}
|
|
2694
|
+
},
|
|
2695
|
+
id: "box"
|
|
2696
|
+
},
|
|
2697
|
+
{
|
|
2698
|
+
convex_hull: {
|
|
2699
|
+
vertices: [
|
|
2700
|
+
{
|
|
2701
|
+
x: 1650,
|
|
2702
|
+
y: 1330,
|
|
2703
|
+
z: 1500
|
|
2704
|
+
},
|
|
2705
|
+
{
|
|
2706
|
+
x: -800,
|
|
2707
|
+
y: 1330,
|
|
2708
|
+
z: 1500
|
|
2709
|
+
},
|
|
2710
|
+
{
|
|
2711
|
+
x: -800,
|
|
2712
|
+
y: 1330,
|
|
2713
|
+
z: -1820
|
|
2714
|
+
},
|
|
2715
|
+
{
|
|
2716
|
+
x: 1650,
|
|
2717
|
+
y: 1330,
|
|
2718
|
+
z: -1820
|
|
2719
|
+
}
|
|
2720
|
+
]
|
|
2721
|
+
},
|
|
2722
|
+
init_pose: {
|
|
2723
|
+
position: {
|
|
2724
|
+
x: 0,
|
|
2725
|
+
y: 0,
|
|
2726
|
+
z: 0
|
|
2727
|
+
},
|
|
2728
|
+
orientation: {
|
|
2729
|
+
x: 0,
|
|
2730
|
+
y: 0,
|
|
2731
|
+
z: 0,
|
|
2732
|
+
w: 1
|
|
2733
|
+
}
|
|
2734
|
+
},
|
|
2735
|
+
id: "box"
|
|
2736
|
+
},
|
|
2737
|
+
{
|
|
2738
|
+
convex_hull: {
|
|
2739
|
+
vertices: [
|
|
2740
|
+
{
|
|
2741
|
+
x: 1650,
|
|
2742
|
+
y: 1330,
|
|
2743
|
+
z: 1500
|
|
2744
|
+
},
|
|
2745
|
+
{
|
|
2746
|
+
x: 1650,
|
|
2747
|
+
y: -1330,
|
|
2748
|
+
z: 1500
|
|
2749
|
+
},
|
|
2750
|
+
{
|
|
2751
|
+
x: 1650,
|
|
2752
|
+
y: -1330,
|
|
2753
|
+
z: -1820
|
|
2754
|
+
},
|
|
2755
|
+
{
|
|
2756
|
+
x: 1650,
|
|
2757
|
+
y: 1330,
|
|
2758
|
+
z: -1820
|
|
2759
|
+
}
|
|
2760
|
+
]
|
|
2761
|
+
},
|
|
2762
|
+
init_pose: {
|
|
2763
|
+
position: {
|
|
2764
|
+
x: 0,
|
|
2765
|
+
y: 0,
|
|
2766
|
+
z: 0
|
|
2767
|
+
},
|
|
2768
|
+
orientation: {
|
|
2769
|
+
x: 0,
|
|
2770
|
+
y: 0,
|
|
2771
|
+
z: 0,
|
|
2772
|
+
w: 1
|
|
2773
|
+
}
|
|
2774
|
+
},
|
|
2775
|
+
id: "box"
|
|
2776
|
+
}
|
|
2777
|
+
]
|
|
2778
|
+
},
|
|
2779
|
+
init_pose: {
|
|
2780
|
+
position: {
|
|
2781
|
+
x: 0,
|
|
2782
|
+
y: 0,
|
|
2783
|
+
z: 0
|
|
2784
|
+
},
|
|
2785
|
+
orientation: {
|
|
2786
|
+
x: 0,
|
|
2787
|
+
y: 0,
|
|
2788
|
+
z: 0,
|
|
2789
|
+
w: 1
|
|
2790
|
+
}
|
|
2791
|
+
},
|
|
2792
|
+
id: "Cell workzone"
|
|
2793
|
+
},
|
|
2794
|
+
motion_group_uid: 1
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
id: 2,
|
|
2798
|
+
priority: 0,
|
|
2799
|
+
geometry: {
|
|
2800
|
+
convex_hull: {
|
|
2801
|
+
vertices: [
|
|
2802
|
+
{
|
|
2803
|
+
x: 1650,
|
|
2804
|
+
y: 1330,
|
|
2805
|
+
z: -1850
|
|
2806
|
+
},
|
|
2807
|
+
{
|
|
2808
|
+
x: 865,
|
|
2809
|
+
y: 1330,
|
|
2810
|
+
z: -1850
|
|
2811
|
+
},
|
|
2812
|
+
{
|
|
2813
|
+
x: 865,
|
|
2814
|
+
y: -720,
|
|
2815
|
+
z: -1850
|
|
2816
|
+
},
|
|
2817
|
+
{
|
|
2818
|
+
x: 1650,
|
|
2819
|
+
y: -720,
|
|
2820
|
+
z: -1850
|
|
2821
|
+
},
|
|
2822
|
+
{
|
|
2823
|
+
x: 1650,
|
|
2824
|
+
y: 1330,
|
|
2825
|
+
z: -920
|
|
2826
|
+
},
|
|
2827
|
+
{
|
|
2828
|
+
x: 865,
|
|
2829
|
+
y: 1330,
|
|
2830
|
+
z: -920
|
|
2831
|
+
},
|
|
2832
|
+
{
|
|
2833
|
+
x: 865,
|
|
2834
|
+
y: -720,
|
|
2835
|
+
z: -920
|
|
2836
|
+
},
|
|
2837
|
+
{
|
|
2838
|
+
x: 1650,
|
|
2839
|
+
y: -720,
|
|
2840
|
+
z: -920
|
|
2841
|
+
}
|
|
2842
|
+
]
|
|
2843
|
+
},
|
|
2844
|
+
init_pose: {
|
|
2845
|
+
position: {
|
|
2846
|
+
x: 0,
|
|
2847
|
+
y: 0,
|
|
2848
|
+
z: 0
|
|
2849
|
+
},
|
|
2850
|
+
orientation: {
|
|
2851
|
+
x: 0,
|
|
2852
|
+
y: 0,
|
|
2853
|
+
z: 0,
|
|
2854
|
+
w: 1
|
|
2855
|
+
}
|
|
2856
|
+
},
|
|
2857
|
+
id: "Transport"
|
|
2858
|
+
},
|
|
2859
|
+
motion_group_uid: 1
|
|
2860
|
+
},
|
|
2861
|
+
{
|
|
2862
|
+
id: 3,
|
|
2863
|
+
priority: 0,
|
|
2864
|
+
geometry: {
|
|
2865
|
+
convex_hull: {
|
|
2866
|
+
vertices: [
|
|
2867
|
+
{
|
|
2868
|
+
x: 1650,
|
|
2869
|
+
y: 1330,
|
|
2870
|
+
z: -600
|
|
2871
|
+
},
|
|
2872
|
+
{
|
|
2873
|
+
x: 865,
|
|
2874
|
+
y: 1330,
|
|
2875
|
+
z: -600
|
|
2876
|
+
},
|
|
2877
|
+
{
|
|
2878
|
+
x: 865,
|
|
2879
|
+
y: 430,
|
|
2880
|
+
z: -600
|
|
2881
|
+
},
|
|
2882
|
+
{
|
|
2883
|
+
x: 1650,
|
|
2884
|
+
y: 430,
|
|
2885
|
+
z: -600
|
|
2886
|
+
},
|
|
2887
|
+
{
|
|
2888
|
+
x: 1650,
|
|
2889
|
+
y: 1330,
|
|
2890
|
+
z: -1250
|
|
2891
|
+
},
|
|
2892
|
+
{
|
|
2893
|
+
x: 865,
|
|
2894
|
+
y: 1330,
|
|
2895
|
+
z: -1250
|
|
2896
|
+
},
|
|
2897
|
+
{
|
|
2898
|
+
x: 865,
|
|
2899
|
+
y: 430,
|
|
2900
|
+
z: -1250
|
|
2901
|
+
},
|
|
2902
|
+
{
|
|
2903
|
+
x: 1650,
|
|
2904
|
+
y: 430,
|
|
2905
|
+
z: -1250
|
|
2906
|
+
}
|
|
2907
|
+
]
|
|
2908
|
+
},
|
|
2909
|
+
init_pose: {
|
|
2910
|
+
position: {
|
|
2911
|
+
x: 0,
|
|
2912
|
+
y: 0,
|
|
2913
|
+
z: 0
|
|
2914
|
+
},
|
|
2915
|
+
orientation: {
|
|
2916
|
+
x: 0,
|
|
2917
|
+
y: 0,
|
|
2918
|
+
z: 0,
|
|
2919
|
+
w: 1
|
|
2920
|
+
}
|
|
2921
|
+
},
|
|
2922
|
+
id: "Tunel"
|
|
2923
|
+
},
|
|
2924
|
+
motion_group_uid: 1
|
|
2925
|
+
},
|
|
2926
|
+
{
|
|
2927
|
+
id: 4,
|
|
2928
|
+
priority: 0,
|
|
2929
|
+
geometry: {
|
|
2930
|
+
convex_hull: {
|
|
2931
|
+
vertices: [
|
|
2932
|
+
{
|
|
2933
|
+
x: 1650,
|
|
2934
|
+
y: -760,
|
|
2935
|
+
z: -440
|
|
2936
|
+
},
|
|
2937
|
+
{
|
|
2938
|
+
x: 900,
|
|
2939
|
+
y: -760,
|
|
2940
|
+
z: -440
|
|
2941
|
+
},
|
|
2942
|
+
{
|
|
2943
|
+
x: 900,
|
|
2944
|
+
y: -1330,
|
|
2945
|
+
z: -440
|
|
2946
|
+
},
|
|
2947
|
+
{
|
|
2948
|
+
x: 1650,
|
|
2949
|
+
y: -1330,
|
|
2950
|
+
z: -440
|
|
2951
|
+
},
|
|
2952
|
+
{
|
|
2953
|
+
x: 1650,
|
|
2954
|
+
y: -760,
|
|
2955
|
+
z: -1800
|
|
2956
|
+
},
|
|
2957
|
+
{
|
|
2958
|
+
x: 900,
|
|
2959
|
+
y: -760,
|
|
2960
|
+
z: -1800
|
|
2961
|
+
},
|
|
2962
|
+
{
|
|
2963
|
+
x: 900,
|
|
2964
|
+
y: -1330,
|
|
2965
|
+
z: -1800
|
|
2966
|
+
},
|
|
2967
|
+
{
|
|
2968
|
+
x: 1650,
|
|
2969
|
+
y: -1330,
|
|
2970
|
+
z: -1800
|
|
2971
|
+
}
|
|
2972
|
+
]
|
|
2973
|
+
},
|
|
2974
|
+
init_pose: {
|
|
2975
|
+
position: {
|
|
2976
|
+
x: 0,
|
|
2977
|
+
y: 0,
|
|
2978
|
+
z: 0
|
|
2979
|
+
},
|
|
2980
|
+
orientation: {
|
|
2981
|
+
x: 0,
|
|
2982
|
+
y: 0,
|
|
2983
|
+
z: 0,
|
|
2984
|
+
w: 1
|
|
2985
|
+
}
|
|
2986
|
+
},
|
|
2987
|
+
id: "Fanuc controller"
|
|
2988
|
+
},
|
|
2989
|
+
motion_group_uid: 1
|
|
2990
|
+
},
|
|
2991
|
+
{
|
|
2992
|
+
id: 6,
|
|
2993
|
+
priority: 0,
|
|
2994
|
+
geometry: {
|
|
2995
|
+
convex_hull: {
|
|
2996
|
+
vertices: [
|
|
2997
|
+
{
|
|
2998
|
+
x: -200,
|
|
2999
|
+
y: -200,
|
|
3000
|
+
z: -1900
|
|
3001
|
+
},
|
|
3002
|
+
{
|
|
3003
|
+
x: 200,
|
|
3004
|
+
y: -200,
|
|
3005
|
+
z: -1900
|
|
3006
|
+
},
|
|
3007
|
+
{
|
|
3008
|
+
x: 200,
|
|
3009
|
+
y: 200,
|
|
3010
|
+
z: -1900
|
|
3011
|
+
},
|
|
3012
|
+
{
|
|
3013
|
+
x: -200,
|
|
3014
|
+
y: 200,
|
|
3015
|
+
z: -1900
|
|
3016
|
+
},
|
|
3017
|
+
{
|
|
3018
|
+
x: -200,
|
|
3019
|
+
y: -200,
|
|
3020
|
+
z: -350
|
|
3021
|
+
},
|
|
3022
|
+
{
|
|
3023
|
+
x: 200,
|
|
3024
|
+
y: -200,
|
|
3025
|
+
z: -350
|
|
3026
|
+
},
|
|
3027
|
+
{
|
|
3028
|
+
x: 200,
|
|
3029
|
+
y: 200,
|
|
3030
|
+
z: -350
|
|
3031
|
+
},
|
|
3032
|
+
{
|
|
3033
|
+
x: -200,
|
|
3034
|
+
y: 200,
|
|
3035
|
+
z: -350
|
|
3036
|
+
}
|
|
3037
|
+
]
|
|
3038
|
+
},
|
|
3039
|
+
init_pose: {
|
|
3040
|
+
position: {
|
|
3041
|
+
x: 0,
|
|
3042
|
+
y: 0,
|
|
3043
|
+
z: 0
|
|
3044
|
+
},
|
|
3045
|
+
orientation: {
|
|
3046
|
+
x: 0,
|
|
3047
|
+
y: 0,
|
|
3048
|
+
z: 0,
|
|
3049
|
+
w: 1
|
|
3050
|
+
}
|
|
3051
|
+
},
|
|
3052
|
+
id: "Robot base"
|
|
3053
|
+
},
|
|
3054
|
+
motion_group_uid: 1
|
|
3055
|
+
}
|
|
3056
|
+
],
|
|
3057
|
+
robot_model_geometries: [
|
|
3058
|
+
{
|
|
3059
|
+
link_index: 1,
|
|
3060
|
+
geometry: {
|
|
3061
|
+
sphere: {
|
|
3062
|
+
radius: 270
|
|
3063
|
+
},
|
|
3064
|
+
init_pose: {
|
|
3065
|
+
position: {
|
|
3066
|
+
x: -70,
|
|
3067
|
+
y: -70,
|
|
3068
|
+
z: -50
|
|
3069
|
+
},
|
|
3070
|
+
orientation: {
|
|
3071
|
+
x: 0,
|
|
3072
|
+
y: 0,
|
|
3073
|
+
z: 0,
|
|
3074
|
+
w: 1
|
|
3075
|
+
}
|
|
3076
|
+
},
|
|
3077
|
+
id: "link1_sphere"
|
|
3078
|
+
}
|
|
3079
|
+
},
|
|
3080
|
+
{
|
|
3081
|
+
link_index: 2,
|
|
3082
|
+
geometry: {
|
|
3083
|
+
capsule: {
|
|
3084
|
+
radius: 160,
|
|
3085
|
+
cylinder_height: 800
|
|
3086
|
+
},
|
|
3087
|
+
init_pose: {
|
|
3088
|
+
position: {
|
|
3089
|
+
x: -450,
|
|
3090
|
+
y: 40,
|
|
3091
|
+
z: 170
|
|
3092
|
+
},
|
|
3093
|
+
orientation: {
|
|
3094
|
+
x: 0,
|
|
3095
|
+
y: -0.7071067811865475,
|
|
3096
|
+
z: 0,
|
|
3097
|
+
w: 0.7071067811865476
|
|
3098
|
+
}
|
|
3099
|
+
},
|
|
3100
|
+
id: "link2_capsule"
|
|
3101
|
+
}
|
|
3102
|
+
},
|
|
3103
|
+
{
|
|
3104
|
+
link_index: 3,
|
|
3105
|
+
geometry: {
|
|
3106
|
+
sphere: {
|
|
3107
|
+
radius: 270
|
|
3108
|
+
},
|
|
3109
|
+
init_pose: {
|
|
3110
|
+
position: {
|
|
3111
|
+
x: -110,
|
|
3112
|
+
y: 10,
|
|
3113
|
+
z: -100
|
|
3114
|
+
},
|
|
3115
|
+
orientation: {
|
|
3116
|
+
x: 0,
|
|
3117
|
+
y: 0,
|
|
3118
|
+
z: 0,
|
|
3119
|
+
w: 1
|
|
3120
|
+
}
|
|
3121
|
+
},
|
|
3122
|
+
id: "link3_sphere"
|
|
3123
|
+
}
|
|
3124
|
+
},
|
|
3125
|
+
{
|
|
3126
|
+
link_index: 4,
|
|
3127
|
+
geometry: {
|
|
3128
|
+
capsule: {
|
|
3129
|
+
radius: 110,
|
|
3130
|
+
cylinder_height: 600
|
|
3131
|
+
},
|
|
3132
|
+
init_pose: {
|
|
3133
|
+
position: {
|
|
3134
|
+
x: 0,
|
|
3135
|
+
y: 300,
|
|
3136
|
+
z: 40
|
|
3137
|
+
},
|
|
3138
|
+
orientation: {
|
|
3139
|
+
x: -0.7071067811865475,
|
|
3140
|
+
y: 0,
|
|
3141
|
+
z: 0,
|
|
3142
|
+
w: 0.7071067811865476
|
|
3143
|
+
}
|
|
3144
|
+
},
|
|
3145
|
+
id: "link4_capsule"
|
|
3146
|
+
}
|
|
3147
|
+
},
|
|
3148
|
+
{
|
|
3149
|
+
link_index: 5,
|
|
3150
|
+
geometry: {
|
|
3151
|
+
sphere: {
|
|
3152
|
+
radius: 75
|
|
3153
|
+
},
|
|
3154
|
+
init_pose: {
|
|
3155
|
+
position: {
|
|
3156
|
+
x: 0,
|
|
3157
|
+
y: 0,
|
|
3158
|
+
z: -50
|
|
3159
|
+
},
|
|
3160
|
+
orientation: {
|
|
3161
|
+
x: 0,
|
|
3162
|
+
y: 0,
|
|
3163
|
+
z: 0,
|
|
3164
|
+
w: 1
|
|
3165
|
+
}
|
|
3166
|
+
},
|
|
3167
|
+
id: "link5_sphere"
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
],
|
|
3171
|
+
tool_geometries: []
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
},
|
|
3175
|
+
{
|
|
3176
|
+
method: "GET",
|
|
3177
|
+
path: "/cells/:cellId/coordinate-systems",
|
|
3178
|
+
handle() {
|
|
3179
|
+
return {
|
|
3180
|
+
coordinatesystems: [
|
|
3181
|
+
{
|
|
3182
|
+
coordinate_system: "",
|
|
3183
|
+
name: "world",
|
|
3184
|
+
reference_uid: "",
|
|
3185
|
+
position: {
|
|
3186
|
+
x: 0,
|
|
3187
|
+
y: 0,
|
|
3188
|
+
z: 0
|
|
3189
|
+
},
|
|
3190
|
+
rotation: {
|
|
3191
|
+
angles: [0, 0, 0],
|
|
3192
|
+
type: "ROTATION_VECTOR"
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
]
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
},
|
|
3199
|
+
{
|
|
3200
|
+
method: "GET",
|
|
3201
|
+
path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
|
|
3202
|
+
handle() {
|
|
3203
|
+
return {
|
|
3204
|
+
tcps: [
|
|
3205
|
+
{
|
|
3206
|
+
id: "Flange",
|
|
3207
|
+
readable_name: "Default-Flange",
|
|
3208
|
+
position: {
|
|
3209
|
+
x: 0,
|
|
3210
|
+
y: 0,
|
|
3211
|
+
z: 0
|
|
3212
|
+
},
|
|
3213
|
+
rotation: {
|
|
3214
|
+
angles: [0, 0, 0, 0],
|
|
3215
|
+
type: "ROTATION_VECTOR"
|
|
3216
|
+
}
|
|
3217
|
+
},
|
|
3218
|
+
{
|
|
3219
|
+
id: "complex-tcp-position",
|
|
3220
|
+
readable_name: "Complex TCP Position",
|
|
3221
|
+
position: {
|
|
3222
|
+
x: -200,
|
|
3223
|
+
y: 300,
|
|
3224
|
+
z: 150
|
|
3225
|
+
},
|
|
3226
|
+
rotation: {
|
|
3227
|
+
angles: [
|
|
3228
|
+
-0.12139440409113832,
|
|
3229
|
+
-0.06356210998212003,
|
|
3230
|
+
-0.2023240068185639,
|
|
3231
|
+
0
|
|
3232
|
+
],
|
|
3233
|
+
type: "ROTATION_VECTOR"
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
]
|
|
3237
|
+
};
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
];
|
|
3241
|
+
const method = ((_a = config.method) == null ? void 0 : _a.toUpperCase()) || "GET";
|
|
3242
|
+
const path = "/cells" + ((_c = (_b = config.url) == null ? void 0 : _b.split("/cells")[1]) == null ? void 0 : _c.split("?")[0]);
|
|
3243
|
+
for (const handler of apiHandlers) {
|
|
3244
|
+
const match2 = pathToRegexp.match(handler.path)(path || "");
|
|
3245
|
+
if (method === handler.method && match2) {
|
|
3246
|
+
const json = handler.handle();
|
|
3247
|
+
return {
|
|
3248
|
+
status: 200,
|
|
3249
|
+
statusText: "Success",
|
|
3250
|
+
data: JSON.stringify(json),
|
|
3251
|
+
headers: {},
|
|
3252
|
+
config,
|
|
3253
|
+
request: {
|
|
3254
|
+
responseURL: config.url
|
|
3255
|
+
}
|
|
3256
|
+
};
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
throw new import_axios2.AxiosError(
|
|
3260
|
+
`No mock handler matched this request: ${method} ${path}`,
|
|
3261
|
+
"404",
|
|
3262
|
+
config
|
|
3263
|
+
);
|
|
3264
|
+
});
|
|
3265
|
+
}
|
|
3266
|
+
handleWebsocketConnection(socket) {
|
|
3267
|
+
this.connections.push(socket);
|
|
3268
|
+
setTimeout(() => {
|
|
3269
|
+
socket.dispatchEvent(new Event("open"));
|
|
3270
|
+
console.log("Websocket connection opened from", socket.url);
|
|
3271
|
+
if (socket.url.includes("/state-stream")) {
|
|
3272
|
+
socket.dispatchEvent(
|
|
3273
|
+
new MessageEvent("message", {
|
|
3274
|
+
data: JSON.stringify(defaultMotionState)
|
|
3275
|
+
})
|
|
3276
|
+
);
|
|
3277
|
+
}
|
|
3278
|
+
if (socket.url.includes("/move-joint")) {
|
|
3279
|
+
socket.dispatchEvent(
|
|
3280
|
+
new MessageEvent("message", {
|
|
3281
|
+
data: JSON.stringify({
|
|
3282
|
+
result: {
|
|
3283
|
+
motion_group: "0@ur",
|
|
3284
|
+
state: {
|
|
3285
|
+
controller: "ur",
|
|
3286
|
+
operation_mode: "OPERATION_MODE_AUTO",
|
|
3287
|
+
safety_state: "SAFETY_STATE_NORMAL",
|
|
3288
|
+
timestamp: "2024-09-18T12:48:26.096266444Z",
|
|
3289
|
+
velocity_override: 100,
|
|
3290
|
+
motion_groups: [
|
|
3291
|
+
{
|
|
3292
|
+
motion_group: "0@ur",
|
|
3293
|
+
controller: "ur",
|
|
3294
|
+
joint_position: {
|
|
3295
|
+
joints: [
|
|
3296
|
+
1.3492152690887451,
|
|
3297
|
+
-1.5659207105636597,
|
|
3298
|
+
1.6653711795806885,
|
|
3299
|
+
-1.0991662740707397,
|
|
3300
|
+
-1.829018235206604,
|
|
3301
|
+
1.264623761177063
|
|
3302
|
+
]
|
|
3303
|
+
},
|
|
3304
|
+
joint_velocity: {
|
|
3305
|
+
joints: [0, 0, 0, 0, 0, 0]
|
|
3306
|
+
},
|
|
3307
|
+
flange_pose: {
|
|
3308
|
+
position: {
|
|
3309
|
+
x: 6.437331889439328,
|
|
3310
|
+
y: -628.4123774830913,
|
|
3311
|
+
z: 577.0569957147832
|
|
3312
|
+
},
|
|
3313
|
+
orientation: {
|
|
3314
|
+
x: -1.683333649797158,
|
|
3315
|
+
y: -1.9783363827298732,
|
|
3316
|
+
z: -0.4928031860165713
|
|
3317
|
+
},
|
|
3318
|
+
coordinate_system: ""
|
|
3319
|
+
},
|
|
3320
|
+
tcp_pose: {
|
|
3321
|
+
position: {
|
|
3322
|
+
x: 6.437331889439328,
|
|
3323
|
+
y: -628.4123774830913,
|
|
3324
|
+
z: 577.0569957147832
|
|
3325
|
+
},
|
|
3326
|
+
orientation: {
|
|
3327
|
+
x: -1.683333649797158,
|
|
3328
|
+
y: -1.9783363827298732,
|
|
3329
|
+
z: -0.4928031860165713
|
|
3330
|
+
},
|
|
3331
|
+
coordinate_system: "",
|
|
3332
|
+
tcp: "Flange"
|
|
3333
|
+
},
|
|
3334
|
+
velocity: {
|
|
3335
|
+
linear: {
|
|
3336
|
+
x: 0,
|
|
3337
|
+
y: 0,
|
|
3338
|
+
z: 0
|
|
3339
|
+
},
|
|
3340
|
+
angular: {
|
|
3341
|
+
x: -0,
|
|
3342
|
+
y: 0,
|
|
3343
|
+
z: 0
|
|
3344
|
+
},
|
|
3345
|
+
coordinate_system: ""
|
|
3346
|
+
},
|
|
3347
|
+
force: {
|
|
3348
|
+
force: {
|
|
3349
|
+
x: 0,
|
|
3350
|
+
y: 0,
|
|
3351
|
+
z: 0
|
|
3352
|
+
},
|
|
3353
|
+
moment: {
|
|
3354
|
+
x: 0,
|
|
3355
|
+
y: 0,
|
|
3356
|
+
z: 0
|
|
3357
|
+
},
|
|
3358
|
+
coordinate_system: ""
|
|
3359
|
+
},
|
|
3360
|
+
joint_limit_reached: {
|
|
3361
|
+
limit_reached: [
|
|
3362
|
+
false,
|
|
3363
|
+
false,
|
|
3364
|
+
false,
|
|
3365
|
+
false,
|
|
3366
|
+
false,
|
|
3367
|
+
false
|
|
3368
|
+
]
|
|
3369
|
+
},
|
|
3370
|
+
joint_current: {
|
|
3371
|
+
joints: [0, 0, 0, 0, 0, 0]
|
|
3372
|
+
},
|
|
3373
|
+
sequence_number: "671259"
|
|
3374
|
+
}
|
|
3375
|
+
],
|
|
3376
|
+
sequence_number: "671259"
|
|
3377
|
+
},
|
|
3378
|
+
movement_state: "MOVEMENT_STATE_MOVING"
|
|
3379
|
+
}
|
|
3380
|
+
})
|
|
3381
|
+
})
|
|
3382
|
+
);
|
|
3383
|
+
}
|
|
3384
|
+
if (socket.url.includes("/move-tcp")) {
|
|
3385
|
+
socket.dispatchEvent(
|
|
3386
|
+
new MessageEvent("message", {
|
|
3387
|
+
data: JSON.stringify({
|
|
3388
|
+
result: {
|
|
3389
|
+
motion_group: "0@ur",
|
|
3390
|
+
state: {
|
|
3391
|
+
controller: "ur",
|
|
3392
|
+
operation_mode: "OPERATION_MODE_AUTO",
|
|
3393
|
+
safety_state: "SAFETY_STATE_NORMAL",
|
|
3394
|
+
timestamp: "2024-09-18T12:43:12.188335774Z",
|
|
3395
|
+
velocity_override: 100,
|
|
3396
|
+
motion_groups: [
|
|
3397
|
+
{
|
|
3398
|
+
motion_group: "0@ur",
|
|
3399
|
+
controller: "ur",
|
|
3400
|
+
joint_position: {
|
|
3401
|
+
joints: [
|
|
3402
|
+
1.3352527618408203,
|
|
3403
|
+
-1.5659207105636597,
|
|
3404
|
+
1.6653711795806885,
|
|
3405
|
+
-1.110615611076355,
|
|
3406
|
+
-1.829018235206604,
|
|
3407
|
+
1.264623761177063
|
|
3408
|
+
]
|
|
3409
|
+
},
|
|
3410
|
+
joint_velocity: {
|
|
3411
|
+
joints: [0, 0, 0, 0, 0, 0]
|
|
3412
|
+
},
|
|
3413
|
+
flange_pose: {
|
|
3414
|
+
position: {
|
|
3415
|
+
x: -2.763015284002938,
|
|
3416
|
+
y: -630.2151479701106,
|
|
3417
|
+
z: 577.524509114342
|
|
3418
|
+
},
|
|
3419
|
+
orientation: {
|
|
3420
|
+
x: -1.704794877102097,
|
|
3421
|
+
y: -1.9722372952861567,
|
|
3422
|
+
z: -0.4852079204210754
|
|
3423
|
+
},
|
|
3424
|
+
coordinate_system: ""
|
|
3425
|
+
},
|
|
3426
|
+
tcp_pose: {
|
|
3427
|
+
position: {
|
|
3428
|
+
x: -2.763015284002938,
|
|
3429
|
+
y: -630.2151479701106,
|
|
3430
|
+
z: 577.524509114342
|
|
3431
|
+
},
|
|
3432
|
+
orientation: {
|
|
3433
|
+
x: -1.704794877102097,
|
|
3434
|
+
y: -1.9722372952861567,
|
|
3435
|
+
z: -0.4852079204210754
|
|
3436
|
+
},
|
|
3437
|
+
coordinate_system: "",
|
|
3438
|
+
tcp: "Flange"
|
|
3439
|
+
},
|
|
3440
|
+
velocity: {
|
|
3441
|
+
linear: {
|
|
3442
|
+
x: 0,
|
|
3443
|
+
y: 0,
|
|
3444
|
+
z: 0
|
|
3445
|
+
},
|
|
3446
|
+
angular: {
|
|
3447
|
+
x: -0,
|
|
3448
|
+
y: 0,
|
|
3449
|
+
z: 0
|
|
3450
|
+
},
|
|
3451
|
+
coordinate_system: ""
|
|
3452
|
+
},
|
|
3453
|
+
force: {
|
|
3454
|
+
force: {
|
|
3455
|
+
x: 0,
|
|
3456
|
+
y: 0,
|
|
3457
|
+
z: 0
|
|
3458
|
+
},
|
|
3459
|
+
moment: {
|
|
3460
|
+
x: 0,
|
|
3461
|
+
y: 0,
|
|
3462
|
+
z: 0
|
|
3463
|
+
},
|
|
3464
|
+
coordinate_system: ""
|
|
3465
|
+
},
|
|
3466
|
+
joint_limit_reached: {
|
|
3467
|
+
limit_reached: [
|
|
3468
|
+
false,
|
|
3469
|
+
false,
|
|
3470
|
+
false,
|
|
3471
|
+
false,
|
|
3472
|
+
false,
|
|
3473
|
+
false
|
|
3474
|
+
]
|
|
3475
|
+
},
|
|
3476
|
+
joint_current: {
|
|
3477
|
+
joints: [0, 0, 0, 0, 0, 0]
|
|
3478
|
+
},
|
|
3479
|
+
sequence_number: "627897"
|
|
3480
|
+
}
|
|
3481
|
+
],
|
|
3482
|
+
sequence_number: "627897"
|
|
3483
|
+
},
|
|
3484
|
+
movement_state: "MOVEMENT_STATE_MOVING"
|
|
3485
|
+
}
|
|
3486
|
+
})
|
|
3487
|
+
})
|
|
3488
|
+
);
|
|
3489
|
+
}
|
|
3490
|
+
}, 10);
|
|
3491
|
+
}
|
|
3492
|
+
handleWebsocketMessage(socket, message) {
|
|
3493
|
+
console.log(`Received message on ${socket.url}`, message);
|
|
3494
|
+
}
|
|
3495
|
+
};
|
|
3496
|
+
var defaultMotionState = {
|
|
3497
|
+
result: {
|
|
3498
|
+
state: {
|
|
3499
|
+
motion_group: "0@universalrobots-ur5e",
|
|
3500
|
+
controller: "universalrobots-ur5e",
|
|
3501
|
+
joint_position: {
|
|
3502
|
+
joints: [
|
|
3503
|
+
1.1699999570846558,
|
|
3504
|
+
-1.5700000524520874,
|
|
3505
|
+
1.3600000143051147,
|
|
3506
|
+
1.0299999713897705,
|
|
3507
|
+
1.2899999618530273,
|
|
3508
|
+
1.2799999713897705
|
|
3509
|
+
]
|
|
3510
|
+
},
|
|
3511
|
+
joint_velocity: {
|
|
3512
|
+
joints: [0, 0, 0, 0, 0, 0]
|
|
3513
|
+
},
|
|
3514
|
+
flange_pose: {
|
|
3515
|
+
position: {
|
|
3516
|
+
x: 1.3300010259703043,
|
|
3517
|
+
y: -409.2680714682808,
|
|
3518
|
+
z: 531.0203477065281
|
|
3519
|
+
},
|
|
3520
|
+
orientation: {
|
|
3521
|
+
x: 1.7564919306270736,
|
|
3522
|
+
y: -1.7542521568325058,
|
|
3523
|
+
z: 0.7326972590614671
|
|
3524
|
+
},
|
|
3525
|
+
coordinate_system: ""
|
|
3526
|
+
},
|
|
3527
|
+
tcp_pose: {
|
|
3528
|
+
position: {
|
|
3529
|
+
x: 1.3300010259703043,
|
|
3530
|
+
y: -409.2680714682808,
|
|
3531
|
+
z: 531.0203477065281
|
|
3532
|
+
},
|
|
3533
|
+
orientation: {
|
|
3534
|
+
x: 1.7564919306270736,
|
|
3535
|
+
y: -1.7542521568325058,
|
|
3536
|
+
z: 0.7326972590614671
|
|
3537
|
+
},
|
|
3538
|
+
coordinate_system: "",
|
|
3539
|
+
tcp: "Flange"
|
|
3540
|
+
},
|
|
3541
|
+
velocity: {
|
|
3542
|
+
linear: {
|
|
3543
|
+
x: 0,
|
|
3544
|
+
y: 0,
|
|
3545
|
+
z: 0
|
|
3546
|
+
},
|
|
3547
|
+
angular: {
|
|
3548
|
+
x: 0,
|
|
3549
|
+
y: 0,
|
|
3550
|
+
z: 0
|
|
3551
|
+
},
|
|
3552
|
+
coordinate_system: ""
|
|
3553
|
+
},
|
|
3554
|
+
force: {
|
|
3555
|
+
force: {
|
|
3556
|
+
x: 0,
|
|
3557
|
+
y: 0,
|
|
3558
|
+
z: 0
|
|
3559
|
+
},
|
|
3560
|
+
moment: {
|
|
3561
|
+
x: 0,
|
|
3562
|
+
y: 0,
|
|
3563
|
+
z: 0
|
|
3564
|
+
},
|
|
3565
|
+
coordinate_system: ""
|
|
3566
|
+
},
|
|
3567
|
+
joint_limit_reached: {
|
|
3568
|
+
limit_reached: [false, false, false, false, false, false]
|
|
3569
|
+
},
|
|
3570
|
+
joint_current: {
|
|
3571
|
+
joints: [0, 0, 0, 0, 0, 0]
|
|
3572
|
+
}
|
|
3573
|
+
},
|
|
3574
|
+
tcp_pose: {
|
|
3575
|
+
position: {
|
|
3576
|
+
x: 302.90748476115556,
|
|
3577
|
+
y: -152.87065869452337,
|
|
3578
|
+
z: 424.0454619321661
|
|
3579
|
+
},
|
|
3580
|
+
orientation: {
|
|
3581
|
+
x: 2.3403056115045353,
|
|
3582
|
+
y: -1.1706836379431356,
|
|
3583
|
+
z: 0.9772511964246311
|
|
3584
|
+
},
|
|
3585
|
+
coordinate_system: "",
|
|
3586
|
+
tcp: "Flange"
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
};
|
|
3590
|
+
|
|
3591
|
+
// src/lib/v1/NovaClient.ts
|
|
3592
|
+
var NovaClient = class {
|
|
3593
|
+
constructor(config) {
|
|
3594
|
+
this.authPromise = null;
|
|
3595
|
+
this.accessToken = null;
|
|
3596
|
+
var _a;
|
|
3597
|
+
const cellId = (_a = config.cellId) != null ? _a : "cell";
|
|
3598
|
+
this.config = __spreadValues({
|
|
3599
|
+
cellId
|
|
3600
|
+
}, config);
|
|
3601
|
+
this.accessToken = config.accessToken || availableStorage.getString("wbjs.access_token") || null;
|
|
3602
|
+
if (this.config.instanceUrl === "https://mock.example.com") {
|
|
3603
|
+
this.mock = new MockNovaInstance();
|
|
3604
|
+
}
|
|
3605
|
+
const axiosInstance = import_axios3.default.create({
|
|
3606
|
+
baseURL: (0, import_url_join.default)(this.config.instanceUrl, "/api/v1")
|
|
3607
|
+
});
|
|
3608
|
+
axiosInstance.interceptors.request.use((request) => __async(this, null, function* () {
|
|
3609
|
+
if (!request.headers.Authorization) {
|
|
3610
|
+
if (this.accessToken) {
|
|
3611
|
+
request.headers.Authorization = `Bearer ${this.accessToken}`;
|
|
3612
|
+
} else if (this.config.username && this.config.password) {
|
|
3613
|
+
request.headers.Authorization = `Basic ${btoa(config.username + ":" + config.password)}`;
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
return request;
|
|
3617
|
+
}));
|
|
3618
|
+
if (typeof window !== "undefined") {
|
|
3619
|
+
axiosInstance.interceptors.response.use(
|
|
3620
|
+
(r) => r,
|
|
3621
|
+
(error) => __async(this, null, function* () {
|
|
3622
|
+
var _a2, _b;
|
|
3623
|
+
if ((0, import_axios3.isAxiosError)(error)) {
|
|
3624
|
+
if (((_a2 = error.response) == null ? void 0 : _a2.status) === 401) {
|
|
3625
|
+
try {
|
|
3626
|
+
yield this.renewAuthentication();
|
|
3627
|
+
if (error.config) {
|
|
3628
|
+
if (this.accessToken) {
|
|
3629
|
+
error.config.headers.Authorization = `Bearer ${this.accessToken}`;
|
|
3630
|
+
} else {
|
|
3631
|
+
delete error.config.headers.Authorization;
|
|
3632
|
+
}
|
|
3633
|
+
return axiosInstance.request(error.config);
|
|
3634
|
+
}
|
|
3635
|
+
} catch (err) {
|
|
3636
|
+
return Promise.reject(err);
|
|
3637
|
+
}
|
|
3638
|
+
} else if (((_b = error.response) == null ? void 0 : _b.status) === 503) {
|
|
3639
|
+
const res = yield fetch(window.location.href);
|
|
3640
|
+
if (res.status === 503) {
|
|
3641
|
+
window.location.reload();
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
return Promise.reject(error);
|
|
3646
|
+
})
|
|
3647
|
+
);
|
|
3648
|
+
}
|
|
3649
|
+
this.api = new NovaCellAPIClient(cellId, __spreadProps(__spreadValues({}, config), {
|
|
3650
|
+
basePath: (0, import_url_join.default)(this.config.instanceUrl, "/api/v1"),
|
|
3651
|
+
isJsonMime: (mime) => {
|
|
3652
|
+
return mime === "application/json";
|
|
3653
|
+
},
|
|
3654
|
+
baseOptions: __spreadValues(__spreadValues({}, this.mock ? {
|
|
3655
|
+
adapter: (config2) => {
|
|
3656
|
+
return this.mock.handleAPIRequest(config2);
|
|
3657
|
+
}
|
|
3658
|
+
} : {}), config.baseOptions),
|
|
3659
|
+
axiosInstance
|
|
3660
|
+
}));
|
|
3661
|
+
}
|
|
3662
|
+
renewAuthentication() {
|
|
3663
|
+
return __async(this, null, function* () {
|
|
3664
|
+
if (this.authPromise) {
|
|
3665
|
+
return;
|
|
3666
|
+
}
|
|
3667
|
+
this.authPromise = loginWithAuth0(this.config.instanceUrl);
|
|
3668
|
+
try {
|
|
3669
|
+
this.accessToken = yield this.authPromise;
|
|
3670
|
+
if (this.accessToken) {
|
|
3671
|
+
availableStorage.setString("wbjs.access_token", this.accessToken);
|
|
3672
|
+
} else {
|
|
3673
|
+
availableStorage.delete("wbjs.access_token");
|
|
3674
|
+
}
|
|
3675
|
+
} finally {
|
|
3676
|
+
this.authPromise = null;
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
makeWebsocketURL(path) {
|
|
3681
|
+
const url = new URL(
|
|
3682
|
+
(0, import_url_join.default)(
|
|
3683
|
+
this.config.instanceUrl,
|
|
3684
|
+
`/api/v1/cells/${this.config.cellId}`,
|
|
3685
|
+
path
|
|
3686
|
+
)
|
|
3687
|
+
);
|
|
3688
|
+
url.protocol = url.protocol.replace("http", "ws");
|
|
3689
|
+
url.protocol = url.protocol.replace("https", "wss");
|
|
3690
|
+
if (this.accessToken) {
|
|
3691
|
+
url.searchParams.append("token", this.accessToken);
|
|
3692
|
+
} else if (this.config.username && this.config.password) {
|
|
3693
|
+
url.username = this.config.username;
|
|
3694
|
+
url.password = this.config.password;
|
|
3695
|
+
}
|
|
3696
|
+
return url.toString();
|
|
3697
|
+
}
|
|
3698
|
+
/**
|
|
3699
|
+
* Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.
|
|
3700
|
+
* If you explicitly want to reconnect an existing websocket, call `reconnect`
|
|
3701
|
+
* on the returned object.
|
|
3702
|
+
*/
|
|
3703
|
+
openReconnectingWebsocket(path) {
|
|
3704
|
+
return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {
|
|
3705
|
+
mock: this.mock
|
|
3706
|
+
});
|
|
3707
|
+
}
|
|
3708
|
+
/**
|
|
3709
|
+
* Connect to the motion state websocket(s) for a given motion group
|
|
3710
|
+
*/
|
|
3711
|
+
connectMotionStream(motionGroupId) {
|
|
3712
|
+
return __async(this, null, function* () {
|
|
3713
|
+
return yield MotionStreamConnection.open(this, motionGroupId);
|
|
3714
|
+
});
|
|
3715
|
+
}
|
|
3716
|
+
/**
|
|
3717
|
+
* Connect to the jogging websocket(s) for a given motion group
|
|
3718
|
+
*/
|
|
3719
|
+
connectJogger(motionGroupId) {
|
|
3720
|
+
return __async(this, null, function* () {
|
|
3721
|
+
return yield JoggerConnection.open(this, motionGroupId);
|
|
3722
|
+
});
|
|
3723
|
+
}
|
|
3724
|
+
connectMotionGroups(motionGroupIds) {
|
|
3725
|
+
return __async(this, null, function* () {
|
|
3726
|
+
const { instances } = yield this.api.controller.listControllers();
|
|
3727
|
+
return Promise.all(
|
|
3728
|
+
motionGroupIds.map(
|
|
3729
|
+
(motionGroupId) => ConnectedMotionGroup.connect(this, motionGroupId, instances)
|
|
3730
|
+
)
|
|
3731
|
+
);
|
|
3732
|
+
});
|
|
3733
|
+
}
|
|
3734
|
+
connectMotionGroup(motionGroupId) {
|
|
3735
|
+
return __async(this, null, function* () {
|
|
3736
|
+
const motionGroups = yield this.connectMotionGroups([motionGroupId]);
|
|
3737
|
+
return motionGroups[0];
|
|
3738
|
+
});
|
|
3739
|
+
}
|
|
3740
|
+
};
|
|
3741
|
+
|
|
3742
|
+
// src/lib/v1/ProgramStateConnection.ts
|
|
3743
|
+
var import_axios4 = require("axios");
|
|
3744
|
+
var import_mobx3 = require("mobx");
|
|
3745
|
+
var ProgramState = /* @__PURE__ */ ((ProgramState2) => {
|
|
3746
|
+
ProgramState2["NotStarted"] = "not started";
|
|
3747
|
+
ProgramState2["Running"] = "running";
|
|
3748
|
+
ProgramState2["Stopped"] = "stopped";
|
|
3749
|
+
ProgramState2["Failed"] = "failed";
|
|
3750
|
+
ProgramState2["Completed"] = "completed";
|
|
3751
|
+
return ProgramState2;
|
|
3752
|
+
})(ProgramState || {});
|
|
3753
|
+
var ProgramStateConnection = class {
|
|
3754
|
+
constructor(nova) {
|
|
3755
|
+
this.nova = nova;
|
|
3756
|
+
this.currentProgram = {};
|
|
3757
|
+
this.logs = [];
|
|
3758
|
+
this.executionState = "idle";
|
|
3759
|
+
this.currentlyExecutingProgramRunnerId = null;
|
|
3760
|
+
(0, import_mobx3.makeAutoObservable)(this, {}, { autoBind: true });
|
|
3761
|
+
this.programStateSocket = nova.openReconnectingWebsocket(`/programs/state`);
|
|
3762
|
+
this.programStateSocket.addEventListener("message", (ev) => {
|
|
3763
|
+
const msg = tryParseJson(ev.data);
|
|
3764
|
+
if (!msg) {
|
|
3765
|
+
console.error("Failed to parse program state message", ev.data);
|
|
3766
|
+
return;
|
|
3767
|
+
}
|
|
3768
|
+
if (msg.type === "update") {
|
|
3769
|
+
this.handleProgramStateMessage(msg);
|
|
3770
|
+
}
|
|
3771
|
+
});
|
|
3772
|
+
}
|
|
3773
|
+
/** Handle a program state update from the backend */
|
|
3774
|
+
handleProgramStateMessage(msg) {
|
|
3775
|
+
return __async(this, null, function* () {
|
|
3776
|
+
var _a;
|
|
3777
|
+
const { runner } = msg;
|
|
3778
|
+
if (runner.id !== this.currentlyExecutingProgramRunnerId) return;
|
|
3779
|
+
if (runner.state === "failed" /* Failed */) {
|
|
3780
|
+
try {
|
|
3781
|
+
const runnerState = yield this.nova.api.program.getProgramRunner(
|
|
3782
|
+
runner.id
|
|
3783
|
+
);
|
|
3784
|
+
const stdout = runnerState.stdout;
|
|
3785
|
+
if (stdout) {
|
|
3786
|
+
this.log(stdout);
|
|
3787
|
+
}
|
|
3788
|
+
this.logError(
|
|
3789
|
+
`Program runner ${runner.id} failed with error: ${runnerState.error}
|
|
3790
|
+
${runnerState.traceback}`
|
|
3791
|
+
);
|
|
3792
|
+
} catch (err) {
|
|
3793
|
+
this.logError(
|
|
3794
|
+
`Failed to retrieve results for program ${runner.id}: ${err}`
|
|
3795
|
+
);
|
|
3796
|
+
}
|
|
3797
|
+
this.currentProgram.state = "failed" /* Failed */;
|
|
3798
|
+
this.gotoIdleState();
|
|
3799
|
+
} else if (runner.state === "stopped" /* Stopped */) {
|
|
3800
|
+
try {
|
|
3801
|
+
const runnerState = yield this.nova.api.program.getProgramRunner(
|
|
3802
|
+
runner.id
|
|
3803
|
+
);
|
|
3804
|
+
const stdout = runnerState.stdout;
|
|
3805
|
+
if (stdout) {
|
|
3806
|
+
this.log(stdout);
|
|
3807
|
+
}
|
|
3808
|
+
this.currentProgram.state = "stopped" /* Stopped */;
|
|
3809
|
+
this.log(`Program runner ${runner.id} stopped`);
|
|
3810
|
+
} catch (err) {
|
|
3811
|
+
this.logError(
|
|
3812
|
+
`Failed to retrieve results for program ${runner.id}: ${err}`
|
|
3813
|
+
);
|
|
3814
|
+
}
|
|
3815
|
+
this.gotoIdleState();
|
|
3816
|
+
} else if (runner.state === "completed" /* Completed */) {
|
|
3817
|
+
try {
|
|
3818
|
+
const runnerState = yield this.nova.api.program.getProgramRunner(
|
|
3819
|
+
runner.id
|
|
3820
|
+
);
|
|
3821
|
+
const stdout = runnerState.stdout;
|
|
3822
|
+
if (stdout) {
|
|
3823
|
+
this.log(stdout);
|
|
3824
|
+
}
|
|
3825
|
+
this.log(
|
|
3826
|
+
`Program runner ${runner.id} finished successfully in ${(_a = runner.execution_time) == null ? void 0 : _a.toFixed(2)} seconds`
|
|
3827
|
+
);
|
|
3828
|
+
this.currentProgram.state = "completed" /* Completed */;
|
|
3829
|
+
} catch (err) {
|
|
3830
|
+
this.logError(
|
|
3831
|
+
`Failed to retrieve results for program ${runner.id}: ${err}`
|
|
3832
|
+
);
|
|
3833
|
+
}
|
|
3834
|
+
this.gotoIdleState();
|
|
3835
|
+
} else if (runner.state === "running" /* Running */) {
|
|
3836
|
+
this.currentProgram.state = "running" /* Running */;
|
|
3837
|
+
this.log(`Program runner ${runner.id} now running`);
|
|
3838
|
+
} else if (runner.state !== "not started" /* NotStarted */) {
|
|
3839
|
+
console.error(runner);
|
|
3840
|
+
this.logError(
|
|
3841
|
+
`Program runner ${runner.id} entered unexpected state: ${runner.state}`
|
|
3842
|
+
);
|
|
3843
|
+
this.currentProgram.state = "not started" /* NotStarted */;
|
|
3844
|
+
this.gotoIdleState();
|
|
3845
|
+
}
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3848
|
+
/** Call when a program is no longer executing */
|
|
3849
|
+
gotoIdleState() {
|
|
3850
|
+
(0, import_mobx3.runInAction)(() => {
|
|
3851
|
+
this.executionState = "idle";
|
|
3852
|
+
});
|
|
3853
|
+
this.currentlyExecutingProgramRunnerId = null;
|
|
3854
|
+
}
|
|
3855
|
+
executeProgram(wandelscript, initial_state, activeRobot) {
|
|
3856
|
+
return __async(this, null, function* () {
|
|
3857
|
+
this.currentProgram = {
|
|
3858
|
+
wandelscript,
|
|
3859
|
+
state: "not started" /* NotStarted */
|
|
3860
|
+
};
|
|
3861
|
+
const { currentProgram: openProgram } = this;
|
|
3862
|
+
if (!openProgram) return;
|
|
3863
|
+
(0, import_mobx3.runInAction)(() => {
|
|
3864
|
+
this.executionState = "starting";
|
|
3865
|
+
});
|
|
3866
|
+
if (activeRobot) {
|
|
3867
|
+
try {
|
|
3868
|
+
yield this.nova.api.motionGroupJogging.stopJogging(
|
|
3869
|
+
activeRobot.motionGroupId
|
|
3870
|
+
);
|
|
3871
|
+
} catch (err) {
|
|
3872
|
+
console.error(err);
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
const trimmedCode = openProgram.wandelscript.replaceAll(/^\s*$/gm, "");
|
|
3876
|
+
try {
|
|
3877
|
+
const programRunnerRef = yield this.nova.api.program.createProgramRunner(
|
|
3878
|
+
{
|
|
3879
|
+
code: trimmedCode,
|
|
3880
|
+
initial_state,
|
|
3881
|
+
default_robot: activeRobot == null ? void 0 : activeRobot.wandelscriptIdentifier
|
|
3882
|
+
},
|
|
3883
|
+
{
|
|
3884
|
+
headers: {
|
|
3885
|
+
"Content-Type": "application/json"
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
);
|
|
3889
|
+
this.log(`Created program runner ${programRunnerRef.id}"`);
|
|
3890
|
+
(0, import_mobx3.runInAction)(() => {
|
|
3891
|
+
this.executionState = "executing";
|
|
3892
|
+
});
|
|
3893
|
+
this.currentlyExecutingProgramRunnerId = programRunnerRef.id;
|
|
3894
|
+
} catch (error) {
|
|
3895
|
+
if (error instanceof import_axios4.AxiosError && error.response && error.request) {
|
|
3896
|
+
this.logError(
|
|
3897
|
+
`${error.response.status} ${error.response.statusText} from ${error.response.config.url} ${JSON.stringify(error.response.data)}`
|
|
3898
|
+
);
|
|
3899
|
+
} else {
|
|
3900
|
+
this.logError(JSON.stringify(error));
|
|
3901
|
+
}
|
|
3902
|
+
(0, import_mobx3.runInAction)(() => {
|
|
3903
|
+
this.executionState = "idle";
|
|
3904
|
+
});
|
|
3905
|
+
}
|
|
3906
|
+
});
|
|
3907
|
+
}
|
|
3908
|
+
stopProgram() {
|
|
3909
|
+
return __async(this, null, function* () {
|
|
3910
|
+
if (!this.currentlyExecutingProgramRunnerId) return;
|
|
3911
|
+
(0, import_mobx3.runInAction)(() => {
|
|
3912
|
+
this.executionState = "stopping";
|
|
3913
|
+
});
|
|
3914
|
+
try {
|
|
3915
|
+
yield this.nova.api.program.stopProgramRunner(
|
|
3916
|
+
this.currentlyExecutingProgramRunnerId
|
|
3917
|
+
);
|
|
3918
|
+
} catch (err) {
|
|
3919
|
+
(0, import_mobx3.runInAction)(() => {
|
|
3920
|
+
this.executionState = "executing";
|
|
3921
|
+
});
|
|
3922
|
+
throw err;
|
|
3923
|
+
}
|
|
3924
|
+
});
|
|
3925
|
+
}
|
|
3926
|
+
reset() {
|
|
3927
|
+
this.currentProgram = {};
|
|
3928
|
+
}
|
|
3929
|
+
log(message) {
|
|
3930
|
+
console.log(message);
|
|
3931
|
+
this.logs.push({
|
|
3932
|
+
timestamp: Date.now(),
|
|
3933
|
+
message
|
|
3934
|
+
});
|
|
3935
|
+
}
|
|
3936
|
+
logError(message) {
|
|
3937
|
+
console.log(message);
|
|
3938
|
+
this.logs.push({
|
|
3939
|
+
timestamp: Date.now(),
|
|
3940
|
+
message,
|
|
3941
|
+
level: "error"
|
|
3942
|
+
});
|
|
3943
|
+
}
|
|
3944
|
+
};
|
|
3945
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3946
|
+
0 && (module.exports = {
|
|
3947
|
+
ConnectedMotionGroup,
|
|
3948
|
+
JoggerConnection,
|
|
3949
|
+
MotionStreamConnection,
|
|
3950
|
+
NovaCellAPIClient,
|
|
3951
|
+
NovaClient,
|
|
3952
|
+
ProgramState,
|
|
3953
|
+
ProgramStateConnection,
|
|
3954
|
+
getLatestTrajectories,
|
|
3955
|
+
...require("@wandelbots/nova-api/v1")
|
|
3956
|
+
});
|
|
3957
|
+
//# sourceMappingURL=index.cjs.map
|