@wemap/providers 10.0.0-alpha.12 → 10.0.0-alpha.2
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.d.ts +6 -46
- package/index.js +0 -2
- package/package.json +10 -10
- package/src/errors/MissingNativeInterfaceError.js +1 -2
- package/src/mapmatching/MapMatchingHandler.js +18 -156
- package/src/providers/FakeProvider.spec.js +1 -1
- package/src/providers/Provider.js +6 -6
- package/src/providers/Provider.spec.js +5 -5
- package/src/providers/attitude/EkfAttitude.js +5 -5
- package/src/providers/attitude/absolute/AbsoluteAttitude.js +7 -27
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowser.js +1 -1
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowser.js +1 -1
- package/src/providers/attitude/relative/RelativeAttitudeFromEkf.js +1 -2
- package/src/providers/attitude/relative/RelativeAttitudeFromInertial.js +4 -3
- package/src/providers/imu/Imu.js +2 -2
- package/src/providers/inclination/Inclination.js +3 -2
- package/src/providers/others/CameraNative.js +4 -5
- package/src/providers/position/absolute/AbsolutePosition.js +16 -69
- package/src/providers/position/absolute/GnssWifi.js +1 -1
- package/src/providers/position/absolute/PoleStar.js +4 -7
- package/src/providers/position/relative/GeoRelativePosition.js +5 -5
- package/src/providers/position/relative/GeoRelativePositionFromArCore.js +1 -5
- package/src/providers/position/relative/Pdr.js +1 -2
- package/src/providers/steps/StepDetector.js +3 -48
- package/src/providers/steps/StraightLineDetector.js +3 -25
- package/src/providers/vision/ArCore.js +2 -2
- package/src/providers/vision/vps/ImageRelocalization.js +16 -13
- package/src/providers/vision/vps/Vps.js +15 -115
- package/src/providers/vision/vps/VpsMetadata.js +6 -6
- package/src/events/AvailabilityHelper.js +0 -26
- package/src/events/AvailabilityHelper.spec.js +0 -30
- package/src/mapmatching/MapMatchingHandler.spec.js +0 -136
- package/src/providers/steps/StepDetectionMinMaxPeaks3.js +0 -201
- package/src/providers/steps/StepDetectorLadetto.js +0 -109
- package/src/providers/steps/StepDetectorMinMaxPeaks.js +0 -109
- package/src/providers/steps/StepDetectorMinMaxPeaks2.js +0 -109
- package/src/providers/steps/StepDetectorMinMaxPeaks3.js +0 -109
- package/src/providers/vision/vps/RelativeRotationCalc.js +0 -60
package/index.d.ts
CHANGED
|
@@ -4,49 +4,10 @@ import {
|
|
|
4
4
|
UserPosition, UserPositionJson
|
|
5
5
|
} from "@wemap/geo";
|
|
6
6
|
import { Quaternion_t } from "@wemap/maths";
|
|
7
|
-
import {
|
|
7
|
+
import { UserAgentWithDetails } from "@wemap/utils";
|
|
8
8
|
|
|
9
9
|
declare module '@wemap/providers' {
|
|
10
10
|
|
|
11
|
-
export type EventTypeValue = string;
|
|
12
|
-
|
|
13
|
-
export class ProviderEvent<T> {
|
|
14
|
-
|
|
15
|
-
dataType: EventTypeValue;
|
|
16
|
-
providersStack: string[];
|
|
17
|
-
data: T;
|
|
18
|
-
|
|
19
|
-
constructor(dataType: EventTypeValue, data: T);
|
|
20
|
-
clone(): ProviderEvent<T>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class Provider {
|
|
24
|
-
static get pname(): string;
|
|
25
|
-
get pname(): string;
|
|
26
|
-
get eventsType(): EventTypeValue[];
|
|
27
|
-
get availability(): Promise<void>;
|
|
28
|
-
|
|
29
|
-
addEventListener(onEvents?: () => void, onError?: () => void, startIfNecessary?: boolean): number;
|
|
30
|
-
removeEventListener(id: number): void;
|
|
31
|
-
|
|
32
|
-
addMonitoringListener(onStarted?: () => void, onStopped?: () => void): number;
|
|
33
|
-
removeMonitoringListener(id: number): void;
|
|
34
|
-
|
|
35
|
-
get lastEvent(): ProviderEvent<any> | null;
|
|
36
|
-
get lastEvents(): ProviderEvent<any>[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class AbsolutePositionProvider extends Provider {
|
|
40
|
-
get lastEvent(): ProviderEvent<UserPosition> | null;
|
|
41
|
-
}
|
|
42
|
-
export const AbsolutePosition: AbsolutePositionProvider;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export class AbsoluteAttitudeProvider extends Provider {
|
|
46
|
-
get lastEvent(): ProviderEvent<Attitude> | null;
|
|
47
|
-
}
|
|
48
|
-
export const AbsoluteAttitude: AbsoluteAttitudeProvider;
|
|
49
|
-
|
|
50
11
|
export type CoarsePoseJson = {
|
|
51
12
|
attitude?: AttitudeJson,
|
|
52
13
|
position?: UserPositionJson,
|
|
@@ -61,7 +22,7 @@ declare module '@wemap/providers' {
|
|
|
61
22
|
size: [number, number], // [width, height]
|
|
62
23
|
calibration?: Calibration,
|
|
63
24
|
coarse?: CoarsePoseJson,
|
|
64
|
-
|
|
25
|
+
userAgent?: UserAgentWithDetails
|
|
65
26
|
}
|
|
66
27
|
|
|
67
28
|
export class VpsMetadata {
|
|
@@ -69,7 +30,7 @@ declare module '@wemap/providers' {
|
|
|
69
30
|
size: { width: number, height: number };
|
|
70
31
|
calibration?: Calibration;
|
|
71
32
|
coarse?: CoarsePose;
|
|
72
|
-
|
|
33
|
+
userAgent?: UserAgentWithDetails;
|
|
73
34
|
|
|
74
35
|
toJson(): VpsMetadataJson;
|
|
75
36
|
static fromJson(json: VpsMetadataJson): VpsMetadata;
|
|
@@ -106,14 +67,13 @@ declare module '@wemap/providers' {
|
|
|
106
67
|
|
|
107
68
|
static _prepareRequest(
|
|
108
69
|
imageCanvas: HTMLCanvasElement,
|
|
109
|
-
calibration?: Calibration
|
|
110
|
-
coarsePose?: CoarsePose
|
|
70
|
+
calibration?: Calibration,
|
|
71
|
+
coarsePose?: CoarsePose
|
|
111
72
|
): VpsRequest
|
|
112
73
|
|
|
113
74
|
static relocalize(
|
|
114
75
|
endpointUrl: string, imageCanvas: HTMLCanvasElement,
|
|
115
|
-
calibration?: Calibration
|
|
116
|
-
customHeaders?: Record<string, string> | null
|
|
76
|
+
calibration?: Calibration, coarsePose?: CoarsePose
|
|
117
77
|
): Promise<VpsResponse>;
|
|
118
78
|
|
|
119
79
|
static getHeadingFromQuaternion(quaternion: Quaternion_t): number;
|
package/index.js
CHANGED
|
@@ -37,8 +37,6 @@ export { default as Inclination } from './src/providers/inclination/Inclination.
|
|
|
37
37
|
|
|
38
38
|
export { default as StepDetector } from './src/providers/steps/StepDetector.js';
|
|
39
39
|
export { default as StraightLineDetector } from './src/providers/steps/StraightLineDetector.js';
|
|
40
|
-
export { default as StepDetectionMinMaxPeaks2 } from './src/providers/steps/StepDetectionMinMaxPeaks2.js';
|
|
41
|
-
export { default as StepDetectionMinMaxPeaks3 } from './src/providers/steps/StepDetectionMinMaxPeaks3.js';
|
|
42
40
|
|
|
43
41
|
export { default as Pdr } from './src/providers/position/relative/Pdr.js';
|
|
44
42
|
export { default as GeoRelativePositionFromArCore } from './src/providers/position/relative/GeoRelativePositionFromArCore.js';
|
package/package.json
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@wemap/camera": "^10.0.0-alpha.
|
|
12
|
-
"@wemap/geo": "^10.0.0-alpha.
|
|
11
|
+
"@wemap/camera": "^10.0.0-alpha.0",
|
|
12
|
+
"@wemap/geo": "^10.0.0-alpha.1",
|
|
13
13
|
"@wemap/geomagnetism": "^0.1.1",
|
|
14
|
-
"@wemap/logger": "^
|
|
15
|
-
"@wemap/map": "^10.0.0-alpha.
|
|
16
|
-
"@wemap/maths": "^
|
|
17
|
-
"@wemap/osm": "^10.0.0-alpha.
|
|
18
|
-
"@wemap/routers": "^10.0.0-alpha.
|
|
19
|
-
"@wemap/utils": "^10.0.0-alpha.
|
|
14
|
+
"@wemap/logger": "^9.0.0",
|
|
15
|
+
"@wemap/map": "^10.0.0-alpha.1",
|
|
16
|
+
"@wemap/maths": "^9.0.0",
|
|
17
|
+
"@wemap/osm": "^10.0.0-alpha.1",
|
|
18
|
+
"@wemap/routers": "^10.0.0-alpha.1",
|
|
19
|
+
"@wemap/utils": "^10.0.0-alpha.0"
|
|
20
20
|
},
|
|
21
21
|
"description": "A package using different geoloc systems",
|
|
22
22
|
"devDependencies": {
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"url": "git+https://github.com/wemap/wemap-modules-js.git"
|
|
43
43
|
},
|
|
44
44
|
"type": "module",
|
|
45
|
-
"version": "10.0.0-alpha.
|
|
46
|
-
"gitHead": "
|
|
45
|
+
"version": "10.0.0-alpha.2",
|
|
46
|
+
"gitHead": "33d8df3243b72a184d335547fb8cccd2e5a43062"
|
|
47
47
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
class MissingNativeInterfaceError extends Error {
|
|
2
2
|
|
|
3
|
-
static DEFAULT_MESSAGE = 'Native interface is missing
|
|
4
|
-
+ 'execute a code which is not available in a web browser';
|
|
3
|
+
static DEFAULT_MESSAGE = 'Native interface is missing';
|
|
5
4
|
|
|
6
5
|
constructor(message) {
|
|
7
6
|
super(message || MissingNativeInterfaceError.DEFAULT_MESSAGE);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-statements */
|
|
2
2
|
import {
|
|
3
|
-
AbsoluteHeading, GraphEdge,
|
|
3
|
+
AbsoluteHeading, GraphEdge, MapMatching, Network, GraphProjection, UserPosition
|
|
4
4
|
} from '@wemap/geo';
|
|
5
5
|
import { deg2rad, diffAngle, diffAngleLines } from '@wemap/maths';
|
|
6
6
|
import { Itinerary } from '@wemap/routers';
|
|
@@ -35,55 +35,28 @@ class MapMatchingHandler extends Provider {
|
|
|
35
35
|
static DEFAULT_USE_ITINERARY_START_AS_POSITION = false;
|
|
36
36
|
|
|
37
37
|
/** @type {boolean} */
|
|
38
|
-
static
|
|
38
|
+
static ORIENTATION_MATCHING = true;
|
|
39
39
|
|
|
40
40
|
/** @type {number} in meters */
|
|
41
|
-
static
|
|
42
|
-
|
|
43
|
-
/** @type {number} in meters */
|
|
44
|
-
static DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE = 2;
|
|
41
|
+
static MM_HUGE_JUMP_DISTANCE = 3;
|
|
45
42
|
|
|
46
43
|
/** @type {number} */
|
|
47
|
-
static
|
|
44
|
+
static MIN_STEPS_BETWEEN_ORIENTATION_MATCHING = 3;
|
|
48
45
|
|
|
49
46
|
/** @type {number} */
|
|
50
|
-
static
|
|
47
|
+
static MIN_STEPS_FOR_ORIENTATION_MATCHING = 5;
|
|
51
48
|
|
|
52
49
|
/** @type {number} */
|
|
53
|
-
static
|
|
50
|
+
static LAST_PROJECTIONS_WINDOW_SIZE = 3;
|
|
54
51
|
|
|
55
52
|
/** @type {number} */
|
|
56
|
-
static
|
|
53
|
+
static LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD = deg2rad(3);
|
|
57
54
|
|
|
58
55
|
/** @type {MapMatching} */
|
|
59
56
|
_mapMatching;
|
|
60
57
|
|
|
61
58
|
/** @type {number} */
|
|
62
|
-
_mapMatchingMinDistance
|
|
63
|
-
|
|
64
|
-
/** @type {boolean} */
|
|
65
|
-
_useItineraryStartAsPosition = MapMatchingHandler.DEFAULT_USE_ITINERARY_START_AS_POSITION;
|
|
66
|
-
|
|
67
|
-
/** @type {boolean} */
|
|
68
|
-
_useOrientationMatching = MapMatchingHandler.DEFAULT_USE_ORIENTATION_MATCHING;
|
|
69
|
-
|
|
70
|
-
/** @type {number} */
|
|
71
|
-
_hugeJumpDistance = MapMatchingHandler.DEFAULT_MM_HUGE_JUMP_DISTANCE;
|
|
72
|
-
|
|
73
|
-
/** @type {number} */
|
|
74
|
-
_disableMMCloseToATurnDistance = MapMatchingHandler.DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE;
|
|
75
|
-
|
|
76
|
-
/** @type {number} */
|
|
77
|
-
_minStepsBetweenOrientationMatching = MapMatchingHandler.DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING;
|
|
78
|
-
|
|
79
|
-
/** @type {number} */
|
|
80
|
-
_minStepsForOrientationMatching = MapMatchingHandler.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING;
|
|
81
|
-
|
|
82
|
-
/** @type {number} */
|
|
83
|
-
_lastProjectionsWindowSize = MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE;
|
|
84
|
-
|
|
85
|
-
/** @type {number} */
|
|
86
|
-
_lastProjectionsEdgeAngleThreshold = MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD;
|
|
59
|
+
_mapMatchingMinDistance;
|
|
87
60
|
|
|
88
61
|
/** @type {boolean} */
|
|
89
62
|
_internalProvidersStarted = false;
|
|
@@ -113,13 +86,8 @@ class MapMatchingHandler extends Provider {
|
|
|
113
86
|
this._mapMatching = new MapMatching();
|
|
114
87
|
this._mapMatching.maxDistance = MapMatchingHandler.DEFAULT_MM_MAX_DIST;
|
|
115
88
|
this._mapMatching.maxAngleBearing = MapMatchingHandler.DEFAULT_MM_MAX_ANGLE;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @override
|
|
120
|
-
*/
|
|
121
|
-
static get pname() {
|
|
122
|
-
return 'MapMatchingHandler';
|
|
89
|
+
this._mapMatchingMinDistance = MapMatchingHandler.DEFAULT_MM_MIN_DIST;
|
|
90
|
+
this._useItineraryStartAsPosition = MapMatchingHandler.DEFAULT_USE_ITINERARY_START_AS_POSITION;
|
|
123
91
|
}
|
|
124
92
|
|
|
125
93
|
/**
|
|
@@ -311,7 +279,7 @@ class MapMatchingHandler extends Provider {
|
|
|
311
279
|
|
|
312
280
|
// newPosition must not be used after this line
|
|
313
281
|
|
|
314
|
-
const thisWillBeAHugeJump = projectionWithBearing.distanceFromNearestElement >
|
|
282
|
+
const thisWillBeAHugeJump = projectionWithBearing.distanceFromNearestElement > MapMatchingHandler.MM_HUGE_JUMP_DISTANCE;
|
|
315
283
|
|
|
316
284
|
// In case of a huge jump, be sure the user is in a straight line
|
|
317
285
|
if (thisWillBeAHugeJump && !StraightLineDetector.isStraight()) {
|
|
@@ -353,11 +321,11 @@ class MapMatchingHandler extends Provider {
|
|
|
353
321
|
if (projection) {
|
|
354
322
|
this._projectionsWithAbsAndWithoutRelAttitudeInARow = [];
|
|
355
323
|
this._lastProjections.push(projection);
|
|
356
|
-
if (this._lastProjections.length >
|
|
324
|
+
if (this._lastProjections.length > MapMatchingHandler.LAST_PROJECTIONS_WINDOW_SIZE) {
|
|
357
325
|
this._lastProjections.shift();
|
|
358
326
|
}
|
|
359
327
|
|
|
360
|
-
const thisWillBeAHugeJump = projection.distanceFromNearestElement >
|
|
328
|
+
const thisWillBeAHugeJump = projection.distanceFromNearestElement > MapMatchingHandler.MM_HUGE_JUMP_DISTANCE;
|
|
361
329
|
|
|
362
330
|
// In case of a huge jump, be sure the user is in a straight line
|
|
363
331
|
if (thisWillBeAHugeJump && !StraightLineDetector.isStraight()) {
|
|
@@ -377,13 +345,6 @@ class MapMatchingHandler extends Provider {
|
|
|
377
345
|
return true;
|
|
378
346
|
}
|
|
379
347
|
|
|
380
|
-
// Detector to avoid map-matching close to network turns
|
|
381
|
-
if (this._disableMMCloseToATurnDistance > 0
|
|
382
|
-
&& this._hasTurnInCircle(projection.projection, this._disableMMCloseToATurnDistance)) {
|
|
383
|
-
AbsolutePosition.notify(positionEvent);
|
|
384
|
-
return true;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
348
|
AbsolutePosition.notify(this.createEvent(
|
|
388
349
|
EventType.AbsolutePosition,
|
|
389
350
|
projection.projection,
|
|
@@ -415,7 +376,7 @@ class MapMatchingHandler extends Provider {
|
|
|
415
376
|
}
|
|
416
377
|
|
|
417
378
|
this._lastProjections.push(projectionWithAbs);
|
|
418
|
-
if (this._lastProjections.length >
|
|
379
|
+
if (this._lastProjections.length > MapMatchingHandler.LAST_PROJECTIONS_WINDOW_SIZE) {
|
|
419
380
|
this._lastProjections.shift();
|
|
420
381
|
}
|
|
421
382
|
|
|
@@ -480,57 +441,22 @@ class MapMatchingHandler extends Provider {
|
|
|
480
441
|
return !this._lastProjections.some(projection =>
|
|
481
442
|
!(projection.nearestElement instanceof GraphEdge)
|
|
482
443
|
|| (diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing)
|
|
483
|
-
>
|
|
444
|
+
> MapMatchingHandler.LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD)
|
|
484
445
|
);
|
|
485
446
|
}
|
|
486
447
|
|
|
487
|
-
/**
|
|
488
|
-
* @param {GraphNode} node
|
|
489
|
-
* @returns {boolean}
|
|
490
|
-
*/
|
|
491
|
-
_nodeHasTurn(node) {
|
|
492
|
-
const { edges } = node;
|
|
493
|
-
for (let i = 0; i < edges.length; i++) {
|
|
494
|
-
for (let j = i + 1; j < edges.length; j++) {
|
|
495
|
-
const angle = diffAngleLines(edges[i].bearing, edges[j].bearing);
|
|
496
|
-
if (angle > MapMatchingHandler.DEFAULT_MM_MAX_ANGLE) {
|
|
497
|
-
return true;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* @param {Coordinates} center
|
|
506
|
-
* @param {number} radius
|
|
507
|
-
* @returns {boolean}
|
|
508
|
-
*/
|
|
509
|
-
_hasTurnInCircle(center, radius) {
|
|
510
|
-
/** @type {Network} */
|
|
511
|
-
const network = this._mapMatching.network;
|
|
512
|
-
if (!network) {
|
|
513
|
-
return false;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
return network.nodes.filter(node =>
|
|
517
|
-
node.coords.distanceTo(center) <= radius
|
|
518
|
-
&& Level.intersect(node.coords.level, center.level)
|
|
519
|
-
).some(this._nodeHasTurn);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
448
|
/**
|
|
523
449
|
* @param {Projection} projection
|
|
524
450
|
*/
|
|
525
451
|
tryOrientationMatching(projection) {
|
|
526
452
|
|
|
527
|
-
if (!
|
|
453
|
+
if (!MapMatchingHandler.ORIENTATION_MATCHING) {
|
|
528
454
|
return;
|
|
529
455
|
}
|
|
530
456
|
|
|
531
457
|
if (this.state !== ProviderState.STARTED
|
|
532
|
-
|| this._countStepsFromLastMatching <
|
|
533
|
-
|| StraightLineDetector.numStepsDetectedFromLastTurn <
|
|
458
|
+
|| this._countStepsFromLastMatching < MapMatchingHandler.MIN_STEPS_BETWEEN_ORIENTATION_MATCHING
|
|
459
|
+
|| StraightLineDetector.numStepsDetectedFromLastTurn < MapMatchingHandler.MIN_STEPS_FOR_ORIENTATION_MATCHING) {
|
|
534
460
|
return;
|
|
535
461
|
}
|
|
536
462
|
|
|
@@ -598,70 +524,6 @@ class MapMatchingHandler extends Provider {
|
|
|
598
524
|
set useItineraryStartAsPosition(useItineraryStartAsPosition) {
|
|
599
525
|
this._useItineraryStartAsPosition = useItineraryStartAsPosition;
|
|
600
526
|
}
|
|
601
|
-
|
|
602
|
-
get useOrientationMatching() {
|
|
603
|
-
return this._useOrientationMatching;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
set useOrientationMatching(useOrientationMatching) {
|
|
607
|
-
this._useOrientationMatching = useOrientationMatching;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
get hugeJumpDistance() {
|
|
611
|
-
return this._hugeJumpDistance;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
set hugeJumpDistance(hugeJumpDistance) {
|
|
615
|
-
this._hugeJumpDistance = hugeJumpDistance;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
get disableMMCloseToATurnDistance() {
|
|
619
|
-
return this._disableMMCloseToATurnDistance;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
set disableMMCloseToATurnDistance(disableMMCloseToATurnDistance) {
|
|
623
|
-
this._disableMMCloseToATurnDistance = disableMMCloseToATurnDistance;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
get useOrientationMatching() {
|
|
627
|
-
return this._useOrientationMatching;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
set useOrientationMatching(useOrientationMatching) {
|
|
631
|
-
this._useOrientationMatching = useOrientationMatching;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
get minStepsBetweenOrientationMatching() {
|
|
635
|
-
return this._minStepsBetweenOrientationMatching;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
set minStepsBetweenOrientationMatching(minStepsBetweenOrientationMatching) {
|
|
639
|
-
this._minStepsBetweenOrientationMatching = minStepsBetweenOrientationMatching;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
get minStepsForOrientationMatching() {
|
|
643
|
-
return this._minStepsForOrientationMatching;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
set minStepsForOrientationMatching(minStepsForOrientationMatching) {
|
|
647
|
-
this._minStepsForOrientationMatching = minStepsForOrientationMatching;
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
get lastProjectionsWindowSize() {
|
|
651
|
-
return this._lastProjectionsWindowSize;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
set lastProjectionsWindowSize(lastProjectionsWindowSize) {
|
|
655
|
-
this._lastProjectionsWindowSize = lastProjectionsWindowSize;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
get lastProjectionsEdgeAngleThreshold() {
|
|
659
|
-
return this._lastProjectionsEdgeAngleThreshold;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
set lastProjectionsEdgeAngleThreshold(lastProjectionsEdgeAngleThreshold) {
|
|
663
|
-
this._lastProjectionsEdgeAngleThreshold = lastProjectionsEdgeAngleThreshold;
|
|
664
|
-
}
|
|
665
527
|
}
|
|
666
528
|
|
|
667
529
|
export default new MapMatchingHandler();
|
|
@@ -69,12 +69,11 @@ class Provider {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* @type {Promise
|
|
73
|
-
* Resolve with an error if the provider is not available
|
|
72
|
+
* @type {Promise} returns an availability promise
|
|
74
73
|
*/
|
|
75
74
|
get availability() {
|
|
76
75
|
if (ProvidersOptions.ignoreProviders.includes(this.pname)) {
|
|
77
|
-
return Promise.
|
|
76
|
+
return Promise.reject(new ContainsIgnoredProviderError());
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
return this._availability;
|
|
@@ -183,10 +182,11 @@ class Provider {
|
|
|
183
182
|
}
|
|
184
183
|
|
|
185
184
|
(async () => {
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
try {
|
|
186
|
+
await availabilityPromise;
|
|
187
|
+
} catch (e) {
|
|
188
188
|
this.state = ProviderState.STOPPED;
|
|
189
|
-
this.notifyError(
|
|
189
|
+
this.notifyError(e);
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
|
|
@@ -37,15 +37,15 @@ describe('Provider', () => {
|
|
|
37
37
|
|
|
38
38
|
it('availability', async () => {
|
|
39
39
|
|
|
40
|
-
expect(FakeProvider1.availability).to.be.fulfilled;
|
|
40
|
+
await expect(FakeProvider1.availability).to.be.fulfilled;
|
|
41
41
|
ProvidersOptions.ignoreProviders.push(FakeProvider1.pname);
|
|
42
|
-
expect(
|
|
42
|
+
await expect(FakeProvider1.availability).to.be.rejectedWith(ContainsIgnoredProviderError);
|
|
43
43
|
ProvidersOptions.ignoreProviders = [];
|
|
44
44
|
|
|
45
|
-
expect(
|
|
45
|
+
await expect(FakeProvider2.availability).to.be.rejectedWith(Error);
|
|
46
46
|
|
|
47
|
-
expect(FakeProvider3.availability).to.be.fulfilled;
|
|
48
|
-
expect(FakeProvider4.availability).to.be.fulfilled;
|
|
47
|
+
await expect(FakeProvider3.availability).to.be.fulfilled;
|
|
48
|
+
await expect(FakeProvider4.availability).to.be.fulfilled;
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
it('checkAvailability on start', async () => {
|
|
@@ -106,7 +106,7 @@ class EkfAttitude {
|
|
|
106
106
|
const eSkew = Matrix3.skew([qArray[1], qArray[2], qArray[3]]);
|
|
107
107
|
|
|
108
108
|
const qPart = [-1 * qArray[1], -1 * qArray[2], -1 * qArray[3]];
|
|
109
|
-
const E = Matrix.concatRow([qPart], Matrix3.
|
|
109
|
+
const E = Matrix.concatRow([qPart], Matrix3.add(eSkew, E1));
|
|
110
110
|
|
|
111
111
|
const Qk = Matrix.multiplyScalar(
|
|
112
112
|
Matrix.multiply(
|
|
@@ -116,7 +116,7 @@ class EkfAttitude {
|
|
|
116
116
|
(diffTime / 2) ** 2
|
|
117
117
|
);
|
|
118
118
|
|
|
119
|
-
const pAPriori = Matrix4.
|
|
119
|
+
const pAPriori = Matrix4.add(
|
|
120
120
|
Matrix.multiply(
|
|
121
121
|
Matrix.multiply(F, this.P),
|
|
122
122
|
Matrix.transpose(F)
|
|
@@ -152,7 +152,7 @@ class EkfAttitude {
|
|
|
152
152
|
K = Matrix.multiply(
|
|
153
153
|
Matrix.multiply(pAPriori, Matrix.transpose(H)),
|
|
154
154
|
Matrix.inverse(
|
|
155
|
-
Matrix.
|
|
155
|
+
Matrix.add(
|
|
156
156
|
Matrix.multiply(
|
|
157
157
|
Matrix.multiply(H, pAPriori),
|
|
158
158
|
Matrix.transpose(H)
|
|
@@ -169,7 +169,7 @@ class EkfAttitude {
|
|
|
169
169
|
K = Matrix.multiply(
|
|
170
170
|
Matrix.multiply(pAPriori, Matrix.transpose(H)),
|
|
171
171
|
Matrix3.inverse(
|
|
172
|
-
Matrix3.
|
|
172
|
+
Matrix3.add(
|
|
173
173
|
Matrix.multiply(
|
|
174
174
|
Matrix.multiply(H, pAPriori),
|
|
175
175
|
Matrix.transpose(H)
|
|
@@ -180,7 +180,7 @@ class EkfAttitude {
|
|
|
180
180
|
);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
q = Quaternion.
|
|
183
|
+
q = Quaternion.add(
|
|
184
184
|
qAPriori,
|
|
185
185
|
Matrix.multiplyVector(K, dz)
|
|
186
186
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-statements */
|
|
2
2
|
import { AbsoluteHeading, Attitude } from '@wemap/geo';
|
|
3
3
|
import { deg2rad, diffAngle, Quaternion } from '@wemap/maths';
|
|
4
|
+
import { PromiseUtils } from '@wemap/utils';
|
|
4
5
|
|
|
5
6
|
import Provider from '../../Provider.js';
|
|
6
7
|
import EventType from '../../../events/EventType.js';
|
|
@@ -9,9 +10,6 @@ import RelativeAttitude from '../relative/RelativeAttitude.js';
|
|
|
9
10
|
import Inclination from '../../inclination/Inclination.js';
|
|
10
11
|
import ProviderEvent from '../../../events/ProviderEvent.js';
|
|
11
12
|
import HighRotationsDetector from '../../imu/HighRotationsDetector.js';
|
|
12
|
-
import ProvidersOptions from '../../../ProvidersOptions.js';
|
|
13
|
-
import Vps from '../../vision/vps/Vps.js';
|
|
14
|
-
import AvailabilityHelper from '../../../events/AvailabilityHelper.js';
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* Absolute attitude provider gives the device attitude in East-North-Up (ENU) frame
|
|
@@ -81,7 +79,7 @@ class AbsoluteAttitude extends Provider {
|
|
|
81
79
|
* @override
|
|
82
80
|
*/
|
|
83
81
|
get _availability() {
|
|
84
|
-
return
|
|
82
|
+
return PromiseUtils.any([
|
|
85
83
|
AbsoluteAttitudeFromBrowser.availability,
|
|
86
84
|
RelativeAttitude.availability
|
|
87
85
|
]);
|
|
@@ -100,15 +98,6 @@ class AbsoluteAttitude extends Provider {
|
|
|
100
98
|
}
|
|
101
99
|
);
|
|
102
100
|
|
|
103
|
-
// Vps
|
|
104
|
-
if (ProvidersOptions.hasVps) {
|
|
105
|
-
this._vpsProviderId = Vps.addEventListener(
|
|
106
|
-
events => this._onAttitudeFromVps(events.find(event => event.dataType === EventType.AbsoluteAttitude)),
|
|
107
|
-
error => this.notifyError(error),
|
|
108
|
-
false
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
101
|
this.relativeAttitudeProviderId = RelativeAttitude.addEventListener(
|
|
113
102
|
events => this._onRelativeAttitudeEvent(events[0]),
|
|
114
103
|
error => {
|
|
@@ -212,17 +201,17 @@ class AbsoluteAttitude extends Provider {
|
|
|
212
201
|
let magnetometerNeedCalibrationEvent = null;
|
|
213
202
|
let divergenceDetected = false;
|
|
214
203
|
|
|
215
|
-
if (this.
|
|
204
|
+
if (this._eventFromBrowser) {
|
|
216
205
|
|
|
217
206
|
const {
|
|
218
207
|
accuracy: accuracyWithAbsolute,
|
|
219
208
|
heading: headingFromAbsolute
|
|
220
|
-
} = this.
|
|
209
|
+
} = this._eventFromBrowser.data;
|
|
221
210
|
|
|
222
211
|
if (this._wasHighRotationInProgress && !highRotationInProgress) {
|
|
223
212
|
// Update heading for relative if it the end of high rotations
|
|
224
213
|
// (probably due to a magnetometer calibratiton)
|
|
225
|
-
this._forceHeadingForRelative(this.
|
|
214
|
+
this._forceHeadingForRelative(this._eventFromBrowser);
|
|
226
215
|
|
|
227
216
|
} else if (accuracyWithAbsolute < accuracyWithRelative) {
|
|
228
217
|
// Update heading for relative if:
|
|
@@ -243,7 +232,7 @@ class AbsoluteAttitude extends Provider {
|
|
|
243
232
|
if (this._timeFirstDivergence !== null
|
|
244
233
|
&& time - this._timeFirstDivergence > AbsoluteAttitude.REL_ABS_DIVERGENCE_TIME_THRESHOLD) {
|
|
245
234
|
|
|
246
|
-
this._forceHeadingForRelative(this.
|
|
235
|
+
this._forceHeadingForRelative(this._eventFromBrowser);
|
|
247
236
|
magnetometerNeedCalibrationEvent = this.createEvent(
|
|
248
237
|
EventType.MagnetometerNeedCalibration,
|
|
249
238
|
{
|
|
@@ -288,7 +277,7 @@ class AbsoluteAttitude extends Provider {
|
|
|
288
277
|
* @param {ProviderEvent<Attitude>} event
|
|
289
278
|
*/
|
|
290
279
|
_onAttitudeFromBrowser(event) {
|
|
291
|
-
this.
|
|
280
|
+
this._eventFromBrowser = event;
|
|
292
281
|
|
|
293
282
|
if (!this._lastForcedHeadingEvent) {
|
|
294
283
|
this._forceHeadingForRelative(event);
|
|
@@ -298,15 +287,6 @@ class AbsoluteAttitude extends Provider {
|
|
|
298
287
|
// Absolute attitude from browser is not used anymore due to magnetometer inaccuracy on pitch and roll
|
|
299
288
|
}
|
|
300
289
|
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* @param {ProviderEvent<Attitude>} event
|
|
304
|
-
*/
|
|
305
|
-
_onAttitudeFromVps(event) {
|
|
306
|
-
// Use every attitude from Vps
|
|
307
|
-
this._forceHeadingForRelative(event);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
290
|
/**
|
|
311
291
|
* @override
|
|
312
292
|
* @param {AbsoluteHeading|Attitude|ProviderEvent} data
|
|
@@ -7,7 +7,6 @@ import RelativeAttitudeFromInertial from './RelativeAttitudeFromInertial.js';
|
|
|
7
7
|
|
|
8
8
|
import Accelerometer from '../../imu/Accelerometer.js';
|
|
9
9
|
import Gyroscope from '../../imu/Gyroscope.js';
|
|
10
|
-
import AvailabilityHelper from '../../../events/AvailabilityHelper.js';
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -45,7 +44,7 @@ class RelativeAttitudeFromEkf extends Provider {
|
|
|
45
44
|
* @override
|
|
46
45
|
*/
|
|
47
46
|
get _availability() {
|
|
48
|
-
return
|
|
47
|
+
return Promise.all([
|
|
49
48
|
Accelerometer.availability,
|
|
50
49
|
Gyroscope.availability
|
|
51
50
|
]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Attitude } from '@wemap/geo';
|
|
2
2
|
import { deg2rad } from '@wemap/maths';
|
|
3
|
+
import { PromiseUtils } from '@wemap/utils';
|
|
3
4
|
|
|
4
5
|
import Provider from '../../Provider.js';
|
|
5
6
|
import ProviderEvent from '../../../events/ProviderEvent.js';
|
|
@@ -7,7 +8,6 @@ import EventType from '../../../events/EventType.js';
|
|
|
7
8
|
import RelativeAttitudeFromEkf from './RelativeAttitudeFromEkf.js';
|
|
8
9
|
import RelativeAttitudeFromBrowser from './RelativeAttitudeFromBrowser.js';
|
|
9
10
|
import HighRotationsDetector from '../../imu/HighRotationsDetector.js';
|
|
10
|
-
import AvailabilityHelper from '../../../events/AvailabilityHelper.js';
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class RelativeAttitudeFromInertial extends Provider {
|
|
@@ -36,9 +36,10 @@ class RelativeAttitudeFromInertial extends Provider {
|
|
|
36
36
|
* @override
|
|
37
37
|
*/
|
|
38
38
|
get _availability() {
|
|
39
|
-
return
|
|
39
|
+
return PromiseUtils.any([
|
|
40
40
|
RelativeAttitudeFromEkf.availability,
|
|
41
|
-
RelativeAttitudeFromBrowser.availability
|
|
41
|
+
RelativeAttitudeFromBrowser.availability,
|
|
42
|
+
HighRotationsDetector.availability
|
|
42
43
|
]);
|
|
43
44
|
}
|
|
44
45
|
|