@wemap/providers 11.0.0-alpha.18 → 11.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/dist/index.js +265 -275
- package/dist/index.js.map +1 -1
- package/index.ts +3 -3
- package/package.json +51 -56
- package/src/events/Types.ts +1 -0
- package/src/mapmatching/MapMatchingHandler.spec.ts +5 -6
- package/src/mapmatching/MapMatchingHandler.ts +11 -16
- package/src/providers/position/absolute/AbsolutePositionProvider.ts +3 -5
- package/src/providers/position/absolute/GnssWifiProvider.ts +0 -10
- package/src/providers/steps/StepProvider.ts +1 -1
- package/dist/index.mjs +0 -3277
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
3
|
var __publicField = (obj, key, value) => {
|
|
5
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
5
|
return value;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
17
|
-
const Logger__default = /* @__PURE__ */ _interopDefaultLegacy(Logger);
|
|
18
|
-
const geomagnetism__default = /* @__PURE__ */ _interopDefaultLegacy(geomagnetism);
|
|
19
|
-
class RelativeAttitude extends geo.Attitude {
|
|
7
|
+
import { Attitude, UserPosition, RelativePosition, GeoRelativePosition, Constants as Constants$1, Level, AbsoluteHeading, MapMatching, GraphEdge } from "@wemap/geo";
|
|
8
|
+
import { deg2rad, Matrix4, Matrix3, Vector3, Quaternion, Matrix, Vector, Rotations, rad2deg, diffAngle, std, diffAngleLines } from "@wemap/maths";
|
|
9
|
+
import { ItineraryInfoManager } from "@wemap/routers";
|
|
10
|
+
import { TimeUtils, BrowserUtils, Browser, UserAgentUtils } from "@wemap/utils";
|
|
11
|
+
import Logger from "@wemap/logger";
|
|
12
|
+
import geomagnetism from "@wemap/geomagnetism";
|
|
13
|
+
import { canvasToBase64, base64ToCanvas, convertToGrayscale, reduceImageSize, Camera, SharedCameras } from "@wemap/camera";
|
|
14
|
+
class RelativeAttitude extends Attitude {
|
|
20
15
|
}
|
|
21
|
-
class AbsoluteAttitude extends
|
|
16
|
+
class AbsoluteAttitude extends Attitude {
|
|
22
17
|
}
|
|
23
|
-
class AbsolutePosition extends
|
|
18
|
+
class AbsolutePosition extends UserPosition {
|
|
24
19
|
}
|
|
25
20
|
const ProvidersOptions = {
|
|
26
21
|
useMapMatching: true,
|
|
@@ -54,7 +49,7 @@ class ProvidersLoggerOld {
|
|
|
54
49
|
}
|
|
55
50
|
this.interval = window.setInterval(() => {
|
|
56
51
|
for (const [key, value] of Object.entries(this.pushEvents)) {
|
|
57
|
-
|
|
52
|
+
Logger.debug("Received " + value + " notifications from " + this.pushEventsRef[Number(key)].getName() + " last second");
|
|
58
53
|
}
|
|
59
54
|
this.pushEvents = {};
|
|
60
55
|
this.pushEventsRef = {};
|
|
@@ -76,7 +71,7 @@ class ProvidersLoggerOld {
|
|
|
76
71
|
this.initializeInterval();
|
|
77
72
|
const objectId = this.getObjectId(object);
|
|
78
73
|
const objectClassName = object.getName();
|
|
79
|
-
|
|
74
|
+
Logger.debug(objectClassName + "[" + objectId + "]." + method);
|
|
80
75
|
}
|
|
81
76
|
incrementNotifications(object) {
|
|
82
77
|
if (!this.enabled) {
|
|
@@ -307,7 +302,6 @@ const Constants = {
|
|
|
307
302
|
const _GnssWifiProvider = class extends Provider {
|
|
308
303
|
constructor() {
|
|
309
304
|
super(...arguments);
|
|
310
|
-
__publicField(this, "discardPositionsAbove", _GnssWifiProvider.DEFAULT_DISCARD_POSITIONS_ABOVE);
|
|
311
305
|
__publicField(this, "geoLocationId");
|
|
312
306
|
__publicField(this, "getName", () => "GnssWifi");
|
|
313
307
|
__publicField(this, "onNewPosition", (geolocation) => {
|
|
@@ -317,10 +311,10 @@ const _GnssWifiProvider = class extends Provider {
|
|
|
317
311
|
}
|
|
318
312
|
let bearing;
|
|
319
313
|
if (coords.heading) {
|
|
320
|
-
bearing =
|
|
314
|
+
bearing = deg2rad(coords.heading);
|
|
321
315
|
}
|
|
322
|
-
const timestamp =
|
|
323
|
-
const position = new
|
|
316
|
+
const timestamp = TimeUtils.unixTimestampToPreciseTime(geolocation.timestamp) / 1e3;
|
|
317
|
+
const position = new UserPosition(
|
|
324
318
|
coords.latitude,
|
|
325
319
|
coords.longitude,
|
|
326
320
|
Constants.DEFAULT_ALTITUDE,
|
|
@@ -329,13 +323,10 @@ const _GnssWifiProvider = class extends Provider {
|
|
|
329
323
|
coords.accuracy,
|
|
330
324
|
bearing
|
|
331
325
|
);
|
|
332
|
-
if (typeof this.discardPositionsAbove === "number" && coords.accuracy > this.discardPositionsAbove) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
326
|
this.notify(position);
|
|
336
327
|
});
|
|
337
328
|
__publicField(this, "onPositionError", (error) => {
|
|
338
|
-
|
|
329
|
+
Logger.warn(`[Providers] watchPosition error: [${error.code}] ${error.message}`);
|
|
339
330
|
let customError;
|
|
340
331
|
switch (error.code) {
|
|
341
332
|
case 1:
|
|
@@ -374,7 +365,6 @@ __publicField(GnssWifiProvider, "POSITION_OPTIONS", {
|
|
|
374
365
|
timeout: Infinity,
|
|
375
366
|
maximumAge: 0
|
|
376
367
|
});
|
|
377
|
-
__publicField(GnssWifiProvider, "DEFAULT_DISCARD_POSITIONS_ABOVE", 50);
|
|
378
368
|
const GnssWifiProvider$1 = new GnssWifiProvider();
|
|
379
369
|
const _MissingArCoreError = class extends Error {
|
|
380
370
|
constructor(message) {
|
|
@@ -431,7 +421,7 @@ const _ArCoreProvider = class extends Provider {
|
|
|
431
421
|
const ref = payload[0];
|
|
432
422
|
let bufferIndex = 1;
|
|
433
423
|
let attitude, position, cameraProjection, barcode;
|
|
434
|
-
const time =
|
|
424
|
+
const time = TimeUtils.preciseTime() / 1e3;
|
|
435
425
|
if (ref & _ArCoreProvider.Payload.Pose.ref) {
|
|
436
426
|
attitude = new RelativeAttitude(
|
|
437
427
|
payload.slice(bufferIndex, bufferIndex + 4),
|
|
@@ -443,7 +433,7 @@ const _ArCoreProvider = class extends Provider {
|
|
|
443
433
|
payload[bufferIndex + 5],
|
|
444
434
|
payload[bufferIndex + 6]
|
|
445
435
|
];
|
|
446
|
-
position = new
|
|
436
|
+
position = new RelativePosition(
|
|
447
437
|
newPosition[0] - this.previousPosition[0],
|
|
448
438
|
newPosition[1] - this.previousPosition[1],
|
|
449
439
|
newPosition[2] - this.previousPosition[2],
|
|
@@ -517,7 +507,7 @@ __publicField(ArCoreProvider, "Payload", {
|
|
|
517
507
|
size: 1
|
|
518
508
|
}
|
|
519
509
|
});
|
|
520
|
-
__publicField(ArCoreProvider, "RELATIVE_ATTITUDE_DRIFT",
|
|
510
|
+
__publicField(ArCoreProvider, "RELATIVE_ATTITUDE_DRIFT", deg2rad(3) / 60);
|
|
521
511
|
const ArCoreProvider$1 = new ArCoreProvider();
|
|
522
512
|
class GeoRelativePositionFromArCoreProvider extends Provider {
|
|
523
513
|
constructor() {
|
|
@@ -559,7 +549,7 @@ class GeoRelativePositionFromArCoreProvider extends Provider {
|
|
|
559
549
|
const east = Math.cos(rotation) * relativePosition.x - Math.sin(rotation) * relativePosition.z;
|
|
560
550
|
const north = -Math.sin(rotation) * relativePosition.x - Math.cos(rotation) * relativePosition.z;
|
|
561
551
|
const up = relativePosition.y;
|
|
562
|
-
const position = new
|
|
552
|
+
const position = new GeoRelativePosition(
|
|
563
553
|
east,
|
|
564
554
|
north,
|
|
565
555
|
up,
|
|
@@ -589,7 +579,7 @@ class EkfAttitude {
|
|
|
589
579
|
__publicField(this, "quaternion");
|
|
590
580
|
this.accRef = accRef;
|
|
591
581
|
this.cRef = ycRef;
|
|
592
|
-
this.P =
|
|
582
|
+
this.P = Matrix4.fromDiagVector(Array(4).fill(0.1 ** 2));
|
|
593
583
|
this.quaternion = null;
|
|
594
584
|
this.noises = {};
|
|
595
585
|
this.setRelativeNoises(DEFAULT_RELATIVE_NOISES);
|
|
@@ -597,34 +587,34 @@ class EkfAttitude {
|
|
|
597
587
|
}
|
|
598
588
|
setRelativeNoises(relativeNoises) {
|
|
599
589
|
this.noises.relative = {
|
|
600
|
-
acc:
|
|
601
|
-
gyr:
|
|
590
|
+
acc: Matrix3.diag(Array(3).fill(relativeNoises.acc ** 2)),
|
|
591
|
+
gyr: Matrix3.diag(Array(3).fill(relativeNoises.gyr ** 2))
|
|
602
592
|
};
|
|
603
593
|
}
|
|
604
594
|
setAbsoluteNoises(absoluteNoises) {
|
|
605
595
|
this.noises.absolute = {
|
|
606
|
-
acc:
|
|
607
|
-
gyr:
|
|
608
|
-
yc:
|
|
596
|
+
acc: Matrix3.diag(Array(3).fill(absoluteNoises.acc ** 2)),
|
|
597
|
+
gyr: Matrix3.diag(Array(3).fill(absoluteNoises.gyr ** 2)),
|
|
598
|
+
yc: Matrix3.diag(Array(3).fill(absoluteNoises.yc ** 2))
|
|
609
599
|
};
|
|
610
600
|
}
|
|
611
601
|
tryInitialize(acc, mag) {
|
|
612
|
-
const accNormalized =
|
|
602
|
+
const accNormalized = Vector3.normalize(acc);
|
|
613
603
|
if (mag) {
|
|
614
|
-
const magNormalized =
|
|
615
|
-
const H =
|
|
616
|
-
const M =
|
|
604
|
+
const magNormalized = Vector3.normalize(mag);
|
|
605
|
+
const H = Vector3.normalize(Vector3.cross(magNormalized, accNormalized));
|
|
606
|
+
const M = Vector3.cross(accNormalized, H);
|
|
617
607
|
const R = [
|
|
618
608
|
[H[0], M[0], accNormalized[0]],
|
|
619
609
|
[H[1], M[1], accNormalized[1]],
|
|
620
610
|
[H[2], M[2], accNormalized[2]]
|
|
621
611
|
];
|
|
622
|
-
this.quaternion =
|
|
612
|
+
this.quaternion = Quaternion.fromMatrix3Matlab(R);
|
|
623
613
|
} else {
|
|
624
|
-
const r =
|
|
625
|
-
const v =
|
|
614
|
+
const r = Vector3.dot(accNormalized, this.accRef) + 1;
|
|
615
|
+
const v = Vector3.cross(accNormalized, this.accRef);
|
|
626
616
|
let quaternion = [r, v[0], v[1], v[2]];
|
|
627
|
-
quaternion =
|
|
617
|
+
quaternion = Quaternion.normalize(quaternion);
|
|
628
618
|
this.quaternion = quaternion;
|
|
629
619
|
}
|
|
630
620
|
return this.quaternion;
|
|
@@ -635,83 +625,83 @@ class EkfAttitude {
|
|
|
635
625
|
}
|
|
636
626
|
let q = this.quaternion;
|
|
637
627
|
const qArray = q;
|
|
638
|
-
const gyrInt =
|
|
628
|
+
const gyrInt = Vector3.multiplyScalar(gyr, 0.5 * diffTime);
|
|
639
629
|
const F = this.computeC([1, gyrInt[0], gyrInt[1], gyrInt[2]]);
|
|
640
|
-
const qAPriori =
|
|
641
|
-
const E1 =
|
|
642
|
-
const eSkew =
|
|
630
|
+
const qAPriori = Matrix4.multiplyVector(F, q);
|
|
631
|
+
const E1 = Matrix3.diag([qArray[0], qArray[0], qArray[0]]);
|
|
632
|
+
const eSkew = Matrix3.skew([qArray[1], qArray[2], qArray[3]]);
|
|
643
633
|
const qPart = [-1 * qArray[1], -1 * qArray[2], -1 * qArray[3]];
|
|
644
|
-
const E =
|
|
645
|
-
const Qk =
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
634
|
+
const E = Matrix.concatRow([qPart], Matrix3.sum(eSkew, E1));
|
|
635
|
+
const Qk = Matrix4.multiplyScalar(
|
|
636
|
+
Matrix.multiply(
|
|
637
|
+
Matrix.multiply(E, this.noises[mag ? "absolute" : "relative"].gyr),
|
|
638
|
+
Matrix.transpose(E)
|
|
649
639
|
),
|
|
650
640
|
(diffTime / 2) ** 2
|
|
651
641
|
);
|
|
652
|
-
const pAPriori =
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
642
|
+
const pAPriori = Matrix4.sum(
|
|
643
|
+
Matrix4.multiply(
|
|
644
|
+
Matrix4.multiply(F, this.P),
|
|
645
|
+
Matrix4.transpose(F)
|
|
656
646
|
),
|
|
657
647
|
Qk
|
|
658
648
|
);
|
|
659
|
-
const accNormalized =
|
|
649
|
+
const accNormalized = Vector3.normalize(acc);
|
|
660
650
|
let dz, K, H;
|
|
661
651
|
if (mag) {
|
|
662
|
-
const magNormalized =
|
|
663
|
-
const yc =
|
|
664
|
-
const ycNormalized =
|
|
665
|
-
const dzYc =
|
|
666
|
-
const dzAcc =
|
|
667
|
-
dz =
|
|
652
|
+
const magNormalized = Vector3.normalize(mag);
|
|
653
|
+
const yc = Vector3.cross(accNormalized, magNormalized);
|
|
654
|
+
const ycNormalized = Vector3.normalize(yc);
|
|
655
|
+
const dzYc = Vector3.subtract(ycNormalized, Quaternion.rotateMatlab(qAPriori, this.cRef));
|
|
656
|
+
const dzAcc = Vector3.subtract(accNormalized, Quaternion.rotateMatlab(qAPriori, this.accRef));
|
|
657
|
+
dz = Vector.concat(dzYc, dzAcc);
|
|
668
658
|
const HYc = this.jacobianES(qAPriori, this.cRef);
|
|
669
659
|
const HAcc = this.jacobianES(qAPriori, this.accRef);
|
|
670
|
-
H =
|
|
671
|
-
const RYc =
|
|
672
|
-
const RAcc =
|
|
673
|
-
const R =
|
|
674
|
-
K =
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
660
|
+
H = Matrix.concatRow(HYc, HAcc);
|
|
661
|
+
const RYc = Matrix.concatLine(this.noises.absolute.yc, Matrix3.zeros);
|
|
662
|
+
const RAcc = Matrix.concatLine(Matrix3.zeros, this.noises.absolute.acc);
|
|
663
|
+
const R = Matrix.concatRow(RYc, RAcc);
|
|
664
|
+
K = Matrix.multiply(
|
|
665
|
+
Matrix.multiply(pAPriori, Matrix.transpose(H)),
|
|
666
|
+
Matrix.inverse(
|
|
667
|
+
Matrix.sum(
|
|
668
|
+
Matrix.multiply(
|
|
669
|
+
Matrix.multiply(H, pAPriori),
|
|
670
|
+
Matrix.transpose(H)
|
|
681
671
|
),
|
|
682
672
|
R
|
|
683
673
|
)
|
|
684
674
|
)
|
|
685
675
|
);
|
|
686
676
|
} else {
|
|
687
|
-
dz =
|
|
677
|
+
dz = Vector3.subtract(accNormalized, Quaternion.rotateMatlab(qAPriori, this.accRef));
|
|
688
678
|
H = this.jacobianES(qAPriori, this.accRef);
|
|
689
679
|
const R = this.noises.relative.acc;
|
|
690
|
-
K =
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
680
|
+
K = Matrix.multiply(
|
|
681
|
+
Matrix.multiply(pAPriori, Matrix.transpose(H)),
|
|
682
|
+
Matrix3.inverse(
|
|
683
|
+
Matrix3.sum(
|
|
684
|
+
Matrix.multiply(
|
|
685
|
+
Matrix.multiply(H, pAPriori),
|
|
686
|
+
Matrix.transpose(H)
|
|
697
687
|
),
|
|
698
688
|
R
|
|
699
689
|
)
|
|
700
690
|
)
|
|
701
691
|
);
|
|
702
692
|
}
|
|
703
|
-
q =
|
|
693
|
+
q = Quaternion.sum(
|
|
704
694
|
qAPriori,
|
|
705
|
-
|
|
695
|
+
Matrix.multiplyVector(K, dz)
|
|
706
696
|
);
|
|
707
|
-
const P =
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
697
|
+
const P = Matrix4.multiply(
|
|
698
|
+
Matrix4.subtract(
|
|
699
|
+
Matrix4.identity,
|
|
700
|
+
Matrix.multiply(K, H)
|
|
711
701
|
),
|
|
712
702
|
pAPriori
|
|
713
703
|
);
|
|
714
|
-
q =
|
|
704
|
+
q = Quaternion.normalize(q);
|
|
715
705
|
this.quaternion = q;
|
|
716
706
|
this.P = P;
|
|
717
707
|
return q;
|
|
@@ -749,7 +739,7 @@ class ImuProvider extends Provider {
|
|
|
749
739
|
} = e.accelerationIncludingGravity;
|
|
750
740
|
if (typeof x === "number" && typeof y === "number" && typeof z === "number") {
|
|
751
741
|
acc = [x, y, z];
|
|
752
|
-
if (
|
|
742
|
+
if (BrowserUtils.name === Browser.SAFARI || BrowserUtils.name === Browser.IOS_WEBVIEW) {
|
|
753
743
|
acc[0] *= -1;
|
|
754
744
|
acc[1] *= -1;
|
|
755
745
|
acc[2] *= -1;
|
|
@@ -764,7 +754,7 @@ class ImuProvider extends Provider {
|
|
|
764
754
|
gamma
|
|
765
755
|
} = e.rotationRate;
|
|
766
756
|
if (typeof alpha === "number" && typeof beta === "number" && typeof gamma === "number") {
|
|
767
|
-
gyr = [
|
|
757
|
+
gyr = [deg2rad(alpha), deg2rad(beta), deg2rad(gamma)];
|
|
768
758
|
}
|
|
769
759
|
}
|
|
770
760
|
if (acc || gyr) {
|
|
@@ -776,7 +766,7 @@ class ImuProvider extends Provider {
|
|
|
776
766
|
});
|
|
777
767
|
}
|
|
778
768
|
availability() {
|
|
779
|
-
return
|
|
769
|
+
return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
780
770
|
}
|
|
781
771
|
start() {
|
|
782
772
|
const subscribe = () => window.addEventListener("devicemotion", this.parseDeviceMotionEvent, true);
|
|
@@ -904,7 +894,7 @@ const _RelativeAttitudeFromEkf = class extends Provider {
|
|
|
904
894
|
}
|
|
905
895
|
};
|
|
906
896
|
let RelativeAttitudeFromEkf = _RelativeAttitudeFromEkf;
|
|
907
|
-
__publicField(RelativeAttitudeFromEkf, "DEFAULT_DRIFT",
|
|
897
|
+
__publicField(RelativeAttitudeFromEkf, "DEFAULT_DRIFT", deg2rad(5) / 60);
|
|
908
898
|
const RelativeAttitudeFromEkfProvider = new RelativeAttitudeFromEkf();
|
|
909
899
|
const _RelativeAttitudeFromBrowser = class extends Provider {
|
|
910
900
|
constructor() {
|
|
@@ -915,7 +905,7 @@ const _RelativeAttitudeFromBrowser = class extends Provider {
|
|
|
915
905
|
this.notifyError(new MissingSensorError().from("deviceorientation"));
|
|
916
906
|
return;
|
|
917
907
|
}
|
|
918
|
-
const quaternion =
|
|
908
|
+
const quaternion = Rotations.eulerToQuaternionZXYDegrees([e.alpha, e.beta, e.gamma]);
|
|
919
909
|
const attitude = new RelativeAttitude(
|
|
920
910
|
quaternion,
|
|
921
911
|
e.timeStamp / 1e3,
|
|
@@ -925,7 +915,7 @@ const _RelativeAttitudeFromBrowser = class extends Provider {
|
|
|
925
915
|
});
|
|
926
916
|
}
|
|
927
917
|
availability() {
|
|
928
|
-
return
|
|
918
|
+
return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
929
919
|
}
|
|
930
920
|
start() {
|
|
931
921
|
const subscribe = () => window.addEventListener("deviceorientation", this.onDeviceOrientationEvent, true);
|
|
@@ -946,7 +936,7 @@ const _RelativeAttitudeFromBrowser = class extends Provider {
|
|
|
946
936
|
}
|
|
947
937
|
};
|
|
948
938
|
let RelativeAttitudeFromBrowser = _RelativeAttitudeFromBrowser;
|
|
949
|
-
__publicField(RelativeAttitudeFromBrowser, "DEFAULT_DRIFT",
|
|
939
|
+
__publicField(RelativeAttitudeFromBrowser, "DEFAULT_DRIFT", deg2rad(5) / 60);
|
|
950
940
|
const RelativeAttitudeFromBrowser$1 = new RelativeAttitudeFromBrowser();
|
|
951
941
|
const _HighRotationsProvider = class extends Provider {
|
|
952
942
|
constructor() {
|
|
@@ -956,7 +946,7 @@ const _HighRotationsProvider = class extends Provider {
|
|
|
956
946
|
__publicField(this, "availability", () => GyroscopeProvider$1.getAvailability());
|
|
957
947
|
__publicField(this, "_parseGyroscopeEvent", (gyroscopeEvent) => {
|
|
958
948
|
const { values, timestamp } = gyroscopeEvent;
|
|
959
|
-
const speed =
|
|
949
|
+
const speed = Vector3.norm(values);
|
|
960
950
|
if (speed > _HighRotationsProvider.THRESHOLD) {
|
|
961
951
|
this.notify({ timestamp });
|
|
962
952
|
}
|
|
@@ -1028,7 +1018,7 @@ const _RelativeAttitudeFromInertial = class extends Provider {
|
|
|
1028
1018
|
}
|
|
1029
1019
|
};
|
|
1030
1020
|
let RelativeAttitudeFromInertial = _RelativeAttitudeFromInertial;
|
|
1031
|
-
__publicField(RelativeAttitudeFromInertial, "DEFAULT_DRIFT",
|
|
1021
|
+
__publicField(RelativeAttitudeFromInertial, "DEFAULT_DRIFT", deg2rad(5) / 60);
|
|
1032
1022
|
const RelativeAttitudeFromInertialProvider = new RelativeAttitudeFromInertial();
|
|
1033
1023
|
const _StepDetectionLadetto = class {
|
|
1034
1024
|
constructor() {
|
|
@@ -1313,25 +1303,6 @@ const _StepProvider = class extends Provider {
|
|
|
1313
1303
|
__publicField(this, "_algorithm", _StepProvider.DEFAULT_ALGORITHM);
|
|
1314
1304
|
__publicField(this, "_accValues", []);
|
|
1315
1305
|
__publicField(this, "getName", () => "StepDetector");
|
|
1316
|
-
__publicField(this, "onAccelerometerEvent", (accelerationEvent) => {
|
|
1317
|
-
if (!this.attitudeEvent || !this.angularRateEvent) {
|
|
1318
|
-
return;
|
|
1319
|
-
}
|
|
1320
|
-
const {
|
|
1321
|
-
values: acceleration,
|
|
1322
|
-
timestamp
|
|
1323
|
-
} = accelerationEvent;
|
|
1324
|
-
const linearAcc = _StepProvider.computeLinearAcceleration(
|
|
1325
|
-
this.attitudeEvent.quaternion,
|
|
1326
|
-
acceleration
|
|
1327
|
-
);
|
|
1328
|
-
const stepDetected = this.stepDetector.compute(timestamp, linearAcc, this.angularRateEvent.values);
|
|
1329
|
-
if (stepDetected) {
|
|
1330
|
-
const size = this.stepDetector.lastStepSize * this._stepSizeMultiplier;
|
|
1331
|
-
this.numOfSteps++;
|
|
1332
|
-
this.notify({ size, number: this.numOfSteps });
|
|
1333
|
-
}
|
|
1334
|
-
});
|
|
1335
1306
|
this.algorithm = this._algorithm;
|
|
1336
1307
|
}
|
|
1337
1308
|
availability() {
|
|
@@ -1361,9 +1332,28 @@ const _StepProvider = class extends Provider {
|
|
|
1361
1332
|
GyroscopeProvider$1.removeEventListener(this.gyroscopeProviderId);
|
|
1362
1333
|
RelativeAttitudeFromInertialProvider.removeEventListener(this.attitudeProviderId);
|
|
1363
1334
|
}
|
|
1335
|
+
onAccelerometerEvent(accelerationEvent) {
|
|
1336
|
+
if (!this.attitudeEvent || !this.angularRateEvent) {
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
const {
|
|
1340
|
+
values: acceleration,
|
|
1341
|
+
timestamp
|
|
1342
|
+
} = accelerationEvent;
|
|
1343
|
+
const linearAcc = _StepProvider.computeLinearAcceleration(
|
|
1344
|
+
this.attitudeEvent.quaternion,
|
|
1345
|
+
acceleration
|
|
1346
|
+
);
|
|
1347
|
+
const stepDetected = this.stepDetector.compute(timestamp, linearAcc, this.angularRateEvent.values);
|
|
1348
|
+
if (stepDetected) {
|
|
1349
|
+
const size = this.stepDetector.lastStepSize * this._stepSizeMultiplier;
|
|
1350
|
+
this.numOfSteps++;
|
|
1351
|
+
this.notify({ size, number: this.numOfSteps });
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1364
1354
|
static computeLinearAcceleration(quaternion, acc) {
|
|
1365
|
-
const linearAcc =
|
|
1366
|
-
linearAcc[2] -=
|
|
1355
|
+
const linearAcc = Quaternion.rotateMatlab(Quaternion.inverse(quaternion), acc);
|
|
1356
|
+
linearAcc[2] -= Constants$1.EARTH_GRAVITY;
|
|
1367
1357
|
return linearAcc;
|
|
1368
1358
|
}
|
|
1369
1359
|
set stepSizeMultiplier(stepSizeMultiplier) {
|
|
@@ -1405,7 +1395,7 @@ class PdrProvider extends Provider {
|
|
|
1405
1395
|
__publicField(this, "absoluteAttitudeProviderId");
|
|
1406
1396
|
__publicField(this, "stepDetectionProviderId");
|
|
1407
1397
|
__publicField(this, "attitudeEvent");
|
|
1408
|
-
__publicField(this, "misalignmentError",
|
|
1398
|
+
__publicField(this, "misalignmentError", deg2rad(3));
|
|
1409
1399
|
__publicField(this, "getName", () => "Pdr");
|
|
1410
1400
|
__publicField(this, "onStepEvent", (stepEvent) => {
|
|
1411
1401
|
if (!this.attitudeEvent) {
|
|
@@ -1417,7 +1407,7 @@ class PdrProvider extends Provider {
|
|
|
1417
1407
|
const deviceDirectionAccuracy = deviceAttitude.accuracy + this.misalignmentError;
|
|
1418
1408
|
const accuracy = stepSize / 2 * Math.sin(deviceDirectionAccuracy / 2);
|
|
1419
1409
|
const timestamp = deviceAttitude.time;
|
|
1420
|
-
const position = new
|
|
1410
|
+
const position = new GeoRelativePosition(
|
|
1421
1411
|
stepSize * Math.sin(deviceDirection),
|
|
1422
1412
|
stepSize * Math.cos(deviceDirection),
|
|
1423
1413
|
0,
|
|
@@ -1615,8 +1605,8 @@ class VpsMetadata {
|
|
|
1615
1605
|
},
|
|
1616
1606
|
json.calibration,
|
|
1617
1607
|
{
|
|
1618
|
-
...((_a = json.coarse) == null ? void 0 : _a.position) && { position:
|
|
1619
|
-
...((_b = json.coarse) == null ? void 0 : _b.attitude) && { attitude:
|
|
1608
|
+
...((_a = json.coarse) == null ? void 0 : _a.position) && { position: UserPosition.fromJson(json.coarse.position) },
|
|
1609
|
+
...((_b = json.coarse) == null ? void 0 : _b.attitude) && { attitude: Attitude.fromJson(json.coarse.attitude) }
|
|
1620
1610
|
},
|
|
1621
1611
|
json.device
|
|
1622
1612
|
);
|
|
@@ -1628,7 +1618,7 @@ class VpsRequest {
|
|
|
1628
1618
|
this.image = image;
|
|
1629
1619
|
}
|
|
1630
1620
|
toJson() {
|
|
1631
|
-
const base64Image =
|
|
1621
|
+
const base64Image = canvasToBase64(this.image);
|
|
1632
1622
|
return {
|
|
1633
1623
|
image: base64Image,
|
|
1634
1624
|
...this.metadata.toJson()
|
|
@@ -1637,7 +1627,7 @@ class VpsRequest {
|
|
|
1637
1627
|
static fromJson(json) {
|
|
1638
1628
|
return new VpsRequest(
|
|
1639
1629
|
VpsMetadata.fromJson(json),
|
|
1640
|
-
|
|
1630
|
+
base64ToCanvas(json.image)
|
|
1641
1631
|
);
|
|
1642
1632
|
}
|
|
1643
1633
|
}
|
|
@@ -1658,12 +1648,12 @@ class VpsResponse {
|
|
|
1658
1648
|
static fromJson(json, imageRecordTime = null) {
|
|
1659
1649
|
let attitude = null;
|
|
1660
1650
|
if (json.attitude) {
|
|
1661
|
-
attitude =
|
|
1651
|
+
attitude = Attitude.fromJson(json.attitude);
|
|
1662
1652
|
attitude.time = imageRecordTime;
|
|
1663
1653
|
}
|
|
1664
1654
|
let position = null;
|
|
1665
1655
|
if (json.position) {
|
|
1666
|
-
position =
|
|
1656
|
+
position = UserPosition.fromJson(json.position);
|
|
1667
1657
|
position.time = imageRecordTime;
|
|
1668
1658
|
}
|
|
1669
1659
|
return new VpsResponse(json.success, attitude, position);
|
|
@@ -1671,23 +1661,23 @@ class VpsResponse {
|
|
|
1671
1661
|
}
|
|
1672
1662
|
class ImageRelocalization {
|
|
1673
1663
|
static _prepareRequest(imageCanvas, calibration = null, coarsePose = null) {
|
|
1674
|
-
|
|
1675
|
-
const reducedImage =
|
|
1664
|
+
convertToGrayscale(imageCanvas);
|
|
1665
|
+
const reducedImage = reduceImageSize(imageCanvas, 1280);
|
|
1676
1666
|
const metadata = new VpsMetadata(
|
|
1677
1667
|
{ width: reducedImage.width, height: reducedImage.height },
|
|
1678
1668
|
calibration,
|
|
1679
1669
|
coarsePose,
|
|
1680
|
-
|
|
1670
|
+
UserAgentUtils.getDeviceFromUserAgent()
|
|
1681
1671
|
);
|
|
1682
1672
|
return new VpsRequest(metadata, reducedImage);
|
|
1683
1673
|
}
|
|
1684
1674
|
static async relocalize(endpointUrl, imageCanvas, calibration = null, coarsePose = null, customHeaders = null) {
|
|
1685
|
-
const timeBeforeRequest =
|
|
1675
|
+
const timeBeforeRequest = TimeUtils.preciseTime() / 1e3;
|
|
1686
1676
|
const vpsRequest = this._prepareRequest(imageCanvas, calibration, coarsePose);
|
|
1687
1677
|
let serverResponse;
|
|
1688
1678
|
try {
|
|
1689
1679
|
const body = JSON.stringify(vpsRequest.toJson());
|
|
1690
|
-
|
|
1680
|
+
Logger.debug(`[VPS] Request (${(body.length / 1024).toFixed(0)} kB) sent to server ${endpointUrl}`);
|
|
1691
1681
|
serverResponse = await fetch(endpointUrl, {
|
|
1692
1682
|
method: "POST",
|
|
1693
1683
|
body,
|
|
@@ -1697,16 +1687,16 @@ class ImageRelocalization {
|
|
|
1697
1687
|
)
|
|
1698
1688
|
});
|
|
1699
1689
|
} catch (e) {
|
|
1700
|
-
|
|
1690
|
+
Logger.debug("[VPS] Server respond error");
|
|
1701
1691
|
return null;
|
|
1702
1692
|
}
|
|
1703
1693
|
if (serverResponse.status !== 200) {
|
|
1704
|
-
|
|
1694
|
+
Logger.debug("[VPS] Server respond error");
|
|
1705
1695
|
return null;
|
|
1706
1696
|
}
|
|
1707
1697
|
const json = await serverResponse.json();
|
|
1708
1698
|
const res = VpsResponse.fromJson(json, timeBeforeRequest);
|
|
1709
|
-
|
|
1699
|
+
Logger.debug(`[VPS] Server respond ${res.success ? "success" : "not found"}`);
|
|
1710
1700
|
return res;
|
|
1711
1701
|
}
|
|
1712
1702
|
static getHeadingFromQuaternion(quaternion) {
|
|
@@ -1736,16 +1726,16 @@ class RelativeRotationCalc {
|
|
|
1736
1726
|
}
|
|
1737
1727
|
tickEnd() {
|
|
1738
1728
|
if (!this._isRunning) {
|
|
1739
|
-
|
|
1729
|
+
Logger.warn("You have to call tickStart before tickEnd");
|
|
1740
1730
|
return null;
|
|
1741
1731
|
}
|
|
1742
1732
|
this._internalStop();
|
|
1743
1733
|
if (!this._dataOnStart) {
|
|
1744
|
-
|
|
1734
|
+
Logger.warn("Delay was too short between tickStart and tickEnd or RelativeAttitudeProvider cannot be retrieved.");
|
|
1745
1735
|
return null;
|
|
1746
1736
|
}
|
|
1747
1737
|
const dataOnEnd = RelativeAttitudeFromBrowser$1.lastEvent;
|
|
1748
|
-
return
|
|
1738
|
+
return Attitude.diff(this._dataOnStart, dataOnEnd);
|
|
1749
1739
|
}
|
|
1750
1740
|
_internalStop() {
|
|
1751
1741
|
RelativeAttitudeFromBrowser$1.removeEventListener(this._providerId);
|
|
@@ -1806,7 +1796,7 @@ class PoleStarProvider extends Provider {
|
|
|
1806
1796
|
callbackError: (errorMessage) => this.notifyError(new Error(errorMessage)),
|
|
1807
1797
|
callbackPosition: (jsonString) => {
|
|
1808
1798
|
const json = JSON.parse(jsonString);
|
|
1809
|
-
const timestamp =
|
|
1799
|
+
const timestamp = TimeUtils.unixTimestampToPreciseTime(json.time) / 1e3;
|
|
1810
1800
|
const position = new AbsolutePosition(
|
|
1811
1801
|
json.lat,
|
|
1812
1802
|
json.lng,
|
|
@@ -1814,7 +1804,7 @@ class PoleStarProvider extends Provider {
|
|
|
1814
1804
|
json.alt / 5,
|
|
1815
1805
|
timestamp,
|
|
1816
1806
|
json.accuracy,
|
|
1817
|
-
|
|
1807
|
+
deg2rad(json.bearing)
|
|
1818
1808
|
);
|
|
1819
1809
|
this.notify(position);
|
|
1820
1810
|
}
|
|
@@ -1835,19 +1825,19 @@ const _VpsProvider = class extends Provider {
|
|
|
1835
1825
|
__publicField(this, "_waitTimeMinInclinationForRequest", _VpsProvider.DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST);
|
|
1836
1826
|
__publicField(this, "_useCoarsePose", _VpsProvider.DEFAULT_USE_COARSE_POSE);
|
|
1837
1827
|
__publicField(this, "getName", () => "Vps");
|
|
1838
|
-
__publicField(this, "availability", () =>
|
|
1839
|
-
__publicField(this, "_onCameraDetected", ({ camera
|
|
1828
|
+
__publicField(this, "availability", () => Camera.checkAvailability());
|
|
1829
|
+
__publicField(this, "_onCameraDetected", ({ camera }) => {
|
|
1840
1830
|
if (this._camera) {
|
|
1841
|
-
|
|
1831
|
+
Logger.warn("It seems that more than 1 camera has been detected for VPS. Taking the first...");
|
|
1842
1832
|
}
|
|
1843
|
-
this._useCamera(
|
|
1833
|
+
this._useCamera(camera);
|
|
1844
1834
|
});
|
|
1845
1835
|
__publicField(this, "_onCameraRemoved", () => {
|
|
1846
1836
|
if (this._camera) {
|
|
1847
1837
|
this._camera.off("started", this._internalStart);
|
|
1848
1838
|
this._camera.off("stopped", this._internalStop);
|
|
1849
1839
|
} else {
|
|
1850
|
-
|
|
1840
|
+
Logger.warn("There is no previously detected camera but once has stopped");
|
|
1851
1841
|
}
|
|
1852
1842
|
this._camera = null;
|
|
1853
1843
|
});
|
|
@@ -1861,11 +1851,11 @@ const _VpsProvider = class extends Provider {
|
|
|
1861
1851
|
const isProviderStopped = () => this.state === "stopped";
|
|
1862
1852
|
while (!isProviderStopped()) {
|
|
1863
1853
|
if (lastRequestTime !== null) {
|
|
1864
|
-
const diffTime =
|
|
1854
|
+
const diffTime = TimeUtils.preciseTime() - lastRequestTime;
|
|
1865
1855
|
const timeToWait = Math.max(0, _VpsProvider.MIN_TIME_BETWEEN_TWO_REQUESTS - diffTime);
|
|
1866
1856
|
await new Promise((resolve) => setTimeout(resolve, timeToWait));
|
|
1867
1857
|
}
|
|
1868
|
-
lastRequestTime =
|
|
1858
|
+
lastRequestTime = TimeUtils.preciseTime();
|
|
1869
1859
|
if (isProviderStopped() || !this._camera || this._camera.state !== "started") {
|
|
1870
1860
|
break;
|
|
1871
1861
|
}
|
|
@@ -1892,16 +1882,16 @@ const _VpsProvider = class extends Provider {
|
|
|
1892
1882
|
continue;
|
|
1893
1883
|
}
|
|
1894
1884
|
const enuToCameraRot = res.attitude.quaternion;
|
|
1895
|
-
const enuToSmartphoneRot =
|
|
1885
|
+
const enuToSmartphoneRot = Quaternion.multiply(
|
|
1896
1886
|
enuToCameraRot,
|
|
1897
1887
|
_VpsProvider.CAMERA_TO_SMARTPHONE_ROT
|
|
1898
1888
|
);
|
|
1899
|
-
const deviceQuaternion =
|
|
1900
|
-
|
|
1889
|
+
const deviceQuaternion = Quaternion.multiply(
|
|
1890
|
+
Quaternion.fromAxisAngle([0, 0, 1], deg2rad(window.orientation || 0)),
|
|
1901
1891
|
enuToSmartphoneRot
|
|
1902
1892
|
);
|
|
1903
|
-
const diffAttitude = ((_b = this._relativeRotationCalc) == null ? void 0 : _b.tickEnd()) || new
|
|
1904
|
-
const deviceQuaternionWithRelOffset =
|
|
1893
|
+
const diffAttitude = ((_b = this._relativeRotationCalc) == null ? void 0 : _b.tickEnd()) || new Attitude([1, 0, 0, 0]);
|
|
1894
|
+
const deviceQuaternionWithRelOffset = Quaternion.multiply(
|
|
1905
1895
|
deviceQuaternion,
|
|
1906
1896
|
diffAttitude.quaternion
|
|
1907
1897
|
);
|
|
@@ -1929,28 +1919,28 @@ const _VpsProvider = class extends Provider {
|
|
|
1929
1919
|
start() {
|
|
1930
1920
|
this._inclinationProviderId = InclinationProvider$1.addEventListener();
|
|
1931
1921
|
this._relativeRotationCalc = new RelativeRotationCalc();
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
if (
|
|
1935
|
-
if (
|
|
1936
|
-
|
|
1922
|
+
SharedCameras.on("added", this._onCameraDetected);
|
|
1923
|
+
SharedCameras.on("removed", this._onCameraRemoved);
|
|
1924
|
+
if (SharedCameras.list.length) {
|
|
1925
|
+
if (SharedCameras.list.length > 1) {
|
|
1926
|
+
Logger.warn("It seems that more than 1 camera has been detected for VPS. Taking the first...");
|
|
1937
1927
|
}
|
|
1938
|
-
this._useCamera(
|
|
1928
|
+
this._useCamera(SharedCameras.list[0].camera);
|
|
1939
1929
|
}
|
|
1940
1930
|
}
|
|
1941
1931
|
stop() {
|
|
1942
1932
|
var _a;
|
|
1943
1933
|
InclinationProvider$1.removeEventListener(this._inclinationProviderId);
|
|
1944
1934
|
(_a = this._relativeRotationCalc) == null ? void 0 : _a.release();
|
|
1945
|
-
|
|
1946
|
-
|
|
1935
|
+
SharedCameras.off("added", this._onCameraDetected);
|
|
1936
|
+
SharedCameras.off("removed", this._onCameraRemoved);
|
|
1947
1937
|
this._camera = null;
|
|
1948
1938
|
}
|
|
1949
|
-
_useCamera(
|
|
1950
|
-
this._camera =
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
if (
|
|
1939
|
+
_useCamera(camera) {
|
|
1940
|
+
this._camera = camera;
|
|
1941
|
+
camera.on("started", this._internalStart);
|
|
1942
|
+
camera.on("stopped", this._internalStop);
|
|
1943
|
+
if (camera.state === "started") {
|
|
1954
1944
|
this._internalStart();
|
|
1955
1945
|
}
|
|
1956
1946
|
}
|
|
@@ -1981,10 +1971,10 @@ const _VpsProvider = class extends Provider {
|
|
|
1981
1971
|
};
|
|
1982
1972
|
let VpsProvider = _VpsProvider;
|
|
1983
1973
|
__publicField(VpsProvider, "MIN_TIME_BETWEEN_TWO_REQUESTS", 1e3);
|
|
1984
|
-
__publicField(VpsProvider, "DEFAULT_MIN_INCLINATION_FOR_REQUEST",
|
|
1974
|
+
__publicField(VpsProvider, "DEFAULT_MIN_INCLINATION_FOR_REQUEST", deg2rad(60));
|
|
1985
1975
|
__publicField(VpsProvider, "DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST", 200);
|
|
1986
1976
|
__publicField(VpsProvider, "DEFAULT_USE_COARSE_POSE", true);
|
|
1987
|
-
__publicField(VpsProvider, "CAMERA_TO_SMARTPHONE_ROT",
|
|
1977
|
+
__publicField(VpsProvider, "CAMERA_TO_SMARTPHONE_ROT", Quaternion.fromAxisAngle([1, 0, 0], Math.PI));
|
|
1988
1978
|
const VpsProvider$1 = new VpsProvider();
|
|
1989
1979
|
const _AbsolutePositionProvider = class extends Provider {
|
|
1990
1980
|
constructor() {
|
|
@@ -2010,9 +2000,7 @@ const _AbsolutePositionProvider = class extends Provider {
|
|
|
2010
2000
|
start() {
|
|
2011
2001
|
GeoRelativePositionProvider$1.getAvailability().then((error) => {
|
|
2012
2002
|
if (!error) {
|
|
2013
|
-
this._relativePositionProviderId = GeoRelativePositionProvider$1.addEventListener(
|
|
2014
|
-
(e) => this._onRelativePosition(e)
|
|
2015
|
-
);
|
|
2003
|
+
this._relativePositionProviderId = GeoRelativePositionProvider$1.addEventListener(this._onRelativePosition);
|
|
2016
2004
|
}
|
|
2017
2005
|
});
|
|
2018
2006
|
this._gnssWifiProviderId = GnssWifiProvider$1.addEventListener(
|
|
@@ -2030,7 +2018,7 @@ const _AbsolutePositionProvider = class extends Provider {
|
|
|
2030
2018
|
if (ProvidersOptions.hasPoleStar) {
|
|
2031
2019
|
this._polestarProviderId = PoleStarProvider$1.addEventListener((polestarPositionEvent) => {
|
|
2032
2020
|
var _a;
|
|
2033
|
-
this._lastPolestarFix =
|
|
2021
|
+
this._lastPolestarFix = TimeUtils.preciseTime();
|
|
2034
2022
|
const psPositionUsed = this._onAbsolutePosition(polestarPositionEvent);
|
|
2035
2023
|
if (!psPositionUsed && ((_a = this.lastEvent) == null ? void 0 : _a.level) === null) {
|
|
2036
2024
|
const lastPositionWithLevel = this.lastEvent.clone();
|
|
@@ -2078,7 +2066,7 @@ const _AbsolutePositionProvider = class extends Provider {
|
|
|
2078
2066
|
if (isBetterEnough && isFarEnoughAndAccuracyIsBetter) {
|
|
2079
2067
|
return true;
|
|
2080
2068
|
}
|
|
2081
|
-
const isChangingLevel = canContainLevel && !
|
|
2069
|
+
const isChangingLevel = canContainLevel && !Level.equals(newPosition.level, lastPosition.level);
|
|
2082
2070
|
if (isChangingLevel) {
|
|
2083
2071
|
return true;
|
|
2084
2072
|
}
|
|
@@ -2125,7 +2113,7 @@ const _AbsolutePositionProvider = class extends Provider {
|
|
|
2125
2113
|
}
|
|
2126
2114
|
feed(data) {
|
|
2127
2115
|
let newPositionEvent;
|
|
2128
|
-
if (data instanceof
|
|
2116
|
+
if (data instanceof AbsolutePosition) {
|
|
2129
2117
|
if (data.time === null) {
|
|
2130
2118
|
throw Error("the time of the position is not defined");
|
|
2131
2119
|
}
|
|
@@ -2163,7 +2151,7 @@ const AbsolutePositionProvider$1 = new AbsolutePositionProvider();
|
|
|
2163
2151
|
class AbsoluteAttitudeFromBrowser extends Provider {
|
|
2164
2152
|
constructor() {
|
|
2165
2153
|
super(...arguments);
|
|
2166
|
-
__publicField(this, "DEFAULT_ACCURACY",
|
|
2154
|
+
__publicField(this, "DEFAULT_ACCURACY", deg2rad(15));
|
|
2167
2155
|
__publicField(this, "absolutePositionProviderId");
|
|
2168
2156
|
__publicField(this, "absolutePositionEvent");
|
|
2169
2157
|
__publicField(this, "declinationQuaternion");
|
|
@@ -2178,7 +2166,7 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2178
2166
|
this.notifyError(new MissingSensorError().from("deviceorientationabsolute"));
|
|
2179
2167
|
return;
|
|
2180
2168
|
}
|
|
2181
|
-
this.magQuaternion =
|
|
2169
|
+
this.magQuaternion = Rotations.eulerToQuaternionZXYDegrees(
|
|
2182
2170
|
[e.alpha, e.beta, e.gamma]
|
|
2183
2171
|
);
|
|
2184
2172
|
this.compute();
|
|
@@ -2194,15 +2182,15 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2194
2182
|
return;
|
|
2195
2183
|
}
|
|
2196
2184
|
let alpha;
|
|
2197
|
-
const [qw, qx, qy, qz] =
|
|
2198
|
-
const groundAngle =
|
|
2185
|
+
const [qw, qx, qy, qz] = Rotations.eulerToQuaternionZXYDegrees([e.webkitCompassHeading, e.beta, e.gamma]);
|
|
2186
|
+
const groundAngle = rad2deg(Math.acos(qw ** 2 - qx ** 2 - qy ** 2 + qz ** 2));
|
|
2199
2187
|
let isSkyMode = null;
|
|
2200
2188
|
if (groundAngle > 136) {
|
|
2201
2189
|
isSkyMode = true;
|
|
2202
2190
|
} else if (groundAngle < 134) {
|
|
2203
2191
|
isSkyMode = false;
|
|
2204
2192
|
} else if (this.iosPreviousQuat && this.iosIsSkyMode !== null) {
|
|
2205
|
-
isSkyMode =
|
|
2193
|
+
isSkyMode = Quaternion.distance([qw, qx, qy, qz], this.iosPreviousQuat) < 0.5 ? this.iosIsSkyMode : !this.iosIsSkyMode;
|
|
2206
2194
|
}
|
|
2207
2195
|
this.iosPreviousQuat = [qw, qx, qy, qz];
|
|
2208
2196
|
this.iosIsSkyMode = isSkyMode;
|
|
@@ -2218,33 +2206,33 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2218
2206
|
e.gamma
|
|
2219
2207
|
);
|
|
2220
2208
|
}
|
|
2221
|
-
this.magQuaternion =
|
|
2209
|
+
this.magQuaternion = Rotations.eulerToQuaternionZXYDegrees([alpha, e.beta, e.gamma]);
|
|
2222
2210
|
this.compute();
|
|
2223
2211
|
});
|
|
2224
2212
|
__publicField(this, "onAbsolutePositionEvent", (position) => {
|
|
2225
2213
|
this.absolutePositionEvent = position;
|
|
2226
|
-
const wmmResult =
|
|
2227
|
-
this.declinationQuaternion =
|
|
2214
|
+
const wmmResult = geomagnetism.model().point([position.lat, position.lng]);
|
|
2215
|
+
this.declinationQuaternion = Quaternion.fromAxisAngle([0, 0, 1], -deg2rad(wmmResult.decl));
|
|
2228
2216
|
AbsolutePositionProvider$1.removeEventListener(this.absolutePositionProviderId);
|
|
2229
2217
|
delete this.absolutePositionProviderId;
|
|
2230
2218
|
this.compute();
|
|
2231
2219
|
});
|
|
2232
2220
|
}
|
|
2233
2221
|
availability() {
|
|
2234
|
-
return
|
|
2222
|
+
return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
2235
2223
|
}
|
|
2236
2224
|
start() {
|
|
2237
2225
|
const subscribe = () => {
|
|
2238
|
-
switch (
|
|
2239
|
-
case
|
|
2226
|
+
switch (BrowserUtils.name) {
|
|
2227
|
+
case Browser.CHROME:
|
|
2240
2228
|
window.addEventListener(
|
|
2241
2229
|
"deviceorientationabsolute",
|
|
2242
2230
|
this.onDeviceOrientationChromeEvent,
|
|
2243
2231
|
true
|
|
2244
2232
|
);
|
|
2245
2233
|
break;
|
|
2246
|
-
case
|
|
2247
|
-
case
|
|
2234
|
+
case Browser.SAFARI:
|
|
2235
|
+
case Browser.IOS_WEBVIEW:
|
|
2248
2236
|
window.addEventListener(
|
|
2249
2237
|
"deviceorientation",
|
|
2250
2238
|
this.onDeviceOrientationSafariEvent,
|
|
@@ -2276,16 +2264,16 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2276
2264
|
}
|
|
2277
2265
|
}
|
|
2278
2266
|
stop() {
|
|
2279
|
-
switch (
|
|
2280
|
-
case
|
|
2267
|
+
switch (BrowserUtils.name) {
|
|
2268
|
+
case Browser.CHROME:
|
|
2281
2269
|
window.removeEventListener(
|
|
2282
2270
|
"deviceorientationabsolute",
|
|
2283
2271
|
this.onDeviceOrientationChromeEvent,
|
|
2284
2272
|
true
|
|
2285
2273
|
);
|
|
2286
2274
|
break;
|
|
2287
|
-
case
|
|
2288
|
-
case
|
|
2275
|
+
case Browser.SAFARI:
|
|
2276
|
+
case Browser.IOS_WEBVIEW:
|
|
2289
2277
|
window.removeEventListener(
|
|
2290
2278
|
"deviceorientation",
|
|
2291
2279
|
this.onDeviceOrientationSafariEvent,
|
|
@@ -2299,14 +2287,14 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2299
2287
|
if (!this.declinationQuaternion || !this.magQuaternion || !this.absolutePositionEvent) {
|
|
2300
2288
|
return;
|
|
2301
2289
|
}
|
|
2302
|
-
const trueQuaternion =
|
|
2290
|
+
const trueQuaternion = Quaternion.multiply(this.declinationQuaternion, this.magQuaternion);
|
|
2303
2291
|
const attitude = new AbsoluteAttitude(trueQuaternion, this.magQuaternionTimestamp, this.DEFAULT_ACCURACY);
|
|
2304
2292
|
this.notify(attitude);
|
|
2305
2293
|
}
|
|
2306
2294
|
static webkitCompassToHeading(_webkitCompassHeading, _beta, _gamma) {
|
|
2307
|
-
const webkitCompassHeading =
|
|
2308
|
-
const beta =
|
|
2309
|
-
const gamma =
|
|
2295
|
+
const webkitCompassHeading = deg2rad(_webkitCompassHeading);
|
|
2296
|
+
const beta = deg2rad(_beta);
|
|
2297
|
+
const gamma = deg2rad(_gamma);
|
|
2310
2298
|
const c1 = Math.cos(webkitCompassHeading / 2);
|
|
2311
2299
|
const c2 = Math.cos(beta / 2);
|
|
2312
2300
|
const c3 = Math.cos(gamma / 2);
|
|
@@ -2315,7 +2303,7 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2315
2303
|
const s3 = Math.sin(gamma / 2);
|
|
2316
2304
|
const qw = c1 * c2 * c3 - s1 * s2 * s3;
|
|
2317
2305
|
const qz = s1 * c2 * c3 + c1 * s2 * s3;
|
|
2318
|
-
return
|
|
2306
|
+
return rad2deg(-2 * Math.atan(qz / qw));
|
|
2319
2307
|
}
|
|
2320
2308
|
}
|
|
2321
2309
|
const AbsoluteAttitudeFromBrowser$1 = new AbsoluteAttitudeFromBrowser();
|
|
@@ -2401,7 +2389,7 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2401
2389
|
}
|
|
2402
2390
|
const calcForceHeading = (relativeAttitude) => {
|
|
2403
2391
|
const currentRelativeHeading = relativeAttitude.heading;
|
|
2404
|
-
this._relAbsQuat =
|
|
2392
|
+
this._relAbsQuat = Quaternion.fromAxisAngle(
|
|
2405
2393
|
[0, 0, 1],
|
|
2406
2394
|
currentRelativeHeading - absoluteHeadingEvent.heading
|
|
2407
2395
|
);
|
|
@@ -2443,9 +2431,9 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2443
2431
|
if (this._wasHighRotationInProgress && !highRotationInProgress) {
|
|
2444
2432
|
this._forceHeadingForRelative(this._absAttitudeFromBrowser);
|
|
2445
2433
|
} else if (accuracyWithAbsolute < accuracyWithRelative) {
|
|
2446
|
-
const relativeQuaternion =
|
|
2447
|
-
const relativeAttitude = new
|
|
2448
|
-
const angle = Math.abs(
|
|
2434
|
+
const relativeQuaternion = Quaternion.multiply(this._relAbsQuat, quaternion);
|
|
2435
|
+
const relativeAttitude = new Attitude(relativeQuaternion);
|
|
2436
|
+
const angle = Math.abs(diffAngle(relativeAttitude.heading, headingFromAbsolute));
|
|
2449
2437
|
const inclination = InclinationProvider$1.lastEvent;
|
|
2450
2438
|
if (angle > _AbsoluteAttitudeProvider.REL_ABS_DIVERGENCE_ANGLE_THRESHOLD && inclination !== null && Math.abs(inclination - Math.PI / 4) > _AbsoluteAttitudeProvider.REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD) {
|
|
2451
2439
|
divergenceDetected = true;
|
|
@@ -2463,7 +2451,7 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2463
2451
|
this._timeFirstDivergence = null;
|
|
2464
2452
|
}
|
|
2465
2453
|
this._wasHighRotationInProgress = highRotationInProgress;
|
|
2466
|
-
const absoluteQuat =
|
|
2454
|
+
const absoluteQuat = Quaternion.multiply(this._relAbsQuat, quaternion);
|
|
2467
2455
|
const attitude = new AbsoluteAttitude(absoluteQuat, time, accuracyWithRelative);
|
|
2468
2456
|
this.notify(attitude);
|
|
2469
2457
|
});
|
|
@@ -2518,7 +2506,7 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2518
2506
|
this._callbackMagCalibration = cb;
|
|
2519
2507
|
}
|
|
2520
2508
|
feed(data) {
|
|
2521
|
-
if (data instanceof
|
|
2509
|
+
if (data instanceof AbsoluteHeading) {
|
|
2522
2510
|
if (data.time === null) {
|
|
2523
2511
|
throw Error("the time of the absolute heading is not defined");
|
|
2524
2512
|
}
|
|
@@ -2540,9 +2528,9 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2540
2528
|
}
|
|
2541
2529
|
};
|
|
2542
2530
|
let AbsoluteAttitudeProvider = _AbsoluteAttitudeProvider;
|
|
2543
|
-
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_ANGLE_THRESHOLD",
|
|
2531
|
+
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_ANGLE_THRESHOLD", deg2rad(25));
|
|
2544
2532
|
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_TIME_THRESHOLD", 2.5);
|
|
2545
|
-
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD",
|
|
2533
|
+
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD", deg2rad(15));
|
|
2546
2534
|
const AbsoluteAttitudeProvider$1 = new AbsoluteAttitudeProvider();
|
|
2547
2535
|
const _TurnProvider = class extends Provider {
|
|
2548
2536
|
constructor() {
|
|
@@ -2556,7 +2544,7 @@ const _TurnProvider = class extends Provider {
|
|
|
2556
2544
|
const timestamp = relativeAttitudeEvent.time;
|
|
2557
2545
|
this.slidingWindow = this.slidingWindow.filter((item) => item[0] >= timestamp - _TurnProvider.SLIDING_WINDOW_TIME);
|
|
2558
2546
|
this.slidingWindow.push([timestamp, heading]);
|
|
2559
|
-
const stdVal =
|
|
2547
|
+
const stdVal = std(this.slidingWindow.map((item) => item[1]));
|
|
2560
2548
|
if (stdVal > _TurnProvider.STD_THRESHOLD) {
|
|
2561
2549
|
this.notify({ timestamp });
|
|
2562
2550
|
}
|
|
@@ -2665,7 +2653,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2665
2653
|
this._stopInternalProviders();
|
|
2666
2654
|
}
|
|
2667
2655
|
});
|
|
2668
|
-
this._mapMatching = new
|
|
2656
|
+
this._mapMatching = new MapMatching();
|
|
2669
2657
|
this._mapMatching.maxDistance = _MapMatchingHandler.DEFAULT_MM_MAX_DIST;
|
|
2670
2658
|
this._mapMatching.maxAngleBearing = _MapMatchingHandler.DEFAULT_MM_MAX_ANGLE;
|
|
2671
2659
|
}
|
|
@@ -2711,7 +2699,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2711
2699
|
}
|
|
2712
2700
|
set itinerary(itinerary) {
|
|
2713
2701
|
this._mapMatching.network = itinerary ? itinerary.toNetwork() : null;
|
|
2714
|
-
this._itineraryInfoManager = new
|
|
2702
|
+
this._itineraryInfoManager = new ItineraryInfoManager(itinerary);
|
|
2715
2703
|
this.notify({ ...itinerary && { itinerary } });
|
|
2716
2704
|
this._manageStartStop();
|
|
2717
2705
|
if (this.canUseMapMatching() && itinerary) {
|
|
@@ -2726,7 +2714,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2726
2714
|
return;
|
|
2727
2715
|
}
|
|
2728
2716
|
const lastPosition = AbsolutePositionProvider$1.lastEvent || null;
|
|
2729
|
-
const newPosition =
|
|
2717
|
+
const newPosition = UserPosition.fromCoordinates(itinerary.from);
|
|
2730
2718
|
if (lastPosition) {
|
|
2731
2719
|
newPosition.alt = lastPosition.alt;
|
|
2732
2720
|
newPosition.time = lastPosition.time;
|
|
@@ -2734,7 +2722,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2734
2722
|
newPosition.bearing = lastPosition.bearing;
|
|
2735
2723
|
} else if (itinerary.coords.length >= 2) {
|
|
2736
2724
|
newPosition.alt = Constants.DEFAULT_ALTITUDE;
|
|
2737
|
-
newPosition.time =
|
|
2725
|
+
newPosition.time = TimeUtils.preciseTime();
|
|
2738
2726
|
newPosition.accuracy = 0;
|
|
2739
2727
|
newPosition.bearing = itinerary.coords[0].bearingTo(itinerary.coords[1]);
|
|
2740
2728
|
} else {
|
|
@@ -2856,14 +2844,14 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2856
2844
|
}
|
|
2857
2845
|
const firstProjection = this._lastProjections[0];
|
|
2858
2846
|
return !this._lastProjections.some(
|
|
2859
|
-
(projection) => !(projection.nearestElement instanceof
|
|
2847
|
+
(projection) => !(projection.nearestElement instanceof GraphEdge) || !(firstProjection.nearestElement instanceof GraphEdge) || diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold
|
|
2860
2848
|
);
|
|
2861
2849
|
}
|
|
2862
2850
|
_nodeHasTurn(node) {
|
|
2863
2851
|
const { edges } = node;
|
|
2864
2852
|
for (let i = 0; i < edges.length; i++) {
|
|
2865
2853
|
for (let j = i + 1; j < edges.length; j++) {
|
|
2866
|
-
const angle =
|
|
2854
|
+
const angle = diffAngleLines(edges[i].bearing, edges[j].bearing);
|
|
2867
2855
|
if (angle > _MapMatchingHandler.DEFAULT_MM_MAX_ANGLE) {
|
|
2868
2856
|
return true;
|
|
2869
2857
|
}
|
|
@@ -2877,7 +2865,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2877
2865
|
return false;
|
|
2878
2866
|
}
|
|
2879
2867
|
return network.nodes.filter(
|
|
2880
|
-
(node) => node.coords.distanceTo(center) <= radius &&
|
|
2868
|
+
(node) => node.coords.distanceTo(center) <= radius && Level.intersect(node.coords.level, center.level)
|
|
2881
2869
|
).some(this._nodeHasTurn);
|
|
2882
2870
|
}
|
|
2883
2871
|
tryOrientationMatching(projection) {
|
|
@@ -2888,18 +2876,18 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2888
2876
|
return;
|
|
2889
2877
|
}
|
|
2890
2878
|
const { nearestElement, origin } = projection;
|
|
2891
|
-
if (!(nearestElement instanceof
|
|
2879
|
+
if (!(nearestElement instanceof GraphEdge)) {
|
|
2892
2880
|
return;
|
|
2893
2881
|
}
|
|
2894
2882
|
let matchingDirection;
|
|
2895
|
-
const matchingDirectionAngle1 =
|
|
2896
|
-
const matchingDirectionAngle2 =
|
|
2883
|
+
const matchingDirectionAngle1 = diffAngle(nearestElement.bearing, origin.bearing);
|
|
2884
|
+
const matchingDirectionAngle2 = diffAngle(nearestElement.bearing + Math.PI, origin.bearing);
|
|
2897
2885
|
if (Math.abs(matchingDirectionAngle1) < Math.abs(matchingDirectionAngle2)) {
|
|
2898
2886
|
matchingDirection = nearestElement.bearing;
|
|
2899
2887
|
} else {
|
|
2900
2888
|
matchingDirection = (nearestElement.bearing + Math.PI) % (2 * Math.PI);
|
|
2901
2889
|
}
|
|
2902
|
-
const matchedHeading = new
|
|
2890
|
+
const matchedHeading = new AbsoluteHeading(
|
|
2903
2891
|
matchingDirection,
|
|
2904
2892
|
origin.time,
|
|
2905
2893
|
0
|
|
@@ -2978,7 +2966,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2978
2966
|
}
|
|
2979
2967
|
};
|
|
2980
2968
|
let MapMatchingHandler = _MapMatchingHandler;
|
|
2981
|
-
__publicField(MapMatchingHandler, "DEFAULT_MM_MAX_ANGLE",
|
|
2969
|
+
__publicField(MapMatchingHandler, "DEFAULT_MM_MAX_ANGLE", deg2rad(30));
|
|
2982
2970
|
__publicField(MapMatchingHandler, "DEFAULT_MM_MAX_DIST", 30);
|
|
2983
2971
|
__publicField(MapMatchingHandler, "DEFAULT_MM_MIN_DIST", 0);
|
|
2984
2972
|
__publicField(MapMatchingHandler, "DEFAULT_USE_ITINERARY_START_AS_POSITION", false);
|
|
@@ -2988,7 +2976,7 @@ __publicField(MapMatchingHandler, "DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE",
|
|
|
2988
2976
|
__publicField(MapMatchingHandler, "DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING", 3);
|
|
2989
2977
|
__publicField(MapMatchingHandler, "DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING", 5);
|
|
2990
2978
|
__publicField(MapMatchingHandler, "DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE", 3);
|
|
2991
|
-
__publicField(MapMatchingHandler, "DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD",
|
|
2979
|
+
__publicField(MapMatchingHandler, "DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD", deg2rad(3));
|
|
2992
2980
|
const MapMatchingHandler$1 = new MapMatchingHandler();
|
|
2993
2981
|
const _PositionSmoother = class {
|
|
2994
2982
|
constructor(callback, frequency = _PositionSmoother.DEFAULT_FREQUENCY) {
|
|
@@ -3010,7 +2998,7 @@ const _PositionSmoother = class {
|
|
|
3010
2998
|
this.frequency = frequency;
|
|
3011
2999
|
}
|
|
3012
3000
|
feed(newPosition, flybyTime = _PositionSmoother.DEFAULT_FLYBY_TIME) {
|
|
3013
|
-
if (!(newPosition instanceof
|
|
3001
|
+
if (!(newPosition instanceof UserPosition)) {
|
|
3014
3002
|
throw new TypeError("newPosition is not instance of UserPosition");
|
|
3015
3003
|
}
|
|
3016
3004
|
if (newPosition.time === null) {
|
|
@@ -3029,7 +3017,7 @@ const _PositionSmoother = class {
|
|
|
3029
3017
|
const azimuth = previousPosition.bearingTo(newPosition);
|
|
3030
3018
|
let i = 1;
|
|
3031
3019
|
const nSamples = this.frequency * flybyTime + 1;
|
|
3032
|
-
const newPositionLevel =
|
|
3020
|
+
const newPositionLevel = Level.clone(newPosition.level);
|
|
3033
3021
|
while (i < nSamples + 1) {
|
|
3034
3022
|
const smoothedPosition = previousPosition.destinationPoint(distance * i / nSamples, azimuth);
|
|
3035
3023
|
smoothedPosition.time = refTimestamp + (i - 1) / this.frequency;
|
|
@@ -3080,7 +3068,7 @@ const _AttitudeSmoother = class {
|
|
|
3080
3068
|
const fromAttitude = this._smoothing === null ? previousAttitude : this._smoothing.interpAttitude(previousAttitude);
|
|
3081
3069
|
const fromHeading = fromAttitude.heading;
|
|
3082
3070
|
const toHeading = newAttitude.heading;
|
|
3083
|
-
const diffAngleHeading =
|
|
3071
|
+
const diffAngleHeading = diffAngle(toHeading, fromHeading);
|
|
3084
3072
|
const isHighJump = Math.abs(diffAngleHeading) < _AttitudeSmoother.HIGH_JUMP_THRESHOLD;
|
|
3085
3073
|
const rotationSpeedConvergence = isHighJump ? _AttitudeSmoother.ROTATION_SPEED_CONVERGENCE : _AttitudeSmoother.ROTATION_SPEED_HIGH_JUMP_CONVERGENCE;
|
|
3086
3074
|
const fromTime = fromAttitude.time;
|
|
@@ -3091,9 +3079,9 @@ const _AttitudeSmoother = class {
|
|
|
3091
3079
|
interpAttitude: (attitude) => {
|
|
3092
3080
|
const angle = rotationSpeedConvergence * (attitude.time - fromTime);
|
|
3093
3081
|
const interpHeading = fromHeading + angle * multiplier;
|
|
3094
|
-
const offsetQuat =
|
|
3095
|
-
const interpQuat =
|
|
3096
|
-
return new
|
|
3082
|
+
const offsetQuat = Quaternion.fromAxisAngle([0, 0, 1], toHeading - interpHeading);
|
|
3083
|
+
const interpQuat = Quaternion.multiply(offsetQuat, attitude.quaternion);
|
|
3084
|
+
return new Attitude(interpQuat, attitude.time, attitude.accuracy);
|
|
3097
3085
|
}
|
|
3098
3086
|
};
|
|
3099
3087
|
}
|
|
@@ -3111,7 +3099,7 @@ const _AttitudeSmoother = class {
|
|
|
3111
3099
|
static isJump(previousAttitude, newAttitude) {
|
|
3112
3100
|
const fromHeading = previousAttitude.heading;
|
|
3113
3101
|
const toHeading = newAttitude.heading;
|
|
3114
|
-
const diffAngleHeading =
|
|
3102
|
+
const diffAngleHeading = diffAngle(toHeading, fromHeading);
|
|
3115
3103
|
const diffTime = newAttitude.time - previousAttitude.time;
|
|
3116
3104
|
const [qw, qx, qy, qz] = newAttitude.quaternion;
|
|
3117
3105
|
const distToPitchThreshold = Math.abs(Math.asin(2 * (qw * qx + qy * qz)) - Math.PI / 4);
|
|
@@ -3122,11 +3110,11 @@ const _AttitudeSmoother = class {
|
|
|
3122
3110
|
}
|
|
3123
3111
|
};
|
|
3124
3112
|
let AttitudeSmoother = _AttitudeSmoother;
|
|
3125
|
-
__publicField(AttitudeSmoother, "ROTATION_SPEED_JUMP_THRESHOLD",
|
|
3126
|
-
__publicField(AttitudeSmoother, "ROTATION_SPEED_CONVERGENCE",
|
|
3127
|
-
__publicField(AttitudeSmoother, "HIGH_JUMP_THRESHOLD",
|
|
3128
|
-
__publicField(AttitudeSmoother, "ROTATION_SPEED_HIGH_JUMP_CONVERGENCE",
|
|
3129
|
-
__publicField(AttitudeSmoother, "PITCH_UNCERTAINITY_HEADING_THRESHOLD",
|
|
3113
|
+
__publicField(AttitudeSmoother, "ROTATION_SPEED_JUMP_THRESHOLD", deg2rad(180));
|
|
3114
|
+
__publicField(AttitudeSmoother, "ROTATION_SPEED_CONVERGENCE", deg2rad(10));
|
|
3115
|
+
__publicField(AttitudeSmoother, "HIGH_JUMP_THRESHOLD", deg2rad(20));
|
|
3116
|
+
__publicField(AttitudeSmoother, "ROTATION_SPEED_HIGH_JUMP_CONVERGENCE", deg2rad(100));
|
|
3117
|
+
__publicField(AttitudeSmoother, "PITCH_UNCERTAINITY_HEADING_THRESHOLD", deg2rad(5));
|
|
3130
3118
|
class MagnetometerCalibrationProvider extends Provider {
|
|
3131
3119
|
constructor() {
|
|
3132
3120
|
super();
|
|
@@ -3159,9 +3147,9 @@ class IpProvider extends Provider {
|
|
|
3159
3147
|
this.notifyError(new IpResolveServerError());
|
|
3160
3148
|
return;
|
|
3161
3149
|
}
|
|
3162
|
-
const timestamp =
|
|
3150
|
+
const timestamp = TimeUtils.preciseTime() / 1e3;
|
|
3163
3151
|
const latLngStr = (await response.json()).loc.split(",");
|
|
3164
|
-
const position = new
|
|
3152
|
+
const position = new UserPosition(
|
|
3165
3153
|
parseFloat(latLngStr[0]),
|
|
3166
3154
|
parseFloat(latLngStr[1]),
|
|
3167
3155
|
null,
|
|
@@ -3234,47 +3222,49 @@ class CameraProjectionMatrixProvider extends Provider {
|
|
|
3234
3222
|
}
|
|
3235
3223
|
}
|
|
3236
3224
|
const CameraProjectionMatrixProvider$1 = new CameraProjectionMatrixProvider();
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3225
|
+
export {
|
|
3226
|
+
AbsoluteAttitude,
|
|
3227
|
+
AbsoluteAttitudeFromBrowser$1 as AbsoluteAttitudeFromBrowserProvider,
|
|
3228
|
+
AbsoluteAttitudeProvider$1 as AbsoluteAttitudeProvider,
|
|
3229
|
+
AbsolutePosition,
|
|
3230
|
+
AbsolutePositionProvider$1 as AbsolutePositionProvider,
|
|
3231
|
+
AccelerometerProvider$1 as AccelerometerProvider,
|
|
3232
|
+
ArCoreProvider$1 as ArCoreProvider,
|
|
3233
|
+
AttitudeSmoother,
|
|
3234
|
+
BarcodeProvider,
|
|
3235
|
+
CameraNativeProvider$1 as CameraNativeProvider,
|
|
3236
|
+
CameraProjectionMatrixProvider$1 as CameraProjectionMatrixProvider,
|
|
3237
|
+
GeoRelativePositionFromArCoreProvider$1 as GeoRelativePositionFromArCoreProvider,
|
|
3238
|
+
GeoRelativePositionProvider$1 as GeoRelativePositionProvider,
|
|
3239
|
+
GnssWifiProvider$1 as GnssWifiProvider,
|
|
3240
|
+
GyroscopeProvider$1 as GyroscopeProvider,
|
|
3241
|
+
HighRotationsProvider$1 as HighRotationsProvider,
|
|
3242
|
+
ImageRelocalization,
|
|
3243
|
+
ImuProvider$1 as ImuProvider,
|
|
3244
|
+
InclinationFromAccProvider$1 as InclinationFromAccProvider,
|
|
3245
|
+
InclinationFromRelativeAttitudeProvider$1 as InclinationFromRelativeAttitudeProvider,
|
|
3246
|
+
InclinationProvider$1 as InclinationProvider,
|
|
3247
|
+
IpProvider$1 as IpProvider,
|
|
3248
|
+
MagnetometerCalibrationProvider$1 as MagnetometerCalibrationProvider,
|
|
3249
|
+
MapMatchingHandler$1 as MapMatchingHandler,
|
|
3250
|
+
PdrProvider$1 as PdrProvider,
|
|
3251
|
+
PoleStarProvider$1 as PoleStarProvider,
|
|
3252
|
+
PositionSmoother,
|
|
3253
|
+
ProvidersLoggerOld$1 as ProvidersLoggerOld,
|
|
3254
|
+
ProvidersOptions,
|
|
3255
|
+
RelativeAttitude,
|
|
3256
|
+
RelativeAttitudeFromBrowser$1 as RelativeAttitudeFromBrowserProvider,
|
|
3257
|
+
RelativeAttitudeFromEkfProvider,
|
|
3258
|
+
RelativeAttitudeFromInertialProvider,
|
|
3259
|
+
RelativeAttitudeProvider$1 as RelativeAttitudeProvider,
|
|
3260
|
+
StepDetectionMinMaxPeaks2,
|
|
3261
|
+
StepDetectionMinMaxPeaks3,
|
|
3262
|
+
StepProvider$1 as StepProvider,
|
|
3263
|
+
StraightLineProvider$1 as StraightLineProvider,
|
|
3264
|
+
TurnProvider$1 as TurnProvider,
|
|
3265
|
+
VpsMetadata,
|
|
3266
|
+
VpsProvider$1 as VpsProvider,
|
|
3267
|
+
VpsRequest,
|
|
3268
|
+
VpsResponse
|
|
3269
|
+
};
|
|
3280
3270
|
//# sourceMappingURL=index.js.map
|