@wemap/providers 3.3.0 → 4.0.1
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 +12 -8
- 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 +26 -79
- package/src/ProvidersInterface.js +12 -9
- package/src/errors/AskImuOnDesktopError.js +4 -3
- package/src/errors/ContainsIgnoredProviderError.js +4 -3
- package/src/errors/GeolocationApiMissingError.js +4 -3
- package/src/errors/GeolocationPermissionDeniedError.js +4 -3
- package/src/errors/GeolocationPositionUnavailableError.js +4 -3
- package/src/errors/IpResolveServerError.js +4 -3
- package/src/errors/MissingAccelerometerError.js +3 -3
- package/src/errors/MissingArCoreError.js +4 -3
- package/src/errors/MissingGyroscopeError.js +3 -3
- package/src/errors/MissingNativeInterfaceError.js +4 -3
- package/src/errors/MissingSensorError.js +4 -3
- package/src/errors/NoProviderFoundError.js +4 -3
- package/src/events/ProviderEvent.js +0 -2
- package/src/events/ProvidersLoggerOld.js +35 -34
- package/src/mapmatching/MapMatchingHandler.js +138 -0
- package/src/providers/FakeProvider.spec.js +15 -17
- package/src/providers/Provider.js +5 -27
- package/src/providers/Provider.spec.js +18 -28
- package/src/providers/attitude/absolute/{AbsoluteAttitudeProvider.js → AbsoluteAttitude.js} +49 -18
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromBrowserProvider.js → AbsoluteAttitudeFromBrowser.js} +4 -5
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromRelAttProvider.js → AbsoluteAttitudeFromRelAtt.js} +8 -7
- package/src/providers/attitude/absolute/AbsoluteAttitudeFused.js +166 -0
- package/src/providers/attitude/relative/{RelativeAttitudeProvider.js → RelativeAttitude.js} +4 -5
- package/src/providers/attitude/relative/{RelativeAttitudeFromBrowserProvider.js → RelativeAttitudeFromBrowser.js} +6 -8
- package/src/providers/attitude/relative/{RelativeAttitudeFromEkfProvider.js → RelativeAttitudeFromEkf.js} +11 -11
- package/src/providers/attitude/relative/{RelativeAttitudeFromInertialProvider.js → RelativeAttitudeFromInertial.js} +5 -5
- package/src/providers/imu/{AccelerometerProvider.js → Accelerometer.js} +3 -3
- package/src/providers/imu/{GyroscopeProvider.js → Gyroscope.js} +3 -3
- package/src/providers/imu/{ImuProvider.js → Imu.js} +11 -5
- package/src/providers/inclination/{InclinationProvider.js → Inclination.js} +4 -5
- package/src/providers/inclination/{InclinationFromAccProvider.js → InclinationFromAcc.js} +5 -5
- package/src/providers/inclination/{InclinationFromRelativeAttitudeProvider.js → InclinationFromRelativeAttitude.js} +4 -4
- package/src/providers/legacy/helpers/ThugDetector.js +7 -7
- package/src/providers/others/{BarcodeProvider.js → Barcode.js} +3 -3
- package/src/providers/others/{CameraNativeProvider.js → CameraNative.js} +2 -2
- package/src/providers/others/{CameraProjectionMatrixProvider.js → CameraProjectionMatrix.js} +3 -3
- package/src/providers/position/absolute/AbsolutePosition.js +187 -0
- package/src/providers/position/absolute/{AbsolutePositionFromRelProvider.js → AbsolutePositionFromRel.js} +6 -8
- package/src/providers/position/absolute/{GnssWifiProvider.js → GnssWifi.js} +10 -9
- package/src/providers/position/absolute/{IpProvider.js → Ip.js} +4 -6
- package/src/providers/position/relative/{ArCoreProvider.js → ArCore.js} +29 -31
- package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js} +5 -5
- package/src/providers/position/relative/{GeoRelativePositionFromArCoreProvider.js → GeoRelativePositionFromArCore.js} +4 -6
- package/src/providers/position/relative/{PdrProvider.js → Pdr.js} +6 -7
- package/src/providers/steps/{StepDetectionProvider.js → StepDetection.js} +10 -9
- package/src/providers/steps/StepDetectionLadetto.js +12 -13
- package/src/providers/steps/StepDetectionMinMaxPeaks.js +19 -17
- package/src/providers/steps/StepDetectionMinMaxPeaks2.js +17 -18
- package/src/smoothers/AttitudeSmoother.js +100 -0
- package/src/providers/position/absolute/AbsolutePositionProvider.js +0 -295
|
@@ -5,21 +5,21 @@ import { PromiseUtils } from '@wemap/utils';
|
|
|
5
5
|
|
|
6
6
|
import MetaProvider from '../../MetaProvider.js';
|
|
7
7
|
import EventType from '../../../events/EventType.js';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import AbsoluteAttitudeFromBrowser from './AbsoluteAttitudeFromBrowser.js';
|
|
9
|
+
import AbsoluteAttitudeFromRelAtt from './AbsoluteAttitudeFromRelAtt.js';
|
|
10
|
+
import AbsoluteAttitudeFused from './AbsoluteAttitudeFused.js';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Absolute attitude provider gives the device attitude in East-North-Up (ENU) frame
|
|
15
14
|
*/
|
|
16
|
-
class
|
|
15
|
+
class AbsoluteAttitude extends MetaProvider {
|
|
17
16
|
|
|
18
17
|
constructor() {
|
|
19
18
|
super();
|
|
20
19
|
|
|
21
20
|
this.attitudeFromBrowserErrored = false;
|
|
22
21
|
this.attitudeFromRelAttErrored = false;
|
|
22
|
+
this.attitudeFusedErrored = false;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -42,7 +42,8 @@ class AbsoluteAttitudeProvider extends MetaProvider {
|
|
|
42
42
|
get _availability() {
|
|
43
43
|
return PromiseUtils.any([
|
|
44
44
|
AbsoluteAttitudeFromBrowser.availability,
|
|
45
|
-
AbsoluteAttitudeFromRelAtt.availability
|
|
45
|
+
AbsoluteAttitudeFromRelAtt.availability,
|
|
46
|
+
AbsoluteAttitudeFused.availability
|
|
46
47
|
]);
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -66,28 +67,59 @@ class AbsoluteAttitudeProvider extends MetaProvider {
|
|
|
66
67
|
this.onError(error);
|
|
67
68
|
}
|
|
68
69
|
);
|
|
70
|
+
|
|
71
|
+
this.fusedProviderId = AbsoluteAttitudeFused.addEventListener(
|
|
72
|
+
events => this.onAttitudeFused(events[0]),
|
|
73
|
+
error => {
|
|
74
|
+
this.attitudeFusedErrored = true;
|
|
75
|
+
this.onError(error);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
onError(error) {
|
|
72
|
-
if (this.attitudeFromBrowserErrored
|
|
81
|
+
if (this.attitudeFromBrowserErrored
|
|
82
|
+
&& this.attitudeFromRelAttErrored
|
|
83
|
+
&& this.attitudeFusedErrored) {
|
|
73
84
|
this.notifyError(error);
|
|
74
85
|
}
|
|
75
86
|
}
|
|
76
87
|
|
|
77
88
|
onAttitudeFromBrowser(event) {
|
|
78
89
|
this.eventFromBrowser = event;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
if (this.eventFromRelAtt && this.eventFromRelAtt.data.accuracy < event.data.accuracy) {
|
|
93
|
+
return;
|
|
82
94
|
}
|
|
95
|
+
if (this.eventFromFused && this.eventFromFused.data.accuracy < event.data.accuracy) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.notify(event.clone());
|
|
83
99
|
}
|
|
84
100
|
|
|
85
101
|
onAttitudeFromRelAtt(event) {
|
|
86
102
|
this.eventFromRelAtt = event;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
|
|
104
|
+
if (this.eventFromBrowser && this.eventFromBrowser.data.accuracy < event.data.accuracy) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (this.eventFromFused && this.eventFromFused.data.accuracy < event.data.accuracy) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.notify(event.clone());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
onAttitudeFused(event) {
|
|
114
|
+
this.eventFromFused = event;
|
|
115
|
+
|
|
116
|
+
if (this.eventFromBrowser && this.eventFromBrowser.data.accuracy < event.data.accuracy) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (this.eventFromRelAtt && this.eventFromRelAtt.data.accuracy < event.data.accuracy) {
|
|
120
|
+
return;
|
|
90
121
|
}
|
|
122
|
+
this.notify(event.clone());
|
|
91
123
|
}
|
|
92
124
|
|
|
93
125
|
/**
|
|
@@ -96,6 +128,7 @@ class AbsoluteAttitudeProvider extends MetaProvider {
|
|
|
96
128
|
stop() {
|
|
97
129
|
AbsoluteAttitudeFromBrowser.removeEventListener(this.fromBrowserProviderId);
|
|
98
130
|
AbsoluteAttitudeFromRelAtt.removeEventListener(this.fromRelAttProviderId);
|
|
131
|
+
AbsoluteAttitudeFused.removeEventListener(this.fusedProviderId);
|
|
99
132
|
}
|
|
100
133
|
|
|
101
134
|
/**
|
|
@@ -115,8 +148,7 @@ class AbsoluteAttitudeProvider extends MetaProvider {
|
|
|
115
148
|
|
|
116
149
|
this.notify(this.createEvent(
|
|
117
150
|
EventType.AbsoluteAttitude,
|
|
118
|
-
data.toAttitude()
|
|
119
|
-
data.time
|
|
151
|
+
data.toAttitude()
|
|
120
152
|
));
|
|
121
153
|
|
|
122
154
|
} else if (data instanceof Attitude) {
|
|
@@ -130,8 +162,7 @@ class AbsoluteAttitudeProvider extends MetaProvider {
|
|
|
130
162
|
|
|
131
163
|
this.notify(this.createEvent(
|
|
132
164
|
EventType.AbsoluteAttitude,
|
|
133
|
-
data
|
|
134
|
-
data.time
|
|
165
|
+
data
|
|
135
166
|
));
|
|
136
167
|
|
|
137
168
|
} else {
|
|
@@ -140,4 +171,4 @@ class AbsoluteAttitudeProvider extends MetaProvider {
|
|
|
140
171
|
}
|
|
141
172
|
}
|
|
142
173
|
|
|
143
|
-
export default
|
|
174
|
+
export default new AbsoluteAttitude();
|
|
@@ -15,7 +15,7 @@ import EventType from '../../../events/EventType.js';
|
|
|
15
15
|
import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError.js';
|
|
16
16
|
import MissingMagnetometerError from '../../../errors/MissingMagnetometerError.js';
|
|
17
17
|
import MissingSensorError from '../../../errors/MissingSensorError.js';
|
|
18
|
-
import
|
|
18
|
+
import AbsolutePosition from '../../position/absolute/AbsolutePosition.js';
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -35,7 +35,7 @@ import { AbsolutePosition } from '../../../Providers.js';
|
|
|
35
35
|
*
|
|
36
36
|
* -----------------------------------
|
|
37
37
|
*/
|
|
38
|
-
class
|
|
38
|
+
class AbsoluteAttitudeFromBrowser extends Provider {
|
|
39
39
|
|
|
40
40
|
// from http://tyrex.inria.fr/mobile/benchmarks-attitude/
|
|
41
41
|
static DEFAULT_ACCURACY = deg2rad(15);
|
|
@@ -207,7 +207,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
207
207
|
if (isSkyMode) {
|
|
208
208
|
alpha = 180 - e.webkitCompassHeading;
|
|
209
209
|
} else {
|
|
210
|
-
alpha =
|
|
210
|
+
alpha = AbsoluteAttitudeFromBrowser.webkitCompassToHeading(
|
|
211
211
|
e.webkitCompassHeading, e.beta, e.gamma);
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -229,7 +229,6 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
229
229
|
this.notify(this.createEvent(
|
|
230
230
|
EventType.AbsoluteAttitude,
|
|
231
231
|
attitude,
|
|
232
|
-
this.magQuaternionTimestamp,
|
|
233
232
|
[this.absolutePositionEvent]
|
|
234
233
|
));
|
|
235
234
|
}
|
|
@@ -277,4 +276,4 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
277
276
|
}
|
|
278
277
|
}
|
|
279
278
|
|
|
280
|
-
export default
|
|
279
|
+
export default new AbsoluteAttitudeFromBrowser();
|
|
@@ -3,14 +3,15 @@ import { Attitude } from '@wemap/geo';
|
|
|
3
3
|
|
|
4
4
|
import Provider from '../../Provider.js';
|
|
5
5
|
import EventType from '../../../events/EventType.js';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import RelativeAttitude from '../relative/RelativeAttitude.js';
|
|
7
|
+
import AbsoluteAttitude from './AbsoluteAttitude.js';
|
|
8
|
+
import AbsoluteAttitudeFromBrowser from './AbsoluteAttitudeFromBrowser.js';
|
|
9
|
+
import AbsoluteAttitudeFused from './AbsoluteAttitudeFused.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Absolute attitude provider gives the device attitude in East-North-Up (ENU) frame
|
|
12
13
|
*/
|
|
13
|
-
class
|
|
14
|
+
class AbsoluteAttitudeFromRelAtt extends Provider {
|
|
14
15
|
|
|
15
16
|
accuracy = 0;
|
|
16
17
|
|
|
@@ -91,7 +92,8 @@ class AbsoluteAttitudeFromRelAttProvider extends Provider {
|
|
|
91
92
|
* Use absolute attitude events only when they are not from this provider
|
|
92
93
|
*/
|
|
93
94
|
if (absoluteAttitudeEvent.providersStack.includes(this.pname)
|
|
94
|
-
|| absoluteAttitudeEvent.providersStack.includes(AbsoluteAttitudeFromBrowser.pname)
|
|
95
|
+
|| absoluteAttitudeEvent.providersStack.includes(AbsoluteAttitudeFromBrowser.pname)
|
|
96
|
+
|| absoluteAttitudeEvent.providersStack.includes(AbsoluteAttitudeFused.pname)) {
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
99
|
this.absoluteAttitudeEvent = absoluteAttitudeEvent;
|
|
@@ -121,7 +123,6 @@ class AbsoluteAttitudeFromRelAttProvider extends Provider {
|
|
|
121
123
|
this.notify(this.createEvent(
|
|
122
124
|
EventType.AbsoluteAttitude,
|
|
123
125
|
attitude,
|
|
124
|
-
time,
|
|
125
126
|
[this.relativeAttitudeEvent, this.absoluteAttitudeEvent]
|
|
126
127
|
));
|
|
127
128
|
|
|
@@ -129,4 +130,4 @@ class AbsoluteAttitudeFromRelAttProvider extends Provider {
|
|
|
129
130
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
export default
|
|
133
|
+
export default new AbsoluteAttitudeFromRelAtt();
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Attitude, Edge } from '@wemap/geo';
|
|
2
|
+
import {
|
|
3
|
+
Quaternion, diffAngle
|
|
4
|
+
} from '@wemap/maths';
|
|
5
|
+
|
|
6
|
+
import Provider from '../../Provider.js';
|
|
7
|
+
import EventType from '../../../events/EventType.js';
|
|
8
|
+
import ProviderState from '../../ProviderState.js';
|
|
9
|
+
import RelativeAttitude from '../relative/RelativeAttitude.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Absolute attitude provider gives the device attitude in East-North-Up (ENU) frame
|
|
13
|
+
*/
|
|
14
|
+
class AbsoluteAttitudeFused extends Provider {
|
|
15
|
+
|
|
16
|
+
accuracy = 0;
|
|
17
|
+
isInitialized = false;
|
|
18
|
+
|
|
19
|
+
/** @type {number[]} quaternion */
|
|
20
|
+
zOffset = null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @override
|
|
24
|
+
*/
|
|
25
|
+
static get pname() {
|
|
26
|
+
return 'AbsoluteAttitudeFused';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @override
|
|
31
|
+
*/
|
|
32
|
+
static get eventsType() {
|
|
33
|
+
return [EventType.AbsoluteAttitude];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @override
|
|
38
|
+
*/
|
|
39
|
+
get _availability() {
|
|
40
|
+
// TODO Enhance
|
|
41
|
+
return RelativeAttitude.availability;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @override
|
|
46
|
+
*/
|
|
47
|
+
start() {
|
|
48
|
+
|
|
49
|
+
this.relativeAttitudeProviderId = RelativeAttitude.addEventListener(
|
|
50
|
+
events => this.onRelativeAttitudeEvent(events[0]),
|
|
51
|
+
error => this.notifyError(error)
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// this.onAbsoluteAttitudeEvent(AbsoluteAttitude.lastEvent);
|
|
56
|
+
// this.absoluteAttitudeProviderId = AbsoluteAttitude.addEventListener(
|
|
57
|
+
// events => this.onAbsoluteAttitudeEvent(events[0]),
|
|
58
|
+
// error => this.notifyError(error),
|
|
59
|
+
// false
|
|
60
|
+
// );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @override
|
|
65
|
+
*/
|
|
66
|
+
stop() {
|
|
67
|
+
RelativeAttitude.removeEventListener(this.relativeAttitudeProviderId);
|
|
68
|
+
// AbsoluteAttitude.removeEventListener(this.absoluteAttitudeProviderId);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
mapMatching(projection) {
|
|
72
|
+
|
|
73
|
+
if (this.state !== ProviderState.STARTED) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
nearestElement, origin
|
|
79
|
+
} = projection;
|
|
80
|
+
if (!(nearestElement instanceof Edge)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let matchingDirection;
|
|
85
|
+
const matchingDirectionAngle1 = diffAngle(nearestElement.bearing, origin.bearing);
|
|
86
|
+
const matchingDirectionAngle2 = diffAngle(nearestElement.bearing + Math.PI, origin.bearing);
|
|
87
|
+
|
|
88
|
+
if (Math.abs(matchingDirectionAngle1) < Math.abs(matchingDirectionAngle2)) {
|
|
89
|
+
matchingDirection = nearestElement.bearing;
|
|
90
|
+
} else {
|
|
91
|
+
matchingDirection = (nearestElement.bearing + Math.PI) % (2 * Math.PI);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.accuracy = 0;
|
|
95
|
+
|
|
96
|
+
// preprocess zOffset for "compute" function
|
|
97
|
+
const currentHeading = this.relativeAttitudeEvent ? this.relativeAttitudeEvent.data.heading : 0;
|
|
98
|
+
this.zOffset = Quaternion.fromAxisAngle([0, 0, 1], -matchingDirection + currentHeading);
|
|
99
|
+
|
|
100
|
+
this.compute();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
onRelativeAttitudeEvent(relativeAttitudeEvent) {
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Calculate relative accuracy
|
|
107
|
+
*/
|
|
108
|
+
if (this.relativeAttitudeEvent) {
|
|
109
|
+
const {
|
|
110
|
+
accuracy, time
|
|
111
|
+
} = relativeAttitudeEvent.data;
|
|
112
|
+
const diffTime = time - this.relativeAttitudeEvent.data.time;
|
|
113
|
+
this.accuracy += diffTime * accuracy;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.relativeAttitudeEvent = relativeAttitudeEvent;
|
|
117
|
+
this.compute();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
// onAbsoluteAttitudeEvent = absoluteAttitudeEvent => {
|
|
122
|
+
|
|
123
|
+
// if (!absoluteAttitudeEvent) {
|
|
124
|
+
// return;
|
|
125
|
+
// }
|
|
126
|
+
|
|
127
|
+
// /**
|
|
128
|
+
// * Use absolute attitude events only when they are not from this provider
|
|
129
|
+
// */
|
|
130
|
+
// if (absoluteAttitudeEvent.providersStack.includes(this.pname)
|
|
131
|
+
// || absoluteAttitudeEvent.providersStack.includes(AbsoluteAttitudeFromBrowser.pname)) {
|
|
132
|
+
// return;
|
|
133
|
+
// }
|
|
134
|
+
// this.absoluteAttitudeEvent = absoluteAttitudeEvent;
|
|
135
|
+
// this.accuracy = 0;
|
|
136
|
+
|
|
137
|
+
// // preprocess zOffset for "compute" function
|
|
138
|
+
// const currentHeading = this.relativeAttitudeEvent ? this.relativeAttitudeEvent.data.heading : 0;
|
|
139
|
+
// this.zOffset = Quaternion.fromAxisAngle([0, 0, 1], -absoluteAttitudeEvent.data.heading + currentHeading);
|
|
140
|
+
// };
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
compute() {
|
|
144
|
+
if (!this.zOffset || !this.relativeAttitudeEvent) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const {
|
|
149
|
+
quaternion, time
|
|
150
|
+
} = this.relativeAttitudeEvent.data;
|
|
151
|
+
|
|
152
|
+
const absoluteQuat = Quaternion.multiply(this.zOffset, quaternion);
|
|
153
|
+
const newAccuracy = Math.min(this.accuracy, Math.PI);
|
|
154
|
+
const attitude = new Attitude(absoluteQuat, time, newAccuracy, this.pname);
|
|
155
|
+
|
|
156
|
+
this.notify(this.createEvent(
|
|
157
|
+
EventType.AbsoluteAttitude,
|
|
158
|
+
attitude,
|
|
159
|
+
[this.relativeAttitudeEvent]
|
|
160
|
+
));
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export default new AbsoluteAttitudeFused();
|
|
@@ -3,17 +3,16 @@ import noop from 'lodash.noop';
|
|
|
3
3
|
import Provider from '../../Provider.js';
|
|
4
4
|
import EventType from '../../../events/EventType.js';
|
|
5
5
|
import ProviderState from '../../ProviderState.js';
|
|
6
|
-
import {
|
|
7
|
-
RelativeAttitudeFromInertial, ArCore
|
|
8
|
-
} from '../../../Providers.js';
|
|
9
6
|
|
|
7
|
+
import RelativeAttitudeFromInertial from './RelativeAttitudeFromInertial.js';
|
|
8
|
+
import ArCore from '../../position/relative/ArCore.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Relative attitude provider gives the device attitude in East-North-Up (ENU) frame using
|
|
13
12
|
* browser deviceorientation
|
|
14
13
|
* The provider does not work until an offset is given.
|
|
15
14
|
*/
|
|
16
|
-
class
|
|
15
|
+
class RelativeAttitude extends Provider {
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* @override
|
|
@@ -95,4 +94,4 @@ class RelativeAttitudeProvider extends Provider {
|
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
export default
|
|
97
|
+
export default new RelativeAttitude();
|
|
@@ -6,7 +6,7 @@ import Provider from '../../Provider.js';
|
|
|
6
6
|
import EventType from '../../../events/EventType.js';
|
|
7
7
|
import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError.js';
|
|
8
8
|
import MissingSensorError from '../../../errors/MissingSensorError.js';
|
|
9
|
-
import
|
|
9
|
+
import RelativeAttitudeFromInertial from './RelativeAttitudeFromInertial.js';
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -24,7 +24,7 @@ import RelativeAttitudeFromInertialProvider from './RelativeAttitudeFromInertial
|
|
|
24
24
|
*
|
|
25
25
|
* -----------------------------------
|
|
26
26
|
*/
|
|
27
|
-
class
|
|
27
|
+
class RelativeAttitudeFromBrowser extends Provider {
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @override
|
|
@@ -80,8 +80,6 @@ class RelativeAttitudeFromBrowserProvider extends Provider {
|
|
|
80
80
|
|
|
81
81
|
onDeviceOrientationEvent = e => {
|
|
82
82
|
|
|
83
|
-
const timestamp = e.timeStamp / 1e3;
|
|
84
|
-
|
|
85
83
|
if (typeof e.alpha !== 'number' || typeof e.beta !== 'number' || typeof e.gamma !== 'number') {
|
|
86
84
|
this.notifyError(new MissingSensorError().from('deviceorientation'));
|
|
87
85
|
return;
|
|
@@ -89,12 +87,12 @@ class RelativeAttitudeFromBrowserProvider extends Provider {
|
|
|
89
87
|
|
|
90
88
|
const quaternion = Rotations.eulerToQuaternionZXYDegrees([e.alpha, e.beta, e.gamma]);
|
|
91
89
|
const attitude = new Attitude(quaternion,
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
e.timeStamp / 1e3,
|
|
91
|
+
RelativeAttitudeFromInertial.DEFAULT_DRIFT,
|
|
94
92
|
this.pname
|
|
95
93
|
);
|
|
96
|
-
this.notify(this.createEvent(EventType.RelativeAttitude, attitude
|
|
94
|
+
this.notify(this.createEvent(EventType.RelativeAttitude, attitude));
|
|
97
95
|
};
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
export default
|
|
98
|
+
export default new RelativeAttitudeFromBrowser();
|
|
@@ -3,10 +3,10 @@ import { Attitude } from '@wemap/geo';
|
|
|
3
3
|
import Provider from '../../Provider.js';
|
|
4
4
|
import EventType from '../../../events/EventType.js';
|
|
5
5
|
import EkfAttitude from '../EkfAttitude.js';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import RelativeAttitudeFromInertial from './RelativeAttitudeFromInertial.js';
|
|
7
|
+
|
|
8
|
+
import Accelerometer from '../../imu/Accelerometer.js';
|
|
9
|
+
import Gyroscope from '../../imu/Gyroscope.js';
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
* browser deviceorientation
|
|
15
15
|
* The provider does not work until an offset is given.
|
|
16
16
|
*/
|
|
17
|
-
class
|
|
17
|
+
class RelativeAttitudeFromEkf extends Provider {
|
|
18
18
|
|
|
19
19
|
lastTimestamp = 0;
|
|
20
20
|
|
|
@@ -82,8 +82,9 @@ class RelativeAttitudeFromEkfProvider extends Provider {
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
const
|
|
86
|
-
|
|
85
|
+
const {
|
|
86
|
+
values: acceleration, timestamp
|
|
87
|
+
} = accelerationEvent.data;
|
|
87
88
|
|
|
88
89
|
// Handle timestamps and dt
|
|
89
90
|
if (this.lastTimestamp === 0) {
|
|
@@ -93,21 +94,20 @@ class RelativeAttitudeFromEkfProvider extends Provider {
|
|
|
93
94
|
const diffTime = timestamp - this.lastTimestamp;
|
|
94
95
|
this.lastTimestamp = timestamp;
|
|
95
96
|
|
|
96
|
-
const quaternion = this.ekfAttitude.update(diffTime, acceleration, this.gyroscopeEvent.data);
|
|
97
|
+
const quaternion = this.ekfAttitude.update(diffTime, acceleration, this.gyroscopeEvent.data.values);
|
|
97
98
|
|
|
98
99
|
if (quaternion) {
|
|
99
100
|
const attitude = new Attitude(quaternion,
|
|
100
101
|
timestamp,
|
|
101
|
-
|
|
102
|
+
RelativeAttitudeFromInertial.DEFAULT_DRIFT,
|
|
102
103
|
this.pname
|
|
103
104
|
);
|
|
104
105
|
this.notify(this.createEvent(
|
|
105
106
|
EventType.RelativeAttitude,
|
|
106
107
|
attitude,
|
|
107
|
-
timestamp,
|
|
108
108
|
[accelerationEvent, this.gyroscopeEvent]));
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
export default
|
|
113
|
+
export default new RelativeAttitudeFromEkf();
|
|
@@ -3,11 +3,11 @@ import { PromiseUtils } from '@wemap/utils';
|
|
|
3
3
|
|
|
4
4
|
import Provider from '../../Provider.js';
|
|
5
5
|
import EventType from '../../../events/EventType.js';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
} from '../../../Providers.js';
|
|
6
|
+
import RelativeAttitudeFromEkf from './RelativeAttitudeFromEkf.js';
|
|
7
|
+
import RelativeAttitudeFromBrowser from './RelativeAttitudeFromBrowser.js';
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
class RelativeAttitudeFromInertial extends Provider {
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* default relative attitude drift in rad.second-1
|
|
@@ -67,4 +67,4 @@ class RelativeAttitudeFromInertialProvider extends Provider {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export default
|
|
70
|
+
export default new RelativeAttitudeFromInertial();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Provider from '../Provider.js';
|
|
2
2
|
import EventType from '../../events/EventType.js';
|
|
3
3
|
import MissingAccelerometerError from '../../errors/MissingAccelerometerError.js';
|
|
4
|
-
import
|
|
4
|
+
import Imu from './Imu.js';
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class Accelerometer extends Provider {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @override
|
|
@@ -58,4 +58,4 @@ class AccelerometerProvider extends Provider {
|
|
|
58
58
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export default
|
|
61
|
+
export default new Accelerometer();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Provider from '../Provider.js';
|
|
2
2
|
import EventType from '../../events/EventType.js';
|
|
3
3
|
import MissingGyroscopeError from '../../errors/MissingGyroscopeError.js';
|
|
4
|
-
import
|
|
4
|
+
import Imu from './Imu.js';
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class Gyroscope extends Provider {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @override
|
|
@@ -58,4 +58,4 @@ class GyroscopeProvider extends Provider {
|
|
|
58
58
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export default
|
|
61
|
+
export default new Gyroscope();
|
|
@@ -22,7 +22,7 @@ import AskImuOnDesktopError from '../../errors/AskImuOnDesktopError.js';
|
|
|
22
22
|
*
|
|
23
23
|
* -----------------------------------
|
|
24
24
|
*/
|
|
25
|
-
class
|
|
25
|
+
class Imu extends Provider {
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @override
|
|
@@ -41,7 +41,7 @@ class ImuProvider extends Provider {
|
|
|
41
41
|
/**
|
|
42
42
|
* @override
|
|
43
43
|
*/
|
|
44
|
-
get _availability() {
|
|
44
|
+
static get _availability() {
|
|
45
45
|
return BrowserUtils.isMobile
|
|
46
46
|
? Promise.resolve()
|
|
47
47
|
: Promise.reject(new AskImuOnDesktopError());
|
|
@@ -105,7 +105,10 @@ class ImuProvider extends Provider {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
if (acc) {
|
|
108
|
-
events.push(this.createEvent(EventType.Acceleration,
|
|
108
|
+
events.push(this.createEvent(EventType.Acceleration, {
|
|
109
|
+
timestamp,
|
|
110
|
+
values: acc
|
|
111
|
+
}));
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
let gyr;
|
|
@@ -120,7 +123,10 @@ class ImuProvider extends Provider {
|
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
if (gyr) {
|
|
123
|
-
events.push(this.createEvent(EventType.AngularRate,
|
|
126
|
+
events.push(this.createEvent(EventType.AngularRate, {
|
|
127
|
+
timestamp,
|
|
128
|
+
values: gyr
|
|
129
|
+
}));
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
if (events.length !== 0) {
|
|
@@ -130,4 +136,4 @@ class ImuProvider extends Provider {
|
|
|
130
136
|
|
|
131
137
|
}
|
|
132
138
|
|
|
133
|
-
export default
|
|
139
|
+
export default new Imu();
|
|
@@ -2,9 +2,8 @@ import { PromiseUtils } from '@wemap/utils';
|
|
|
2
2
|
|
|
3
3
|
import MetaProvider from '../MetaProvider.js';
|
|
4
4
|
import EventType from '../../events/EventType.js';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
} from '../../Providers.js';
|
|
5
|
+
import InclinationFromAcc from './InclinationFromAcc.js';
|
|
6
|
+
import InclinationFromRelativeAttitude from './InclinationFromRelativeAttitude.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Inclination provider gives the inclination of the device using Imu Sensor
|
|
@@ -12,7 +11,7 @@ import {
|
|
|
12
11
|
* when the device is layed on a table, inclination = 0
|
|
13
12
|
* This provider use window.orientation to return a result in function of screen orientation
|
|
14
13
|
*/
|
|
15
|
-
class
|
|
14
|
+
class Inclination extends MetaProvider {
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* @override
|
|
@@ -75,4 +74,4 @@ class InclinationProvider extends MetaProvider {
|
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
export default
|
|
77
|
+
export default new Inclination();
|