@wemap/providers 3.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/babel.config.js +11 -0
- package/config.json +4 -0
- package/debug/absolute-attitude.html +16 -0
- package/debug/absolute-position.html +16 -0
- package/debug/attitude.html +16 -0
- package/debug/components/AbsoluteAttitudeComponent.jsx +142 -0
- package/debug/components/AbsolutePositionComponent.jsx +79 -0
- package/debug/components/AttitudeComponent.jsx +40 -0
- package/debug/components/Common.css +27 -0
- package/debug/components/GnssWifiComponent.jsx +53 -0
- package/debug/components/ImuComponent.jsx +53 -0
- package/debug/components/InclinationComponent.jsx +68 -0
- package/debug/components/MapComponent.jsx +366 -0
- package/debug/components/NavigationConfig.js +112 -0
- package/debug/components/PoseComponent.jsx +168 -0
- package/debug/components/RelativeAttitudeComponent.jsx +85 -0
- package/debug/components/StartStopComponent.jsx +45 -0
- package/debug/components/StepDetectionComponent.jsx +39 -0
- package/debug/components/Utils.js +216 -0
- package/debug/components/index.js +30 -0
- package/debug/components/old/PositioningComponent.jsx +29 -0
- package/debug/components/old/PositioningInclinationComponent.jsx +82 -0
- package/debug/components/old/PositioningPoseComponent.jsx +117 -0
- package/debug/gnss-wifi.html +16 -0
- package/debug/imu.html +16 -0
- package/debug/inclination.html +16 -0
- package/debug/pose.html +16 -0
- package/debug/positioning-legacy.html +16 -0
- package/debug/relative-attitude.html +16 -0
- package/debug/step-detection.html +16 -0
- package/index.js +7 -0
- package/package.json +67 -0
- package/src/Providers.js +80 -0
- package/src/ProvidersInterface.js +125 -0
- package/src/ProvidersOptions.js +29 -0
- package/src/errors/AskImuOnDesktopError.js +9 -0
- package/src/errors/ContainsIgnoredProviderError.js +9 -0
- package/src/errors/GeolocationApiMissingError.js +9 -0
- package/src/errors/GeolocationPermissionDeniedError.js +9 -0
- package/src/errors/GeolocationPositionUnavailableError.js +9 -0
- package/src/errors/IpResolveServerError.js +9 -0
- package/src/errors/MissingAccelerometerError.js +11 -0
- package/src/errors/MissingArCoreError.js +9 -0
- package/src/errors/MissingGyroscopeError.js +11 -0
- package/src/errors/MissingMagnetometerError.js +9 -0
- package/src/errors/MissingNativeInterfaceError.js +9 -0
- package/src/errors/MissingSensorError.js +14 -0
- package/src/errors/NoProviderFoundError.js +9 -0
- package/src/events/Availability.js +44 -0
- package/src/events/EventType.js +33 -0
- package/src/events/ProviderEvent.js +32 -0
- package/src/events/ProvidersLogger.js +83 -0
- package/src/providers/Constants.js +5 -0
- package/src/providers/FakeProvider.spec.js +57 -0
- package/src/providers/MetaProvider.js +42 -0
- package/src/providers/Provider.js +314 -0
- package/src/providers/Provider.spec.js +136 -0
- package/src/providers/ProviderState.js +5 -0
- package/src/providers/attitude/AttitudeProvider.js +63 -0
- package/src/providers/attitude/EkfAttitude.js +224 -0
- package/src/providers/attitude/EkfAttitude.spec.js +114 -0
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +224 -0
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js +134 -0
- package/src/providers/attitude/absolute/AbsoluteAttitudeProvider.js +143 -0
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +89 -0
- package/src/providers/attitude/relative/RelativeAttitudeFromEkfProvider.js +114 -0
- package/src/providers/attitude/relative/RelativeAttitudeProvider.js +103 -0
- package/src/providers/imu/AccelerometerProvider.js +61 -0
- package/src/providers/imu/GyroscopeProvider.js +61 -0
- package/src/providers/imu/ImuProvider.js +122 -0
- package/src/providers/inclination/InclinationFromAccProvider.js +87 -0
- package/src/providers/inclination/InclinationFromAttitudeProvider.js +77 -0
- package/src/providers/inclination/InclinationProvider.js +69 -0
- package/src/providers/legacy/AbsolutePdrProvider.js +258 -0
- package/src/providers/legacy/ArCoreAbsoluteProvider.js +230 -0
- package/src/providers/legacy/GnssWifiPdrProvider.js +217 -0
- package/src/providers/legacy/MapMatchingProvider.js +65 -0
- package/src/providers/legacy/PdrProvider.old.js +300 -0
- package/src/providers/legacy/PoseProvider.js +68 -0
- package/src/providers/legacy/helpers/HeadingUnlocker.js +47 -0
- package/src/providers/legacy/helpers/HeadingUnlocker.spec.js +53 -0
- package/src/providers/legacy/helpers/Smoother.js +92 -0
- package/src/providers/legacy/helpers/Smoother.spec.js +426 -0
- package/src/providers/legacy/helpers/ThugDetector.js +37 -0
- package/src/providers/others/CameraNativeProvider.js +44 -0
- package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +109 -0
- package/src/providers/position/absolute/AbsolutePositionProvider.js +172 -0
- package/src/providers/position/absolute/GnssWifiProvider.js +122 -0
- package/src/providers/position/absolute/IpProvider.js +68 -0
- package/src/providers/position/relative/ArCoreProvider.js +197 -0
- package/src/providers/position/relative/GeoRelativePositionFromArCoreProvider.js +85 -0
- package/src/providers/position/relative/GeoRelativePositionProvider.js +66 -0
- package/src/providers/position/relative/PdrProvider.js +132 -0
- package/src/providers/steps/StepDetectionLadetto.js +67 -0
- package/src/providers/steps/StepDetectionMinMaxPeaks.js +80 -0
- package/src/providers/steps/StepDetectionMinMaxPeaks2.js +108 -0
- package/src/providers/steps/StepDetectionProvider.js +100 -0
- package/src/smoothers/PositionSmoother.js +86 -0
- package/src/smoothers/PositionSmoother.spec.js +55 -0
- package/webpack/webpack.common.js +20 -0
- package/webpack/webpack.dev.js +24 -0
- package/webpack/webpack.prod.js +15 -0
package/babel.config.js
ADDED
package/config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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 Absolute Attitude</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(AbsoluteAttitudeComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
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 Absolute Attitude</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body style="margin: 0">
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(AbsolutePositionComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
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 Attitude</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(AttitudeComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { deg2rad } from '@wemap/maths';
|
|
4
|
+
import {
|
|
5
|
+
UserPosition, AbsoluteHeading
|
|
6
|
+
} from '@wemap/geo';
|
|
7
|
+
import { TimeUtils } from '@wemap/utils';
|
|
8
|
+
|
|
9
|
+
import ProvidersLogger from '../../src/events/ProvidersLogger';
|
|
10
|
+
import {
|
|
11
|
+
AbsoluteAttitudeFromBrowser, AbsoluteAttitudeFromRelAtt, AbsoluteAttitude, AbsolutePosition
|
|
12
|
+
} from '../../src/Providers';
|
|
13
|
+
import Utils from './Utils';
|
|
14
|
+
|
|
15
|
+
ProvidersLogger.enabled = true;
|
|
16
|
+
|
|
17
|
+
class AbsoluteAttitudeComponent extends React.Component {
|
|
18
|
+
|
|
19
|
+
constructor(props, context) {
|
|
20
|
+
super(props, context);
|
|
21
|
+
|
|
22
|
+
this.state = {
|
|
23
|
+
attitude: null,
|
|
24
|
+
attitudeFromRelAtt: null,
|
|
25
|
+
attitudeFromBrowser: null,
|
|
26
|
+
deviceorientation: null,
|
|
27
|
+
deviceorientationabsolute: null
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
componentDidMount() {
|
|
33
|
+
|
|
34
|
+
this.providerFromBrowserId = AbsoluteAttitudeFromBrowser.addEventListener(
|
|
35
|
+
events => this.setState({ attitudeFromBrowser: events[0] }),
|
|
36
|
+
error => this.setState({ attitudeFromBrowser: error }),
|
|
37
|
+
this.name);
|
|
38
|
+
|
|
39
|
+
this.providerFromRelAttId = AbsoluteAttitudeFromRelAtt.addEventListener(
|
|
40
|
+
events => this.setState({ attitudeFromRelAtt: events[0] }),
|
|
41
|
+
error => this.setState({ attitudeFromRelAtt: error }),
|
|
42
|
+
this.name);
|
|
43
|
+
|
|
44
|
+
this.providerId = AbsoluteAttitude.addEventListener(
|
|
45
|
+
events => this.setState({ attitude: events[0] }),
|
|
46
|
+
error => this.setState({ attitude: error }),
|
|
47
|
+
this.name);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
this.onDeviceOrientationEventListener = (e) => this.setState({ deviceorientation: e });
|
|
51
|
+
window.addEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
|
|
52
|
+
|
|
53
|
+
this.onDeviceOrientationAbsoluteEventListener = (e) => this.setState({ deviceorientationabsolute: e });
|
|
54
|
+
window.addEventListener('deviceorientationabsolute', this.onDeviceOrientationAbsoluteEventListener, true);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
componentWillUnmount() {
|
|
58
|
+
AbsoluteAttitudeFromBrowser.removeEventListener(this.providerFromBrowserId);
|
|
59
|
+
AbsoluteAttitudeFromRelAtt.removeEventListener(this.providerFromRelAttId);
|
|
60
|
+
AbsoluteAttitude.removeEventListener(this.providerId);
|
|
61
|
+
window.removeEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
|
|
62
|
+
window.removeEventListener('deviceorientationabsolute', this.onDeviceOrientationAbsoluteEventListener, true);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
handleHeadingSubmit() {
|
|
66
|
+
const heading = Number(this.inputHeading);
|
|
67
|
+
if (!isNaN(heading)) {
|
|
68
|
+
AbsoluteAttitude.feed(
|
|
69
|
+
new AbsoluteHeading(deg2rad(heading), TimeUtils.preciseTime / 1e3, 0)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
handlePosSubmit() {
|
|
75
|
+
AbsolutePosition.feed(
|
|
76
|
+
new UserPosition(43.61, 3.8, null, null, TimeUtils.preciseTime / 1e3, 1000)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
render() {
|
|
82
|
+
|
|
83
|
+
let rawRender = <span>Not available</span>;
|
|
84
|
+
|
|
85
|
+
if (this.state.deviceorientation && this.state.deviceorientation.webkitCompassHeading) {
|
|
86
|
+
const alpha = this.state.deviceorientation.alpha;
|
|
87
|
+
const beta = this.state.deviceorientation.beta;
|
|
88
|
+
const gamma = this.state.deviceorientation.gamma;
|
|
89
|
+
const webkitCompassHeading = this.state.deviceorientation.webkitCompassHeading;
|
|
90
|
+
|
|
91
|
+
if (alpha && beta && gamma && webkitCompassHeading) {
|
|
92
|
+
rawRender = <p>alpha: {alpha.toFixed(2)}, <br />
|
|
93
|
+
beta: {beta.toFixed(2)}, <br />
|
|
94
|
+
gamma: {gamma.toFixed(2)}, <br />
|
|
95
|
+
webkitCompassHeading: {webkitCompassHeading.toFixed(2)}</p>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
} else if (this.state.deviceorientationabsolute) {
|
|
99
|
+
const alpha = this.state.deviceorientationabsolute.alpha;
|
|
100
|
+
const beta = this.state.deviceorientationabsolute.beta;
|
|
101
|
+
const gamma = this.state.deviceorientationabsolute.gamma;
|
|
102
|
+
|
|
103
|
+
if (alpha && beta && gamma) {
|
|
104
|
+
rawRender = <p>alpha: {alpha.toFixed(2)}, <br />
|
|
105
|
+
beta: {beta.toFixed(2)}, <br />
|
|
106
|
+
gamma: {gamma.toFixed(2)}</p>;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div>
|
|
113
|
+
<input type="text"
|
|
114
|
+
style={{ width: '50px' }}
|
|
115
|
+
placeholder='Heading'
|
|
116
|
+
pattern="[0-9]*"
|
|
117
|
+
onChange={event => (this.inputHeading = event.target.value)}
|
|
118
|
+
/>
|
|
119
|
+
<input type="button"
|
|
120
|
+
style={{ marginRight: '20px' }}
|
|
121
|
+
onClick={() => this.handleHeadingSubmit()}
|
|
122
|
+
value="Send" />
|
|
123
|
+
|
|
|
124
|
+
<input type="button"
|
|
125
|
+
style={{ marginLeft: '20px' }}
|
|
126
|
+
onClick={() => this.handlePosSubmit()}
|
|
127
|
+
value="Send Montpellier position" />
|
|
128
|
+
<h3>Raw:</h3>
|
|
129
|
+
{rawRender}
|
|
130
|
+
<h3>Absolute attitude:</h3>
|
|
131
|
+
{Utils.renderAttitudeEvent(this.state.attitude)}
|
|
132
|
+
<h3>Absolute attitude From relative + offset:</h3>
|
|
133
|
+
{Utils.renderAttitudeEvent(this.state.attitudeFromRelAtt)}
|
|
134
|
+
<h3>Absolute attitude From browser:</h3>
|
|
135
|
+
{Utils.renderAttitudeEvent(this.state.attitudeFromBrowser)}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default AbsoluteAttitudeComponent;
|
|
142
|
+
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { AbsolutePosition } from '../../src/Providers';
|
|
4
|
+
import Utils from './Utils';
|
|
5
|
+
import NavigationConfig from './NavigationConfig';
|
|
6
|
+
import MapComponent from './MapComponent';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AbsolutePositionComponent extends React.Component {
|
|
10
|
+
|
|
11
|
+
constructor(props, context) {
|
|
12
|
+
super(props, context);
|
|
13
|
+
this.state = { position: null };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
componentDidMount() {
|
|
17
|
+
this.providerId = AbsolutePosition.addEventListener(
|
|
18
|
+
events => this.onNewPosition(events[0]),
|
|
19
|
+
error => this.setState({ absolutePosition: error }),
|
|
20
|
+
this.name
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentWillUnmount() {
|
|
25
|
+
AbsolutePosition.removeEventListener(this.providerId);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onNewPosition = position => {
|
|
29
|
+
this.setState({ absolutePosition: position });
|
|
30
|
+
if (this.map) {
|
|
31
|
+
this.map.updatePosition(position.data);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
handlePosSubmit() {
|
|
36
|
+
AbsolutePosition.feed(NavigationConfig.INITIAL_POSITION);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handleHeadingSubmit() {
|
|
40
|
+
AbsolutePosition.feed(NavigationConfig.INITIAL_HEADING);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div style={{
|
|
47
|
+
display: 'flex',
|
|
48
|
+
flexFlow: 'column',
|
|
49
|
+
height: 'calc(100vh - 16px)',
|
|
50
|
+
padding: '8px'
|
|
51
|
+
}}>
|
|
52
|
+
<div>
|
|
53
|
+
<input type="button"
|
|
54
|
+
onClick={() => this.handlePosSubmit()}
|
|
55
|
+
value="Send Wemap position" />
|
|
56
|
+
<input type="button"
|
|
57
|
+
style={{ marginLeft: '10px' }}
|
|
58
|
+
onClick={() => this.handleHeadingSubmit()}
|
|
59
|
+
value="Send heading" />
|
|
60
|
+
</div>
|
|
61
|
+
<h3>Position</h3>
|
|
62
|
+
{Utils.renderPositionEvent(this.state.absolutePosition)}
|
|
63
|
+
<h3>Map</h3>
|
|
64
|
+
<div style={{
|
|
65
|
+
flexGrow: 1,
|
|
66
|
+
flexShrink: 1,
|
|
67
|
+
flexBasis: 'auto',
|
|
68
|
+
minHeight: '300px'
|
|
69
|
+
}}>
|
|
70
|
+
<MapComponent
|
|
71
|
+
ref={map => (this.map = map)}
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default AbsolutePositionComponent;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Utils from './Utils';
|
|
4
|
+
import ProvidersLogger from '../../src/events/ProvidersLogger';
|
|
5
|
+
import { Attitude } from '../../src/Providers';
|
|
6
|
+
|
|
7
|
+
ProvidersLogger.enabled = true;
|
|
8
|
+
|
|
9
|
+
class AttitudeComponent extends React.Component {
|
|
10
|
+
|
|
11
|
+
constructor(props, context) {
|
|
12
|
+
super(props, context);
|
|
13
|
+
|
|
14
|
+
this.state = { attitude: null };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
this.providerId = Attitude.addEventListener(
|
|
19
|
+
events => this.setState({ attitude: events[0] }),
|
|
20
|
+
error => this.setState({ attitude: error })
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentWillUnmount() {
|
|
25
|
+
Attitude.removeEventListener(this.providerId);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
<h3>Attitude:</h3>
|
|
33
|
+
{Utils.renderAttitudeEvent(this.state.attitude)}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default AttitudeComponent;
|
|
40
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
html,
|
|
2
|
+
body {
|
|
3
|
+
margin: 0;
|
|
4
|
+
font-size: 12px;
|
|
5
|
+
height: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@media screen and (min-width: 400px) {
|
|
9
|
+
body {
|
|
10
|
+
font-size: 14px;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#app {
|
|
15
|
+
height: 100%
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
p {
|
|
19
|
+
margin-top: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.title {
|
|
23
|
+
font-size: 18px;
|
|
24
|
+
font-weight: bold;
|
|
25
|
+
margin-top: 10px;
|
|
26
|
+
margin-bottom: 5px;
|
|
27
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Utils from './Utils';
|
|
4
|
+
import MapComponent from './MapComponent';
|
|
5
|
+
import ProvidersLogger from '../../src/events/ProvidersLogger';
|
|
6
|
+
import { GnssWifi } from '../../src/Providers';
|
|
7
|
+
|
|
8
|
+
ProvidersLogger.enabled = true;
|
|
9
|
+
class GnssWifiComponent extends React.Component {
|
|
10
|
+
|
|
11
|
+
constructor(props, context) {
|
|
12
|
+
super(props, context);
|
|
13
|
+
|
|
14
|
+
this.state = { position: null };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
componentDidMount() {
|
|
19
|
+
this.providerId = GnssWifi.addEventListener(
|
|
20
|
+
events => this.onNewPosition(events[0]),
|
|
21
|
+
error => this.setState({ position: error }),
|
|
22
|
+
this.name
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
componentWillUnmount() {
|
|
27
|
+
GnssWifi.removeEventListener(this.providerId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onNewPosition = position => {
|
|
31
|
+
this.setState({ position });
|
|
32
|
+
if (this.map) {
|
|
33
|
+
this.map.updatePosition(position.data);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
onError = error => {
|
|
38
|
+
this.setState({ position: error });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render() {
|
|
42
|
+
return (
|
|
43
|
+
<div>
|
|
44
|
+
<h3>Position</h3>
|
|
45
|
+
{Utils.renderPositionEvent(this.state.position)}
|
|
46
|
+
<h3>Map</h3>
|
|
47
|
+
<MapComponent ref={map => (this.map = map)} />
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default GnssWifiComponent;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Utils from './Utils';
|
|
4
|
+
import ProvidersLogger from '../../src/events/ProvidersLogger';
|
|
5
|
+
import {
|
|
6
|
+
Accelerometer, Gyroscope
|
|
7
|
+
} from '../../src/Providers';
|
|
8
|
+
|
|
9
|
+
ProvidersLogger.enabled = true;
|
|
10
|
+
|
|
11
|
+
class ImuComponent extends React.Component {
|
|
12
|
+
|
|
13
|
+
constructor(props, context) {
|
|
14
|
+
super(props, context);
|
|
15
|
+
|
|
16
|
+
this.state = {
|
|
17
|
+
acc: null,
|
|
18
|
+
gyr: null
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
componentDidMount() {
|
|
24
|
+
this.accelerometerProviderId = Accelerometer.addEventListener(
|
|
25
|
+
events => this.setState({ acc: events[0] }),
|
|
26
|
+
error => this.setState({ acc: error }),
|
|
27
|
+
this);
|
|
28
|
+
|
|
29
|
+
this.gyroscopeProviderId = Gyroscope.addEventListener(
|
|
30
|
+
events => this.setState({ gyr: events[0] }),
|
|
31
|
+
error => this.setState({ gyr: error }),
|
|
32
|
+
this);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
componentWillUnmount() {
|
|
36
|
+
Accelerometer.removeEventListener(this.accelerometerProviderId);
|
|
37
|
+
Gyroscope.removeEventListener(this.gyroscopeProviderId);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render() {
|
|
41
|
+
return (
|
|
42
|
+
<div>
|
|
43
|
+
<h3>Acceleration</h3>
|
|
44
|
+
{Utils.renderVector3Event(this.state.acc)}
|
|
45
|
+
<h3>Angular Velocity</h3>
|
|
46
|
+
{Utils.renderVector3Event(this.state.gyr)}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default ImuComponent;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Utils from './Utils';
|
|
4
|
+
import ProvidersLogger from '../../src/events/ProvidersLogger';
|
|
5
|
+
import {
|
|
6
|
+
InclinationFromAcc, InclinationFromAttitude, Inclination
|
|
7
|
+
} from '../../src/Providers';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class InclinationComponent extends React.Component {
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
constructor(props, context) {
|
|
14
|
+
super(props, context);
|
|
15
|
+
ProvidersLogger.enabled = false;
|
|
16
|
+
|
|
17
|
+
this.state = {
|
|
18
|
+
inclination: null,
|
|
19
|
+
inclinationFromAcc: null,
|
|
20
|
+
inclinationFromAtt: null
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentDidMount() {
|
|
25
|
+
|
|
26
|
+
this.providerAccId = InclinationFromAcc.addEventListener(
|
|
27
|
+
events => this.setState({ inclinationFromAcc: events[0] }),
|
|
28
|
+
error => this.setState({ inclinationFromAcc: error }),
|
|
29
|
+
this.name
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
this.providerAttId = InclinationFromAttitude.addEventListener(
|
|
33
|
+
events => this.setState({ inclinationFromAtt: events[0] }),
|
|
34
|
+
error => this.setState({ inclinationFromAtt: error }),
|
|
35
|
+
this.name
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
this.providerId = Inclination.addEventListener(
|
|
39
|
+
events => this.setState({ inclination: events[0] }),
|
|
40
|
+
error => this.setState({ inclination: error }),
|
|
41
|
+
this.name
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
componentWillUnmount() {
|
|
47
|
+
InclinationFromAcc.removeEventListener(this.providerAccId);
|
|
48
|
+
InclinationFromAttitude.removeEventListener(this.providerAttId);
|
|
49
|
+
Inclination.removeEventListener(this.providerId);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div>
|
|
56
|
+
<h3>Inclination from accelerometer</h3>
|
|
57
|
+
{Utils.renderInclinationEvent(this.state.inclinationFromAcc)}
|
|
58
|
+
<h3>Inclination from attitude</h3>
|
|
59
|
+
{Utils.renderInclinationEvent(this.state.inclinationFromAtt)}
|
|
60
|
+
<h3>Inclination</h3>
|
|
61
|
+
{Utils.renderInclinationEvent(this.state.inclination)}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default InclinationComponent;
|