@robotical/webapp-types 3.7.8 → 3.7.10
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/dist-types/src/application/ApplicationManager/ApplicationManager.d.ts +24 -1
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +222 -0
- package/dist-types/src/application/RAFTs/Marty/CalibrationManager.d.ts +11 -0
- package/dist-types/src/application/RAFTs/Marty/CalibrationManager.js +153 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +6 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.js +9 -0
- package/dist-types/src/application/RAFTs/Marty/MartyAddonsManager.d.ts +13 -0
- package/dist-types/src/application/RAFTs/Marty/MartyAddonsManager.js +253 -0
- package/dist-types/src/application/RAFTs/Marty/MartyWifiManager.d.ts +19 -0
- package/dist-types/src/application/RAFTs/Marty/MartyWifiManager.js +277 -0
- package/dist-types/src/application/RAFTs/RAFT.d.ts +1 -0
- package/dist-types/src/application/RAFTs/RAFT.js +46 -2
- package/dist-types/src/components/modals/LEDLightsOrQRVerificationModal/index.js +1 -1
- package/dist-types/src/store/SelectedRaftContext.d.ts +2 -0
- package/dist-types/src/store/SelectedRaftContext.js +10 -1
- package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +3 -1
- package/dist-types/src/types/communication-between-apps/wrapper-communication.js +2 -0
- package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.d.ts +2 -1
- package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.js +25 -28
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +16 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.js +47 -0
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +36 -13
- package/dist-types/src/wrapper-app/utils/ColourSensorManualCalibratorMarty.d.ts +19 -0
- package/dist-types/src/wrapper-app/utils/ColourSensorManualCalibratorMarty.js +461 -0
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import Cog from "../RAFTs/Cog/Cog";
|
|
|
6
6
|
import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../types/phone-app-communicator";
|
|
7
7
|
import { RaftObserver } from "../RAFTs/RaftObserver";
|
|
8
8
|
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
9
|
-
import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent } from "@robotical/raftjs";
|
|
9
|
+
import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent, RaftWifiScanResults, RaftWifiConnStatus, RaftOKFail } from "@robotical/raftjs";
|
|
10
10
|
import { ConnectedRaftItem } from "../../store/SelectedRaftContext";
|
|
11
11
|
import Toaster from "../../utils/Toaster";
|
|
12
12
|
import { AnalyticsManager } from "../../analytics/AnalyticsManager";
|
|
@@ -30,9 +30,32 @@ export default class ApplicationManager {
|
|
|
30
30
|
addConnectedRaft: (connectedRaft: ConnectedRaftItem) => void;
|
|
31
31
|
removeConnectedRaft: (connectedRaftId: string) => void;
|
|
32
32
|
setSelectedRaft: (connectedRaftId: string) => void;
|
|
33
|
+
nameUpdated: () => void;
|
|
33
34
|
};
|
|
34
35
|
isPhoneApp: () => boolean;
|
|
35
36
|
constructor();
|
|
37
|
+
updateRaftNameInAllStates(raftId: string, name: string): Promise<boolean>;
|
|
38
|
+
pauseWifiConnectionMarty(raftId: string, pause: boolean): Promise<boolean>;
|
|
39
|
+
getCachedWifiStatusMarty(martyId: string): RaftWifiConnStatus | undefined;
|
|
40
|
+
wifiConnectMarty(martyId: string, ssid: string, password: string): Promise<boolean>;
|
|
41
|
+
wifiDisconnectMarty(martyId: string): Promise<boolean>;
|
|
42
|
+
getWiFiConnStatusMarty(martyId: string): Promise<boolean | null>;
|
|
43
|
+
getWifiScanResultsMarty(martyId: string): Promise<RaftWifiScanResults | RaftOKFail | boolean>;
|
|
44
|
+
calibrateMarty(martyId: string, cmd: string, joints: string): Promise<false | RaftOKFail | undefined>;
|
|
45
|
+
calibrateColourSensorsMarty(raftId: string): Promise<unknown>;
|
|
46
|
+
getCommsStatsMarty(martyId: string): Promise<{
|
|
47
|
+
msgRxRate: number;
|
|
48
|
+
msgRoundtripWorstMs: number;
|
|
49
|
+
msgRoundtripLastMs: number;
|
|
50
|
+
msgRoundtripBestMs: number;
|
|
51
|
+
msgRetries: number;
|
|
52
|
+
}>;
|
|
53
|
+
getConnectedColourSensorsMarty(martyId: string): Promise<any>;
|
|
54
|
+
getConnectedAddOnsMarty(martyId: string): Promise<any>;
|
|
55
|
+
getAddOnConfigsMarty(martyId: string): Promise<any>;
|
|
56
|
+
identifyAddOnMarty(martyId: string, addOnSN: string): Promise<any>;
|
|
57
|
+
setAddOnConfigMarty(martyId: string, addOnSN: string, config: any): Promise<any>;
|
|
58
|
+
deleteAddOnMarty(martyId: string, addOnSN: string): Promise<any>;
|
|
36
59
|
createNewCog(id: string): Cog;
|
|
37
60
|
createNewMarty(id: string): Marty;
|
|
38
61
|
connectGenericMarty(afterRaftConnectedCb: (raft: RAFT) => void): Promise<void>;
|
|
@@ -90,6 +90,7 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
90
90
|
addConnectedRaft: function (connectedRaft) { },
|
|
91
91
|
removeConnectedRaft: function (connectedRaftId) { },
|
|
92
92
|
setSelectedRaft: function (connectedRaftId) { },
|
|
93
|
+
nameUpdated: function () { },
|
|
93
94
|
};
|
|
94
95
|
this.isPhoneApp = isPhoneApp;
|
|
95
96
|
// super();
|
|
@@ -108,6 +109,227 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
108
109
|
Logger.error(SHOW_LOGS, TAG, "Router is not set");
|
|
109
110
|
}
|
|
110
111
|
};
|
|
112
|
+
ApplicationManager.prototype.updateRaftNameInAllStates = function (raftId, name) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var wasSuccessful;
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
if (!this.connectedRafts[raftId]) return [3 /*break*/, 2];
|
|
119
|
+
return [4 /*yield*/, this.connectedRafts[raftId].setRaftName(name)];
|
|
120
|
+
case 1:
|
|
121
|
+
wasSuccessful = _a.sent();
|
|
122
|
+
if (wasSuccessful) {
|
|
123
|
+
this.connectedRaftsContext.forEach(function (connectedRaft) {
|
|
124
|
+
if (connectedRaft.id === raftId) {
|
|
125
|
+
connectedRaft.name = name;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
this.connectedRaftContextMethods.nameUpdated();
|
|
129
|
+
Logger.info(SHOW_LOGS, TAG, "Successfully updated the name of the RAFT with id: ".concat(raftId, " to ").concat(name));
|
|
130
|
+
return [2 /*return*/, true];
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
Logger.error(SHOW_LOGS, TAG, "Failed to update the name of the RAFT with id: ".concat(raftId));
|
|
134
|
+
this.toaster.error("Failed to update the name of the device");
|
|
135
|
+
}
|
|
136
|
+
_a.label = 2;
|
|
137
|
+
case 2: return [2 /*return*/, false];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
//======================//
|
|
143
|
+
/* MARTY WIFI */
|
|
144
|
+
//======================//
|
|
145
|
+
ApplicationManager.prototype.pauseWifiConnectionMarty = function (raftId, pause) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
+
var raft;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
raft = this.connectedRafts[raftId];
|
|
150
|
+
if (raft && raft.type === RaftTypeE.MARTY) {
|
|
151
|
+
return [2 /*return*/, raft.wifiManager.pauseWifiConnection(pause)];
|
|
152
|
+
}
|
|
153
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(raftId, " doesn't exist or is not a Marty"));
|
|
154
|
+
return [2 /*return*/, false];
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
ApplicationManager.prototype.getCachedWifiStatusMarty = function (martyId) {
|
|
159
|
+
var raft = this.connectedRafts[martyId];
|
|
160
|
+
if (raft && raft.type === RaftTypeE.MARTY) {
|
|
161
|
+
return raft.wifiManager.getCachedWifiStatus();
|
|
162
|
+
}
|
|
163
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
164
|
+
return undefined;
|
|
165
|
+
};
|
|
166
|
+
ApplicationManager.prototype.wifiConnectMarty = function (martyId, ssid, password) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var raft;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
raft = this.connectedRafts[martyId];
|
|
171
|
+
if (raft && raft.type === RaftTypeE.MARTY) {
|
|
172
|
+
return [2 /*return*/, raft.wifiManager.wifiConnect(ssid, password)];
|
|
173
|
+
}
|
|
174
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
175
|
+
return [2 /*return*/, false];
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
ApplicationManager.prototype.wifiDisconnectMarty = function (martyId) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
+
var raft;
|
|
182
|
+
return __generator(this, function (_a) {
|
|
183
|
+
raft = this.connectedRafts[martyId];
|
|
184
|
+
if (raft && raft.type === RaftTypeE.MARTY) {
|
|
185
|
+
return [2 /*return*/, raft.wifiManager.wifiDisconnect()];
|
|
186
|
+
}
|
|
187
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
188
|
+
return [2 /*return*/, false];
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
ApplicationManager.prototype.getWiFiConnStatusMarty = function (martyId) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
var raft;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
raft = this.connectedRafts[martyId];
|
|
197
|
+
if (raft && raft.type === RaftTypeE.MARTY) {
|
|
198
|
+
return [2 /*return*/, raft.wifiManager.getWiFiConnStatus()];
|
|
199
|
+
}
|
|
200
|
+
return [2 /*return*/, null];
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
ApplicationManager.prototype.getWifiScanResultsMarty = function (martyId) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
var raft;
|
|
207
|
+
return __generator(this, function (_a) {
|
|
208
|
+
raft = this.connectedRafts[martyId];
|
|
209
|
+
if (raft && raft.type === RaftTypeE.MARTY) {
|
|
210
|
+
return [2 /*return*/, raft.wifiManager.getWifiScanResults()];
|
|
211
|
+
}
|
|
212
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
213
|
+
return [2 /*return*/, false];
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
//======================//
|
|
218
|
+
/* END MARTY WIFI */
|
|
219
|
+
//======================//
|
|
220
|
+
//======================//
|
|
221
|
+
/* CALIBRATION MARTY */
|
|
222
|
+
//======================//
|
|
223
|
+
ApplicationManager.prototype.calibrateMarty = function (martyId, cmd, joints) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
if (this.connectedRafts[martyId]) {
|
|
227
|
+
return [2 /*return*/, this.connectedRafts[martyId].calibrationManager.calibrate(cmd, joints)];
|
|
228
|
+
}
|
|
229
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
230
|
+
return [2 /*return*/];
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
ApplicationManager.prototype.calibrateColourSensorsMarty = function (raftId) {
|
|
235
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
236
|
+
return __generator(this, function (_a) {
|
|
237
|
+
if (this.connectedRafts[raftId]) {
|
|
238
|
+
return [2 /*return*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.MARTY_CALIBRATE_COLOUR_SENSOR, { raftId: raftId })];
|
|
239
|
+
}
|
|
240
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(raftId, " doesn't exist or is not a Marty"));
|
|
241
|
+
return [2 /*return*/];
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
//======================//
|
|
246
|
+
/* END CALIBRATION MARTY*/
|
|
247
|
+
//======================//
|
|
248
|
+
//======================//
|
|
249
|
+
/* COMMS STATS MARTY */
|
|
250
|
+
//======================//
|
|
251
|
+
ApplicationManager.prototype.getCommsStatsMarty = function (martyId) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
return __generator(this, function (_a) {
|
|
254
|
+
return [2 /*return*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.MARTY_GET_COMMS_STATS, { raftId: martyId })];
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
//======================//
|
|
259
|
+
/* END COMMS STATS MARTY*/
|
|
260
|
+
//======================//
|
|
261
|
+
//=====================//
|
|
262
|
+
/* ADDONS MARTY */
|
|
263
|
+
//=====================//
|
|
264
|
+
ApplicationManager.prototype.getConnectedColourSensorsMarty = function (martyId) {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
266
|
+
return __generator(this, function (_a) {
|
|
267
|
+
if (this.connectedRafts[martyId]) {
|
|
268
|
+
return [2 /*return*/, this.connectedRafts[martyId].addonsManager.getConnectedColourSensors()];
|
|
269
|
+
}
|
|
270
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
271
|
+
return [2 /*return*/];
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
ApplicationManager.prototype.getConnectedAddOnsMarty = function (martyId) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
return __generator(this, function (_a) {
|
|
278
|
+
if (this.connectedRafts[martyId]) {
|
|
279
|
+
return [2 /*return*/, this.connectedRafts[martyId].addonsManager.getHWElemList("RSAddOn")];
|
|
280
|
+
}
|
|
281
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
282
|
+
return [2 /*return*/];
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
ApplicationManager.prototype.getAddOnConfigsMarty = function (martyId) {
|
|
287
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
+
return __generator(this, function (_a) {
|
|
289
|
+
if (this.connectedRafts[martyId]) {
|
|
290
|
+
return [2 /*return*/, this.connectedRafts[martyId].addonsManager.getAddOnConfigs()];
|
|
291
|
+
}
|
|
292
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
293
|
+
return [2 /*return*/];
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
ApplicationManager.prototype.identifyAddOnMarty = function (martyId, addOnSN) {
|
|
298
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
299
|
+
return __generator(this, function (_a) {
|
|
300
|
+
if (this.connectedRafts[martyId]) {
|
|
301
|
+
return [2 /*return*/, this.connectedRafts[martyId].addonsManager.identifyAddOn(addOnSN)];
|
|
302
|
+
}
|
|
303
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
304
|
+
return [2 /*return*/];
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
ApplicationManager.prototype.setAddOnConfigMarty = function (martyId, addOnSN, config) {
|
|
309
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
310
|
+
return __generator(this, function (_a) {
|
|
311
|
+
if (this.connectedRafts[martyId]) {
|
|
312
|
+
return [2 /*return*/, this.connectedRafts[martyId].addonsManager.setAddOnConfig(addOnSN, config)];
|
|
313
|
+
}
|
|
314
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
315
|
+
return [2 /*return*/];
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
ApplicationManager.prototype.deleteAddOnMarty = function (martyId, addOnSN) {
|
|
320
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
+
return __generator(this, function (_a) {
|
|
322
|
+
if (this.connectedRafts[martyId]) {
|
|
323
|
+
return [2 /*return*/, this.connectedRafts[martyId].addonsManager.deleteAddOn(addOnSN)];
|
|
324
|
+
}
|
|
325
|
+
Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(martyId, " doesn't exist or is not a Marty"));
|
|
326
|
+
return [2 /*return*/];
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
//=====================//
|
|
331
|
+
/* END ADDONS MARTY */
|
|
332
|
+
//=====================//
|
|
111
333
|
ApplicationManager.prototype.createNewCog = function (id) {
|
|
112
334
|
return new Cog(id);
|
|
113
335
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RaftOKFail } from "@robotical/raftjs";
|
|
2
|
+
import Marty from "./Marty";
|
|
3
|
+
export default class CalibrationManager {
|
|
4
|
+
marty: Marty;
|
|
5
|
+
private _jointNames;
|
|
6
|
+
constructor(marty: Marty);
|
|
7
|
+
calibrate(cmd: string, joints: string): Promise<false | RaftOKFail>;
|
|
8
|
+
_calibrate(cmd: string, jointList: Array<string>, jointNames: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
}): Promise<false | RaftOKFail>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { RaftOKFail } from "@robotical/raftjs";
|
|
38
|
+
import Logger from "../../../services/logger/Logger";
|
|
39
|
+
var SHOW_LOGS = true;
|
|
40
|
+
var TAG = "CalibrationManager";
|
|
41
|
+
var CalibrationManager = /** @class */ (function () {
|
|
42
|
+
function CalibrationManager(marty) {
|
|
43
|
+
this.marty = marty;
|
|
44
|
+
this._jointNames = {
|
|
45
|
+
LeftHip: "LeftHip",
|
|
46
|
+
LeftTwist: "LeftTwist",
|
|
47
|
+
LeftKnee: "LeftKnee",
|
|
48
|
+
RightHip: "RightHip",
|
|
49
|
+
RightTwist: "RightTwist",
|
|
50
|
+
RightKnee: "RightKnee",
|
|
51
|
+
LeftArm: "LeftArm",
|
|
52
|
+
RightArm: "RightArm",
|
|
53
|
+
Eyes: "Eyes",
|
|
54
|
+
};
|
|
55
|
+
this.marty = marty;
|
|
56
|
+
}
|
|
57
|
+
CalibrationManager.prototype.calibrate = function (cmd, joints) {
|
|
58
|
+
// Make a list of joints to calibrate on
|
|
59
|
+
var jointList = new Array();
|
|
60
|
+
if (joints === "legs") {
|
|
61
|
+
jointList.push(this._jointNames.LeftHip);
|
|
62
|
+
jointList.push(this._jointNames.LeftTwist);
|
|
63
|
+
jointList.push(this._jointNames.LeftKnee);
|
|
64
|
+
jointList.push(this._jointNames.RightHip);
|
|
65
|
+
jointList.push(this._jointNames.RightTwist);
|
|
66
|
+
jointList.push(this._jointNames.RightKnee);
|
|
67
|
+
}
|
|
68
|
+
else if (joints === "arms") {
|
|
69
|
+
jointList.push(this._jointNames.LeftArm);
|
|
70
|
+
jointList.push(this._jointNames.RightArm);
|
|
71
|
+
}
|
|
72
|
+
if (joints === "eyes") {
|
|
73
|
+
jointList.push(this._jointNames.Eyes);
|
|
74
|
+
}
|
|
75
|
+
return this._calibrate(cmd, jointList, this._jointNames);
|
|
76
|
+
};
|
|
77
|
+
CalibrationManager.prototype._calibrate = function (cmd, jointList, jointNames) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var overallResult, _i, jointList_1, jnt, cmdUrl, rsl, saveCalibCmd, error_1, _a, _b, _c, _d, jnt, cmdUrl, rsl, error_2, rslt;
|
|
80
|
+
return __generator(this, function (_e) {
|
|
81
|
+
switch (_e.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
overallResult = true;
|
|
84
|
+
if (!(cmd === "set")) return [3 /*break*/, 14];
|
|
85
|
+
_i = 0, jointList_1 = jointList;
|
|
86
|
+
_e.label = 1;
|
|
87
|
+
case 1:
|
|
88
|
+
if (!(_i < jointList_1.length)) return [3 /*break*/, 7];
|
|
89
|
+
jnt = jointList_1[_i];
|
|
90
|
+
_e.label = 2;
|
|
91
|
+
case 2:
|
|
92
|
+
_e.trys.push([2, 5, , 6]);
|
|
93
|
+
cmdUrl = "calibrate/set/" + jnt;
|
|
94
|
+
return [4 /*yield*/, this.marty.sendRestMessage(cmdUrl)];
|
|
95
|
+
case 3:
|
|
96
|
+
rsl = _e.sent();
|
|
97
|
+
saveCalibCmd = "elem/".concat(jnt, "/saveparams");
|
|
98
|
+
return [4 /*yield*/, this.marty.sendRestMessage(saveCalibCmd)];
|
|
99
|
+
case 4:
|
|
100
|
+
_e.sent();
|
|
101
|
+
if (rsl.rslt != "ok")
|
|
102
|
+
overallResult = false;
|
|
103
|
+
return [3 /*break*/, 6];
|
|
104
|
+
case 5:
|
|
105
|
+
error_1 = _e.sent();
|
|
106
|
+
Logger.error(SHOW_LOGS, TAG, "calibrate failed on joint ".concat(jnt, " ").concat(error_1));
|
|
107
|
+
return [3 /*break*/, 6];
|
|
108
|
+
case 6:
|
|
109
|
+
_i++;
|
|
110
|
+
return [3 /*break*/, 1];
|
|
111
|
+
case 7:
|
|
112
|
+
_a = jointNames;
|
|
113
|
+
_b = [];
|
|
114
|
+
for (_c in _a)
|
|
115
|
+
_b.push(_c);
|
|
116
|
+
_d = 0;
|
|
117
|
+
_e.label = 8;
|
|
118
|
+
case 8:
|
|
119
|
+
if (!(_d < _b.length)) return [3 /*break*/, 13];
|
|
120
|
+
_c = _b[_d];
|
|
121
|
+
if (!(_c in _a)) return [3 /*break*/, 12];
|
|
122
|
+
jnt = _c;
|
|
123
|
+
_e.label = 9;
|
|
124
|
+
case 9:
|
|
125
|
+
_e.trys.push([9, 11, , 12]);
|
|
126
|
+
cmdUrl = "servo/" + jnt + "/enable/1";
|
|
127
|
+
return [4 /*yield*/, this.marty.sendRestMessage(cmdUrl)];
|
|
128
|
+
case 10:
|
|
129
|
+
rsl = _e.sent();
|
|
130
|
+
if (rsl.rslt != "ok")
|
|
131
|
+
overallResult = false;
|
|
132
|
+
return [3 /*break*/, 12];
|
|
133
|
+
case 11:
|
|
134
|
+
error_2 = _e.sent();
|
|
135
|
+
Logger.error(SHOW_LOGS, TAG, "enable failed on joint ".concat(jnt, " ").concat(error_2));
|
|
136
|
+
return [3 /*break*/, 12];
|
|
137
|
+
case 12:
|
|
138
|
+
_d++;
|
|
139
|
+
return [3 /*break*/, 8];
|
|
140
|
+
case 13:
|
|
141
|
+
// Result
|
|
142
|
+
Logger.info(SHOW_LOGS, TAG, "Set calibration flag to true");
|
|
143
|
+
rslt = new RaftOKFail();
|
|
144
|
+
rslt.rslt = overallResult ? "ok" : "fail";
|
|
145
|
+
return [2 /*return*/, rslt];
|
|
146
|
+
case 14: return [2 /*return*/, false];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
return CalibrationManager;
|
|
152
|
+
}());
|
|
153
|
+
export default CalibrationManager;
|
|
@@ -4,11 +4,17 @@ import RAFT from "../RAFT";
|
|
|
4
4
|
import { RaftConnEvent, RaftPublishEvent, RaftSystemInfo, RaftUpdateEvent } from "@robotical/raftjs";
|
|
5
5
|
import { RaftInfoEvents } from "../../../types/events/raft-info";
|
|
6
6
|
import { RICLedLcdColours, RICStateInfo } from "@robotical/roboticaljs";
|
|
7
|
+
import { MartyWifiManager } from "./MartyWifiManager";
|
|
8
|
+
import MartyAddonsManager from "./MartyAddonsManager";
|
|
9
|
+
import CalibrationManager from "./CalibrationManager";
|
|
7
10
|
export declare class Marty extends RAFT implements RICInterface {
|
|
8
11
|
id: string;
|
|
9
12
|
type: RaftTypeE;
|
|
10
13
|
raftStateInfo: RICStateInfo | null;
|
|
11
14
|
systemInfo: RaftSystemInfo | null;
|
|
15
|
+
wifiManager: MartyWifiManager;
|
|
16
|
+
addonsManager: MartyAddonsManager;
|
|
17
|
+
calibrationManager: CalibrationManager;
|
|
12
18
|
_ledLcdColours: RICLedLcdColours;
|
|
13
19
|
private rssiValues;
|
|
14
20
|
private MAX_RSSI_VALUES_N;
|
|
@@ -52,6 +52,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
52
52
|
import { RaftTypeE } from "../../../types/raft";
|
|
53
53
|
import RAFT from "../RAFT";
|
|
54
54
|
import { RaftPublishEvent } from "@robotical/raftjs";
|
|
55
|
+
import { MartyWifiManager } from "./MartyWifiManager";
|
|
56
|
+
import MartyAddonsManager from "./MartyAddonsManager";
|
|
57
|
+
import CalibrationManager from "./CalibrationManager";
|
|
55
58
|
var Marty = /** @class */ (function (_super) {
|
|
56
59
|
__extends(Marty, _super);
|
|
57
60
|
function Marty(id) {
|
|
@@ -62,6 +65,12 @@ var Marty = /** @class */ (function (_super) {
|
|
|
62
65
|
_this.raftStateInfo = null;
|
|
63
66
|
// Marty System info
|
|
64
67
|
_this.systemInfo = null;
|
|
68
|
+
// Marty wifi manager
|
|
69
|
+
_this.wifiManager = new MartyWifiManager(_this);
|
|
70
|
+
// Addons Manager
|
|
71
|
+
_this.addonsManager = new MartyAddonsManager(_this);
|
|
72
|
+
// Calibration Manager
|
|
73
|
+
_this.calibrationManager = new CalibrationManager(_this);
|
|
65
74
|
// Colours to use for LED patterns
|
|
66
75
|
_this._ledLcdColours = [
|
|
67
76
|
{ led: "#202000", lcd: "#FFFF00" },
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RICConfiguredAddOns, RICHWElem } from "@robotical/roboticaljs";
|
|
2
|
+
import Marty from "./Marty";
|
|
3
|
+
export default class MartyAddonsManager {
|
|
4
|
+
marty: Marty;
|
|
5
|
+
private _connectedAddOns;
|
|
6
|
+
constructor(marty: Marty);
|
|
7
|
+
getHWElemList(filterByType?: string): Promise<Array<RICHWElem>>;
|
|
8
|
+
getAddOnConfigs(): Promise<RICConfiguredAddOns>;
|
|
9
|
+
identifyAddOn(name: string): Promise<boolean>;
|
|
10
|
+
setAddOnConfig(serialNo: string, newName: string): Promise<boolean>;
|
|
11
|
+
deleteAddOn(serialNo: string): Promise<boolean>;
|
|
12
|
+
getConnectedColourSensors(): Promise<string[]>;
|
|
13
|
+
}
|