@wemap/providers 11.0.0-alpha.3 → 11.0.0-alpha.5
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 +248 -245
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3270 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +56 -51
package/dist/index.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
4
|
var __publicField = (obj, key, value) => {
|
|
4
5
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
6
|
return value;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
+
const geo = require("@wemap/geo");
|
|
10
|
+
const maths = require("@wemap/maths");
|
|
11
|
+
const routers = require("@wemap/routers");
|
|
12
|
+
const utils = require("@wemap/utils");
|
|
13
|
+
const Logger = require("@wemap/logger");
|
|
14
|
+
const geomagnetism = require("@wemap/geomagnetism");
|
|
15
|
+
const camera = require("@wemap/camera");
|
|
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 {
|
|
15
20
|
}
|
|
16
|
-
class AbsoluteAttitude extends Attitude {
|
|
21
|
+
class AbsoluteAttitude extends geo.Attitude {
|
|
17
22
|
}
|
|
18
|
-
class AbsolutePosition extends UserPosition {
|
|
23
|
+
class AbsolutePosition extends geo.UserPosition {
|
|
19
24
|
}
|
|
20
25
|
const ProvidersOptions = {
|
|
21
26
|
useMapMatching: true,
|
|
@@ -49,7 +54,7 @@ class ProvidersLoggerOld {
|
|
|
49
54
|
}
|
|
50
55
|
this.interval = window.setInterval(() => {
|
|
51
56
|
for (const [key, value] of Object.entries(this.pushEvents)) {
|
|
52
|
-
|
|
57
|
+
Logger__default.default.debug("Received " + value + " notifications from " + this.pushEventsRef[Number(key)].getName() + " last second");
|
|
53
58
|
}
|
|
54
59
|
this.pushEvents = {};
|
|
55
60
|
this.pushEventsRef = {};
|
|
@@ -71,7 +76,7 @@ class ProvidersLoggerOld {
|
|
|
71
76
|
this.initializeInterval();
|
|
72
77
|
const objectId = this.getObjectId(object);
|
|
73
78
|
const objectClassName = object.getName();
|
|
74
|
-
|
|
79
|
+
Logger__default.default.debug(objectClassName + "[" + objectId + "]." + method);
|
|
75
80
|
}
|
|
76
81
|
incrementNotifications(object) {
|
|
77
82
|
if (!this.enabled) {
|
|
@@ -311,10 +316,10 @@ const _GnssWifiProvider = class extends Provider {
|
|
|
311
316
|
}
|
|
312
317
|
let bearing;
|
|
313
318
|
if (coords.heading) {
|
|
314
|
-
bearing = deg2rad(coords.heading);
|
|
319
|
+
bearing = maths.deg2rad(coords.heading);
|
|
315
320
|
}
|
|
316
|
-
const timestamp = TimeUtils.unixTimestampToPreciseTime(geolocation.timestamp) / 1e3;
|
|
317
|
-
const position = new UserPosition(
|
|
321
|
+
const timestamp = utils.TimeUtils.unixTimestampToPreciseTime(geolocation.timestamp) / 1e3;
|
|
322
|
+
const position = new geo.UserPosition(
|
|
318
323
|
coords.latitude,
|
|
319
324
|
coords.longitude,
|
|
320
325
|
Constants.DEFAULT_ALTITUDE,
|
|
@@ -326,7 +331,7 @@ const _GnssWifiProvider = class extends Provider {
|
|
|
326
331
|
this.notify(position);
|
|
327
332
|
});
|
|
328
333
|
__publicField(this, "onPositionError", (error) => {
|
|
329
|
-
|
|
334
|
+
Logger__default.default.warn(`[Providers] watchPosition error: [${error.code}] ${error.message}`);
|
|
330
335
|
let customError;
|
|
331
336
|
switch (error.code) {
|
|
332
337
|
case 1:
|
|
@@ -421,7 +426,7 @@ const _ArCoreProvider = class extends Provider {
|
|
|
421
426
|
const ref = payload[0];
|
|
422
427
|
let bufferIndex = 1;
|
|
423
428
|
let attitude, position, cameraProjection, barcode;
|
|
424
|
-
const time = TimeUtils.preciseTime() / 1e3;
|
|
429
|
+
const time = utils.TimeUtils.preciseTime() / 1e3;
|
|
425
430
|
if (ref & _ArCoreProvider.Payload.Pose.ref) {
|
|
426
431
|
attitude = new RelativeAttitude(
|
|
427
432
|
payload.slice(bufferIndex, bufferIndex + 4),
|
|
@@ -433,7 +438,7 @@ const _ArCoreProvider = class extends Provider {
|
|
|
433
438
|
payload[bufferIndex + 5],
|
|
434
439
|
payload[bufferIndex + 6]
|
|
435
440
|
];
|
|
436
|
-
position = new RelativePosition(
|
|
441
|
+
position = new geo.RelativePosition(
|
|
437
442
|
newPosition[0] - this.previousPosition[0],
|
|
438
443
|
newPosition[1] - this.previousPosition[1],
|
|
439
444
|
newPosition[2] - this.previousPosition[2],
|
|
@@ -507,7 +512,7 @@ __publicField(ArCoreProvider, "Payload", {
|
|
|
507
512
|
size: 1
|
|
508
513
|
}
|
|
509
514
|
});
|
|
510
|
-
__publicField(ArCoreProvider, "RELATIVE_ATTITUDE_DRIFT", deg2rad(3) / 60);
|
|
515
|
+
__publicField(ArCoreProvider, "RELATIVE_ATTITUDE_DRIFT", maths.deg2rad(3) / 60);
|
|
511
516
|
const ArCoreProvider$1 = new ArCoreProvider();
|
|
512
517
|
class GeoRelativePositionFromArCoreProvider extends Provider {
|
|
513
518
|
constructor() {
|
|
@@ -549,7 +554,7 @@ class GeoRelativePositionFromArCoreProvider extends Provider {
|
|
|
549
554
|
const east = Math.cos(rotation) * relativePosition.x - Math.sin(rotation) * relativePosition.z;
|
|
550
555
|
const north = -Math.sin(rotation) * relativePosition.x - Math.cos(rotation) * relativePosition.z;
|
|
551
556
|
const up = relativePosition.y;
|
|
552
|
-
const position = new GeoRelativePosition(
|
|
557
|
+
const position = new geo.GeoRelativePosition(
|
|
553
558
|
east,
|
|
554
559
|
north,
|
|
555
560
|
up,
|
|
@@ -579,7 +584,7 @@ class EkfAttitude {
|
|
|
579
584
|
__publicField(this, "quaternion");
|
|
580
585
|
this.accRef = accRef;
|
|
581
586
|
this.cRef = ycRef;
|
|
582
|
-
this.P = Matrix4.fromDiagVector(Array(4).fill(0.1 ** 2));
|
|
587
|
+
this.P = maths.Matrix4.fromDiagVector(Array(4).fill(0.1 ** 2));
|
|
583
588
|
this.quaternion = null;
|
|
584
589
|
this.noises = {};
|
|
585
590
|
this.setRelativeNoises(DEFAULT_RELATIVE_NOISES);
|
|
@@ -587,34 +592,34 @@ class EkfAttitude {
|
|
|
587
592
|
}
|
|
588
593
|
setRelativeNoises(relativeNoises) {
|
|
589
594
|
this.noises.relative = {
|
|
590
|
-
acc: Matrix3.diag(Array(3).fill(relativeNoises.acc ** 2)),
|
|
591
|
-
gyr: Matrix3.diag(Array(3).fill(relativeNoises.gyr ** 2))
|
|
595
|
+
acc: maths.Matrix3.diag(Array(3).fill(relativeNoises.acc ** 2)),
|
|
596
|
+
gyr: maths.Matrix3.diag(Array(3).fill(relativeNoises.gyr ** 2))
|
|
592
597
|
};
|
|
593
598
|
}
|
|
594
599
|
setAbsoluteNoises(absoluteNoises) {
|
|
595
600
|
this.noises.absolute = {
|
|
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))
|
|
601
|
+
acc: maths.Matrix3.diag(Array(3).fill(absoluteNoises.acc ** 2)),
|
|
602
|
+
gyr: maths.Matrix3.diag(Array(3).fill(absoluteNoises.gyr ** 2)),
|
|
603
|
+
yc: maths.Matrix3.diag(Array(3).fill(absoluteNoises.yc ** 2))
|
|
599
604
|
};
|
|
600
605
|
}
|
|
601
606
|
tryInitialize(acc, mag) {
|
|
602
|
-
const accNormalized = Vector3.normalize(acc);
|
|
607
|
+
const accNormalized = maths.Vector3.normalize(acc);
|
|
603
608
|
if (mag) {
|
|
604
|
-
const magNormalized = Vector3.normalize(mag);
|
|
605
|
-
const H = Vector3.normalize(Vector3.cross(magNormalized, accNormalized));
|
|
606
|
-
const M = Vector3.cross(accNormalized, H);
|
|
609
|
+
const magNormalized = maths.Vector3.normalize(mag);
|
|
610
|
+
const H = maths.Vector3.normalize(maths.Vector3.cross(magNormalized, accNormalized));
|
|
611
|
+
const M = maths.Vector3.cross(accNormalized, H);
|
|
607
612
|
const R = [
|
|
608
613
|
[H[0], M[0], accNormalized[0]],
|
|
609
614
|
[H[1], M[1], accNormalized[1]],
|
|
610
615
|
[H[2], M[2], accNormalized[2]]
|
|
611
616
|
];
|
|
612
|
-
this.quaternion = Quaternion.fromMatrix3Matlab(R);
|
|
617
|
+
this.quaternion = maths.Quaternion.fromMatrix3Matlab(R);
|
|
613
618
|
} else {
|
|
614
|
-
const r = Vector3.dot(accNormalized, this.accRef) + 1;
|
|
615
|
-
const v = Vector3.cross(accNormalized, this.accRef);
|
|
619
|
+
const r = maths.Vector3.dot(accNormalized, this.accRef) + 1;
|
|
620
|
+
const v = maths.Vector3.cross(accNormalized, this.accRef);
|
|
616
621
|
let quaternion = [r, v[0], v[1], v[2]];
|
|
617
|
-
quaternion = Quaternion.normalize(quaternion);
|
|
622
|
+
quaternion = maths.Quaternion.normalize(quaternion);
|
|
618
623
|
this.quaternion = quaternion;
|
|
619
624
|
}
|
|
620
625
|
return this.quaternion;
|
|
@@ -625,83 +630,83 @@ class EkfAttitude {
|
|
|
625
630
|
}
|
|
626
631
|
let q = this.quaternion;
|
|
627
632
|
const qArray = q;
|
|
628
|
-
const gyrInt = Vector3.multiplyScalar(gyr, 0.5 * diffTime);
|
|
633
|
+
const gyrInt = maths.Vector3.multiplyScalar(gyr, 0.5 * diffTime);
|
|
629
634
|
const F = this.computeC([1, gyrInt[0], gyrInt[1], gyrInt[2]]);
|
|
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]]);
|
|
635
|
+
const qAPriori = maths.Matrix4.multiplyVector(F, q);
|
|
636
|
+
const E1 = maths.Matrix3.diag([qArray[0], qArray[0], qArray[0]]);
|
|
637
|
+
const eSkew = maths.Matrix3.skew([qArray[1], qArray[2], qArray[3]]);
|
|
633
638
|
const qPart = [-1 * qArray[1], -1 * qArray[2], -1 * qArray[3]];
|
|
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)
|
|
639
|
+
const E = maths.Matrix.concatRow([qPart], maths.Matrix3.sum(eSkew, E1));
|
|
640
|
+
const Qk = maths.Matrix4.multiplyScalar(
|
|
641
|
+
maths.Matrix.multiply(
|
|
642
|
+
maths.Matrix.multiply(E, this.noises[mag ? "absolute" : "relative"].gyr),
|
|
643
|
+
maths.Matrix.transpose(E)
|
|
639
644
|
),
|
|
640
645
|
(diffTime / 2) ** 2
|
|
641
646
|
);
|
|
642
|
-
const pAPriori = Matrix4.sum(
|
|
643
|
-
Matrix4.multiply(
|
|
644
|
-
Matrix4.multiply(F, this.P),
|
|
645
|
-
Matrix4.transpose(F)
|
|
647
|
+
const pAPriori = maths.Matrix4.sum(
|
|
648
|
+
maths.Matrix4.multiply(
|
|
649
|
+
maths.Matrix4.multiply(F, this.P),
|
|
650
|
+
maths.Matrix4.transpose(F)
|
|
646
651
|
),
|
|
647
652
|
Qk
|
|
648
653
|
);
|
|
649
|
-
const accNormalized = Vector3.normalize(acc);
|
|
654
|
+
const accNormalized = maths.Vector3.normalize(acc);
|
|
650
655
|
let dz, K, H;
|
|
651
656
|
if (mag) {
|
|
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);
|
|
657
|
+
const magNormalized = maths.Vector3.normalize(mag);
|
|
658
|
+
const yc = maths.Vector3.cross(accNormalized, magNormalized);
|
|
659
|
+
const ycNormalized = maths.Vector3.normalize(yc);
|
|
660
|
+
const dzYc = maths.Vector3.subtract(ycNormalized, maths.Quaternion.rotateMatlab(qAPriori, this.cRef));
|
|
661
|
+
const dzAcc = maths.Vector3.subtract(accNormalized, maths.Quaternion.rotateMatlab(qAPriori, this.accRef));
|
|
662
|
+
dz = maths.Vector.concat(dzYc, dzAcc);
|
|
658
663
|
const HYc = this.jacobianES(qAPriori, this.cRef);
|
|
659
664
|
const HAcc = this.jacobianES(qAPriori, this.accRef);
|
|
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)
|
|
665
|
+
H = maths.Matrix.concatRow(HYc, HAcc);
|
|
666
|
+
const RYc = maths.Matrix.concatLine(this.noises.absolute.yc, maths.Matrix3.zeros);
|
|
667
|
+
const RAcc = maths.Matrix.concatLine(maths.Matrix3.zeros, this.noises.absolute.acc);
|
|
668
|
+
const R = maths.Matrix.concatRow(RYc, RAcc);
|
|
669
|
+
K = maths.Matrix.multiply(
|
|
670
|
+
maths.Matrix.multiply(pAPriori, maths.Matrix.transpose(H)),
|
|
671
|
+
maths.Matrix.inverse(
|
|
672
|
+
maths.Matrix.sum(
|
|
673
|
+
maths.Matrix.multiply(
|
|
674
|
+
maths.Matrix.multiply(H, pAPriori),
|
|
675
|
+
maths.Matrix.transpose(H)
|
|
671
676
|
),
|
|
672
677
|
R
|
|
673
678
|
)
|
|
674
679
|
)
|
|
675
680
|
);
|
|
676
681
|
} else {
|
|
677
|
-
dz = Vector3.subtract(accNormalized, Quaternion.rotateMatlab(qAPriori, this.accRef));
|
|
682
|
+
dz = maths.Vector3.subtract(accNormalized, maths.Quaternion.rotateMatlab(qAPriori, this.accRef));
|
|
678
683
|
H = this.jacobianES(qAPriori, this.accRef);
|
|
679
684
|
const R = this.noises.relative.acc;
|
|
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)
|
|
685
|
+
K = maths.Matrix.multiply(
|
|
686
|
+
maths.Matrix.multiply(pAPriori, maths.Matrix.transpose(H)),
|
|
687
|
+
maths.Matrix3.inverse(
|
|
688
|
+
maths.Matrix3.sum(
|
|
689
|
+
maths.Matrix.multiply(
|
|
690
|
+
maths.Matrix.multiply(H, pAPriori),
|
|
691
|
+
maths.Matrix.transpose(H)
|
|
687
692
|
),
|
|
688
693
|
R
|
|
689
694
|
)
|
|
690
695
|
)
|
|
691
696
|
);
|
|
692
697
|
}
|
|
693
|
-
q = Quaternion.sum(
|
|
698
|
+
q = maths.Quaternion.sum(
|
|
694
699
|
qAPriori,
|
|
695
|
-
Matrix.multiplyVector(K, dz)
|
|
700
|
+
maths.Matrix.multiplyVector(K, dz)
|
|
696
701
|
);
|
|
697
|
-
const P = Matrix4.multiply(
|
|
698
|
-
Matrix4.subtract(
|
|
699
|
-
Matrix4.identity,
|
|
700
|
-
Matrix.multiply(K, H)
|
|
702
|
+
const P = maths.Matrix4.multiply(
|
|
703
|
+
maths.Matrix4.subtract(
|
|
704
|
+
maths.Matrix4.identity,
|
|
705
|
+
maths.Matrix.multiply(K, H)
|
|
701
706
|
),
|
|
702
707
|
pAPriori
|
|
703
708
|
);
|
|
704
|
-
q = Quaternion.normalize(q);
|
|
709
|
+
q = maths.Quaternion.normalize(q);
|
|
705
710
|
this.quaternion = q;
|
|
706
711
|
this.P = P;
|
|
707
712
|
return q;
|
|
@@ -739,7 +744,7 @@ class ImuProvider extends Provider {
|
|
|
739
744
|
} = e.accelerationIncludingGravity;
|
|
740
745
|
if (typeof x === "number" && typeof y === "number" && typeof z === "number") {
|
|
741
746
|
acc = [x, y, z];
|
|
742
|
-
if (BrowserUtils.name === Browser.SAFARI || BrowserUtils.name === Browser.IOS_WEBVIEW) {
|
|
747
|
+
if (utils.BrowserUtils.name === utils.Browser.SAFARI || utils.BrowserUtils.name === utils.Browser.IOS_WEBVIEW) {
|
|
743
748
|
acc[0] *= -1;
|
|
744
749
|
acc[1] *= -1;
|
|
745
750
|
acc[2] *= -1;
|
|
@@ -754,7 +759,7 @@ class ImuProvider extends Provider {
|
|
|
754
759
|
gamma
|
|
755
760
|
} = e.rotationRate;
|
|
756
761
|
if (typeof alpha === "number" && typeof beta === "number" && typeof gamma === "number") {
|
|
757
|
-
gyr = [deg2rad(alpha), deg2rad(beta), deg2rad(gamma)];
|
|
762
|
+
gyr = [maths.deg2rad(alpha), maths.deg2rad(beta), maths.deg2rad(gamma)];
|
|
758
763
|
}
|
|
759
764
|
}
|
|
760
765
|
if (acc || gyr) {
|
|
@@ -766,7 +771,7 @@ class ImuProvider extends Provider {
|
|
|
766
771
|
});
|
|
767
772
|
}
|
|
768
773
|
availability() {
|
|
769
|
-
return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
774
|
+
return utils.BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
770
775
|
}
|
|
771
776
|
start() {
|
|
772
777
|
const subscribe = () => window.addEventListener("devicemotion", this.parseDeviceMotionEvent, true);
|
|
@@ -894,7 +899,7 @@ const _RelativeAttitudeFromEkf = class extends Provider {
|
|
|
894
899
|
}
|
|
895
900
|
};
|
|
896
901
|
let RelativeAttitudeFromEkf = _RelativeAttitudeFromEkf;
|
|
897
|
-
__publicField(RelativeAttitudeFromEkf, "DEFAULT_DRIFT", deg2rad(5) / 60);
|
|
902
|
+
__publicField(RelativeAttitudeFromEkf, "DEFAULT_DRIFT", maths.deg2rad(5) / 60);
|
|
898
903
|
const RelativeAttitudeFromEkfProvider = new RelativeAttitudeFromEkf();
|
|
899
904
|
const _RelativeAttitudeFromBrowser = class extends Provider {
|
|
900
905
|
constructor() {
|
|
@@ -905,7 +910,7 @@ const _RelativeAttitudeFromBrowser = class extends Provider {
|
|
|
905
910
|
this.notifyError(new MissingSensorError().from("deviceorientation"));
|
|
906
911
|
return;
|
|
907
912
|
}
|
|
908
|
-
const quaternion = Rotations.eulerToQuaternionZXYDegrees([e.alpha, e.beta, e.gamma]);
|
|
913
|
+
const quaternion = maths.Rotations.eulerToQuaternionZXYDegrees([e.alpha, e.beta, e.gamma]);
|
|
909
914
|
const attitude = new RelativeAttitude(
|
|
910
915
|
quaternion,
|
|
911
916
|
e.timeStamp / 1e3,
|
|
@@ -915,7 +920,7 @@ const _RelativeAttitudeFromBrowser = class extends Provider {
|
|
|
915
920
|
});
|
|
916
921
|
}
|
|
917
922
|
availability() {
|
|
918
|
-
return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
923
|
+
return utils.BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
919
924
|
}
|
|
920
925
|
start() {
|
|
921
926
|
const subscribe = () => window.addEventListener("deviceorientation", this.onDeviceOrientationEvent, true);
|
|
@@ -936,7 +941,7 @@ const _RelativeAttitudeFromBrowser = class extends Provider {
|
|
|
936
941
|
}
|
|
937
942
|
};
|
|
938
943
|
let RelativeAttitudeFromBrowser = _RelativeAttitudeFromBrowser;
|
|
939
|
-
__publicField(RelativeAttitudeFromBrowser, "DEFAULT_DRIFT", deg2rad(5) / 60);
|
|
944
|
+
__publicField(RelativeAttitudeFromBrowser, "DEFAULT_DRIFT", maths.deg2rad(5) / 60);
|
|
940
945
|
const RelativeAttitudeFromBrowser$1 = new RelativeAttitudeFromBrowser();
|
|
941
946
|
const _HighRotationsProvider = class extends Provider {
|
|
942
947
|
constructor() {
|
|
@@ -946,7 +951,7 @@ const _HighRotationsProvider = class extends Provider {
|
|
|
946
951
|
__publicField(this, "availability", () => GyroscopeProvider$1.getAvailability());
|
|
947
952
|
__publicField(this, "_parseGyroscopeEvent", (gyroscopeEvent) => {
|
|
948
953
|
const { values, timestamp } = gyroscopeEvent;
|
|
949
|
-
const speed = Vector3.norm(values);
|
|
954
|
+
const speed = maths.Vector3.norm(values);
|
|
950
955
|
if (speed > _HighRotationsProvider.THRESHOLD) {
|
|
951
956
|
this.notify({ timestamp });
|
|
952
957
|
}
|
|
@@ -1018,7 +1023,7 @@ const _RelativeAttitudeFromInertial = class extends Provider {
|
|
|
1018
1023
|
}
|
|
1019
1024
|
};
|
|
1020
1025
|
let RelativeAttitudeFromInertial = _RelativeAttitudeFromInertial;
|
|
1021
|
-
__publicField(RelativeAttitudeFromInertial, "DEFAULT_DRIFT", deg2rad(5) / 60);
|
|
1026
|
+
__publicField(RelativeAttitudeFromInertial, "DEFAULT_DRIFT", maths.deg2rad(5) / 60);
|
|
1022
1027
|
const RelativeAttitudeFromInertialProvider = new RelativeAttitudeFromInertial();
|
|
1023
1028
|
const _StepDetectionLadetto = class {
|
|
1024
1029
|
constructor() {
|
|
@@ -1352,8 +1357,8 @@ const _StepProvider = class extends Provider {
|
|
|
1352
1357
|
}
|
|
1353
1358
|
}
|
|
1354
1359
|
static computeLinearAcceleration(quaternion, acc) {
|
|
1355
|
-
const linearAcc = Quaternion.rotateMatlab(Quaternion.inverse(quaternion), acc);
|
|
1356
|
-
linearAcc[2] -= Constants
|
|
1360
|
+
const linearAcc = maths.Quaternion.rotateMatlab(maths.Quaternion.inverse(quaternion), acc);
|
|
1361
|
+
linearAcc[2] -= geo.Constants.EARTH_GRAVITY;
|
|
1357
1362
|
return linearAcc;
|
|
1358
1363
|
}
|
|
1359
1364
|
set stepSizeMultiplier(stepSizeMultiplier) {
|
|
@@ -1395,7 +1400,7 @@ class PdrProvider extends Provider {
|
|
|
1395
1400
|
__publicField(this, "absoluteAttitudeProviderId");
|
|
1396
1401
|
__publicField(this, "stepDetectionProviderId");
|
|
1397
1402
|
__publicField(this, "attitudeEvent");
|
|
1398
|
-
__publicField(this, "misalignmentError", deg2rad(3));
|
|
1403
|
+
__publicField(this, "misalignmentError", maths.deg2rad(3));
|
|
1399
1404
|
__publicField(this, "getName", () => "Pdr");
|
|
1400
1405
|
__publicField(this, "onStepEvent", (stepEvent) => {
|
|
1401
1406
|
if (!this.attitudeEvent) {
|
|
@@ -1407,7 +1412,7 @@ class PdrProvider extends Provider {
|
|
|
1407
1412
|
const deviceDirectionAccuracy = deviceAttitude.accuracy + this.misalignmentError;
|
|
1408
1413
|
const accuracy = stepSize / 2 * Math.sin(deviceDirectionAccuracy / 2);
|
|
1409
1414
|
const timestamp = deviceAttitude.time;
|
|
1410
|
-
const position = new GeoRelativePosition(
|
|
1415
|
+
const position = new geo.GeoRelativePosition(
|
|
1411
1416
|
stepSize * Math.sin(deviceDirection),
|
|
1412
1417
|
stepSize * Math.cos(deviceDirection),
|
|
1413
1418
|
0,
|
|
@@ -1605,8 +1610,8 @@ class VpsMetadata {
|
|
|
1605
1610
|
},
|
|
1606
1611
|
json.calibration,
|
|
1607
1612
|
{
|
|
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) }
|
|
1613
|
+
...((_a = json.coarse) == null ? void 0 : _a.position) && { position: geo.UserPosition.fromJson(json.coarse.position) },
|
|
1614
|
+
...((_b = json.coarse) == null ? void 0 : _b.attitude) && { attitude: geo.Attitude.fromJson(json.coarse.attitude) }
|
|
1610
1615
|
},
|
|
1611
1616
|
json.device
|
|
1612
1617
|
);
|
|
@@ -1618,7 +1623,7 @@ class VpsRequest {
|
|
|
1618
1623
|
this.image = image;
|
|
1619
1624
|
}
|
|
1620
1625
|
toJson() {
|
|
1621
|
-
const base64Image = canvasToBase64(this.image);
|
|
1626
|
+
const base64Image = camera.canvasToBase64(this.image);
|
|
1622
1627
|
return {
|
|
1623
1628
|
image: base64Image,
|
|
1624
1629
|
...this.metadata.toJson()
|
|
@@ -1627,7 +1632,7 @@ class VpsRequest {
|
|
|
1627
1632
|
static fromJson(json) {
|
|
1628
1633
|
return new VpsRequest(
|
|
1629
1634
|
VpsMetadata.fromJson(json),
|
|
1630
|
-
base64ToCanvas(json.image)
|
|
1635
|
+
camera.base64ToCanvas(json.image)
|
|
1631
1636
|
);
|
|
1632
1637
|
}
|
|
1633
1638
|
}
|
|
@@ -1648,12 +1653,12 @@ class VpsResponse {
|
|
|
1648
1653
|
static fromJson(json, imageRecordTime = null) {
|
|
1649
1654
|
let attitude = null;
|
|
1650
1655
|
if (json.attitude) {
|
|
1651
|
-
attitude = Attitude.fromJson(json.attitude);
|
|
1656
|
+
attitude = geo.Attitude.fromJson(json.attitude);
|
|
1652
1657
|
attitude.time = imageRecordTime;
|
|
1653
1658
|
}
|
|
1654
1659
|
let position = null;
|
|
1655
1660
|
if (json.position) {
|
|
1656
|
-
position = UserPosition.fromJson(json.position);
|
|
1661
|
+
position = geo.UserPosition.fromJson(json.position);
|
|
1657
1662
|
position.time = imageRecordTime;
|
|
1658
1663
|
}
|
|
1659
1664
|
return new VpsResponse(json.success, attitude, position);
|
|
@@ -1661,23 +1666,23 @@ class VpsResponse {
|
|
|
1661
1666
|
}
|
|
1662
1667
|
class ImageRelocalization {
|
|
1663
1668
|
static _prepareRequest(imageCanvas, calibration = null, coarsePose = null) {
|
|
1664
|
-
convertToGrayscale(imageCanvas);
|
|
1665
|
-
const reducedImage = reduceImageSize(imageCanvas, 1280);
|
|
1669
|
+
camera.convertToGrayscale(imageCanvas);
|
|
1670
|
+
const reducedImage = camera.reduceImageSize(imageCanvas, 1280);
|
|
1666
1671
|
const metadata = new VpsMetadata(
|
|
1667
1672
|
{ width: reducedImage.width, height: reducedImage.height },
|
|
1668
1673
|
calibration,
|
|
1669
1674
|
coarsePose,
|
|
1670
|
-
UserAgentUtils.getDeviceFromUserAgent()
|
|
1675
|
+
utils.UserAgentUtils.getDeviceFromUserAgent()
|
|
1671
1676
|
);
|
|
1672
1677
|
return new VpsRequest(metadata, reducedImage);
|
|
1673
1678
|
}
|
|
1674
1679
|
static async relocalize(endpointUrl, imageCanvas, calibration = null, coarsePose = null, customHeaders = null) {
|
|
1675
|
-
const timeBeforeRequest = TimeUtils.preciseTime() / 1e3;
|
|
1680
|
+
const timeBeforeRequest = utils.TimeUtils.preciseTime() / 1e3;
|
|
1676
1681
|
const vpsRequest = this._prepareRequest(imageCanvas, calibration, coarsePose);
|
|
1677
1682
|
let serverResponse;
|
|
1678
1683
|
try {
|
|
1679
1684
|
const body = JSON.stringify(vpsRequest.toJson());
|
|
1680
|
-
|
|
1685
|
+
Logger__default.default.debug(`[VPS] Request (${(body.length / 1024).toFixed(0)} kB) sent to server ${endpointUrl}`);
|
|
1681
1686
|
serverResponse = await fetch(endpointUrl, {
|
|
1682
1687
|
method: "POST",
|
|
1683
1688
|
body,
|
|
@@ -1687,16 +1692,16 @@ class ImageRelocalization {
|
|
|
1687
1692
|
)
|
|
1688
1693
|
});
|
|
1689
1694
|
} catch (e) {
|
|
1690
|
-
|
|
1695
|
+
Logger__default.default.debug("[VPS] Server respond error");
|
|
1691
1696
|
return null;
|
|
1692
1697
|
}
|
|
1693
1698
|
if (serverResponse.status !== 200) {
|
|
1694
|
-
|
|
1699
|
+
Logger__default.default.debug("[VPS] Server respond error");
|
|
1695
1700
|
return null;
|
|
1696
1701
|
}
|
|
1697
1702
|
const json = await serverResponse.json();
|
|
1698
1703
|
const res = VpsResponse.fromJson(json, timeBeforeRequest);
|
|
1699
|
-
|
|
1704
|
+
Logger__default.default.debug(`[VPS] Server respond ${res.success ? "success" : "not found"}`);
|
|
1700
1705
|
return res;
|
|
1701
1706
|
}
|
|
1702
1707
|
static getHeadingFromQuaternion(quaternion) {
|
|
@@ -1726,16 +1731,16 @@ class RelativeRotationCalc {
|
|
|
1726
1731
|
}
|
|
1727
1732
|
tickEnd() {
|
|
1728
1733
|
if (!this._isRunning) {
|
|
1729
|
-
|
|
1734
|
+
Logger__default.default.warn("You have to call tickStart before tickEnd");
|
|
1730
1735
|
return null;
|
|
1731
1736
|
}
|
|
1732
1737
|
this._internalStop();
|
|
1733
1738
|
if (!this._dataOnStart) {
|
|
1734
|
-
|
|
1739
|
+
Logger__default.default.warn("Delay was too short between tickStart and tickEnd or RelativeAttitudeProvider cannot be retrieved.");
|
|
1735
1740
|
return null;
|
|
1736
1741
|
}
|
|
1737
1742
|
const dataOnEnd = RelativeAttitudeFromBrowser$1.lastEvent;
|
|
1738
|
-
return Attitude.diff(this._dataOnStart, dataOnEnd);
|
|
1743
|
+
return geo.Attitude.diff(this._dataOnStart, dataOnEnd);
|
|
1739
1744
|
}
|
|
1740
1745
|
_internalStop() {
|
|
1741
1746
|
RelativeAttitudeFromBrowser$1.removeEventListener(this._providerId);
|
|
@@ -1796,7 +1801,7 @@ class PoleStarProvider extends Provider {
|
|
|
1796
1801
|
callbackError: (errorMessage) => this.notifyError(new Error(errorMessage)),
|
|
1797
1802
|
callbackPosition: (jsonString) => {
|
|
1798
1803
|
const json = JSON.parse(jsonString);
|
|
1799
|
-
const timestamp = TimeUtils.unixTimestampToPreciseTime(json.time) / 1e3;
|
|
1804
|
+
const timestamp = utils.TimeUtils.unixTimestampToPreciseTime(json.time) / 1e3;
|
|
1800
1805
|
const position = new AbsolutePosition(
|
|
1801
1806
|
json.lat,
|
|
1802
1807
|
json.lng,
|
|
@@ -1804,7 +1809,7 @@ class PoleStarProvider extends Provider {
|
|
|
1804
1809
|
json.alt / 5,
|
|
1805
1810
|
timestamp,
|
|
1806
1811
|
json.accuracy,
|
|
1807
|
-
deg2rad(json.bearing)
|
|
1812
|
+
maths.deg2rad(json.bearing)
|
|
1808
1813
|
);
|
|
1809
1814
|
this.notify(position);
|
|
1810
1815
|
}
|
|
@@ -1825,19 +1830,19 @@ const _VpsProvider = class extends Provider {
|
|
|
1825
1830
|
__publicField(this, "_waitTimeMinInclinationForRequest", _VpsProvider.DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST);
|
|
1826
1831
|
__publicField(this, "_useCoarsePose", _VpsProvider.DEFAULT_USE_COARSE_POSE);
|
|
1827
1832
|
__publicField(this, "getName", () => "Vps");
|
|
1828
|
-
__publicField(this, "availability", () => Camera.checkAvailability());
|
|
1829
|
-
__publicField(this, "_onCameraDetected", ({ camera }) => {
|
|
1833
|
+
__publicField(this, "availability", () => camera.Camera.checkAvailability());
|
|
1834
|
+
__publicField(this, "_onCameraDetected", ({ camera: camera2 }) => {
|
|
1830
1835
|
if (this._camera) {
|
|
1831
|
-
|
|
1836
|
+
Logger__default.default.warn("It seems that more than 1 camera has been detected for VPS. Taking the first...");
|
|
1832
1837
|
}
|
|
1833
|
-
this._useCamera(
|
|
1838
|
+
this._useCamera(camera2);
|
|
1834
1839
|
});
|
|
1835
1840
|
__publicField(this, "_onCameraRemoved", () => {
|
|
1836
1841
|
if (this._camera) {
|
|
1837
1842
|
this._camera.off("started", this._internalStart);
|
|
1838
1843
|
this._camera.off("stopped", this._internalStop);
|
|
1839
1844
|
} else {
|
|
1840
|
-
|
|
1845
|
+
Logger__default.default.warn("There is no previously detected camera but once has stopped");
|
|
1841
1846
|
}
|
|
1842
1847
|
this._camera = null;
|
|
1843
1848
|
});
|
|
@@ -1851,11 +1856,11 @@ const _VpsProvider = class extends Provider {
|
|
|
1851
1856
|
const isProviderStopped = () => this.state === "stopped";
|
|
1852
1857
|
while (!isProviderStopped()) {
|
|
1853
1858
|
if (lastRequestTime !== null) {
|
|
1854
|
-
const diffTime = TimeUtils.preciseTime() - lastRequestTime;
|
|
1859
|
+
const diffTime = utils.TimeUtils.preciseTime() - lastRequestTime;
|
|
1855
1860
|
const timeToWait = Math.max(0, _VpsProvider.MIN_TIME_BETWEEN_TWO_REQUESTS - diffTime);
|
|
1856
1861
|
await new Promise((resolve) => setTimeout(resolve, timeToWait));
|
|
1857
1862
|
}
|
|
1858
|
-
lastRequestTime = TimeUtils.preciseTime();
|
|
1863
|
+
lastRequestTime = utils.TimeUtils.preciseTime();
|
|
1859
1864
|
if (isProviderStopped() || !this._camera || this._camera.state !== "started") {
|
|
1860
1865
|
break;
|
|
1861
1866
|
}
|
|
@@ -1882,16 +1887,16 @@ const _VpsProvider = class extends Provider {
|
|
|
1882
1887
|
continue;
|
|
1883
1888
|
}
|
|
1884
1889
|
const enuToCameraRot = res.attitude.quaternion;
|
|
1885
|
-
const enuToSmartphoneRot = Quaternion.multiply(
|
|
1890
|
+
const enuToSmartphoneRot = maths.Quaternion.multiply(
|
|
1886
1891
|
enuToCameraRot,
|
|
1887
1892
|
_VpsProvider.CAMERA_TO_SMARTPHONE_ROT
|
|
1888
1893
|
);
|
|
1889
|
-
const deviceQuaternion = Quaternion.multiply(
|
|
1890
|
-
Quaternion.fromAxisAngle([0, 0, 1], deg2rad(window.orientation || 0)),
|
|
1894
|
+
const deviceQuaternion = maths.Quaternion.multiply(
|
|
1895
|
+
maths.Quaternion.fromAxisAngle([0, 0, 1], maths.deg2rad(window.orientation || 0)),
|
|
1891
1896
|
enuToSmartphoneRot
|
|
1892
1897
|
);
|
|
1893
|
-
const diffAttitude = ((_b = this._relativeRotationCalc) == null ? void 0 : _b.tickEnd()) || new Attitude([1, 0, 0, 0]);
|
|
1894
|
-
const deviceQuaternionWithRelOffset = Quaternion.multiply(
|
|
1898
|
+
const diffAttitude = ((_b = this._relativeRotationCalc) == null ? void 0 : _b.tickEnd()) || new geo.Attitude([1, 0, 0, 0]);
|
|
1899
|
+
const deviceQuaternionWithRelOffset = maths.Quaternion.multiply(
|
|
1895
1900
|
deviceQuaternion,
|
|
1896
1901
|
diffAttitude.quaternion
|
|
1897
1902
|
);
|
|
@@ -1919,28 +1924,28 @@ const _VpsProvider = class extends Provider {
|
|
|
1919
1924
|
start() {
|
|
1920
1925
|
this._inclinationProviderId = InclinationProvider$1.addEventListener();
|
|
1921
1926
|
this._relativeRotationCalc = new RelativeRotationCalc();
|
|
1922
|
-
SharedCameras.on("added", this._onCameraDetected);
|
|
1923
|
-
SharedCameras.on("removed", this._onCameraRemoved);
|
|
1924
|
-
if (SharedCameras.list.length) {
|
|
1925
|
-
if (SharedCameras.list.length > 1) {
|
|
1926
|
-
|
|
1927
|
+
camera.SharedCameras.on("added", this._onCameraDetected);
|
|
1928
|
+
camera.SharedCameras.on("removed", this._onCameraRemoved);
|
|
1929
|
+
if (camera.SharedCameras.list.length) {
|
|
1930
|
+
if (camera.SharedCameras.list.length > 1) {
|
|
1931
|
+
Logger__default.default.warn("It seems that more than 1 camera has been detected for VPS. Taking the first...");
|
|
1927
1932
|
}
|
|
1928
|
-
this._useCamera(SharedCameras.list[0].camera);
|
|
1933
|
+
this._useCamera(camera.SharedCameras.list[0].camera);
|
|
1929
1934
|
}
|
|
1930
1935
|
}
|
|
1931
1936
|
stop() {
|
|
1932
1937
|
var _a;
|
|
1933
1938
|
InclinationProvider$1.removeEventListener(this._inclinationProviderId);
|
|
1934
1939
|
(_a = this._relativeRotationCalc) == null ? void 0 : _a.release();
|
|
1935
|
-
SharedCameras.off("added", this._onCameraDetected);
|
|
1936
|
-
SharedCameras.off("removed", this._onCameraRemoved);
|
|
1940
|
+
camera.SharedCameras.off("added", this._onCameraDetected);
|
|
1941
|
+
camera.SharedCameras.off("removed", this._onCameraRemoved);
|
|
1937
1942
|
this._camera = null;
|
|
1938
1943
|
}
|
|
1939
|
-
_useCamera(
|
|
1940
|
-
this._camera =
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
if (
|
|
1944
|
+
_useCamera(camera2) {
|
|
1945
|
+
this._camera = camera2;
|
|
1946
|
+
camera2.on("started", this._internalStart);
|
|
1947
|
+
camera2.on("stopped", this._internalStop);
|
|
1948
|
+
if (camera2.state === "started") {
|
|
1944
1949
|
this._internalStart();
|
|
1945
1950
|
}
|
|
1946
1951
|
}
|
|
@@ -1971,10 +1976,10 @@ const _VpsProvider = class extends Provider {
|
|
|
1971
1976
|
};
|
|
1972
1977
|
let VpsProvider = _VpsProvider;
|
|
1973
1978
|
__publicField(VpsProvider, "MIN_TIME_BETWEEN_TWO_REQUESTS", 1e3);
|
|
1974
|
-
__publicField(VpsProvider, "DEFAULT_MIN_INCLINATION_FOR_REQUEST", deg2rad(60));
|
|
1979
|
+
__publicField(VpsProvider, "DEFAULT_MIN_INCLINATION_FOR_REQUEST", maths.deg2rad(60));
|
|
1975
1980
|
__publicField(VpsProvider, "DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST", 200);
|
|
1976
1981
|
__publicField(VpsProvider, "DEFAULT_USE_COARSE_POSE", true);
|
|
1977
|
-
__publicField(VpsProvider, "CAMERA_TO_SMARTPHONE_ROT", Quaternion.fromAxisAngle([1, 0, 0], Math.PI));
|
|
1982
|
+
__publicField(VpsProvider, "CAMERA_TO_SMARTPHONE_ROT", maths.Quaternion.fromAxisAngle([1, 0, 0], Math.PI));
|
|
1978
1983
|
const VpsProvider$1 = new VpsProvider();
|
|
1979
1984
|
const _AbsolutePositionProvider = class extends Provider {
|
|
1980
1985
|
constructor() {
|
|
@@ -2018,7 +2023,7 @@ const _AbsolutePositionProvider = class extends Provider {
|
|
|
2018
2023
|
if (ProvidersOptions.hasPoleStar) {
|
|
2019
2024
|
this._polestarProviderId = PoleStarProvider$1.addEventListener((polestarPositionEvent) => {
|
|
2020
2025
|
var _a;
|
|
2021
|
-
this._lastPolestarFix = TimeUtils.preciseTime();
|
|
2026
|
+
this._lastPolestarFix = utils.TimeUtils.preciseTime();
|
|
2022
2027
|
const psPositionUsed = this._onAbsolutePosition(polestarPositionEvent);
|
|
2023
2028
|
if (!psPositionUsed && ((_a = this.lastEvent) == null ? void 0 : _a.level) === null) {
|
|
2024
2029
|
const lastPositionWithLevel = this.lastEvent.clone();
|
|
@@ -2066,7 +2071,7 @@ const _AbsolutePositionProvider = class extends Provider {
|
|
|
2066
2071
|
if (isBetterEnough && isFarEnoughAndAccuracyIsBetter) {
|
|
2067
2072
|
return true;
|
|
2068
2073
|
}
|
|
2069
|
-
const isChangingLevel = canContainLevel && !Level.equals(newPosition.level, lastPosition.level);
|
|
2074
|
+
const isChangingLevel = canContainLevel && !geo.Level.equals(newPosition.level, lastPosition.level);
|
|
2070
2075
|
if (isChangingLevel) {
|
|
2071
2076
|
return true;
|
|
2072
2077
|
}
|
|
@@ -2113,7 +2118,7 @@ const _AbsolutePositionProvider = class extends Provider {
|
|
|
2113
2118
|
}
|
|
2114
2119
|
feed(data) {
|
|
2115
2120
|
let newPositionEvent;
|
|
2116
|
-
if (data instanceof UserPosition) {
|
|
2121
|
+
if (data instanceof geo.UserPosition) {
|
|
2117
2122
|
if (data.time === null) {
|
|
2118
2123
|
throw Error("the time of the position is not defined");
|
|
2119
2124
|
}
|
|
@@ -2151,7 +2156,7 @@ const AbsolutePositionProvider$1 = new AbsolutePositionProvider();
|
|
|
2151
2156
|
class AbsoluteAttitudeFromBrowser extends Provider {
|
|
2152
2157
|
constructor() {
|
|
2153
2158
|
super(...arguments);
|
|
2154
|
-
__publicField(this, "DEFAULT_ACCURACY", deg2rad(15));
|
|
2159
|
+
__publicField(this, "DEFAULT_ACCURACY", maths.deg2rad(15));
|
|
2155
2160
|
__publicField(this, "absolutePositionProviderId");
|
|
2156
2161
|
__publicField(this, "absolutePositionEvent");
|
|
2157
2162
|
__publicField(this, "declinationQuaternion");
|
|
@@ -2166,7 +2171,7 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2166
2171
|
this.notifyError(new MissingSensorError().from("deviceorientationabsolute"));
|
|
2167
2172
|
return;
|
|
2168
2173
|
}
|
|
2169
|
-
this.magQuaternion = Rotations.eulerToQuaternionZXYDegrees(
|
|
2174
|
+
this.magQuaternion = maths.Rotations.eulerToQuaternionZXYDegrees(
|
|
2170
2175
|
[e.alpha, e.beta, e.gamma]
|
|
2171
2176
|
);
|
|
2172
2177
|
this.compute();
|
|
@@ -2182,15 +2187,15 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2182
2187
|
return;
|
|
2183
2188
|
}
|
|
2184
2189
|
let alpha;
|
|
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));
|
|
2190
|
+
const [qw, qx, qy, qz] = maths.Rotations.eulerToQuaternionZXYDegrees([e.webkitCompassHeading, e.beta, e.gamma]);
|
|
2191
|
+
const groundAngle = maths.rad2deg(Math.acos(qw ** 2 - qx ** 2 - qy ** 2 + qz ** 2));
|
|
2187
2192
|
let isSkyMode = null;
|
|
2188
2193
|
if (groundAngle > 136) {
|
|
2189
2194
|
isSkyMode = true;
|
|
2190
2195
|
} else if (groundAngle < 134) {
|
|
2191
2196
|
isSkyMode = false;
|
|
2192
2197
|
} else if (this.iosPreviousQuat && this.iosIsSkyMode !== null) {
|
|
2193
|
-
isSkyMode = Quaternion.distance([qw, qx, qy, qz], this.iosPreviousQuat) < 0.5 ? this.iosIsSkyMode : !this.iosIsSkyMode;
|
|
2198
|
+
isSkyMode = maths.Quaternion.distance([qw, qx, qy, qz], this.iosPreviousQuat) < 0.5 ? this.iosIsSkyMode : !this.iosIsSkyMode;
|
|
2194
2199
|
}
|
|
2195
2200
|
this.iosPreviousQuat = [qw, qx, qy, qz];
|
|
2196
2201
|
this.iosIsSkyMode = isSkyMode;
|
|
@@ -2206,33 +2211,33 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2206
2211
|
e.gamma
|
|
2207
2212
|
);
|
|
2208
2213
|
}
|
|
2209
|
-
this.magQuaternion = Rotations.eulerToQuaternionZXYDegrees([alpha, e.beta, e.gamma]);
|
|
2214
|
+
this.magQuaternion = maths.Rotations.eulerToQuaternionZXYDegrees([alpha, e.beta, e.gamma]);
|
|
2210
2215
|
this.compute();
|
|
2211
2216
|
});
|
|
2212
2217
|
__publicField(this, "onAbsolutePositionEvent", (position) => {
|
|
2213
2218
|
this.absolutePositionEvent = position;
|
|
2214
|
-
const wmmResult =
|
|
2215
|
-
this.declinationQuaternion = Quaternion.fromAxisAngle([0, 0, 1], -deg2rad(wmmResult.decl));
|
|
2219
|
+
const wmmResult = geomagnetism__default.default.model().point([position.lat, position.lng]);
|
|
2220
|
+
this.declinationQuaternion = maths.Quaternion.fromAxisAngle([0, 0, 1], -maths.deg2rad(wmmResult.decl));
|
|
2216
2221
|
AbsolutePositionProvider$1.removeEventListener(this.absolutePositionProviderId);
|
|
2217
2222
|
delete this.absolutePositionProviderId;
|
|
2218
2223
|
this.compute();
|
|
2219
2224
|
});
|
|
2220
2225
|
}
|
|
2221
2226
|
availability() {
|
|
2222
|
-
return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
2227
|
+
return utils.BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError());
|
|
2223
2228
|
}
|
|
2224
2229
|
start() {
|
|
2225
2230
|
const subscribe = () => {
|
|
2226
|
-
switch (BrowserUtils.name) {
|
|
2227
|
-
case Browser.CHROME:
|
|
2231
|
+
switch (utils.BrowserUtils.name) {
|
|
2232
|
+
case utils.Browser.CHROME:
|
|
2228
2233
|
window.addEventListener(
|
|
2229
2234
|
"deviceorientationabsolute",
|
|
2230
2235
|
this.onDeviceOrientationChromeEvent,
|
|
2231
2236
|
true
|
|
2232
2237
|
);
|
|
2233
2238
|
break;
|
|
2234
|
-
case Browser.SAFARI:
|
|
2235
|
-
case Browser.IOS_WEBVIEW:
|
|
2239
|
+
case utils.Browser.SAFARI:
|
|
2240
|
+
case utils.Browser.IOS_WEBVIEW:
|
|
2236
2241
|
window.addEventListener(
|
|
2237
2242
|
"deviceorientation",
|
|
2238
2243
|
this.onDeviceOrientationSafariEvent,
|
|
@@ -2264,16 +2269,16 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2264
2269
|
}
|
|
2265
2270
|
}
|
|
2266
2271
|
stop() {
|
|
2267
|
-
switch (BrowserUtils.name) {
|
|
2268
|
-
case Browser.CHROME:
|
|
2272
|
+
switch (utils.BrowserUtils.name) {
|
|
2273
|
+
case utils.Browser.CHROME:
|
|
2269
2274
|
window.removeEventListener(
|
|
2270
2275
|
"deviceorientationabsolute",
|
|
2271
2276
|
this.onDeviceOrientationChromeEvent,
|
|
2272
2277
|
true
|
|
2273
2278
|
);
|
|
2274
2279
|
break;
|
|
2275
|
-
case Browser.SAFARI:
|
|
2276
|
-
case Browser.IOS_WEBVIEW:
|
|
2280
|
+
case utils.Browser.SAFARI:
|
|
2281
|
+
case utils.Browser.IOS_WEBVIEW:
|
|
2277
2282
|
window.removeEventListener(
|
|
2278
2283
|
"deviceorientation",
|
|
2279
2284
|
this.onDeviceOrientationSafariEvent,
|
|
@@ -2287,14 +2292,14 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2287
2292
|
if (!this.declinationQuaternion || !this.magQuaternion || !this.absolutePositionEvent) {
|
|
2288
2293
|
return;
|
|
2289
2294
|
}
|
|
2290
|
-
const trueQuaternion = Quaternion.multiply(this.declinationQuaternion, this.magQuaternion);
|
|
2295
|
+
const trueQuaternion = maths.Quaternion.multiply(this.declinationQuaternion, this.magQuaternion);
|
|
2291
2296
|
const attitude = new AbsoluteAttitude(trueQuaternion, this.magQuaternionTimestamp, this.DEFAULT_ACCURACY);
|
|
2292
2297
|
this.notify(attitude);
|
|
2293
2298
|
}
|
|
2294
2299
|
static webkitCompassToHeading(_webkitCompassHeading, _beta, _gamma) {
|
|
2295
|
-
const webkitCompassHeading = deg2rad(_webkitCompassHeading);
|
|
2296
|
-
const beta = deg2rad(_beta);
|
|
2297
|
-
const gamma = deg2rad(_gamma);
|
|
2300
|
+
const webkitCompassHeading = maths.deg2rad(_webkitCompassHeading);
|
|
2301
|
+
const beta = maths.deg2rad(_beta);
|
|
2302
|
+
const gamma = maths.deg2rad(_gamma);
|
|
2298
2303
|
const c1 = Math.cos(webkitCompassHeading / 2);
|
|
2299
2304
|
const c2 = Math.cos(beta / 2);
|
|
2300
2305
|
const c3 = Math.cos(gamma / 2);
|
|
@@ -2303,7 +2308,7 @@ class AbsoluteAttitudeFromBrowser extends Provider {
|
|
|
2303
2308
|
const s3 = Math.sin(gamma / 2);
|
|
2304
2309
|
const qw = c1 * c2 * c3 - s1 * s2 * s3;
|
|
2305
2310
|
const qz = s1 * c2 * c3 + c1 * s2 * s3;
|
|
2306
|
-
return rad2deg(-2 * Math.atan(qz / qw));
|
|
2311
|
+
return maths.rad2deg(-2 * Math.atan(qz / qw));
|
|
2307
2312
|
}
|
|
2308
2313
|
}
|
|
2309
2314
|
const AbsoluteAttitudeFromBrowser$1 = new AbsoluteAttitudeFromBrowser();
|
|
@@ -2389,7 +2394,7 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2389
2394
|
}
|
|
2390
2395
|
const calcForceHeading = (relativeAttitude) => {
|
|
2391
2396
|
const currentRelativeHeading = relativeAttitude.heading;
|
|
2392
|
-
this._relAbsQuat = Quaternion.fromAxisAngle(
|
|
2397
|
+
this._relAbsQuat = maths.Quaternion.fromAxisAngle(
|
|
2393
2398
|
[0, 0, 1],
|
|
2394
2399
|
currentRelativeHeading - absoluteHeadingEvent.heading
|
|
2395
2400
|
);
|
|
@@ -2431,9 +2436,9 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2431
2436
|
if (this._wasHighRotationInProgress && !highRotationInProgress) {
|
|
2432
2437
|
this._forceHeadingForRelative(this._absAttitudeFromBrowser);
|
|
2433
2438
|
} else if (accuracyWithAbsolute < accuracyWithRelative) {
|
|
2434
|
-
const relativeQuaternion = Quaternion.multiply(this._relAbsQuat, quaternion);
|
|
2435
|
-
const relativeAttitude = new Attitude(relativeQuaternion);
|
|
2436
|
-
const angle = Math.abs(diffAngle(relativeAttitude.heading, headingFromAbsolute));
|
|
2439
|
+
const relativeQuaternion = maths.Quaternion.multiply(this._relAbsQuat, quaternion);
|
|
2440
|
+
const relativeAttitude = new geo.Attitude(relativeQuaternion);
|
|
2441
|
+
const angle = Math.abs(maths.diffAngle(relativeAttitude.heading, headingFromAbsolute));
|
|
2437
2442
|
const inclination = InclinationProvider$1.lastEvent;
|
|
2438
2443
|
if (angle > _AbsoluteAttitudeProvider.REL_ABS_DIVERGENCE_ANGLE_THRESHOLD && inclination !== null && Math.abs(inclination - Math.PI / 4) > _AbsoluteAttitudeProvider.REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD) {
|
|
2439
2444
|
divergenceDetected = true;
|
|
@@ -2451,7 +2456,7 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2451
2456
|
this._timeFirstDivergence = null;
|
|
2452
2457
|
}
|
|
2453
2458
|
this._wasHighRotationInProgress = highRotationInProgress;
|
|
2454
|
-
const absoluteQuat = Quaternion.multiply(this._relAbsQuat, quaternion);
|
|
2459
|
+
const absoluteQuat = maths.Quaternion.multiply(this._relAbsQuat, quaternion);
|
|
2455
2460
|
const attitude = new AbsoluteAttitude(absoluteQuat, time, accuracyWithRelative);
|
|
2456
2461
|
this.notify(attitude);
|
|
2457
2462
|
});
|
|
@@ -2506,7 +2511,7 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2506
2511
|
this._callbackMagCalibration = cb;
|
|
2507
2512
|
}
|
|
2508
2513
|
feed(data) {
|
|
2509
|
-
if (data instanceof AbsoluteHeading) {
|
|
2514
|
+
if (data instanceof geo.AbsoluteHeading) {
|
|
2510
2515
|
if (data.time === null) {
|
|
2511
2516
|
throw Error("the time of the absolute heading is not defined");
|
|
2512
2517
|
}
|
|
@@ -2528,9 +2533,9 @@ const _AbsoluteAttitudeProvider = class extends Provider {
|
|
|
2528
2533
|
}
|
|
2529
2534
|
};
|
|
2530
2535
|
let AbsoluteAttitudeProvider = _AbsoluteAttitudeProvider;
|
|
2531
|
-
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_ANGLE_THRESHOLD", deg2rad(25));
|
|
2536
|
+
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_ANGLE_THRESHOLD", maths.deg2rad(25));
|
|
2532
2537
|
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_TIME_THRESHOLD", 2.5);
|
|
2533
|
-
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD", deg2rad(15));
|
|
2538
|
+
__publicField(AbsoluteAttitudeProvider, "REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD", maths.deg2rad(15));
|
|
2534
2539
|
const AbsoluteAttitudeProvider$1 = new AbsoluteAttitudeProvider();
|
|
2535
2540
|
const _TurnProvider = class extends Provider {
|
|
2536
2541
|
constructor() {
|
|
@@ -2544,7 +2549,7 @@ const _TurnProvider = class extends Provider {
|
|
|
2544
2549
|
const timestamp = relativeAttitudeEvent.time;
|
|
2545
2550
|
this.slidingWindow = this.slidingWindow.filter((item) => item[0] >= timestamp - _TurnProvider.SLIDING_WINDOW_TIME);
|
|
2546
2551
|
this.slidingWindow.push([timestamp, heading]);
|
|
2547
|
-
const stdVal = std(this.slidingWindow.map((item) => item[1]));
|
|
2552
|
+
const stdVal = maths.std(this.slidingWindow.map((item) => item[1]));
|
|
2548
2553
|
if (stdVal > _TurnProvider.STD_THRESHOLD) {
|
|
2549
2554
|
this.notify({ timestamp });
|
|
2550
2555
|
}
|
|
@@ -2653,7 +2658,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2653
2658
|
this._stopInternalProviders();
|
|
2654
2659
|
}
|
|
2655
2660
|
});
|
|
2656
|
-
this._mapMatching = new MapMatching();
|
|
2661
|
+
this._mapMatching = new geo.MapMatching();
|
|
2657
2662
|
this._mapMatching.maxDistance = _MapMatchingHandler.DEFAULT_MM_MAX_DIST;
|
|
2658
2663
|
this._mapMatching.maxAngleBearing = _MapMatchingHandler.DEFAULT_MM_MAX_ANGLE;
|
|
2659
2664
|
}
|
|
@@ -2699,7 +2704,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2699
2704
|
}
|
|
2700
2705
|
set itinerary(itinerary) {
|
|
2701
2706
|
this._mapMatching.network = itinerary ? itinerary.toNetwork() : null;
|
|
2702
|
-
this._itineraryInfoManager = new ItineraryInfoManager(itinerary);
|
|
2707
|
+
this._itineraryInfoManager = new routers.ItineraryInfoManager(itinerary);
|
|
2703
2708
|
this.notify({ ...itinerary && { itinerary } });
|
|
2704
2709
|
this._manageStartStop();
|
|
2705
2710
|
if (this.canUseMapMatching() && itinerary) {
|
|
@@ -2714,7 +2719,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2714
2719
|
return;
|
|
2715
2720
|
}
|
|
2716
2721
|
const lastPosition = AbsolutePositionProvider$1.lastEvent || null;
|
|
2717
|
-
const newPosition = UserPosition.fromCoordinates(itinerary.from);
|
|
2722
|
+
const newPosition = geo.UserPosition.fromCoordinates(itinerary.from);
|
|
2718
2723
|
if (lastPosition) {
|
|
2719
2724
|
newPosition.alt = lastPosition.alt;
|
|
2720
2725
|
newPosition.time = lastPosition.time;
|
|
@@ -2722,7 +2727,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2722
2727
|
newPosition.bearing = lastPosition.bearing;
|
|
2723
2728
|
} else if (itinerary.coords.length >= 2) {
|
|
2724
2729
|
newPosition.alt = Constants.DEFAULT_ALTITUDE;
|
|
2725
|
-
newPosition.time = TimeUtils.preciseTime();
|
|
2730
|
+
newPosition.time = utils.TimeUtils.preciseTime();
|
|
2726
2731
|
newPosition.accuracy = 0;
|
|
2727
2732
|
newPosition.bearing = itinerary.coords[0].bearingTo(itinerary.coords[1]);
|
|
2728
2733
|
} else {
|
|
@@ -2844,14 +2849,14 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2844
2849
|
}
|
|
2845
2850
|
const firstProjection = this._lastProjections[0];
|
|
2846
2851
|
return !this._lastProjections.some(
|
|
2847
|
-
(projection) => !(projection.nearestElement instanceof GraphEdge) || !(firstProjection.nearestElement instanceof GraphEdge) || diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold
|
|
2852
|
+
(projection) => !(projection.nearestElement instanceof geo.GraphEdge) || !(firstProjection.nearestElement instanceof geo.GraphEdge) || maths.diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold
|
|
2848
2853
|
);
|
|
2849
2854
|
}
|
|
2850
2855
|
_nodeHasTurn(node) {
|
|
2851
2856
|
const { edges } = node;
|
|
2852
2857
|
for (let i = 0; i < edges.length; i++) {
|
|
2853
2858
|
for (let j = i + 1; j < edges.length; j++) {
|
|
2854
|
-
const angle = diffAngleLines(edges[i].bearing, edges[j].bearing);
|
|
2859
|
+
const angle = maths.diffAngleLines(edges[i].bearing, edges[j].bearing);
|
|
2855
2860
|
if (angle > _MapMatchingHandler.DEFAULT_MM_MAX_ANGLE) {
|
|
2856
2861
|
return true;
|
|
2857
2862
|
}
|
|
@@ -2865,7 +2870,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2865
2870
|
return false;
|
|
2866
2871
|
}
|
|
2867
2872
|
return network.nodes.filter(
|
|
2868
|
-
(node) => node.coords.distanceTo(center) <= radius && Level.intersect(node.coords.level, center.level)
|
|
2873
|
+
(node) => node.coords.distanceTo(center) <= radius && geo.Level.intersect(node.coords.level, center.level)
|
|
2869
2874
|
).some(this._nodeHasTurn);
|
|
2870
2875
|
}
|
|
2871
2876
|
tryOrientationMatching(projection) {
|
|
@@ -2876,18 +2881,18 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2876
2881
|
return;
|
|
2877
2882
|
}
|
|
2878
2883
|
const { nearestElement, origin } = projection;
|
|
2879
|
-
if (!(nearestElement instanceof GraphEdge)) {
|
|
2884
|
+
if (!(nearestElement instanceof geo.GraphEdge)) {
|
|
2880
2885
|
return;
|
|
2881
2886
|
}
|
|
2882
2887
|
let matchingDirection;
|
|
2883
|
-
const matchingDirectionAngle1 = diffAngle(nearestElement.bearing, origin.bearing);
|
|
2884
|
-
const matchingDirectionAngle2 = diffAngle(nearestElement.bearing + Math.PI, origin.bearing);
|
|
2888
|
+
const matchingDirectionAngle1 = maths.diffAngle(nearestElement.bearing, origin.bearing);
|
|
2889
|
+
const matchingDirectionAngle2 = maths.diffAngle(nearestElement.bearing + Math.PI, origin.bearing);
|
|
2885
2890
|
if (Math.abs(matchingDirectionAngle1) < Math.abs(matchingDirectionAngle2)) {
|
|
2886
2891
|
matchingDirection = nearestElement.bearing;
|
|
2887
2892
|
} else {
|
|
2888
2893
|
matchingDirection = (nearestElement.bearing + Math.PI) % (2 * Math.PI);
|
|
2889
2894
|
}
|
|
2890
|
-
const matchedHeading = new AbsoluteHeading(
|
|
2895
|
+
const matchedHeading = new geo.AbsoluteHeading(
|
|
2891
2896
|
matchingDirection,
|
|
2892
2897
|
origin.time,
|
|
2893
2898
|
0
|
|
@@ -2966,7 +2971,7 @@ const _MapMatchingHandler = class extends Provider {
|
|
|
2966
2971
|
}
|
|
2967
2972
|
};
|
|
2968
2973
|
let MapMatchingHandler = _MapMatchingHandler;
|
|
2969
|
-
__publicField(MapMatchingHandler, "DEFAULT_MM_MAX_ANGLE", deg2rad(30));
|
|
2974
|
+
__publicField(MapMatchingHandler, "DEFAULT_MM_MAX_ANGLE", maths.deg2rad(30));
|
|
2970
2975
|
__publicField(MapMatchingHandler, "DEFAULT_MM_MAX_DIST", 30);
|
|
2971
2976
|
__publicField(MapMatchingHandler, "DEFAULT_MM_MIN_DIST", 0);
|
|
2972
2977
|
__publicField(MapMatchingHandler, "DEFAULT_USE_ITINERARY_START_AS_POSITION", false);
|
|
@@ -2976,7 +2981,7 @@ __publicField(MapMatchingHandler, "DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE",
|
|
|
2976
2981
|
__publicField(MapMatchingHandler, "DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING", 3);
|
|
2977
2982
|
__publicField(MapMatchingHandler, "DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING", 5);
|
|
2978
2983
|
__publicField(MapMatchingHandler, "DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE", 3);
|
|
2979
|
-
__publicField(MapMatchingHandler, "DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD", deg2rad(3));
|
|
2984
|
+
__publicField(MapMatchingHandler, "DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD", maths.deg2rad(3));
|
|
2980
2985
|
const MapMatchingHandler$1 = new MapMatchingHandler();
|
|
2981
2986
|
const _PositionSmoother = class {
|
|
2982
2987
|
constructor(callback, frequency = _PositionSmoother.DEFAULT_FREQUENCY) {
|
|
@@ -2998,7 +3003,7 @@ const _PositionSmoother = class {
|
|
|
2998
3003
|
this.frequency = frequency;
|
|
2999
3004
|
}
|
|
3000
3005
|
feed(newPosition, flybyTime = _PositionSmoother.DEFAULT_FLYBY_TIME) {
|
|
3001
|
-
if (!(newPosition instanceof UserPosition)) {
|
|
3006
|
+
if (!(newPosition instanceof geo.UserPosition)) {
|
|
3002
3007
|
throw new TypeError("newPosition is not instance of UserPosition");
|
|
3003
3008
|
}
|
|
3004
3009
|
if (newPosition.time === null) {
|
|
@@ -3017,7 +3022,7 @@ const _PositionSmoother = class {
|
|
|
3017
3022
|
const azimuth = previousPosition.bearingTo(newPosition);
|
|
3018
3023
|
let i = 1;
|
|
3019
3024
|
const nSamples = this.frequency * flybyTime + 1;
|
|
3020
|
-
const newPositionLevel = Level.clone(newPosition.level);
|
|
3025
|
+
const newPositionLevel = geo.Level.clone(newPosition.level);
|
|
3021
3026
|
while (i < nSamples + 1) {
|
|
3022
3027
|
const smoothedPosition = previousPosition.destinationPoint(distance * i / nSamples, azimuth);
|
|
3023
3028
|
smoothedPosition.time = refTimestamp + (i - 1) / this.frequency;
|
|
@@ -3068,7 +3073,7 @@ const _AttitudeSmoother = class {
|
|
|
3068
3073
|
const fromAttitude = this._smoothing === null ? previousAttitude : this._smoothing.interpAttitude(previousAttitude);
|
|
3069
3074
|
const fromHeading = fromAttitude.heading;
|
|
3070
3075
|
const toHeading = newAttitude.heading;
|
|
3071
|
-
const diffAngleHeading = diffAngle(toHeading, fromHeading);
|
|
3076
|
+
const diffAngleHeading = maths.diffAngle(toHeading, fromHeading);
|
|
3072
3077
|
const isHighJump = Math.abs(diffAngleHeading) < _AttitudeSmoother.HIGH_JUMP_THRESHOLD;
|
|
3073
3078
|
const rotationSpeedConvergence = isHighJump ? _AttitudeSmoother.ROTATION_SPEED_CONVERGENCE : _AttitudeSmoother.ROTATION_SPEED_HIGH_JUMP_CONVERGENCE;
|
|
3074
3079
|
const fromTime = fromAttitude.time;
|
|
@@ -3079,9 +3084,9 @@ const _AttitudeSmoother = class {
|
|
|
3079
3084
|
interpAttitude: (attitude) => {
|
|
3080
3085
|
const angle = rotationSpeedConvergence * (attitude.time - fromTime);
|
|
3081
3086
|
const interpHeading = fromHeading + angle * multiplier;
|
|
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);
|
|
3087
|
+
const offsetQuat = maths.Quaternion.fromAxisAngle([0, 0, 1], toHeading - interpHeading);
|
|
3088
|
+
const interpQuat = maths.Quaternion.multiply(offsetQuat, attitude.quaternion);
|
|
3089
|
+
return new geo.Attitude(interpQuat, attitude.time, attitude.accuracy);
|
|
3085
3090
|
}
|
|
3086
3091
|
};
|
|
3087
3092
|
}
|
|
@@ -3099,7 +3104,7 @@ const _AttitudeSmoother = class {
|
|
|
3099
3104
|
static isJump(previousAttitude, newAttitude) {
|
|
3100
3105
|
const fromHeading = previousAttitude.heading;
|
|
3101
3106
|
const toHeading = newAttitude.heading;
|
|
3102
|
-
const diffAngleHeading = diffAngle(toHeading, fromHeading);
|
|
3107
|
+
const diffAngleHeading = maths.diffAngle(toHeading, fromHeading);
|
|
3103
3108
|
const diffTime = newAttitude.time - previousAttitude.time;
|
|
3104
3109
|
const [qw, qx, qy, qz] = newAttitude.quaternion;
|
|
3105
3110
|
const distToPitchThreshold = Math.abs(Math.asin(2 * (qw * qx + qy * qz)) - Math.PI / 4);
|
|
@@ -3110,11 +3115,11 @@ const _AttitudeSmoother = class {
|
|
|
3110
3115
|
}
|
|
3111
3116
|
};
|
|
3112
3117
|
let AttitudeSmoother = _AttitudeSmoother;
|
|
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));
|
|
3118
|
+
__publicField(AttitudeSmoother, "ROTATION_SPEED_JUMP_THRESHOLD", maths.deg2rad(180));
|
|
3119
|
+
__publicField(AttitudeSmoother, "ROTATION_SPEED_CONVERGENCE", maths.deg2rad(10));
|
|
3120
|
+
__publicField(AttitudeSmoother, "HIGH_JUMP_THRESHOLD", maths.deg2rad(20));
|
|
3121
|
+
__publicField(AttitudeSmoother, "ROTATION_SPEED_HIGH_JUMP_CONVERGENCE", maths.deg2rad(100));
|
|
3122
|
+
__publicField(AttitudeSmoother, "PITCH_UNCERTAINITY_HEADING_THRESHOLD", maths.deg2rad(5));
|
|
3118
3123
|
class MagnetometerCalibrationProvider extends Provider {
|
|
3119
3124
|
constructor() {
|
|
3120
3125
|
super();
|
|
@@ -3147,9 +3152,9 @@ class IpProvider extends Provider {
|
|
|
3147
3152
|
this.notifyError(new IpResolveServerError());
|
|
3148
3153
|
return;
|
|
3149
3154
|
}
|
|
3150
|
-
const timestamp = TimeUtils.preciseTime() / 1e3;
|
|
3155
|
+
const timestamp = utils.TimeUtils.preciseTime() / 1e3;
|
|
3151
3156
|
const latLngStr = (await response.json()).loc.split(",");
|
|
3152
|
-
const position = new UserPosition(
|
|
3157
|
+
const position = new geo.UserPosition(
|
|
3153
3158
|
parseFloat(latLngStr[0]),
|
|
3154
3159
|
parseFloat(latLngStr[1]),
|
|
3155
3160
|
null,
|
|
@@ -3222,49 +3227,47 @@ class CameraProjectionMatrixProvider extends Provider {
|
|
|
3222
3227
|
}
|
|
3223
3228
|
}
|
|
3224
3229
|
const CameraProjectionMatrixProvider$1 = new CameraProjectionMatrixProvider();
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
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
|
-
VpsResponse
|
|
3269
|
-
};
|
|
3230
|
+
exports.AbsoluteAttitude = AbsoluteAttitude;
|
|
3231
|
+
exports.AbsoluteAttitudeFromBrowserProvider = AbsoluteAttitudeFromBrowser$1;
|
|
3232
|
+
exports.AbsoluteAttitudeProvider = AbsoluteAttitudeProvider$1;
|
|
3233
|
+
exports.AbsolutePosition = AbsolutePosition;
|
|
3234
|
+
exports.AbsolutePositionProvider = AbsolutePositionProvider$1;
|
|
3235
|
+
exports.AccelerometerProvider = AccelerometerProvider$1;
|
|
3236
|
+
exports.ArCoreProvider = ArCoreProvider$1;
|
|
3237
|
+
exports.AttitudeSmoother = AttitudeSmoother;
|
|
3238
|
+
exports.BarcodeProvider = BarcodeProvider;
|
|
3239
|
+
exports.CameraNativeProvider = CameraNativeProvider$1;
|
|
3240
|
+
exports.CameraProjectionMatrixProvider = CameraProjectionMatrixProvider$1;
|
|
3241
|
+
exports.GeoRelativePositionFromArCoreProvider = GeoRelativePositionFromArCoreProvider$1;
|
|
3242
|
+
exports.GeoRelativePositionProvider = GeoRelativePositionProvider$1;
|
|
3243
|
+
exports.GnssWifiProvider = GnssWifiProvider$1;
|
|
3244
|
+
exports.GyroscopeProvider = GyroscopeProvider$1;
|
|
3245
|
+
exports.HighRotationsProvider = HighRotationsProvider$1;
|
|
3246
|
+
exports.ImageRelocalization = ImageRelocalization;
|
|
3247
|
+
exports.ImuProvider = ImuProvider$1;
|
|
3248
|
+
exports.InclinationFromAccProvider = InclinationFromAccProvider$1;
|
|
3249
|
+
exports.InclinationFromRelativeAttitudeProvider = InclinationFromRelativeAttitudeProvider$1;
|
|
3250
|
+
exports.InclinationProvider = InclinationProvider$1;
|
|
3251
|
+
exports.IpProvider = IpProvider$1;
|
|
3252
|
+
exports.MagnetometerCalibrationProvider = MagnetometerCalibrationProvider$1;
|
|
3253
|
+
exports.MapMatchingHandler = MapMatchingHandler$1;
|
|
3254
|
+
exports.PdrProvider = PdrProvider$1;
|
|
3255
|
+
exports.PoleStarProvider = PoleStarProvider$1;
|
|
3256
|
+
exports.PositionSmoother = PositionSmoother;
|
|
3257
|
+
exports.ProvidersLoggerOld = ProvidersLoggerOld$1;
|
|
3258
|
+
exports.ProvidersOptions = ProvidersOptions;
|
|
3259
|
+
exports.RelativeAttitude = RelativeAttitude;
|
|
3260
|
+
exports.RelativeAttitudeFromBrowserProvider = RelativeAttitudeFromBrowser$1;
|
|
3261
|
+
exports.RelativeAttitudeFromEkfProvider = RelativeAttitudeFromEkfProvider;
|
|
3262
|
+
exports.RelativeAttitudeFromInertialProvider = RelativeAttitudeFromInertialProvider;
|
|
3263
|
+
exports.RelativeAttitudeProvider = RelativeAttitudeProvider$1;
|
|
3264
|
+
exports.StepDetectionMinMaxPeaks2 = StepDetectionMinMaxPeaks2;
|
|
3265
|
+
exports.StepDetectionMinMaxPeaks3 = StepDetectionMinMaxPeaks3;
|
|
3266
|
+
exports.StepProvider = StepProvider$1;
|
|
3267
|
+
exports.StraightLineProvider = StraightLineProvider$1;
|
|
3268
|
+
exports.TurnProvider = TurnProvider$1;
|
|
3269
|
+
exports.VpsMetadata = VpsMetadata;
|
|
3270
|
+
exports.VpsProvider = VpsProvider$1;
|
|
3271
|
+
exports.VpsRequest = VpsRequest;
|
|
3272
|
+
exports.VpsResponse = VpsResponse;
|
|
3270
3273
|
//# sourceMappingURL=index.js.map
|