@wemap/providers 3.3.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/debug/src/AbsoluteAttitudeComponent.jsx +8 -7
- package/debug/src/NavigationConfig.js +7 -8
- package/debug/src/RelativeAttitudeComponent.jsx +3 -3
- package/debug/src/Utils.js +32 -41
- package/index.js +6 -8
- package/package.json +8 -9
- package/src/Providers.js +3 -0
- package/src/ProvidersInterface.js +12 -9
- package/src/events/ProviderEvent.js +0 -2
- package/src/mapmatching/MapMatchingHandler.js +150 -0
- package/src/providers/FakeProvider.spec.js +0 -2
- package/src/providers/Provider.js +3 -8
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +0 -1
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js +3 -3
- package/src/providers/attitude/absolute/AbsoluteAttitudeFusedProvider.js +166 -0
- package/src/providers/attitude/absolute/AbsoluteAttitudeProvider.js +45 -13
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +2 -4
- package/src/providers/attitude/relative/RelativeAttitudeFromEkfProvider.js +4 -4
- package/src/providers/imu/ImuProvider.js +8 -2
- package/src/providers/inclination/InclinationFromAccProvider.js +1 -2
- package/src/providers/inclination/InclinationFromRelativeAttitudeProvider.js +0 -1
- package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +2 -3
- package/src/providers/position/absolute/AbsolutePositionProvider.js +32 -138
- package/src/providers/position/absolute/GnssWifiProvider.js +1 -1
- package/src/providers/position/absolute/IpProvider.js +2 -4
- package/src/providers/position/relative/ArCoreProvider.js +1 -1
- package/src/providers/position/relative/GeoRelativePositionFromArCoreProvider.js +0 -1
- package/src/providers/position/relative/PdrProvider.js +1 -2
- package/src/providers/steps/StepDetectionProvider.js +4 -4
- package/src/smoothers/AttitudeSmoother.js +100 -0
|
@@ -39,7 +39,7 @@ class IpProvider extends Provider {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const timestamp = TimeUtils.preciseTime / 1e3;
|
|
42
|
+
const timestamp = TimeUtils.preciseTime() / 1e3;
|
|
43
43
|
|
|
44
44
|
const latLngStr = response.loc.split(',');
|
|
45
45
|
const position = new UserPosition(
|
|
@@ -50,9 +50,7 @@ class IpProvider extends Provider {
|
|
|
50
50
|
timestamp
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
this.notify(this.createEvent(
|
|
54
|
-
EventType.AbsolutePosition, position, timestamp
|
|
55
|
-
));
|
|
53
|
+
this.notify(this.createEvent(EventType.AbsolutePosition, position));
|
|
56
54
|
});
|
|
57
55
|
}
|
|
58
56
|
|
|
@@ -72,7 +72,6 @@ class PdrProvider extends Provider {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const timestamp = stepEvent.timestamp;
|
|
76
75
|
const stepSize = stepEvent.data.size;
|
|
77
76
|
|
|
78
77
|
/**
|
|
@@ -106,6 +105,7 @@ class PdrProvider extends Provider {
|
|
|
106
105
|
*/
|
|
107
106
|
const deviceDirectionAccuracy = deviceAttitude.accuracy + this.misalignmentError;
|
|
108
107
|
const accuracy = (stepSize / 2) * Math.sin(deviceDirectionAccuracy / 2);
|
|
108
|
+
const timestamp = deviceAttitude.time;
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Relative position is defined in ENU frame
|
|
@@ -122,7 +122,6 @@ class PdrProvider extends Provider {
|
|
|
122
122
|
this.notify(this.createEvent(
|
|
123
123
|
EventType.GeoRelativePosition,
|
|
124
124
|
position,
|
|
125
|
-
timestamp,
|
|
126
125
|
[stepEvent, this.attitudeEvent]
|
|
127
126
|
));
|
|
128
127
|
}
|
|
@@ -71,15 +71,16 @@ class StepDetectionProvider extends Provider {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const {
|
|
75
|
-
|
|
74
|
+
const {
|
|
75
|
+
values: acceleration, timestamp
|
|
76
|
+
} = accelerationEvent.data;
|
|
76
77
|
|
|
77
78
|
/**
|
|
78
79
|
* Step Detection and Step Size Detection
|
|
79
80
|
*/
|
|
80
81
|
const linearAcc = this.constructor.computeLinearAcceleration(
|
|
81
82
|
this.attitudeEvent.data.quaternion, acceleration);
|
|
82
|
-
const stepDetected = this.stepDetector.compute(timestamp, linearAcc, this.angularRateEvent.data);
|
|
83
|
+
const stepDetected = this.stepDetector.compute(timestamp, linearAcc, this.angularRateEvent.data.values);
|
|
83
84
|
|
|
84
85
|
if (stepDetected) {
|
|
85
86
|
const size = this.stepDetector.lastStepSize;
|
|
@@ -89,7 +90,6 @@ class StepDetectionProvider extends Provider {
|
|
|
89
90
|
size,
|
|
90
91
|
number: this.numOfSteps
|
|
91
92
|
},
|
|
92
|
-
timestamp,
|
|
93
93
|
[accelerationEvent, this.angularRateEvent, this.attitudeEvent]
|
|
94
94
|
));
|
|
95
95
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* eslint-disable max-statements */
|
|
2
|
+
import { Attitude } from '@wemap/geo';
|
|
3
|
+
import { Quaternion } from '@wemap/maths';
|
|
4
|
+
|
|
5
|
+
class AttitudeSmoother {
|
|
6
|
+
|
|
7
|
+
// Generated attitude by second
|
|
8
|
+
static DEFAULT_FREQUENCY = 60;
|
|
9
|
+
|
|
10
|
+
// In radians/s
|
|
11
|
+
static MAX_ROTATE_SPEED = 0.5;
|
|
12
|
+
|
|
13
|
+
/** @type {Attitude[]} */
|
|
14
|
+
queue;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {Function} callback
|
|
18
|
+
* @param {Number} frequency in Hz
|
|
19
|
+
*/
|
|
20
|
+
constructor(callback, frequency = this.constructor.DEFAULT_FREQUENCY) {
|
|
21
|
+
this.callback = callback;
|
|
22
|
+
this.queue = [];
|
|
23
|
+
this.frequency = frequency;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {Attitude} attitude
|
|
28
|
+
*/
|
|
29
|
+
feed(newAttitude) {
|
|
30
|
+
|
|
31
|
+
if (!(newAttitude instanceof Attitude)) {
|
|
32
|
+
throw new TypeError('newAttitude is not instance of Attitude');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (newAttitude.time === null) {
|
|
36
|
+
throw new Error('newAttitude does not have time property');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let previousAttitude;
|
|
40
|
+
if (this.queue.length !== 0) {
|
|
41
|
+
previousAttitude = this.queue[0];
|
|
42
|
+
this.queue = [];
|
|
43
|
+
} else {
|
|
44
|
+
previousAttitude = this.previousAttitude;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (previousAttitude) {
|
|
48
|
+
const previousQuat = previousAttitude.quaternion;
|
|
49
|
+
const nextQuat = newAttitude.quaternion;
|
|
50
|
+
const quatAngle = Quaternion.distance(previousQuat, nextQuat);
|
|
51
|
+
|
|
52
|
+
/** max rotation for the next value (radians) */
|
|
53
|
+
const maxRotAtEpoch = this.constructor.MAX_ROTATE_SPEED / this.frequency;
|
|
54
|
+
|
|
55
|
+
if (quatAngle > maxRotAtEpoch) {
|
|
56
|
+
for (let i = 1; i <= Math.floor(quatAngle / maxRotAtEpoch); i++) {
|
|
57
|
+
|
|
58
|
+
// coef is contained in [0; 1[
|
|
59
|
+
const coef = i * maxRotAtEpoch / quatAngle;
|
|
60
|
+
|
|
61
|
+
const smoothedAttitude = new Attitude(
|
|
62
|
+
Quaternion.slerp(previousQuat, nextQuat, coef),
|
|
63
|
+
newAttitude.time + i / this.frequency,
|
|
64
|
+
Math.max(
|
|
65
|
+
previousAttitude.accuracy + (newAttitude.accuracy - previousAttitude.accuracy) * coef,
|
|
66
|
+
0
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
this.queue.push(smoothedAttitude);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.queue.push(newAttitude.clone());
|
|
76
|
+
|
|
77
|
+
this.previousAttitude = newAttitude;
|
|
78
|
+
|
|
79
|
+
if (!this.timeoutNotify) {
|
|
80
|
+
this._notifyNext();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_notifyNext = () => {
|
|
85
|
+
this.callback(this.queue.shift());
|
|
86
|
+
if (this.queue.length !== 0) {
|
|
87
|
+
this.timeoutNotify = setTimeout(this._notifyNext, 1e3 / this.frequency);
|
|
88
|
+
} else {
|
|
89
|
+
delete this.timeoutNotify;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
clear() {
|
|
94
|
+
clearTimeout(this.timeoutNotify);
|
|
95
|
+
delete this.timeoutNotify;
|
|
96
|
+
this.queue = [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default AttitudeSmoother;
|