@wemap/providers 9.0.9 → 9.1.0
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/index.js +1 -0
- package/package.json +2 -2
- package/src/mapmatching/MapMatchingHandler.js +92 -17
- package/src/providers/position/absolute/AbsolutePosition.js +54 -18
- package/src/providers/position/absolute/PoleStar.js +2 -1
- package/src/providers/steps/StepDetector.js +14 -1
- package/src/providers/steps/StraightLineDetector.js +14 -3
- package/src/providers/vision/Vps.js +58 -8
package/index.js
CHANGED
|
@@ -35,6 +35,7 @@ export { default as Inclination } from './src/providers/inclination/Inclination.
|
|
|
35
35
|
|
|
36
36
|
export { default as StepDetector } from './src/providers/steps/StepDetector.js';
|
|
37
37
|
export { default as StraightLineDetector } from './src/providers/steps/StraightLineDetector.js';
|
|
38
|
+
export { default as StepDetectionMinMaxPeaks2 } from './src/providers/steps/StepDetectionMinMaxPeaks2.js';
|
|
38
39
|
|
|
39
40
|
export { default as Pdr } from './src/providers/position/relative/Pdr.js';
|
|
40
41
|
export { default as GeoRelativePositionFromArCore } from './src/providers/position/relative/GeoRelativePositionFromArCore.js';
|
package/package.json
CHANGED
|
@@ -35,28 +35,49 @@ class MapMatchingHandler extends Provider {
|
|
|
35
35
|
static DEFAULT_USE_ITINERARY_START_AS_POSITION = false;
|
|
36
36
|
|
|
37
37
|
/** @type {boolean} */
|
|
38
|
-
static
|
|
38
|
+
static DEFAULT_USE_ORIENTATION_MATCHING = true;
|
|
39
39
|
|
|
40
40
|
/** @type {number} in meters */
|
|
41
|
-
static
|
|
41
|
+
static DEFAULT_MM_HUGE_JUMP_DISTANCE = 3;
|
|
42
42
|
|
|
43
43
|
/** @type {number} */
|
|
44
|
-
static
|
|
44
|
+
static DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING = 3;
|
|
45
45
|
|
|
46
46
|
/** @type {number} */
|
|
47
|
-
static
|
|
47
|
+
static DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING = 5;
|
|
48
48
|
|
|
49
49
|
/** @type {number} */
|
|
50
|
-
static
|
|
50
|
+
static DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE = 3;
|
|
51
51
|
|
|
52
52
|
/** @type {number} */
|
|
53
|
-
static
|
|
53
|
+
static DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD = deg2rad(3);
|
|
54
54
|
|
|
55
55
|
/** @type {MapMatching} */
|
|
56
56
|
_mapMatching;
|
|
57
57
|
|
|
58
58
|
/** @type {number} */
|
|
59
|
-
_mapMatchingMinDistance;
|
|
59
|
+
_mapMatchingMinDistance = MapMatchingHandler.DEFAULT_MM_MIN_DIST;
|
|
60
|
+
|
|
61
|
+
/** @type {boolean} */
|
|
62
|
+
_useItineraryStartAsPosition = MapMatchingHandler.DEFAULT_USE_ITINERARY_START_AS_POSITION;
|
|
63
|
+
|
|
64
|
+
/** @type {boolean} */
|
|
65
|
+
_useOrientationMatching = MapMatchingHandler.DEFAULT_USE_ORIENTATION_MATCHING;
|
|
66
|
+
|
|
67
|
+
/** @type {number} */
|
|
68
|
+
_hugeJumpDistance = MapMatchingHandler.DEFAULT_MM_HUGE_JUMP_DISTANCE;
|
|
69
|
+
|
|
70
|
+
/** @type {number} */
|
|
71
|
+
_minStepsBetweenOrientationMatching = MapMatchingHandler.DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING;
|
|
72
|
+
|
|
73
|
+
/** @type {number} */
|
|
74
|
+
_minStepsForOrientationMatching = MapMatchingHandler.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING;
|
|
75
|
+
|
|
76
|
+
/** @type {number} */
|
|
77
|
+
_lastProjectionsWindowSize = MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE;
|
|
78
|
+
|
|
79
|
+
/** @type {number} */
|
|
80
|
+
_lastProjectionsEdgeAngleThreshold = MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD;
|
|
60
81
|
|
|
61
82
|
/** @type {boolean} */
|
|
62
83
|
_internalProvidersStarted = false;
|
|
@@ -86,8 +107,6 @@ class MapMatchingHandler extends Provider {
|
|
|
86
107
|
this._mapMatching = new MapMatching();
|
|
87
108
|
this._mapMatching.maxDistance = MapMatchingHandler.DEFAULT_MM_MAX_DIST;
|
|
88
109
|
this._mapMatching.maxAngleBearing = MapMatchingHandler.DEFAULT_MM_MAX_ANGLE;
|
|
89
|
-
this._mapMatchingMinDistance = MapMatchingHandler.DEFAULT_MM_MIN_DIST;
|
|
90
|
-
this._useItineraryStartAsPosition = MapMatchingHandler.DEFAULT_USE_ITINERARY_START_AS_POSITION;
|
|
91
110
|
}
|
|
92
111
|
|
|
93
112
|
/**
|
|
@@ -279,7 +298,7 @@ class MapMatchingHandler extends Provider {
|
|
|
279
298
|
|
|
280
299
|
// newPosition must not be used after this line
|
|
281
300
|
|
|
282
|
-
const thisWillBeAHugeJump = projectionWithBearing.distanceFromNearestElement >
|
|
301
|
+
const thisWillBeAHugeJump = projectionWithBearing.distanceFromNearestElement > this._hugeJumpDistance;
|
|
283
302
|
|
|
284
303
|
// In case of a huge jump, be sure the user is in a straight line
|
|
285
304
|
if (thisWillBeAHugeJump && !StraightLineDetector.isStraight()) {
|
|
@@ -321,11 +340,11 @@ class MapMatchingHandler extends Provider {
|
|
|
321
340
|
if (projection) {
|
|
322
341
|
this._projectionsWithAbsAndWithoutRelAttitudeInARow = [];
|
|
323
342
|
this._lastProjections.push(projection);
|
|
324
|
-
if (this._lastProjections.length >
|
|
343
|
+
if (this._lastProjections.length > this._lastProjectionsWindowSize) {
|
|
325
344
|
this._lastProjections.shift();
|
|
326
345
|
}
|
|
327
346
|
|
|
328
|
-
const thisWillBeAHugeJump = projection.distanceFromNearestElement >
|
|
347
|
+
const thisWillBeAHugeJump = projection.distanceFromNearestElement > this._hugeJumpDistance;
|
|
329
348
|
|
|
330
349
|
// In case of a huge jump, be sure the user is in a straight line
|
|
331
350
|
if (thisWillBeAHugeJump && !StraightLineDetector.isStraight()) {
|
|
@@ -376,7 +395,7 @@ class MapMatchingHandler extends Provider {
|
|
|
376
395
|
}
|
|
377
396
|
|
|
378
397
|
this._lastProjections.push(projectionWithAbs);
|
|
379
|
-
if (this._lastProjections.length >
|
|
398
|
+
if (this._lastProjections.length > this._lastProjectionsWindowSize) {
|
|
380
399
|
this._lastProjections.shift();
|
|
381
400
|
}
|
|
382
401
|
|
|
@@ -441,7 +460,7 @@ class MapMatchingHandler extends Provider {
|
|
|
441
460
|
return !this._lastProjections.some(projection =>
|
|
442
461
|
!(projection.nearestElement instanceof GraphEdge)
|
|
443
462
|
|| (diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing)
|
|
444
|
-
>
|
|
463
|
+
> this._lastProjectionsEdgeAngleThreshold)
|
|
445
464
|
);
|
|
446
465
|
}
|
|
447
466
|
|
|
@@ -450,13 +469,13 @@ class MapMatchingHandler extends Provider {
|
|
|
450
469
|
*/
|
|
451
470
|
tryOrientationMatching(projection) {
|
|
452
471
|
|
|
453
|
-
if (!
|
|
472
|
+
if (!this._useOrientationMatching) {
|
|
454
473
|
return;
|
|
455
474
|
}
|
|
456
475
|
|
|
457
476
|
if (this.state !== ProviderState.STARTED
|
|
458
|
-
|| this._countStepsFromLastMatching <
|
|
459
|
-
|| StraightLineDetector.numStepsDetectedFromLastTurn <
|
|
477
|
+
|| this._countStepsFromLastMatching < this._minStepsBetweenOrientationMatching
|
|
478
|
+
|| StraightLineDetector.numStepsDetectedFromLastTurn < this._minStepsForOrientationMatching) {
|
|
460
479
|
return;
|
|
461
480
|
}
|
|
462
481
|
|
|
@@ -524,6 +543,62 @@ class MapMatchingHandler extends Provider {
|
|
|
524
543
|
set useItineraryStartAsPosition(useItineraryStartAsPosition) {
|
|
525
544
|
this._useItineraryStartAsPosition = useItineraryStartAsPosition;
|
|
526
545
|
}
|
|
546
|
+
|
|
547
|
+
get useOrientationMatching() {
|
|
548
|
+
return this._useOrientationMatching;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
set useOrientationMatching(useOrientationMatching) {
|
|
552
|
+
this._useOrientationMatching = useOrientationMatching;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
get hugeJumpDistance() {
|
|
556
|
+
return this._hugeJumpDistance;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
set hugeJumpDistance(hugeJumpDistance) {
|
|
560
|
+
this._hugeJumpDistance = hugeJumpDistance;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
get useOrientationMatching() {
|
|
564
|
+
return this._useOrientationMatching;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
set useOrientationMatching(useOrientationMatching) {
|
|
568
|
+
this._useOrientationMatching = useOrientationMatching;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
get minStepsBetweenOrientationMatching() {
|
|
572
|
+
return this._minStepsBetweenOrientationMatching;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
set minStepsBetweenOrientationMatching(minStepsBetweenOrientationMatching) {
|
|
576
|
+
this._minStepsBetweenOrientationMatching = minStepsBetweenOrientationMatching;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
get minStepsForOrientationMatching() {
|
|
580
|
+
return this._minStepsForOrientationMatching;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
set minStepsForOrientationMatching(minStepsForOrientationMatching) {
|
|
584
|
+
this._minStepsForOrientationMatching = minStepsForOrientationMatching;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
get lastProjectionsWindowSize() {
|
|
588
|
+
return this._lastProjectionsWindowSize;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
set lastProjectionsWindowSize(lastProjectionsWindowSize) {
|
|
592
|
+
this._lastProjectionsWindowSize = lastProjectionsWindowSize;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
get lastProjectionsEdgeAngleThreshold() {
|
|
596
|
+
return this._lastProjectionsEdgeAngleThreshold;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
set lastProjectionsEdgeAngleThreshold(lastProjectionsEdgeAngleThreshold) {
|
|
600
|
+
this._lastProjectionsEdgeAngleThreshold = lastProjectionsEdgeAngleThreshold;
|
|
601
|
+
}
|
|
527
602
|
}
|
|
528
603
|
|
|
529
604
|
export default new MapMatchingHandler();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserPosition, GeoRelativePosition } from '@wemap/geo';
|
|
1
|
+
import { UserPosition, GeoRelativePosition, Level } from '@wemap/geo';
|
|
2
2
|
import { PromiseUtils, TimeUtils } from '@wemap/utils';
|
|
3
3
|
|
|
4
4
|
import Provider from '../../Provider.js';
|
|
@@ -158,33 +158,69 @@ class AbsolutePosition extends Provider {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
* @param {ProviderEvent<UserPosition>}
|
|
161
|
+
* @param {ProviderEvent<UserPosition>} newPositionEvent
|
|
162
162
|
* @param {boolean} canContainLevel
|
|
163
|
-
* @returns {boolean}
|
|
163
|
+
* @returns {boolean}
|
|
164
164
|
*/
|
|
165
|
-
|
|
165
|
+
_shouldTakeIntoAccountNewAbsolutePosition(newPositionEvent, canContainLevel = true) {
|
|
166
166
|
|
|
167
|
-
const newPosition =
|
|
167
|
+
const newPosition = newPositionEvent.data;
|
|
168
168
|
const lastPosition = this.lastEvent ? this.lastEvent.data : null;
|
|
169
169
|
|
|
170
|
-
if
|
|
170
|
+
// 1. Verifiy if it is the first known absolute position
|
|
171
|
+
if (!lastPosition) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
171
174
|
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
// 2. Is the new position accuracy is better enough than the last position accuracy
|
|
176
|
+
const isBetterEnough = newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO <= lastPosition.accuracy;
|
|
177
|
+
if (isBetterEnough) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
174
180
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
// 3.a. Is the new position is far from the new one (regarding accuracy)
|
|
182
|
+
// This condition return true if the two positions accuracy circles does not intersect.
|
|
183
|
+
// This is important if the person put the current page in the background during a while. But,
|
|
184
|
+
// could be dangerous if two providers do not provide close positions (ping-pong effect). This
|
|
185
|
+
// is why the 3.b. condition has been added.
|
|
186
|
+
// TODO: add a routine to augment the current position accuracy when the page is in background
|
|
187
|
+
const isFarEnough = lastPosition.distanceTo(newPosition) > lastPosition.accuracy + newPosition.accuracy;
|
|
178
188
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
189
|
+
// 3.b. Added on 16/06/22
|
|
190
|
+
// The goal of this condition is to avoid continuous jumps between positions from two providers
|
|
191
|
+
// (i.e. GnssWifi and PoleStar)
|
|
192
|
+
const isFarEnoughAndAccuracyIsBetter = isFarEnough && newPosition.accuracy <= lastPosition.accuracy;
|
|
183
193
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
194
|
+
if (isBetterEnough && isFarEnoughAndAccuracyIsBetter) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// 4. Added on 23/06/22
|
|
199
|
+
// The goal of this condition is to take into account levels change when map-matching is not enabled / set
|
|
200
|
+
const isChangingLevel = canContainLevel && !Level.equals(newPosition.level, lastPosition.level);
|
|
201
|
+
if (isChangingLevel) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @param {ProviderEvent<UserPosition>} positionEvent
|
|
210
|
+
* @param {boolean} canContainLevel
|
|
211
|
+
* @returns {boolean} if input position is used by the system (true = used, false = discarded)
|
|
212
|
+
*/
|
|
213
|
+
_onAbsolutePosition(positionEvent, canContainLevel = true) {
|
|
214
|
+
|
|
215
|
+
if (!this._shouldTakeIntoAccountNewAbsolutePosition(positionEvent, canContainLevel)
|
|
216
|
+
&& !this.useAllAbsolutePositions) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const newPosition = positionEvent.data.clone();
|
|
221
|
+
const lastPosition = this.lastEvent ? this.lastEvent.data : null;
|
|
187
222
|
|
|
223
|
+
if (lastPosition) {
|
|
188
224
|
if (!canContainLevel) {
|
|
189
225
|
newPosition.level = lastPosition.level;
|
|
190
226
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-bitwise */
|
|
2
2
|
|
|
3
3
|
import { UserPosition } from '@wemap/geo';
|
|
4
|
+
import { deg2rad } from '@wemap/maths';
|
|
4
5
|
import { TimeUtils } from '@wemap/utils';
|
|
5
6
|
|
|
6
7
|
import Provider from '../../Provider.js';
|
|
@@ -97,7 +98,7 @@ class PoleStar extends Provider {
|
|
|
97
98
|
json.alt / 5,
|
|
98
99
|
timestamp,
|
|
99
100
|
json.accuracy,
|
|
100
|
-
json.bearing,
|
|
101
|
+
deg2rad(json.bearing),
|
|
101
102
|
this.pname);
|
|
102
103
|
|
|
103
104
|
this.notify(this.createEvent(
|
|
@@ -11,6 +11,11 @@ import StepDetectionMinMaxPeaks2 from './StepDetectionMinMaxPeaks2.js';
|
|
|
11
11
|
|
|
12
12
|
class StepDetector extends Provider {
|
|
13
13
|
|
|
14
|
+
/** @type {number} */
|
|
15
|
+
static DEFAULT_STEP_SIZE_MULTIPLIER = 1;
|
|
16
|
+
|
|
17
|
+
_stepSizeMultiplier = StepDetector.DEFAULT_STEP_SIZE_MULTIPLIER;
|
|
18
|
+
|
|
14
19
|
constructor() {
|
|
15
20
|
super();
|
|
16
21
|
this.stepDetector = new StepDetectionMinMaxPeaks2();
|
|
@@ -84,7 +89,7 @@ class StepDetector extends Provider {
|
|
|
84
89
|
const stepDetected = this.stepDetector.compute(timestamp, linearAcc, this.angularRateEvent.data.values);
|
|
85
90
|
|
|
86
91
|
if (stepDetected) {
|
|
87
|
-
const size = this.stepDetector.lastStepSize;
|
|
92
|
+
const size = this.stepDetector.lastStepSize * this._stepSizeMultiplier;
|
|
88
93
|
this.numOfSteps++;
|
|
89
94
|
this.notify(this.createEvent(
|
|
90
95
|
EventType.Step, {
|
|
@@ -102,6 +107,14 @@ class StepDetector extends Provider {
|
|
|
102
107
|
linearAcc[2] -= GeoConstants.EARTH_GRAVITY;
|
|
103
108
|
return linearAcc;
|
|
104
109
|
}
|
|
110
|
+
|
|
111
|
+
set stepSizeMultiplier(stepSizeMultiplier) {
|
|
112
|
+
this._stepSizeMultiplier = stepSizeMultiplier;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get stepSizeMultiplier() {
|
|
116
|
+
return this._stepSizeMultiplier;
|
|
117
|
+
}
|
|
105
118
|
}
|
|
106
119
|
|
|
107
120
|
export default new StepDetector();
|
|
@@ -6,7 +6,7 @@ import EventType from '../../events/EventType.js';
|
|
|
6
6
|
class StraightLineDetector extends Provider {
|
|
7
7
|
|
|
8
8
|
/** @type {number} */
|
|
9
|
-
static
|
|
9
|
+
static DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE = 2;
|
|
10
10
|
|
|
11
11
|
/** @type {number?} */
|
|
12
12
|
_turnDetectorProviderId = null;
|
|
@@ -17,6 +17,9 @@ class StraightLineDetector extends Provider {
|
|
|
17
17
|
/** @type {number} */
|
|
18
18
|
_countSteps = 0;
|
|
19
19
|
|
|
20
|
+
/** @type {number} */
|
|
21
|
+
_stepsConsideredForStraightLine = StraightLineDetector.DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE;
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* @override
|
|
22
25
|
*/
|
|
@@ -41,7 +44,7 @@ class StraightLineDetector extends Provider {
|
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
_onTurn = (event) => {
|
|
44
|
-
if (this._countSteps >=
|
|
47
|
+
if (this._countSteps >= this._stepsConsideredForStraightLine) {
|
|
45
48
|
|
|
46
49
|
const fromEvents = [event];
|
|
47
50
|
if (StepDetector.lastEvent !== null) {
|
|
@@ -57,7 +60,7 @@ class StraightLineDetector extends Provider {
|
|
|
57
60
|
_onStep = (event) => {
|
|
58
61
|
this._countSteps++;
|
|
59
62
|
|
|
60
|
-
if (this._countSteps ===
|
|
63
|
+
if (this._countSteps === this._stepsConsideredForStraightLine) {
|
|
61
64
|
|
|
62
65
|
const fromEvents = [event];
|
|
63
66
|
if (TurnDectector.lastEvent !== null) {
|
|
@@ -79,6 +82,14 @@ class StraightLineDetector extends Provider {
|
|
|
79
82
|
get numStepsDetectedFromLastTurn() {
|
|
80
83
|
return this._countSteps;
|
|
81
84
|
}
|
|
85
|
+
|
|
86
|
+
get stepsConsideredForStraightLine() {
|
|
87
|
+
return this._stepsConsideredForStraightLine;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
set stepsConsideredForStraightLine(stepsConsideredForStraightLine) {
|
|
91
|
+
this._stepsConsideredForStraightLine = stepsConsideredForStraightLine;
|
|
92
|
+
}
|
|
82
93
|
}
|
|
83
94
|
|
|
84
95
|
export default new StraightLineDetector();
|
|
@@ -6,6 +6,7 @@ import { Quaternion, deg2rad } from '@wemap/maths';
|
|
|
6
6
|
import { TimeUtils } from '@wemap/utils';
|
|
7
7
|
|
|
8
8
|
import EventType from '../../events/EventType.js';
|
|
9
|
+
import Inclination from '../inclination/Inclination.js';
|
|
9
10
|
import Provider from '../Provider.js';
|
|
10
11
|
import ProviderState from '../ProviderState.js';
|
|
11
12
|
import ImageRelocalization from './ImageRelocalization.js';
|
|
@@ -14,6 +15,10 @@ class Vps extends Provider {
|
|
|
14
15
|
|
|
15
16
|
static MIN_TIME_BETWEEN_TWO_REQUESTS = 1000;
|
|
16
17
|
|
|
18
|
+
static DEFAULT_MIN_INCLINATION_FOR_REQUEST = deg2rad(60);
|
|
19
|
+
|
|
20
|
+
static DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST = 200;
|
|
21
|
+
|
|
17
22
|
static CAMERA_TO_SMARTPHONE_ROT = Quaternion.fromAxisAngle([1, 0, 0], Math.PI);
|
|
18
23
|
|
|
19
24
|
/** @type {boolean} */
|
|
@@ -28,6 +33,14 @@ class Vps extends Provider {
|
|
|
28
33
|
/** @type {?string} */
|
|
29
34
|
_endpoint = null;
|
|
30
35
|
|
|
36
|
+
/** @type {?number} */
|
|
37
|
+
_inclinationProviderId = null;
|
|
38
|
+
|
|
39
|
+
/** @type {number} */
|
|
40
|
+
_minInclinationForRequest = Vps.DEFAULT_MIN_INCLINATION_FOR_REQUEST;
|
|
41
|
+
|
|
42
|
+
/** @type {number} */
|
|
43
|
+
_waitTimeMinInclinationForRequest = Vps.DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST;
|
|
31
44
|
|
|
32
45
|
/**
|
|
33
46
|
* @override
|
|
@@ -67,6 +80,9 @@ class Vps extends Provider {
|
|
|
67
80
|
}
|
|
68
81
|
this._useCamera(SharedCameras.list[0].camera);
|
|
69
82
|
}
|
|
83
|
+
|
|
84
|
+
// 3. Inclination
|
|
85
|
+
this._inclinationProviderId = Inclination.addEventListener();
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
/**
|
|
@@ -77,13 +93,8 @@ class Vps extends Provider {
|
|
|
77
93
|
SharedCameras.off('removed', this._onCameraRemoved);
|
|
78
94
|
|
|
79
95
|
this._camera = null;
|
|
80
|
-
}
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
* @param {string} endpoint
|
|
84
|
-
*/
|
|
85
|
-
setEndpoint(endpoint) {
|
|
86
|
-
this._endpoint = endpoint;
|
|
97
|
+
Inclination.removeEventListener(this._inclinationProviderId);
|
|
87
98
|
}
|
|
88
99
|
|
|
89
100
|
_onCameraDetected = ({ camera }) => {
|
|
@@ -142,6 +153,14 @@ class Vps extends Provider {
|
|
|
142
153
|
break;
|
|
143
154
|
}
|
|
144
155
|
|
|
156
|
+
// 2.a. Do not send an image if smartphone looks at the floor
|
|
157
|
+
const inclination = Inclination.lastEvent ? Inclination.lastEvent.data : null;
|
|
158
|
+
if (inclination !== null
|
|
159
|
+
&& inclination < this._minInclinationForRequest) {
|
|
160
|
+
await new Promise(resolve => setTimeout(resolve, this._waitTimeMinInclinationForRequest));
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
|
|
145
164
|
// 3. Get current image from camera and relocalize it.
|
|
146
165
|
const image = await this._camera.currentImage;
|
|
147
166
|
const res = await ImageRelocalization.relocalize(this._endpoint, image);
|
|
@@ -163,9 +182,13 @@ class Vps extends Provider {
|
|
|
163
182
|
);
|
|
164
183
|
const attitude = new Attitude(deviceQuaternion, res.attitude.time, res.attitude.accuracy);
|
|
165
184
|
|
|
166
|
-
//
|
|
185
|
+
// [16/06/22] Force VPS accuracy to 5m if the information does not exist
|
|
186
|
+
// this allows to correctly fuse positions from different providers (VPS,
|
|
187
|
+
// GnssWifi, Pole Star...)
|
|
167
188
|
const devicePosition = res.userPosition.clone();
|
|
168
|
-
devicePosition.accuracy
|
|
189
|
+
if (devicePosition.accuracy === null) {
|
|
190
|
+
devicePosition.accuracy = 5;
|
|
191
|
+
}
|
|
169
192
|
|
|
170
193
|
// 5. Finally, notify the listeners if the VPS is not stopped
|
|
171
194
|
if (this.state === ProviderState.STOPPED) {
|
|
@@ -183,6 +206,33 @@ class Vps extends Provider {
|
|
|
183
206
|
_internalStop = () => {
|
|
184
207
|
// do nothing
|
|
185
208
|
}
|
|
209
|
+
|
|
210
|
+
get endpoint() {
|
|
211
|
+
return this._endpoint;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @param {string} endpoint
|
|
216
|
+
*/
|
|
217
|
+
set endpoint(endpoint) {
|
|
218
|
+
this._endpoint = endpoint;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
get minInclinationForRequest() {
|
|
222
|
+
return this._minInclinationForRequest;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
set minInclinationForRequest(minInclinationForRequest) {
|
|
226
|
+
this._minInclinationForRequest = minInclinationForRequest;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
get waitTimeMinInclinationForRequest() {
|
|
230
|
+
return this._waitTimeMinInclinationForRequest;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
set waitTimeMinInclinationForRequest(waitTimeMinInclinationForRequest) {
|
|
234
|
+
this._waitTimeMinInclinationForRequest = waitTimeMinInclinationForRequest;
|
|
235
|
+
}
|
|
186
236
|
}
|
|
187
237
|
|
|
188
238
|
export default new Vps();
|