@robotical/webapp-types 1.0.7 → 1.0.8
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.
|
@@ -1,32 +1,52 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { CogStateInfo } from "@robotical/roboticaljs";
|
|
2
3
|
import RAFT from "../RAFT";
|
|
3
4
|
import PublishedDataGetter from "./PublishedDataGetter";
|
|
5
|
+
import EventEmitter from "events";
|
|
4
6
|
interface CogState {
|
|
5
|
-
tilt:
|
|
6
|
-
movementType:
|
|
7
|
-
rotation:
|
|
8
|
-
buttonClick:
|
|
9
|
-
objectSense:
|
|
10
|
-
lightSense:
|
|
11
|
-
irMessage: boolean | "left" | "right";
|
|
7
|
+
tilt: "none" | "forward" | "backward" | "left" | "right";
|
|
8
|
+
movementType: "none" | "shake" | "move";
|
|
9
|
+
rotation: "none" | "clockwise" | "counterClockwise";
|
|
10
|
+
buttonClick: "none" | "click" | "release";
|
|
11
|
+
objectSense: "none" | "left" | "right";
|
|
12
|
+
lightSense: "none" | "high" | "mid" | "low";
|
|
12
13
|
}
|
|
13
|
-
declare class PublishedDataAnalyser {
|
|
14
|
+
declare class PublishedDataAnalyser extends EventEmitter {
|
|
14
15
|
private cog;
|
|
15
16
|
cogState: CogState;
|
|
16
17
|
private pubSub;
|
|
18
|
+
eventsMap: {
|
|
19
|
+
tilt: {
|
|
20
|
+
[key in CogState["tilt"]]: string;
|
|
21
|
+
};
|
|
22
|
+
movementType: {
|
|
23
|
+
[key in CogState["movementType"]]: string;
|
|
24
|
+
};
|
|
25
|
+
rotation: {
|
|
26
|
+
[key in CogState["rotation"]]: string;
|
|
27
|
+
};
|
|
28
|
+
buttonClick: {
|
|
29
|
+
[key in CogState["buttonClick"]]: string;
|
|
30
|
+
};
|
|
31
|
+
objectSense: {
|
|
32
|
+
[key in CogState["objectSense"]]: string;
|
|
33
|
+
};
|
|
34
|
+
lightSense: {
|
|
35
|
+
[key in CogState["lightSense"]]: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
17
38
|
TiltDetection: typeof TiltDetection;
|
|
18
39
|
PublishedDataGetter: typeof PublishedDataGetter;
|
|
19
40
|
constructor(cog: RAFT);
|
|
20
41
|
subscribeToPublishedData(): void;
|
|
21
42
|
unsubscribeFromPublishedData(): void;
|
|
22
43
|
analyse(data: CogStateInfo): void;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
detectIRMessage(data: CogStateInfo): void;
|
|
44
|
+
setTilt(tilt: CogState["tilt"]): void;
|
|
45
|
+
setMovementType(movementType: CogState["movementType"]): void;
|
|
46
|
+
setRotation(rotation: CogState["rotation"]): void;
|
|
47
|
+
setButtonClick(buttonClick: CogState["buttonClick"]): void;
|
|
48
|
+
setObjectSense(objectSense: CogState["objectSense"]): void;
|
|
49
|
+
setLightSense(lightSense: CogState["lightSense"]): void;
|
|
30
50
|
}
|
|
31
51
|
declare class TiltDetection {
|
|
32
52
|
distance(a: number, b: number): number;
|
|
@@ -35,6 +55,6 @@ declare class TiltDetection {
|
|
|
35
55
|
y: number;
|
|
36
56
|
z: number;
|
|
37
57
|
};
|
|
38
|
-
detectTilt(ax: number, ay: number, az: number, isMoving: boolean | undefined,
|
|
58
|
+
detectTilt(ax: number, ay: number, az: number, isMoving: boolean | undefined, analyser: PublishedDataAnalyser, cogVersion: string): void;
|
|
39
59
|
}
|
|
40
60
|
export default PublishedDataAnalyser;
|
|
@@ -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;
|