@wemap/positioning 2.1.0 → 2.2.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/arcore.html +16 -0
- package/package.json +2 -1
- package/src/components/ArCoreComponent.jsx +74 -0
- package/src/components/GnssWifiComponent.jsx +14 -2
- package/src/components/GnssWifiPdrComponent.jsx +9 -0
- package/src/components/MapComponent.jsx +226 -0
- package/src/components/PdrComponent.jsx +9 -0
- package/src/components/PoseComponent.jsx +7 -0
- package/src/components/PositioningPoseComponent.jsx +9 -0
- package/src/components/Utils.js +18 -0
- package/src/components/index.js +2 -0
- package/src/errors/MissingArCoreError.js +9 -0
- package/src/errors/MissingNativeInterfaceError.js +9 -0
- package/src/providers/Provider.js +15 -3
- package/src/providers/pose/ArCoreProvider.js +127 -0
- package/src/providers/pose/pdr/PdrProvider.js +1 -1
- package/webpack/webpack.common.js +1 -1
- package/src.old/Constants.js +0 -11
- package/src.old/NavigationHandler.js +0 -244
- package/src.old/Pose.js +0 -8
- package/src.old/attitude/AttitudeHandler.js +0 -342
- package/src.old/attitude/EkfAttitude.js +0 -238
- package/src.old/attitude/EkfAttitude.spec.js +0 -116
- package/src.old/components/AbsoluteAttitude.jsx +0 -136
- package/src.old/components/Imu.jsx +0 -89
- package/src.old/components/LocationSource.jsx +0 -434
- package/src.old/components/Logger.jsx +0 -113
- package/src.old/components/NavigationDebugApp.jsx +0 -106
- package/src.old/components/Others.jsx +0 -121
- package/src.old/components/RelativeAttitude.jsx +0 -104
- package/src.old/components/Utils.js +0 -35
- package/src.old/components/index.js +0 -13
- package/src.old/index.js +0 -7
- package/src.old/providers/FixedLocationImuLocationSource.js +0 -66
- package/src.old/providers/GnssLocationSource.js +0 -118
- package/src.old/providers/GnssPdrLocationSource.js +0 -182
- package/src.old/providers/IPLocationSource.js +0 -96
- package/src.old/providers/LocationSource.js +0 -290
- package/src.old/providers/PdrLocationSource.js +0 -320
- package/src.old/providers/ProvidersLogger.js +0 -77
- package/src.old/providers/pdr/HeadingUnlocker.js +0 -41
- package/src.old/providers/pdr/HeadingUnlocker.spec.js +0 -26
- package/src.old/providers/pdr/Smoother.js +0 -90
- package/src.old/providers/pdr/Smoother.spec.js +0 -424
- package/src.old/providers/pdr/ThugDetector.js +0 -37
- package/src.old/providers/steps/StepDetection.js +0 -7
- package/src.old/providers/steps/StepDetectionLadetto.js +0 -67
- package/src.old/providers/steps/StepDetectionMinMaxPeaks.js +0 -80
- package/src.old/providers/steps/StepDetectionMinMaxPeaks2.js +0 -108
- package/src.old/sensors/SensorsCompatibility.js +0 -486
- package/src.old/sensors/SensorsCompatibility.spec.js +0 -270
- package/src.old/sensors/SensorsLogger.js +0 -94
- package/src.old/sensors/SensorsLoggerUtils.js +0 -35
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Attitude } from '@wemap/geo';
|
|
2
|
+
|
|
3
|
+
import Provider from '../Provider';
|
|
4
|
+
import EventType from '../../events/EventType';
|
|
5
|
+
import MissingArCoreError from '../../errors/MissingArCoreError';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pose provider is the provider used by the PositioningHandler. It uses the best fusion
|
|
9
|
+
* of what he can and provides an AbsoluteAttitude and an AbsolutePosition as an output.
|
|
10
|
+
*/
|
|
11
|
+
class ArCoreProvider extends Provider {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @override
|
|
15
|
+
*/
|
|
16
|
+
constructor(onEvent, onError, options) {
|
|
17
|
+
super(onEvent, onError, options);
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @override
|
|
23
|
+
*/
|
|
24
|
+
static get displayName() {
|
|
25
|
+
return 'ArCore provider';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @override
|
|
30
|
+
*/
|
|
31
|
+
static get eventsType() {
|
|
32
|
+
return [EventType.RelativeAttitude, EventType.RelativePosition];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Return the list of required providers
|
|
37
|
+
*/
|
|
38
|
+
static get requiredProviders() {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @override
|
|
44
|
+
*/
|
|
45
|
+
startInternal() {
|
|
46
|
+
const nativeProvider = this.constructor.getNativeProvider();
|
|
47
|
+
if (Array.isArray(nativeProvider)) {
|
|
48
|
+
this.notifyError(nativeProvider);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
nativeProvider.start();
|
|
52
|
+
|
|
53
|
+
this.pullDataLoop();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @override
|
|
58
|
+
*/
|
|
59
|
+
stopInternal() {
|
|
60
|
+
const nativeProvider = this.constructor.getNativeProvider();
|
|
61
|
+
if (Array.isArray(nativeProvider)) {
|
|
62
|
+
this.notifyError(nativeProvider);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
nativeProvider.stop();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
pullDataLoop = () => {
|
|
69
|
+
|
|
70
|
+
if (this.state !== Provider.State.STARTED) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const nativeProvider = this.constructor.getNativeProvider();
|
|
75
|
+
if (Array.isArray(nativeProvider)) {
|
|
76
|
+
this.notifyError(...nativeProvider);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const pose = JSON.parse(nativeProvider.getInfo());
|
|
81
|
+
if (pose.length !== 0) {
|
|
82
|
+
const attitude = new Attitude(pose.slice(0, 4));
|
|
83
|
+
const position = pose.slice(4, 7);
|
|
84
|
+
this.notify(
|
|
85
|
+
this.createEvent(EventType.RelativeAttitude, attitude),
|
|
86
|
+
this.createEvent(EventType.RelativePosition, position)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
requestAnimationFrame(this.pullDataLoop);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static getNativeProvider() {
|
|
94
|
+
const nativeInterface = this.getNativeInterface();
|
|
95
|
+
|
|
96
|
+
if (!nativeInterface) {
|
|
97
|
+
return [
|
|
98
|
+
this.createMissingNativeInterfaceError(EventType.RelativeAttitude),
|
|
99
|
+
this.createMissingNativeInterfaceError(EventType.RelativePosition)
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return nativeInterface.getArCoreProvider();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @override
|
|
108
|
+
*/
|
|
109
|
+
static checkAvailabilityErrors() {
|
|
110
|
+
|
|
111
|
+
const nativeProvider = this.getNativeProvider();
|
|
112
|
+
if (Array.isArray(nativeProvider)) {
|
|
113
|
+
return nativeProvider;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (nativeProvider.checkAvailability()) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return [
|
|
121
|
+
this.createError(EventType.RelativeAttitude, new MissingArCoreError()),
|
|
122
|
+
this.createError(EventType.RelativePosition, new MissingArCoreError())
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default ArCoreProvider;
|
package/src.old/Constants.js
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash.noop';
|
|
2
|
-
|
|
3
|
-
import { WGS84UserPosition, Itinerary } from '@wemap/geo';
|
|
4
|
-
|
|
5
|
-
import LocationSource from './providers/LocationSource';
|
|
6
|
-
import IPLocationSource from './providers/IPLocationSource';
|
|
7
|
-
import GnssLocationSource from './providers/GnssLocationSource';
|
|
8
|
-
import PdrLocationSource from './providers/PdrLocationSource';
|
|
9
|
-
import GnssPdrLocationSource from './providers/GnssPdrLocationSource';
|
|
10
|
-
import FixedLocationImuLocationSource from './providers/FixedLocationImuLocationSource';
|
|
11
|
-
import SensorsLogger from './sensors/SensorsLogger';
|
|
12
|
-
|
|
13
|
-
const DEFAULT_ALTITUDE = 1.6;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @private
|
|
17
|
-
*/
|
|
18
|
-
class NavigationHandler {
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Constructor of NavigationHandler
|
|
22
|
-
* @param {Function} callbackOnStart callback when navigation starts
|
|
23
|
-
* @param {Function} callbackOnStop callback when navigation stops
|
|
24
|
-
* @param {Function} callbackOnNewPose callback on new pose
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
constructor(callbackOnStart, callbackOnStop, callbackOnNewPose) {
|
|
28
|
-
this.callback = this.callback.bind(this);
|
|
29
|
-
|
|
30
|
-
this.callbackOnStart = callbackOnStart || noop;
|
|
31
|
-
this.callbackOnStop = callbackOnStop || noop;
|
|
32
|
-
this.callbackOnNewPose = callbackOnNewPose || noop;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Starts navigation from an initial position an initial heading
|
|
38
|
-
* @param {*} initialPosition initial position {lat: xx, lng: xx}
|
|
39
|
-
* @param {Number} initialHeading initial heading in radians and clockwise: north: 0, east = PI/2
|
|
40
|
-
* @param {Array} path an optional itinerary (list of 2D points [lng, lat])
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
startRelative(initialPosition, initialHeading, path = null) {
|
|
44
|
-
|
|
45
|
-
const initialPositionWgs84 = new WGS84UserPosition(
|
|
46
|
-
initialPosition.lat,
|
|
47
|
-
initialPosition.lng,
|
|
48
|
-
initialPosition.alt || DEFAULT_ALTITUDE
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
// stop current location source if already started
|
|
52
|
-
if (this.locationSource) {
|
|
53
|
-
this.locationSource.stop();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this.locationSource = new PdrLocationSource(this.callback, {
|
|
57
|
-
'stepdetectionlocker': true,
|
|
58
|
-
'smoother': true
|
|
59
|
-
});
|
|
60
|
-
this.locationSource.setLogger(this.logger);
|
|
61
|
-
|
|
62
|
-
if (path) {
|
|
63
|
-
const itinerary = Itinerary.fromPoints(path);
|
|
64
|
-
this.locationSource.enableMapMatching(itinerary);
|
|
65
|
-
this.locationSource.setItinerary(itinerary);
|
|
66
|
-
}
|
|
67
|
-
this.locationSource.setLocation(initialPositionWgs84);
|
|
68
|
-
this.locationSource.setHeading(initialHeading);
|
|
69
|
-
const promise = this.locationSource.start();
|
|
70
|
-
|
|
71
|
-
this.callbackOnStart();
|
|
72
|
-
return promise;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Starts navigation handler without any knowledge on starting point
|
|
77
|
-
* @param {Array} path an optional itinerary (list of 2D points [lng, lat])
|
|
78
|
-
* @public
|
|
79
|
-
*/
|
|
80
|
-
startAbsolute(path) {
|
|
81
|
-
// stop if already started
|
|
82
|
-
if (this.locationSource) {
|
|
83
|
-
this.locationSource.stop();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const itinerary = Itinerary.fromPoints(path);
|
|
87
|
-
this.locationSource = new GnssPdrLocationSource(this.callback);
|
|
88
|
-
this.locationSource.enableMapMatching(itinerary);
|
|
89
|
-
this.locationSource.setItinerary(itinerary);
|
|
90
|
-
this.locationSource.setLogger(this.logger);
|
|
91
|
-
|
|
92
|
-
const promise = this.locationSource.start();
|
|
93
|
-
this.callbackOnStart();
|
|
94
|
-
return promise;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
locateme(
|
|
98
|
-
options = {
|
|
99
|
-
ip: true,
|
|
100
|
-
browser: true,
|
|
101
|
-
attitude: true
|
|
102
|
-
}
|
|
103
|
-
) {
|
|
104
|
-
const useIPProvider = !options.hasOwnProperty('ip') || options.ip === true;
|
|
105
|
-
const useBrowserProvider = !options.hasOwnProperty('browser') || options.browser === true;
|
|
106
|
-
const useImu = !options.hasOwnProperty('attitude') || options.attitude === true;
|
|
107
|
-
|
|
108
|
-
return new Promise((resolve, reject) => {
|
|
109
|
-
const gnss = new GnssLocationSource(pose => {
|
|
110
|
-
resolve(pose);
|
|
111
|
-
this.callback(pose);
|
|
112
|
-
}, useImu);
|
|
113
|
-
|
|
114
|
-
const ip = new IPLocationSource(pose => {
|
|
115
|
-
resolve(pose);
|
|
116
|
-
this.callback(pose);
|
|
117
|
-
}, useImu);
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
this.locationSource
|
|
121
|
-
&& LocationSource.getMostAccurateLocationSource(this.locationSource, gnss) === this.locationSource
|
|
122
|
-
) {
|
|
123
|
-
resolve(this.locationSource.getPose());
|
|
124
|
-
} else {
|
|
125
|
-
if (this.locationSource) {
|
|
126
|
-
this.locationSource.stop();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (useBrowserProvider) {
|
|
130
|
-
this.locationSource = gnss;
|
|
131
|
-
gnss.start().catch(e => {
|
|
132
|
-
if (useIPProvider) {
|
|
133
|
-
this.locationSource = ip;
|
|
134
|
-
ip.start();
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
reject(e);
|
|
138
|
-
});
|
|
139
|
-
} else if (useIPProvider) {
|
|
140
|
-
this.locationSource = ip;
|
|
141
|
-
ip.start();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Stop relative, absolute or locateme navigation if started
|
|
150
|
-
* @public
|
|
151
|
-
*/
|
|
152
|
-
stop() {
|
|
153
|
-
if (
|
|
154
|
-
this.locationSource
|
|
155
|
-
) {
|
|
156
|
-
this.locationSource.stop();
|
|
157
|
-
this.locationSource = null;
|
|
158
|
-
}
|
|
159
|
-
this.callbackOnStop();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @see LocationSource#getProjectionOnNetwork()
|
|
165
|
-
* @public
|
|
166
|
-
*/
|
|
167
|
-
getProjectionOnNetwork(location) {
|
|
168
|
-
return this.locationSource.getProjectionOnNetwork(location);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @see LocationSource#getItineraryInfo()
|
|
173
|
-
* @public
|
|
174
|
-
*/
|
|
175
|
-
getItineraryInfo(location) {
|
|
176
|
-
return this.locationSource.getItineraryInfo(location);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
forceUserLocation(location) {
|
|
180
|
-
if (
|
|
181
|
-
this.locationSource
|
|
182
|
-
&& (!(this.locationSource instanceof FixedLocationImuLocationSource) || !location)
|
|
183
|
-
) {
|
|
184
|
-
this.locationSource.stop();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (location) {
|
|
188
|
-
if (
|
|
189
|
-
!this.locationSource
|
|
190
|
-
|| !(this.locationSource instanceof FixedLocationImuLocationSource)
|
|
191
|
-
) {
|
|
192
|
-
this.locationSource = new FixedLocationImuLocationSource(this.callback);
|
|
193
|
-
this.locationSource.start(location);
|
|
194
|
-
} else {
|
|
195
|
-
this.locationSource.setLocation(location);
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
this.locationSource = null;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* @private
|
|
204
|
-
*/
|
|
205
|
-
callback(pose) {
|
|
206
|
-
this.callbackOnNewPose(pose);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Assign a SensorsLogger to LocationSource and start recording.
|
|
211
|
-
* This logger will be fed with sensors output.
|
|
212
|
-
* Logger is not working on locateme()
|
|
213
|
-
* @param {SensorsLogger} logger An instance of SensorsLogger.
|
|
214
|
-
* @public
|
|
215
|
-
*/
|
|
216
|
-
startLogger(logger) {
|
|
217
|
-
if (!(logger instanceof SensorsLogger)) {
|
|
218
|
-
throw new Error('logger is not an instance of SensorsLogger');
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
this.logger = logger;
|
|
222
|
-
|
|
223
|
-
if (this.locationSource) {
|
|
224
|
-
this.locationSource.setLogger(this.logger);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Stop recording sensors
|
|
230
|
-
* @public
|
|
231
|
-
*/
|
|
232
|
-
stopLogger() {
|
|
233
|
-
this.logger = null;
|
|
234
|
-
if (this.locationSource) {
|
|
235
|
-
this.locationSource.setLogger(this.logger);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
static get DEFAULT_ALTITUDE() {
|
|
240
|
-
return DEFAULT_ALTITUDE;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export default NavigationHandler;
|