@robotical/webapp-types 1.0.7 → 1.0.9
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/analytics/AnalyticsManager.d.ts +28 -0
- package/dist-types/src/analytics/AnalyticsManager.js +171 -0
- package/dist-types/src/application/ApplicationManager/ApplicationManager.d.ts +8 -2
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +23 -8
- package/dist-types/src/application/RAFTs/Cog/Cog.d.ts +1 -1
- package/dist-types/src/application/RAFTs/Cog/Cog.js +1 -1
- package/dist-types/src/application/RAFTs/Cog/PublishedDataAnalyser.d.ts +36 -16
- package/dist-types/src/application/RAFTs/Cog/PublishedDataAnalyser.js +130 -88
- package/dist-types/src/application/RAFTs/Cog/PublishedDataGetter.d.ts +1 -1
- package/dist-types/src/application/RAFTs/Cog/PublishedDataGetter.js +1 -1
- package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +5 -3
- package/dist-types/src/application/RAFTs/Marty/Marty.js +24 -16
- package/dist-types/src/application/RAFTs/RAFT.d.ts +5 -1
- package/dist-types/src/application/RAFTs/RAFT.js +30 -1
- package/dist-types/src/application/RAFTs/RAFTInterface.d.ts +1 -1
- package/dist-types/src/application/RAFTs/RaftObserver.d.ts +1 -1
- package/dist-types/src/application/RAFTs/raft-subscription-helpers.js +1 -1
- package/dist-types/src/components/modals/DisconnectConfirmation/index.js +3 -1
- package/dist-types/src/components/modals/VerificationModal/index.js +1 -1
- package/dist-types/src/components/modals/VerificationModalPhoneApp/index.js +1 -1
- package/dist-types/src/components/oneoffs/LEDs/index.js +1 -1
- package/dist-types/src/components/oneoffs/RaftSignal/index.d.ts +7 -0
- package/dist-types/src/components/oneoffs/{RICSignal → RaftSignal}/index.js +2 -2
- package/dist-types/src/state-observables/modal/ModalState.d.ts +1 -0
- package/dist-types/src/state-observables/modal/ModalState.js +1 -0
- package/dist-types/src/store/SelectedRaftContext.d.ts +2 -0
- package/dist-types/src/store/SelectedRaftContext.js +2 -1
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +2 -2
- package/dist-types/src/wrapper-app/WrapperAppManager.js +3 -3
- package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.d.ts +1 -1
- package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.js +1 -1
- package/dist-types/src/wrapper-app/connectors/Connector.d.ts +2 -2
- package/dist-types/src/wrapper-app/connectors/Connector.js +1 -1
- package/dist-types/src/wrapper-app/connectors/ConnectorInterface.d.ts +1 -1
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.d.ts +1 -1
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.js +1 -1
- package/package.json +1 -1
- package/dist-types/src/components/oneoffs/RICSignal/index.d.ts +0 -7
|
@@ -1,23 +1,76 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
1
16
|
import { raftPubSubscriptionHelper } from "../raft-subscription-helpers";
|
|
2
17
|
import { isVersionGreater_errorCatching } from "../../../utils/helpers/compare-version";
|
|
3
18
|
import PublishedDataGetter from "./PublishedDataGetter";
|
|
4
|
-
|
|
19
|
+
import EventEmitter from "events";
|
|
20
|
+
var PublishedDataAnalyser = /** @class */ (function (_super) {
|
|
21
|
+
__extends(PublishedDataAnalyser, _super);
|
|
5
22
|
function PublishedDataAnalyser(cog) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
var _this = _super.call(this) || this;
|
|
24
|
+
_this.cog = cog;
|
|
25
|
+
_this.eventsMap = {
|
|
26
|
+
tilt: {
|
|
27
|
+
forward: "tiltForward",
|
|
28
|
+
backward: "tiltBackward",
|
|
29
|
+
left: "tiltLeft",
|
|
30
|
+
right: "tiltRight",
|
|
31
|
+
none: "noTilt"
|
|
32
|
+
},
|
|
33
|
+
movementType: {
|
|
34
|
+
shake: "shake",
|
|
35
|
+
move: "move",
|
|
36
|
+
none: "noMovement"
|
|
37
|
+
},
|
|
38
|
+
rotation: {
|
|
39
|
+
clockwise: "rotationClockwise",
|
|
40
|
+
counterClockwise: "rotationCounterClockwise",
|
|
41
|
+
none: "noRotation"
|
|
42
|
+
},
|
|
43
|
+
buttonClick: {
|
|
44
|
+
click: "buttonClick",
|
|
45
|
+
release: "buttonRelease",
|
|
46
|
+
none: "noButtonClick"
|
|
47
|
+
},
|
|
48
|
+
objectSense: {
|
|
49
|
+
left: "objectSenseLeft",
|
|
50
|
+
right: "objectSenseRight",
|
|
51
|
+
none: "noObjectSense"
|
|
52
|
+
},
|
|
53
|
+
lightSense: {
|
|
54
|
+
high: "highLightSense",
|
|
55
|
+
mid: "midLightSense",
|
|
56
|
+
low: "lowLightSense",
|
|
57
|
+
none: "noLightSense"
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
_this.TiltDetection = TiltDetection;
|
|
61
|
+
_this.PublishedDataGetter = PublishedDataGetter;
|
|
62
|
+
_this.cog = cog;
|
|
63
|
+
_this.cogState = {
|
|
64
|
+
tilt: "none",
|
|
65
|
+
movementType: "none",
|
|
66
|
+
rotation: "none",
|
|
67
|
+
buttonClick: "none",
|
|
68
|
+
objectSense: "none",
|
|
69
|
+
lightSense: "none",
|
|
18
70
|
};
|
|
19
|
-
|
|
20
|
-
|
|
71
|
+
_this.pubSub = null;
|
|
72
|
+
_this.subscribeToPublishedData();
|
|
73
|
+
return _this;
|
|
21
74
|
}
|
|
22
75
|
PublishedDataAnalyser.prototype.subscribeToPublishedData = function () {
|
|
23
76
|
var _this = this;
|
|
@@ -31,44 +84,47 @@ var PublishedDataAnalyser = /** @class */ (function () {
|
|
|
31
84
|
(_a = this.pubSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
32
85
|
};
|
|
33
86
|
PublishedDataAnalyser.prototype.analyse = function (data) {
|
|
87
|
+
//@ts-ignore
|
|
34
88
|
var accelData = PublishedDataGetter.getAccelerometerData(data.deviceManager);
|
|
89
|
+
//@ts-ignore
|
|
35
90
|
var gyroData = PublishedDataGetter.getGyroscopeData(data.deviceManager);
|
|
91
|
+
//@ts-ignore
|
|
36
92
|
var lightData = PublishedDataGetter.getLightData(data.deviceManager);
|
|
37
93
|
var isMoving;
|
|
38
94
|
if (accelData)
|
|
39
|
-
isMoving =
|
|
40
|
-
accelData &&
|
|
41
|
-
gyroData &&
|
|
42
|
-
lightData &&
|
|
43
|
-
lightData &&
|
|
44
|
-
lightData &&
|
|
45
|
-
// this.detectIRMessage(data);
|
|
95
|
+
isMoving = shakeDetector.detectShake(accelData.ax, accelData.ay, accelData.az, Date.now(), this);
|
|
96
|
+
accelData && tiltDetection.detectTilt(accelData.ax, accelData.ay, accelData.az, isMoving, this, this.cog.getRaftVersion());
|
|
97
|
+
gyroData && rotationDetection.detectRotation(gyroData.gz, isMoving, this);
|
|
98
|
+
lightData && buttonClickDetection.detectButtonClick(lightData.ir2, this, this.cog.getRaftVersion());
|
|
99
|
+
lightData && objectSenseDetection.detectObjectSense([lightData.ir0, lightData.ir1], this);
|
|
100
|
+
lightData && lightSenseDetection.detectLightSense(lightData.amb0, this);
|
|
46
101
|
};
|
|
47
|
-
PublishedDataAnalyser.prototype.
|
|
48
|
-
|
|
102
|
+
PublishedDataAnalyser.prototype.setTilt = function (tilt) {
|
|
103
|
+
this.cogState.tilt = tilt;
|
|
104
|
+
this.emit(this.eventsMap.tilt[tilt]);
|
|
49
105
|
};
|
|
50
|
-
PublishedDataAnalyser.prototype.
|
|
51
|
-
|
|
106
|
+
PublishedDataAnalyser.prototype.setMovementType = function (movementType) {
|
|
107
|
+
this.cogState.movementType = movementType;
|
|
108
|
+
this.emit(this.eventsMap.movementType[movementType]);
|
|
52
109
|
};
|
|
53
|
-
PublishedDataAnalyser.prototype.
|
|
54
|
-
|
|
110
|
+
PublishedDataAnalyser.prototype.setRotation = function (rotation) {
|
|
111
|
+
this.cogState.rotation = rotation;
|
|
112
|
+
this.emit(this.eventsMap.rotation[rotation]);
|
|
55
113
|
};
|
|
56
|
-
PublishedDataAnalyser.prototype.
|
|
57
|
-
|
|
114
|
+
PublishedDataAnalyser.prototype.setButtonClick = function (buttonClick) {
|
|
115
|
+
this.cogState.buttonClick = buttonClick;
|
|
116
|
+
this.emit(this.eventsMap.buttonClick[buttonClick]);
|
|
58
117
|
};
|
|
59
|
-
PublishedDataAnalyser.prototype.
|
|
60
|
-
|
|
61
|
-
|
|
118
|
+
PublishedDataAnalyser.prototype.setObjectSense = function (objectSense) {
|
|
119
|
+
this.cogState.objectSense = objectSense;
|
|
120
|
+
this.emit(this.eventsMap.objectSense[objectSense]);
|
|
62
121
|
};
|
|
63
|
-
PublishedDataAnalyser.prototype.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
PublishedDataAnalyser.prototype.detectIRMessage = function (data) {
|
|
67
|
-
var irMessageData = data;
|
|
68
|
-
// irMessageDetection.detectIRMessage(data, this.cogState);
|
|
122
|
+
PublishedDataAnalyser.prototype.setLightSense = function (lightSense) {
|
|
123
|
+
this.cogState.lightSense = lightSense;
|
|
124
|
+
this.emit(this.eventsMap.lightSense[lightSense]);
|
|
69
125
|
};
|
|
70
126
|
return PublishedDataAnalyser;
|
|
71
|
-
}());
|
|
127
|
+
}(EventEmitter));
|
|
72
128
|
var TiltDetection = /** @class */ (function () {
|
|
73
129
|
function TiltDetection() {
|
|
74
130
|
}
|
|
@@ -90,7 +146,7 @@ var TiltDetection = /** @class */ (function () {
|
|
|
90
146
|
rotatedZ = rotatedZ; // z remains unchanged as the rotation is around the z-axis
|
|
91
147
|
return { x: rotatedX, y: rotatedY, z: rotatedZ };
|
|
92
148
|
};
|
|
93
|
-
TiltDetection.prototype.detectTilt = function (ax, ay, az, isMoving,
|
|
149
|
+
TiltDetection.prototype.detectTilt = function (ax, ay, az, isMoving, analyser, cogVersion) {
|
|
94
150
|
if (isMoving === void 0) { isMoving = false; }
|
|
95
151
|
if (isMoving)
|
|
96
152
|
return;
|
|
@@ -113,7 +169,7 @@ var TiltDetection = /** @class */ (function () {
|
|
|
113
169
|
var forwardBackwardThreshold = 20 * (Math.PI / 180); // threshold for forward and backward tilt
|
|
114
170
|
var leftRightThreshold = 20 * (Math.PI / 180); // threshold for left and right tilt
|
|
115
171
|
var upDownThreshold = 0.5; // threshold for up and down tilt
|
|
116
|
-
var tiltDirection =
|
|
172
|
+
var tiltDirection = "none";
|
|
117
173
|
if (pitch < -forwardBackwardThreshold) { // && Math.abs(yaw) < upDownThreshold) {
|
|
118
174
|
tiltDirection = "forward";
|
|
119
175
|
}
|
|
@@ -126,7 +182,7 @@ var TiltDetection = /** @class */ (function () {
|
|
|
126
182
|
if (roll > leftRightThreshold) { // && Math.abs(yaw) < upDownThreshold) {
|
|
127
183
|
tiltDirection = "right";
|
|
128
184
|
}
|
|
129
|
-
|
|
185
|
+
analyser.setTilt(tiltDirection);
|
|
130
186
|
};
|
|
131
187
|
return TiltDetection;
|
|
132
188
|
}());
|
|
@@ -146,11 +202,8 @@ var RotationDetection = /** @class */ (function () {
|
|
|
146
202
|
this.dataBuffer.shift();
|
|
147
203
|
}
|
|
148
204
|
};
|
|
149
|
-
RotationDetection.prototype.detectRotation = function (gz, isMoving,
|
|
205
|
+
RotationDetection.prototype.detectRotation = function (gz, isMoving, analyser) {
|
|
150
206
|
if (isMoving === void 0) { isMoving = false; }
|
|
151
|
-
this.bufferSize = this.bufferSize;
|
|
152
|
-
this.DELAY_FOR_ROTATION = this.DELAY_FOR_ROTATION;
|
|
153
|
-
this.ROTATION_THRESHOLD = this.ROTATION_THRESHOLD;
|
|
154
207
|
var currentTime = Date.now();
|
|
155
208
|
this.addToBuffer(gz);
|
|
156
209
|
if (this.dataBuffer.length < this.bufferSize) {
|
|
@@ -165,17 +218,18 @@ var RotationDetection = /** @class */ (function () {
|
|
|
165
218
|
if (metric > this.ROTATION_THRESHOLD || metric < -this.ROTATION_THRESHOLD) {
|
|
166
219
|
this.lastRotationDetectionTime = currentTime;
|
|
167
220
|
this.dataBuffer = [];
|
|
221
|
+
console.log("Rotation detected. Rotation: ", metric > this.ROTATION_THRESHOLD ? "clockwise" : "counter-clockwise");
|
|
168
222
|
if (metric > this.ROTATION_THRESHOLD) {
|
|
169
223
|
// console.log("Clockwise rotation detected:", metric);
|
|
170
|
-
|
|
224
|
+
analyser.setRotation("clockwise");
|
|
171
225
|
}
|
|
172
226
|
else if (metric < -this.ROTATION_THRESHOLD) {
|
|
173
227
|
// console.log("Counter-clockwise rotation detected:", metric);
|
|
174
|
-
|
|
228
|
+
analyser.setRotation("counterClockwise");
|
|
175
229
|
}
|
|
176
230
|
}
|
|
177
231
|
else {
|
|
178
|
-
|
|
232
|
+
analyser.setRotation("none");
|
|
179
233
|
}
|
|
180
234
|
};
|
|
181
235
|
RotationDetection.prototype.calculateMetric = function () {
|
|
@@ -208,7 +262,7 @@ var ShakeDetector = /** @class */ (function () {
|
|
|
208
262
|
this.shakeInProgress = false;
|
|
209
263
|
this.moveInProgress = false;
|
|
210
264
|
}
|
|
211
|
-
ShakeDetector.prototype.detectShake = function (xAcc, yAcc, zAcc, timestamp,
|
|
265
|
+
ShakeDetector.prototype.detectShake = function (xAcc, yAcc, zAcc, timestamp, analyser) {
|
|
212
266
|
this.thresholdAcceleration = this.thresholdAcceleration;
|
|
213
267
|
this.thresholdAccelerationMove = this.thresholdAccelerationMove;
|
|
214
268
|
this.thresholdShakeNumber = this.thresholdShakeNumber;
|
|
@@ -221,11 +275,11 @@ var ShakeDetector = /** @class */ (function () {
|
|
|
221
275
|
this.gravityVector = [xAcc, yAcc, zAcc];
|
|
222
276
|
if (this.moveInProgress) {
|
|
223
277
|
// console.log("move detected");
|
|
224
|
-
|
|
278
|
+
analyser.setMovementType("move");
|
|
225
279
|
}
|
|
226
280
|
else {
|
|
227
281
|
// console.log("no move detected");
|
|
228
|
-
|
|
282
|
+
analyser.setMovementType("none");
|
|
229
283
|
}
|
|
230
284
|
this.moveInProgress = false;
|
|
231
285
|
this.shakeInProgress = false;
|
|
@@ -256,7 +310,7 @@ var ShakeDetector = /** @class */ (function () {
|
|
|
256
310
|
// console.log("Shake detected!");
|
|
257
311
|
this.sensorBundles = [];
|
|
258
312
|
this.shakeInProgress = false;
|
|
259
|
-
|
|
313
|
+
analyser.setMovementType("shake");
|
|
260
314
|
}
|
|
261
315
|
}
|
|
262
316
|
// this.noMoveCallback();
|
|
@@ -267,7 +321,7 @@ var ShakeDetector = /** @class */ (function () {
|
|
|
267
321
|
this.sensorBundles = [];
|
|
268
322
|
// console.log("resetting shake detector. Move detected");
|
|
269
323
|
// fire move detector
|
|
270
|
-
|
|
324
|
+
analyser.setMovementType("move");
|
|
271
325
|
}
|
|
272
326
|
}
|
|
273
327
|
}
|
|
@@ -285,7 +339,7 @@ var ShakeDetector = /** @class */ (function () {
|
|
|
285
339
|
*/
|
|
286
340
|
}
|
|
287
341
|
};
|
|
288
|
-
ShakeDetector.prototype.performCheck = function (
|
|
342
|
+
ShakeDetector.prototype.performCheck = function (analyser) {
|
|
289
343
|
var _this = this;
|
|
290
344
|
var matrix = [
|
|
291
345
|
[0, 0],
|
|
@@ -308,7 +362,7 @@ var ShakeDetector = /** @class */ (function () {
|
|
|
308
362
|
}
|
|
309
363
|
this.lastTimeShakeDetected = Date.now();
|
|
310
364
|
// console.log("Shake detected!", JSON.stringify(matrix));
|
|
311
|
-
|
|
365
|
+
analyser.setMovementType("shake");
|
|
312
366
|
this.sensorBundles = [];
|
|
313
367
|
}
|
|
314
368
|
};
|
|
@@ -337,7 +391,7 @@ var ButtonClickDetection = /** @class */ (function () {
|
|
|
337
391
|
this.lastTime = 0;
|
|
338
392
|
this.buttonClicked = false;
|
|
339
393
|
}
|
|
340
|
-
ButtonClickDetection.prototype.detectButtonClick = function (buttonValue,
|
|
394
|
+
ButtonClickDetection.prototype.detectButtonClick = function (buttonValue, analyser, cogVersion) {
|
|
341
395
|
var correctionCutOffVersion = "1.2.0";
|
|
342
396
|
var clickThreshold = 1600;
|
|
343
397
|
if (isVersionGreater_errorCatching(cogVersion, correctionCutOffVersion)) {
|
|
@@ -354,12 +408,12 @@ var ButtonClickDetection = /** @class */ (function () {
|
|
|
354
408
|
// console.log("Button clicked", buttonValue);
|
|
355
409
|
this.buttonClicked = true;
|
|
356
410
|
this.lastTime = currentTime;
|
|
357
|
-
|
|
411
|
+
analyser.setButtonClick("click");
|
|
358
412
|
}
|
|
359
413
|
else if (buttonValue < this.releaseThreshold && this.buttonClicked) {
|
|
360
414
|
// console.log("Button released", buttonValue);
|
|
361
415
|
this.buttonClicked = false;
|
|
362
|
-
|
|
416
|
+
analyser.setButtonClick("release");
|
|
363
417
|
}
|
|
364
418
|
// } else {
|
|
365
419
|
// this.buttonClicked = false;
|
|
@@ -374,51 +428,40 @@ var ObjectSenseDetection = /** @class */ (function () {
|
|
|
374
428
|
this.objectSensed1Threshold = 2500; // right of the arrow
|
|
375
429
|
this.objectSensed2Threshold = 1500; // button
|
|
376
430
|
}
|
|
377
|
-
ObjectSenseDetection.prototype.detectObjectSense = function (objectSenseValue,
|
|
431
|
+
ObjectSenseDetection.prototype.detectObjectSense = function (objectSenseValue, analyser) {
|
|
378
432
|
if (objectSenseValue[0] > this.objectSensed0Threshold) {
|
|
379
|
-
|
|
433
|
+
analyser.setObjectSense("left");
|
|
380
434
|
}
|
|
381
435
|
else if (objectSenseValue[1] > this.objectSensed1Threshold) {
|
|
382
|
-
|
|
436
|
+
analyser.setObjectSense("right");
|
|
383
437
|
}
|
|
384
438
|
else {
|
|
385
|
-
|
|
439
|
+
analyser.setObjectSense("none");
|
|
386
440
|
}
|
|
387
441
|
};
|
|
388
442
|
return ObjectSenseDetection;
|
|
389
443
|
}());
|
|
390
444
|
var LightSenseDetection = /** @class */ (function () {
|
|
391
445
|
function LightSenseDetection() {
|
|
392
|
-
this.
|
|
446
|
+
this.lowLightThreshold = 5;
|
|
447
|
+
this.midLightThreshold = 250;
|
|
448
|
+
this.highLightThreshold = 450;
|
|
393
449
|
}
|
|
394
|
-
LightSenseDetection.prototype.detectLightSense = function (lightSenseValue,
|
|
395
|
-
if (lightSenseValue > this.
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
cogState.lightSense = false;
|
|
450
|
+
LightSenseDetection.prototype.detectLightSense = function (lightSenseValue, analyser) {
|
|
451
|
+
if (lightSenseValue > this.highLightThreshold) {
|
|
452
|
+
analyser.setLightSense("high");
|
|
400
453
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}());
|
|
404
|
-
var IRMessageDetection = /** @class */ (function () {
|
|
405
|
-
function IRMessageDetection() {
|
|
406
|
-
this.irMessage0Threshold = 0;
|
|
407
|
-
this.irMessage1Threshold = 0;
|
|
408
|
-
}
|
|
409
|
-
IRMessageDetection.prototype.detectIRMessage = function (irMessageValue, cogState) {
|
|
410
|
-
// placeholder for now
|
|
411
|
-
if (irMessageValue[0] > this.irMessage0Threshold) {
|
|
412
|
-
cogState.irMessage = "left";
|
|
454
|
+
else if (lightSenseValue > this.midLightThreshold) {
|
|
455
|
+
analyser.setLightSense("mid");
|
|
413
456
|
}
|
|
414
|
-
else if (
|
|
415
|
-
|
|
457
|
+
else if (lightSenseValue > this.lowLightThreshold) {
|
|
458
|
+
analyser.setLightSense("low");
|
|
416
459
|
}
|
|
417
460
|
else {
|
|
418
|
-
|
|
461
|
+
analyser.setLightSense("none");
|
|
419
462
|
}
|
|
420
463
|
};
|
|
421
|
-
return
|
|
464
|
+
return LightSenseDetection;
|
|
422
465
|
}());
|
|
423
466
|
var rotationDetection = new RotationDetection();
|
|
424
467
|
var shakeDetector = new ShakeDetector();
|
|
@@ -426,5 +469,4 @@ var buttonClickDetection = new ButtonClickDetection();
|
|
|
426
469
|
var tiltDetection = new TiltDetection();
|
|
427
470
|
var objectSenseDetection = new ObjectSenseDetection();
|
|
428
471
|
var lightSenseDetection = new LightSenseDetection();
|
|
429
|
-
var irMessageDetection = new IRMessageDetection();
|
|
430
472
|
export default PublishedDataAnalyser;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeviceManager } from "@
|
|
1
|
+
import { DeviceManager } from "@robotical/raftjs/dist/web/RaftDeviceManager";
|
|
2
2
|
export default class PublishedDataGetter {
|
|
3
3
|
static getPowerData(deviceManager: DeviceManager): {
|
|
4
4
|
battV: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import RICInterface from "../RAFTInterface";
|
|
2
2
|
import { RaftTypeE } from "../../../types/raft";
|
|
3
3
|
import RAFT from "../RAFT";
|
|
4
|
-
import { RaftConnEvent, RaftPublishEvent, RaftSystemInfo, RaftUpdateEvent } from "@
|
|
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
7
|
export declare class Marty extends RAFT implements RICInterface {
|
|
@@ -10,6 +10,8 @@ export declare class Marty extends RAFT implements RICInterface {
|
|
|
10
10
|
raftStateInfo: RICStateInfo | null;
|
|
11
11
|
systemInfo: RaftSystemInfo | null;
|
|
12
12
|
_ledLcdColours: RICLedLcdColours;
|
|
13
|
+
private rssiValues;
|
|
14
|
+
private MAX_RSSI_VALUES_N;
|
|
13
15
|
constructor(id: string);
|
|
14
16
|
get ledLcdColours(): RICLedLcdColours;
|
|
15
17
|
/**
|
|
@@ -25,8 +27,8 @@ export declare class Marty extends RAFT implements RICInterface {
|
|
|
25
27
|
*/
|
|
26
28
|
highlight(): Promise<void>;
|
|
27
29
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
* This methods handles RAFT events coming from the RICConnector of the wrapper
|
|
31
|
+
*/
|
|
30
32
|
handleRaftEvent(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
|
|
31
33
|
/**
|
|
32
34
|
* Pub Event Handler
|
|
@@ -51,21 +51,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
51
51
|
};
|
|
52
52
|
import { RaftTypeE } from "../../../types/raft";
|
|
53
53
|
import RAFT from "../RAFT";
|
|
54
|
-
import { RaftPublishEvent } from "@
|
|
54
|
+
import { RaftPublishEvent } from "@robotical/raftjs";
|
|
55
55
|
var Marty = /** @class */ (function (_super) {
|
|
56
56
|
__extends(Marty, _super);
|
|
57
|
-
// // Joint names
|
|
58
|
-
// private _jointNames = {
|
|
59
|
-
// LeftHip: "LeftHip",
|
|
60
|
-
// LeftTwist: "LeftTwist",
|
|
61
|
-
// LeftKnee: "LeftKnee",
|
|
62
|
-
// RightHip: "RightHip",
|
|
63
|
-
// RightTwist: "RightTwist",
|
|
64
|
-
// RightKnee: "RightKnee",
|
|
65
|
-
// LeftArm: "LeftArm",
|
|
66
|
-
// RightArm: "RightArm",
|
|
67
|
-
// Eyes: "Eyes",
|
|
68
|
-
// };
|
|
69
57
|
function Marty(id) {
|
|
70
58
|
var _this = _super.call(this, id) || this;
|
|
71
59
|
_this.id = id;
|
|
@@ -80,6 +68,20 @@ var Marty = /** @class */ (function (_super) {
|
|
|
80
68
|
{ led: "#880000", lcd: "#FF0000" },
|
|
81
69
|
{ led: "#000040", lcd: "#0080FF" },
|
|
82
70
|
];
|
|
71
|
+
// // Joint names
|
|
72
|
+
// private _jointNames = {
|
|
73
|
+
// LeftHip: "LeftHip",
|
|
74
|
+
// LeftTwist: "LeftTwist",
|
|
75
|
+
// LeftKnee: "LeftKnee",
|
|
76
|
+
// RightHip: "RightHip",
|
|
77
|
+
// RightTwist: "RightTwist",
|
|
78
|
+
// RightKnee: "RightKnee",
|
|
79
|
+
// LeftArm: "LeftArm",
|
|
80
|
+
// RightArm: "RightArm",
|
|
81
|
+
// Eyes: "Eyes",
|
|
82
|
+
// };
|
|
83
|
+
_this.rssiValues = []; // Array to store recent RSSI values
|
|
84
|
+
_this.MAX_RSSI_VALUES_N = 8; // Number of values to consider for averaging
|
|
83
85
|
return _this;
|
|
84
86
|
}
|
|
85
87
|
Object.defineProperty(Marty.prototype, "ledLcdColours", {
|
|
@@ -94,7 +96,13 @@ var Marty = /** @class */ (function (_super) {
|
|
|
94
96
|
*/
|
|
95
97
|
Marty.prototype.getRSSI = function () {
|
|
96
98
|
var _a;
|
|
97
|
-
|
|
99
|
+
var newRssi = ((_a = this.raftStateInfo) === null || _a === void 0 ? void 0 : _a.robotStatus.robotStatus.bleRSSI) || -200;
|
|
100
|
+
if (this.rssiValues.length >= this.MAX_RSSI_VALUES_N) {
|
|
101
|
+
this.rssiValues.shift();
|
|
102
|
+
}
|
|
103
|
+
this.rssiValues.push(newRssi);
|
|
104
|
+
var rssiAverage = this.rssiValues.reduce(function (sum, val) { return sum + val; }, 0) / this.rssiValues.length;
|
|
105
|
+
return this.rssiValues.reduce(function (sum, val) { return sum + val; }, 0) / this.rssiValues.length;
|
|
98
106
|
};
|
|
99
107
|
/**
|
|
100
108
|
* Gets the battery strength of the RAFT
|
|
@@ -128,8 +136,8 @@ var Marty = /** @class */ (function (_super) {
|
|
|
128
136
|
});
|
|
129
137
|
};
|
|
130
138
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
139
|
+
* This methods handles RAFT events coming from the RICConnector of the wrapper
|
|
140
|
+
*/
|
|
133
141
|
Marty.prototype.handleRaftEvent = function (eventType, eventEnum, eventName, eventData) {
|
|
134
142
|
_super.prototype.handleRaftEvent.call(this, eventType, eventEnum, eventName, eventData);
|
|
135
143
|
switch (eventType) {
|
|
@@ -3,7 +3,7 @@ import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
|
3
3
|
import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../types/phone-app-communicator";
|
|
4
4
|
import RICInterface from "./RAFTInterface";
|
|
5
5
|
import { RaftObserver } from "./RaftObserver";
|
|
6
|
-
import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent, RaftOKFail, RaftSystemInfo } from "@
|
|
6
|
+
import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent, RaftOKFail, RaftSystemInfo } from "@robotical/raftjs";
|
|
7
7
|
import { CogStateInfo, RICLedLcdColours, RICStateInfo } from "@robotical/roboticaljs";
|
|
8
8
|
export default class RAFT implements RICInterface {
|
|
9
9
|
id: string;
|
|
@@ -98,6 +98,10 @@ export default class RAFT implements RICInterface {
|
|
|
98
98
|
* (to be implemented in child classes)
|
|
99
99
|
*/
|
|
100
100
|
handleRaftEvent(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
|
|
101
|
+
/**
|
|
102
|
+
* Connection Event Handler
|
|
103
|
+
*/
|
|
104
|
+
_connectionEventHandler(eventEnum: RaftConnEvent, eventName: string, data: any): Promise<void>;
|
|
101
105
|
/**
|
|
102
106
|
* Pub Event Handler
|
|
103
107
|
*/
|
|
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import { AppSentMessage } from "../../types/communication-between-apps/wrapper-communication";
|
|
38
38
|
import { RaftTypeE } from "../../types/raft";
|
|
39
39
|
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
40
|
-
import { RaftPublishEvent, } from "@
|
|
40
|
+
import { RaftConnEvent, RaftPublishEvent, } from "@robotical/raftjs";
|
|
41
41
|
var RAFT = /** @class */ (function () {
|
|
42
42
|
function RAFT(id) {
|
|
43
43
|
this.id = id;
|
|
@@ -261,6 +261,9 @@ var RAFT = /** @class */ (function () {
|
|
|
261
261
|
*/
|
|
262
262
|
RAFT.prototype.handleRaftEvent = function (eventType, eventEnum, eventName, eventData) {
|
|
263
263
|
switch (eventType) {
|
|
264
|
+
case "conn":
|
|
265
|
+
this._connectionEventHandler(eventEnum, eventName, eventData);
|
|
266
|
+
break;
|
|
264
267
|
case "pub":
|
|
265
268
|
this._pubEventHandler(eventEnum, eventName, eventData);
|
|
266
269
|
break;
|
|
@@ -271,6 +274,32 @@ var RAFT = /** @class */ (function () {
|
|
|
271
274
|
break;
|
|
272
275
|
}
|
|
273
276
|
};
|
|
277
|
+
/**
|
|
278
|
+
* Connection Event Handler
|
|
279
|
+
*/
|
|
280
|
+
RAFT.prototype._connectionEventHandler = function (eventEnum, eventName, data) {
|
|
281
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
switch (eventEnum) {
|
|
284
|
+
case RaftConnEvent.CONN_VERIFIED_CORRECT:
|
|
285
|
+
window.applicationManager.analyticsManager.logEvent("connection", { raftType: this.type, systemInfo: this.systemInfo });
|
|
286
|
+
break;
|
|
287
|
+
case RaftConnEvent.CONN_DISCONNECTED:
|
|
288
|
+
window.applicationManager.analyticsManager.logEvent("disconnection", { raftType: this.type });
|
|
289
|
+
break;
|
|
290
|
+
case RaftConnEvent.CONN_ISSUE_DETECTED:
|
|
291
|
+
window.applicationManager.analyticsManager.logEvent("connection_issue", { data: data });
|
|
292
|
+
break;
|
|
293
|
+
case RaftConnEvent.CONN_ISSUE_RESOLVED:
|
|
294
|
+
window.applicationManager.analyticsManager.logEvent("connection_issue_resolved", { data: data });
|
|
295
|
+
break;
|
|
296
|
+
default:
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
return [2 /*return*/];
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
};
|
|
274
303
|
/**
|
|
275
304
|
* Pub Event Handler
|
|
276
305
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RaftTypeE } from "../../types/raft";
|
|
2
|
-
import { RaftConnEvent, RaftPublishEvent, RaftUpdateEvent } from "@
|
|
2
|
+
import { RaftConnEvent, RaftPublishEvent, RaftUpdateEvent } from "@robotical/raftjs";
|
|
3
3
|
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
4
4
|
import { RICLedLcdColours } from "@robotical/roboticaljs";
|
|
5
5
|
export default abstract class RICInterface {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
2
|
-
import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent } from "@
|
|
2
|
+
import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent } from "@robotical/raftjs";
|
|
3
3
|
export interface MartyObservable {
|
|
4
4
|
subscribe(observer: RaftObserver, topics: Array<string>): void;
|
|
5
5
|
unsubscribe(observer: RaftObserver): void;
|
|
@@ -48,8 +48,10 @@ export default function DisconnectConfirmationModal(_a) {
|
|
|
48
48
|
return __generator(this, function (_a) {
|
|
49
49
|
switch (_a.label) {
|
|
50
50
|
case 0:
|
|
51
|
-
if (!connectedRaft)
|
|
51
|
+
if (!connectedRaft) {
|
|
52
|
+
console.warn("No connected raft found", connectedRaft);
|
|
52
53
|
return [2 /*return*/];
|
|
54
|
+
}
|
|
53
55
|
return [4 /*yield*/, window.applicationManager.disconnectFromRaft(connectedRaft.id)];
|
|
54
56
|
case 1:
|
|
55
57
|
_a.sent();
|
|
@@ -51,7 +51,7 @@ import "./styles.css";
|
|
|
51
51
|
import { ReactComponent as BluetoothSVG } from "../../../assets/configuration/bluetooth.svg";
|
|
52
52
|
import { MAIN_BLUE } from "../../../styles/colors";
|
|
53
53
|
import modalState from "../../../state-observables/modal/ModalState";
|
|
54
|
-
import RICSignal from "../../oneoffs/
|
|
54
|
+
import RICSignal from "../../oneoffs/RaftSignal";
|
|
55
55
|
import SimpleButton from "../../disposables/buttons/SimpleButton";
|
|
56
56
|
import LEDs from "../../oneoffs/LEDs";
|
|
57
57
|
import { raftConnectingSubscriptionHelper } from "../../../application/RAFTs/raft-subscription-helpers";
|
|
@@ -52,7 +52,7 @@ import { ReactComponent as BluetoothSVG } from "../../../assets/configuration/bl
|
|
|
52
52
|
import { ReactComponent as RefreshSVG } from "../../../assets/refresh.svg";
|
|
53
53
|
import { MAIN_BLUE, WHITE } from "../../../styles/colors";
|
|
54
54
|
import modalState from "../../../state-observables/modal/ModalState";
|
|
55
|
-
import RICSignal from "../../oneoffs/
|
|
55
|
+
import RICSignal from "../../oneoffs/RaftSignal";
|
|
56
56
|
import SimpleButton from "../../disposables/buttons/SimpleButton";
|
|
57
57
|
import LEDs from "../../oneoffs/LEDs";
|
|
58
58
|
import SVGImageButton from "../../disposables/buttons/SVGImageButton";
|
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { RaftUtils } from "@
|
|
13
|
+
import { RaftUtils } from "@robotical/raftjs";
|
|
14
14
|
import "./styles.css";
|
|
15
15
|
import { RaftTypeE } from "../../../types/raft";
|
|
16
16
|
export default function LEDs(_a) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import RAFT from "../../../application/RAFTs/RAFT";
|
|
2
|
+
type RaftSignalProps = {
|
|
3
|
+
signalStrength: number;
|
|
4
|
+
connectedRaft?: RAFT;
|
|
5
|
+
};
|
|
6
|
+
export default function RaftSignal({ signalStrength, connectedRaft }: RaftSignalProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|