@wemap/providers 4.0.1 → 4.0.3
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/dist/index.html +1 -0
- package/debug/dist/turn-detection.html +19 -0
- package/debug/index.js +2 -0
- package/debug/src/AbsoluteAttitudeComponent.jsx +0 -10
- package/debug/src/StepDetectionComponent.jsx +3 -3
- package/debug/src/TurnDetectionComponent.jsx +47 -0
- package/debug/src/Utils.js +20 -0
- package/package.json +7 -9
- package/src/Providers.js +5 -4
- package/src/ProvidersInterface.js +5 -6
- package/src/events/EventType.js +5 -1
- package/src/events/ProviderEvent.js +7 -0
- package/src/mapmatching/MapMatchingHandler.js +332 -54
- package/src/providers/Provider.js +42 -8
- package/src/providers/Provider.spec.js +3 -4
- package/src/providers/attitude/TurnDectector.js +71 -0
- package/src/providers/attitude/absolute/AbsoluteAttitude.js +123 -65
- package/src/providers/attitude/relative/RelativeAttitude.js +1 -3
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowser.js +1 -2
- package/src/providers/attitude/relative/RelativeAttitudeFromEkf.js +1 -2
- package/src/providers/attitude/relative/RelativeAttitudeFromInertial.js +19 -2
- package/src/providers/imu/HighRotationsDetector.js +62 -0
- package/src/providers/inclination/Inclination.js +2 -2
- package/src/providers/others/CameraNative.js +2 -2
- package/src/providers/others/CameraProjectionMatrix.js +2 -2
- package/src/providers/position/absolute/AbsolutePosition.js +112 -82
- package/src/providers/position/relative/GeoRelativePosition.js +2 -2
- package/src/providers/position/relative/Pdr.js +4 -4
- package/src/providers/steps/{StepDetection.js → StepDetector.js} +4 -4
- package/src/providers/steps/StraightLineDetector.js +80 -0
- package/src/smoothers/AttitudeSmoother.js +94 -59
- package/src/providers/MetaProvider.js +0 -44
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromRelAtt.js +0 -133
- package/src/providers/attitude/absolute/AbsoluteAttitudeFused.js +0 -166
- package/src/providers/position/absolute/AbsolutePositionFromRel.js +0 -106
package/debug/dist/index.html
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<a href="./absolute-attitude.html">Absolute Attitude</a><br />
|
|
15
15
|
<a href="./gnss-wifi.html">GNSS-Wifi</a><br />
|
|
16
16
|
<a href="./step-detection.html">Step Detection</a><br />
|
|
17
|
+
<a href="./turn-detection.html">Turn Detection</a><br />
|
|
17
18
|
<a href="./absolute-position.html">Absolute Position</a>
|
|
18
19
|
</body>
|
|
19
20
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, user-scalable=no">
|
|
7
|
+
<title>Debug Step Detection</title>
|
|
8
|
+
<script src="/js/providers-lib.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>
|
|
14
|
+
/* global createReactElement, TurnDetectionComponent */
|
|
15
|
+
createReactElement(TurnDetectionComponent, document.getElementById('app'));
|
|
16
|
+
</script>
|
|
17
|
+
</body>
|
|
18
|
+
|
|
19
|
+
</html>
|
package/debug/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import ImuComponent from './src/ImuComponent.jsx';
|
|
|
8
8
|
import InclinationComponent from './src/InclinationComponent.jsx';
|
|
9
9
|
import RelativeAttitudeComponent from './src/RelativeAttitudeComponent.jsx';
|
|
10
10
|
import StepDetectionComponent from './src/StepDetectionComponent.jsx';
|
|
11
|
+
import TurnDetectionComponent from './src/TurnDetectionComponent.jsx';
|
|
11
12
|
|
|
12
13
|
const createReactElement = (component, container) => ReactDOM.render(
|
|
13
14
|
React.createElement(component, {}, null),
|
|
@@ -22,5 +23,6 @@ export {
|
|
|
22
23
|
GnssWifiComponent,
|
|
23
24
|
RelativeAttitudeComponent,
|
|
24
25
|
StepDetectionComponent,
|
|
26
|
+
TurnDetectionComponent,
|
|
25
27
|
createReactElement
|
|
26
28
|
};
|
|
@@ -9,7 +9,6 @@ import { TimeUtils } from '@wemap/utils';
|
|
|
9
9
|
import ProvidersLoggerOld from '../../src/events/ProvidersLoggerOld.js';
|
|
10
10
|
import {
|
|
11
11
|
AbsoluteAttitudeFromBrowser,
|
|
12
|
-
AbsoluteAttitudeFromRelAtt,
|
|
13
12
|
AbsoluteAttitude,
|
|
14
13
|
AbsolutePosition
|
|
15
14
|
} from '../../src/Providers.js';
|
|
@@ -26,7 +25,6 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
26
25
|
|
|
27
26
|
this.state = {
|
|
28
27
|
attitude: null,
|
|
29
|
-
attitudeFromRelAtt: null,
|
|
30
28
|
attitudeFromBrowser: null,
|
|
31
29
|
deviceorientation: null,
|
|
32
30
|
deviceorientationabsolute: null
|
|
@@ -46,11 +44,6 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
46
44
|
error => this.setState({ attitudeFromBrowser: error })
|
|
47
45
|
);
|
|
48
46
|
|
|
49
|
-
this.providerFromRelAttId = AbsoluteAttitudeFromRelAtt.addEventListener(
|
|
50
|
-
events => this.setState({ attitudeFromRelAtt: events[0] }),
|
|
51
|
-
error => this.setState({ attitudeFromRelAtt: error })
|
|
52
|
-
);
|
|
53
|
-
|
|
54
47
|
this.providerId = AbsoluteAttitude.addEventListener(
|
|
55
48
|
events => this.setState({ attitude: events[0] }),
|
|
56
49
|
error => this.setState({ attitude: error })
|
|
@@ -67,7 +60,6 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
67
60
|
stop() {
|
|
68
61
|
this.isStarted = false;
|
|
69
62
|
AbsoluteAttitudeFromBrowser.removeEventListener(this.providerFromBrowserId);
|
|
70
|
-
AbsoluteAttitudeFromRelAtt.removeEventListener(this.providerFromRelAttId);
|
|
71
63
|
AbsoluteAttitude.removeEventListener(this.providerId);
|
|
72
64
|
window.removeEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
|
|
73
65
|
window.removeEventListener('deviceorientationabsolute', this.onDeviceOrientationAbsoluteEventListener, true);
|
|
@@ -158,8 +150,6 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
158
150
|
{rawRender}
|
|
159
151
|
<h3>Absolute attitude:</h3>
|
|
160
152
|
{Utils.renderAttitudeEvent(this.state.attitude)}
|
|
161
|
-
<h3>Absolute attitude From relative + offset:</h3>
|
|
162
|
-
{Utils.renderAttitudeEvent(this.state.attitudeFromRelAtt)}
|
|
163
153
|
<h3>Absolute attitude From browser:</h3>
|
|
164
154
|
{Utils.renderAttitudeEvent(this.state.attitudeFromBrowser)}
|
|
165
155
|
</div>
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import Utils from './Utils.js';
|
|
4
4
|
import ProvidersLoggerOld from '../../src/events/ProvidersLoggerOld.js';
|
|
5
|
-
import {
|
|
5
|
+
import { StepDetector } from '../../src/Providers.js';
|
|
6
6
|
|
|
7
7
|
ProvidersLoggerOld.enabled = true;
|
|
8
8
|
|
|
@@ -15,14 +15,14 @@ class StepDetectionComponent extends React.Component {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
componentDidMount() {
|
|
18
|
-
this.providerId =
|
|
18
|
+
this.providerId = StepDetector.addEventListener(
|
|
19
19
|
events => this.setState({ stepDetected: events[0] }),
|
|
20
20
|
error => this.setState({ stepDetected: error })
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
componentWillUnmount() {
|
|
25
|
-
|
|
25
|
+
StepDetector.removeEventListener(this.providerId);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
render() {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Utils from './Utils.js';
|
|
4
|
+
import ProvidersLoggerOld from '../../src/events/ProvidersLoggerOld.js';
|
|
5
|
+
import { TurnDetector, HighRotationsDetector } from '../../src/Providers.js';
|
|
6
|
+
|
|
7
|
+
ProvidersLoggerOld.enabled = true;
|
|
8
|
+
|
|
9
|
+
class TurnDetectionComponent extends React.Component {
|
|
10
|
+
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
|
|
14
|
+
this.state = { turnDetected: 0, highRotationsDetected: 0 };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
this.turnDetectorId = TurnDetector.addEventListener(
|
|
19
|
+
() => this.setState(({ turnDetected }) => ({ turnDetected: turnDetected + 1 })),
|
|
20
|
+
error => this.setState({ turnDetected: error })
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
this.highRotationsDetectorId = HighRotationsDetector.addEventListener(
|
|
24
|
+
() => this.setState(({ highRotationsDetected }) => ({ highRotationsDetected: highRotationsDetected + 1 })),
|
|
25
|
+
error => this.setState({ highRotationsDetected: error })
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
componentWillUnmount() {
|
|
30
|
+
TurnDetector.removeEventListener(this.turnDetectorId);
|
|
31
|
+
HighRotationsDetector.removeEventListener(this.highRotationsDetectorId);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render() {
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
<h3>Turn detected</h3>
|
|
38
|
+
{Utils.renderTurnEvent(this.state.turnDetected)}
|
|
39
|
+
<h3>High rotation detected</h3>
|
|
40
|
+
{Utils.renderTurnEvent(this.state.highRotationsDetected)}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default TurnDetectionComponent;
|
package/debug/src/Utils.js
CHANGED
|
@@ -189,6 +189,26 @@ class Utils {
|
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @param {number|Error} event
|
|
194
|
+
*/
|
|
195
|
+
static renderTurnEvent(event) {
|
|
196
|
+
if (event === null) {
|
|
197
|
+
return 'Waiting';
|
|
198
|
+
}
|
|
199
|
+
if (event instanceof Error) {
|
|
200
|
+
return Utils.renderError(event);
|
|
201
|
+
}
|
|
202
|
+
return (
|
|
203
|
+
<div>
|
|
204
|
+
<pre style={{ margin: 0 }}>
|
|
205
|
+
Number: {event}
|
|
206
|
+
</pre>
|
|
207
|
+
{/* {Utils.renderFromStack(event)} */}
|
|
208
|
+
</div>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
192
212
|
static renderError(error) {
|
|
193
213
|
return (<div style={{ maxWidth: '180px' }}><strong>[{error.constructor.name}]</strong><br />{error.message}</div>);
|
|
194
214
|
}
|
package/package.json
CHANGED
|
@@ -8,18 +8,16 @@
|
|
|
8
8
|
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@wemap/geo": "^4.0.
|
|
11
|
+
"@wemap/geo": "^4.0.3",
|
|
12
12
|
"@wemap/geomagnetism": "^0.1.1",
|
|
13
13
|
"@wemap/logger": "^4.0.0",
|
|
14
|
-
"@wemap/map": "^4.0.
|
|
15
|
-
"@wemap/maths": "^4.0.
|
|
16
|
-
"@wemap/utils": "^4.0.0"
|
|
17
|
-
"lodash.isempty": "^4.4.0",
|
|
18
|
-
"lodash.noop": "^3.0.1"
|
|
14
|
+
"@wemap/map": "^4.0.3",
|
|
15
|
+
"@wemap/maths": "^4.0.3",
|
|
16
|
+
"@wemap/utils": "^4.0.0"
|
|
19
17
|
},
|
|
20
18
|
"description": "A package using different geoloc systems",
|
|
21
19
|
"devDependencies": {
|
|
22
|
-
"@wemap/osm": "^4.0.
|
|
20
|
+
"@wemap/osm": "^4.0.3",
|
|
23
21
|
"mapbox-gl": "^1.11.1"
|
|
24
22
|
},
|
|
25
23
|
"homepage": "https://github.com/wemap/wemap-modules-js#readme",
|
|
@@ -41,6 +39,6 @@
|
|
|
41
39
|
"url": "git+https://github.com/wemap/wemap-modules-js.git"
|
|
42
40
|
},
|
|
43
41
|
"type": "module",
|
|
44
|
-
"version": "4.0.
|
|
45
|
-
"gitHead": "
|
|
42
|
+
"version": "4.0.3",
|
|
43
|
+
"gitHead": "91a82028ddda32038999582da381d1d0d8acd091"
|
|
46
44
|
}
|
package/src/Providers.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export { default as Imu } from './providers/imu/Imu.js';
|
|
4
4
|
export { default as Accelerometer } from './providers/imu/Accelerometer.js';
|
|
5
5
|
export { default as Gyroscope } from './providers/imu/Gyroscope.js';
|
|
6
|
+
export { default as HighRotationsDetector } from './providers/imu/HighRotationsDetector.js';
|
|
6
7
|
|
|
7
8
|
export { default as RelativeAttitudeFromBrowser } from './providers/attitude/relative/RelativeAttitudeFromBrowser.js';
|
|
8
9
|
export { default as RelativeAttitudeFromEkf } from './providers/attitude/relative/RelativeAttitudeFromEkf.js';
|
|
@@ -10,22 +11,22 @@ export { default as RelativeAttitudeFromInertial } from './providers/attitude/re
|
|
|
10
11
|
export { default as RelativeAttitude } from './providers/attitude/relative/RelativeAttitude.js';
|
|
11
12
|
|
|
12
13
|
export { default as AbsoluteAttitudeFromBrowser } from './providers/attitude/absolute/AbsoluteAttitudeFromBrowser.js';
|
|
13
|
-
export { default as AbsoluteAttitudeFromRelAtt } from './providers/attitude/absolute/AbsoluteAttitudeFromRelAtt.js';
|
|
14
|
-
export { default as AbsoluteAttitudeFused } from './providers/attitude/absolute/AbsoluteAttitudeFused.js';
|
|
15
14
|
export { default as AbsoluteAttitude } from './providers/attitude/absolute/AbsoluteAttitude.js';
|
|
16
15
|
|
|
16
|
+
export { default as TurnDetector } from './providers/attitude/TurnDectector.js';
|
|
17
|
+
|
|
17
18
|
export { default as InclinationFromAcc } from './providers/inclination/InclinationFromAcc.js';
|
|
18
19
|
export { default as InclinationFromRelativeAttitude } from './providers/inclination/InclinationFromRelativeAttitude.js';
|
|
19
20
|
export { default as Inclination } from './providers/inclination/Inclination.js';
|
|
20
21
|
|
|
21
|
-
export { default as
|
|
22
|
+
export { default as StepDetector } from './providers/steps/StepDetector.js';
|
|
23
|
+
export { default as StraightLineDetector } from './providers/steps/StraightLineDetector.js';
|
|
22
24
|
|
|
23
25
|
export { default as ArCore } from './providers/position/relative/ArCore.js';
|
|
24
26
|
export { default as Pdr } from './providers/position/relative/Pdr.js';
|
|
25
27
|
export { default as GeoRelativePositionFromArCore } from './providers/position/relative/GeoRelativePositionFromArCore.js';
|
|
26
28
|
export { default as GeoRelativePosition } from './providers/position/relative/GeoRelativePosition.js';
|
|
27
29
|
|
|
28
|
-
export { default as AbsolutePositionFromRel } from './providers/position/absolute/AbsolutePositionFromRel.js';
|
|
29
30
|
export { default as GnssWifi } from './providers/position/absolute/GnssWifi.js';
|
|
30
31
|
export { default as Ip } from './providers/position/absolute/Ip.js';
|
|
31
32
|
export { default as AbsolutePosition } from './providers/position/absolute/AbsolutePosition.js';
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
} from '@wemap/geo';
|
|
5
5
|
|
|
6
6
|
import EventType from './events/EventType.js';
|
|
7
|
-
import MetaProvider from './providers/MetaProvider.js';
|
|
8
7
|
import {
|
|
9
8
|
AbsoluteAttitude, AbsolutePosition, Barcode, CameraNative, CameraProjectionMatrix, Inclination, RelativeAttitude
|
|
10
9
|
} from './Providers.js';
|
|
@@ -23,7 +22,7 @@ class ProvidersInterface {
|
|
|
23
22
|
* @returns {Number}
|
|
24
23
|
*/
|
|
25
24
|
static addEventListener(eventType, onEvent, onError, watchOnly = false) {
|
|
26
|
-
const provider = this.
|
|
25
|
+
const provider = this._getProviderFromEventType(eventType);
|
|
27
26
|
const id = provider.addEventListener(events => onEvent(events[0].data), onError, !watchOnly);
|
|
28
27
|
this.idListeners.set(id, provider);
|
|
29
28
|
return id;
|
|
@@ -52,22 +51,22 @@ class ProvidersInterface {
|
|
|
52
51
|
MapMatchingHandler.network = data;
|
|
53
52
|
return;
|
|
54
53
|
}
|
|
55
|
-
this.
|
|
54
|
+
this._getProviderFromEventType(eventType).feed(data, eventType);
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
/**
|
|
59
58
|
* @param {EventType} eventType
|
|
60
59
|
*/
|
|
61
60
|
static getLastKnown(eventType) {
|
|
62
|
-
const { lastEvent } = this.
|
|
61
|
+
const { lastEvent } = this._getProviderFromEventType(eventType);
|
|
63
62
|
return lastEvent ? lastEvent.data : null;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
66
|
* @param {EventType} eventType
|
|
68
|
-
* @returns {
|
|
67
|
+
* @returns {Provider}
|
|
69
68
|
*/
|
|
70
|
-
static
|
|
69
|
+
static _getProviderFromEventType(eventType) {
|
|
71
70
|
|
|
72
71
|
switch (eventType) {
|
|
73
72
|
case EventType.AbsoluteAttitude:
|
package/src/events/EventType.js
CHANGED
|
@@ -8,18 +8,22 @@ export default {
|
|
|
8
8
|
AngularRate: 'ANGULAR_RATE',
|
|
9
9
|
Acceleration: 'ACCELERATION',
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
RelativeAttitude: 'RELATIVE_ATTITUDE',
|
|
13
12
|
AbsoluteAttitude: 'ABSOLUTE_ATTITUDE',
|
|
14
13
|
Attitude: 'ATTITUDE',
|
|
15
14
|
|
|
16
15
|
Inclination: 'INCLINATION',
|
|
17
16
|
AbsoluteHeading: 'ABSOLUTE_HEADING',
|
|
17
|
+
Turn: 'TURN',
|
|
18
|
+
HighRotation: 'HIGH_ROTATION',
|
|
18
19
|
|
|
19
20
|
RelativePosition: 'RELATIVE_POSITION',
|
|
20
21
|
GeoRelativePosition: 'GEO_RELATIVE_POSITION',
|
|
21
22
|
AbsolutePosition: 'ABSOLUTE_POSITION',
|
|
22
23
|
|
|
24
|
+
Step: 'STEP',
|
|
25
|
+
StraightLine: 'STRAIGHT_LINE',
|
|
26
|
+
|
|
23
27
|
Pressure: 'PRESSURE',
|
|
24
28
|
BluetoothSignals: 'BLUETOOTH_SIGNALS',
|
|
25
29
|
WifiSignals: 'WIFI_SIGNALS',
|
|
@@ -3,11 +3,15 @@ import EventType from './EventType.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* A provider event is an event which can be triggered by device sensors
|
|
5
5
|
* or can be computed from raw providers.
|
|
6
|
+
*
|
|
7
|
+
* @template T
|
|
6
8
|
*/
|
|
7
9
|
class ProviderEvent {
|
|
8
10
|
|
|
9
11
|
dataType = EventType.Unknown;
|
|
10
12
|
providersStack = [];
|
|
13
|
+
|
|
14
|
+
/** @type {T} */
|
|
11
15
|
data = null;
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -20,6 +24,9 @@ class ProviderEvent {
|
|
|
20
24
|
this.data = data;
|
|
21
25
|
}
|
|
22
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @return {ProviderEvent<T>}
|
|
29
|
+
*/
|
|
23
30
|
clone() {
|
|
24
31
|
const evt = new ProviderEvent(this.dataType, this.data);
|
|
25
32
|
evt.providersStack = this.providersStack.slice(0);
|