@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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Utils from './Utils';
|
|
4
|
+
import ProvidersLogger from '../../src/events/ProvidersLogger';
|
|
5
|
+
import {
|
|
6
|
+
RelativeAttitudeFromBrowser, RelativeAttitudeFromEkf, RelativeAttitude
|
|
7
|
+
} from '../../src/Providers';
|
|
8
|
+
|
|
9
|
+
ProvidersLogger.enabled = true;
|
|
10
|
+
|
|
11
|
+
class RelativeAttitudeComponent extends React.Component {
|
|
12
|
+
|
|
13
|
+
constructor(props, context) {
|
|
14
|
+
super(props, context);
|
|
15
|
+
|
|
16
|
+
this.state = {
|
|
17
|
+
attitude: null,
|
|
18
|
+
attitudeFromBrowser: null,
|
|
19
|
+
attitudeFromEkf: null,
|
|
20
|
+
deviceorientation: null
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentDidMount() {
|
|
25
|
+
|
|
26
|
+
this.providerFromBrowserId = RelativeAttitudeFromBrowser.addEventListener(
|
|
27
|
+
events => this.setState({ attitudeFromBrowser: events[0] }),
|
|
28
|
+
error => this.setState({ attitudeFromBrowser: error }),
|
|
29
|
+
this);
|
|
30
|
+
|
|
31
|
+
this.providerFromEkfId = RelativeAttitudeFromEkf.addEventListener(
|
|
32
|
+
events => this.setState({ attitudeFromEkf: events[0] }),
|
|
33
|
+
error => this.setState({ attitudeFromEkf: error }),
|
|
34
|
+
this);
|
|
35
|
+
|
|
36
|
+
this.providerId = RelativeAttitude.addEventListener(
|
|
37
|
+
events => this.setState({ attitude: events[0] }),
|
|
38
|
+
error => this.setState({ attitude: error }),
|
|
39
|
+
this);
|
|
40
|
+
|
|
41
|
+
window.addEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
componentWillUnmount() {
|
|
45
|
+
RelativeAttitudeFromBrowser.removeEventListener(this.providerFromBrowserId);
|
|
46
|
+
RelativeAttitudeFromEkf.removeEventListener(this.providerFromEkfId);
|
|
47
|
+
RelativeAttitude.removeEventListener(this.providerId);
|
|
48
|
+
window.removeEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onDeviceOrientationEventListener = (e) => this.setState({ deviceorientation: e });
|
|
52
|
+
|
|
53
|
+
render() {
|
|
54
|
+
|
|
55
|
+
let rawRender = <span>Not available</span>;
|
|
56
|
+
|
|
57
|
+
if (this.state.deviceorientation) {
|
|
58
|
+
const alpha = this.state.deviceorientation.alpha;
|
|
59
|
+
const beta = this.state.deviceorientation.beta;
|
|
60
|
+
const gamma = this.state.deviceorientation.gamma;
|
|
61
|
+
|
|
62
|
+
if (alpha && beta && gamma) {
|
|
63
|
+
rawRender = <p>alpha: {alpha.toFixed(2)}, <br />
|
|
64
|
+
beta: {beta.toFixed(2)}, <br />
|
|
65
|
+
gamma: {gamma.toFixed(2)}</p>;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div>
|
|
71
|
+
<h3>Raw:</h3>
|
|
72
|
+
{rawRender}
|
|
73
|
+
<h3>Relative Attitude From Browser</h3>
|
|
74
|
+
{Utils.renderAttitudeEvent(this.state.attitudeFromBrowser)}
|
|
75
|
+
<h3>Relative Attitude From Ekf</h3>
|
|
76
|
+
{Utils.renderAttitudeEvent(this.state.attitudeFromEkf)}
|
|
77
|
+
<h3>Relative Attitude</h3>
|
|
78
|
+
{Utils.renderAttitudeEvent(this.state.attitude)}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default RelativeAttitudeComponent;
|
|
85
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
class StartStopComponent extends React.Component {
|
|
5
|
+
|
|
6
|
+
static propTypes = {
|
|
7
|
+
onStart: PropTypes.func.isRequired,
|
|
8
|
+
onStop: PropTypes.func.isRequired,
|
|
9
|
+
errored: PropTypes.bool.isRequired
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
constructor(props, context) {
|
|
13
|
+
super(props, context);
|
|
14
|
+
this.state = { started: false };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
start() {
|
|
18
|
+
this.setState({started: true});
|
|
19
|
+
this.props.onStart();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
stop() {
|
|
23
|
+
this.setState({started: false});
|
|
24
|
+
this.props.onStop();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
render() {
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<button onClick={() => this.start()}
|
|
31
|
+
disabled={(this.state.started && !this.props.errored)}>
|
|
32
|
+
Start
|
|
33
|
+
</button>
|
|
34
|
+
<button onClick={() => this.stop()}
|
|
35
|
+
disabled={!(this.state.started && !this.props.errored)}>
|
|
36
|
+
Stop
|
|
37
|
+
</button>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default StartStopComponent;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Utils from './Utils';
|
|
4
|
+
import ProvidersLogger from '../../src/events/ProvidersLogger';
|
|
5
|
+
import { StepDetection } from '../../src/Providers';
|
|
6
|
+
|
|
7
|
+
ProvidersLogger.enabled = true;
|
|
8
|
+
|
|
9
|
+
class StepDetectionComponent extends React.Component {
|
|
10
|
+
|
|
11
|
+
constructor(props, context) {
|
|
12
|
+
super(props, context);
|
|
13
|
+
|
|
14
|
+
this.state = { stepDetected: null };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
this.providerId = StepDetection.addEventListener(
|
|
19
|
+
events => this.setState({ stepDetected: events[0] }),
|
|
20
|
+
error => this.setState({ stepDetected: error }),
|
|
21
|
+
this.name);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentWillUnmount() {
|
|
25
|
+
StepDetection.removeEventListener(this.providerId);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
return (
|
|
30
|
+
<div>
|
|
31
|
+
<h3>Step detected</h3>
|
|
32
|
+
{Utils.renderStepEvent(this.state.stepDetected)}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default StepDetectionComponent;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import React from 'react'; // eslint-disable-line no-unused-vars
|
|
2
|
+
|
|
3
|
+
import { rad2deg } from '@wemap/maths';
|
|
4
|
+
import { OsrmUtils } from '@wemap/osm';
|
|
5
|
+
|
|
6
|
+
import ProviderEvent from '../../src/events/ProviderEvent';
|
|
7
|
+
import isNumber from 'lodash.isnumber';
|
|
8
|
+
|
|
9
|
+
const NOT_AVAILABLE_STR = 'Not available';
|
|
10
|
+
|
|
11
|
+
class Utils {
|
|
12
|
+
|
|
13
|
+
static renderAttitudeEvent(event) {
|
|
14
|
+
|
|
15
|
+
if (!event) {
|
|
16
|
+
return <p>Waiting</p>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (event instanceof Error) {
|
|
20
|
+
return Utils.renderError(event);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const attitude = event instanceof ProviderEvent ? event.data : event;
|
|
25
|
+
const quaternion = attitude.quaternion;
|
|
26
|
+
|
|
27
|
+
const w = quaternion[0].toFixed(3);
|
|
28
|
+
const x = quaternion[1].toFixed(3);
|
|
29
|
+
const y = quaternion[2].toFixed(3);
|
|
30
|
+
const z = quaternion[3].toFixed(3);
|
|
31
|
+
|
|
32
|
+
const euler = attitude.eulerAnglesDegrees;
|
|
33
|
+
const yaw = euler[0].toFixed(2);
|
|
34
|
+
const pitch = euler[1].toFixed(2);
|
|
35
|
+
const roll = euler[2].toFixed(2);
|
|
36
|
+
const heading = attitude.headingDegrees.toFixed(2);
|
|
37
|
+
|
|
38
|
+
const accuracyString = isNumber(attitude.accuracy) ? rad2deg(attitude.accuracy).toFixed(1) : '';
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<p>
|
|
43
|
+
Quaternion: [{w}, {x}, {y}, {z}]<br />
|
|
44
|
+
Eulers: [{yaw}, {pitch}, {roll}]<br />
|
|
45
|
+
Heading: {heading}<br />
|
|
46
|
+
Time: {attitude.time.toFixed(2)}<br />
|
|
47
|
+
Accuracy: {accuracyString}
|
|
48
|
+
</p>
|
|
49
|
+
{(event instanceof ProviderEvent) ? Utils.renderTimeAndFromStack(event) : ''}
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static renderVector3Event(event) {
|
|
55
|
+
|
|
56
|
+
if (!event) {
|
|
57
|
+
return <p>Waiting</p>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (event instanceof Error) {
|
|
61
|
+
return Utils.renderError(event);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const { data } = event;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div>
|
|
68
|
+
<p style={{ margin: 0 }}>
|
|
69
|
+
[{data[0].toFixed(2)}, {data[1].toFixed(2)}, {data[2].toFixed(2)}]
|
|
70
|
+
</p>
|
|
71
|
+
{Utils.renderTimeAndFromStack(event)}
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static renderPositionEvent(event) {
|
|
77
|
+
|
|
78
|
+
if (!event) {
|
|
79
|
+
return <p>Waiting</p>;
|
|
80
|
+
}
|
|
81
|
+
if (event instanceof Error) {
|
|
82
|
+
return Utils.renderError(event);
|
|
83
|
+
}
|
|
84
|
+
const position = event instanceof ProviderEvent ? event.data : event;
|
|
85
|
+
return (
|
|
86
|
+
<div>
|
|
87
|
+
<p>
|
|
88
|
+
Latitude: {position.lat.toFixed(7)}<br />
|
|
89
|
+
Longitude: {position.lng.toFixed(7)}<br />
|
|
90
|
+
Altitude: {position.alt ? position.alt.toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
91
|
+
Level: {position.level ? position.level.toString() : NOT_AVAILABLE_STR}<br />
|
|
92
|
+
Bearing: {isNumber(position.bearing) ? rad2deg(position.bearing).toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
93
|
+
Accuracy: {isNumber(position.accuracy) ? position.accuracy.toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
94
|
+
Time: {isNumber(position.time) ? position.time.toFixed(2) : NOT_AVAILABLE_STR}
|
|
95
|
+
</p>
|
|
96
|
+
{(event instanceof ProviderEvent) ? Utils.renderTimeAndFromStack(event) : ''}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static renderRelativePosition(position) {
|
|
103
|
+
|
|
104
|
+
if (!position) {
|
|
105
|
+
return <p>Waiting</p>;
|
|
106
|
+
}
|
|
107
|
+
if (position instanceof Error) {
|
|
108
|
+
return Utils.renderError(position);
|
|
109
|
+
}
|
|
110
|
+
return (
|
|
111
|
+
<p>
|
|
112
|
+
x: {position[0].toFixed(2)}<br />
|
|
113
|
+
y: {position[1].toFixed(2)}<br />
|
|
114
|
+
z: {position[2].toFixed(2)}
|
|
115
|
+
</p>
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static renderItineraryInfo(info) {
|
|
121
|
+
|
|
122
|
+
if (!info) {
|
|
123
|
+
return <p>Waiting</p>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const step = info.nextStep;
|
|
127
|
+
let nextStepStr = '[' + step.number + '] ';
|
|
128
|
+
if (step.firstStep) {
|
|
129
|
+
nextStepStr += 'Depart';
|
|
130
|
+
} else if (step.lastStep) {
|
|
131
|
+
nextStepStr += 'Arrive';
|
|
132
|
+
} else {
|
|
133
|
+
nextStepStr += 'Turn '
|
|
134
|
+
+ OsrmUtils.getModifierFromAngle(step.angle);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<p>
|
|
140
|
+
projection: {info.projection.nearestElement.constructor.name}<br />
|
|
141
|
+
distanceOfProjection: {info.projection.distanceFromNearestElement.toFixed(1)}m<br />
|
|
142
|
+
traveledDistance: {info.traveledDistance.toFixed(1)}m
|
|
143
|
+
({(info.traveledPercentage * 100).toFixed(1)}%)<br />
|
|
144
|
+
remainingDistance: {info.remainingDistance.toFixed(1)}m
|
|
145
|
+
({(info.remainingPercentage * 100).toFixed(1)}%)<br />
|
|
146
|
+
nextStep: {nextStepStr}
|
|
147
|
+
</p>
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static renderInclinationEvent(event) {
|
|
153
|
+
if (event === null) {
|
|
154
|
+
return 'Waiting';
|
|
155
|
+
}
|
|
156
|
+
if (event instanceof Error) {
|
|
157
|
+
return Utils.renderError(event);
|
|
158
|
+
}
|
|
159
|
+
return (
|
|
160
|
+
<div>
|
|
161
|
+
<p style={{ margin: 0 }}>
|
|
162
|
+
Inclination: {rad2deg(event.data).toFixed(2)} deg
|
|
163
|
+
</p>
|
|
164
|
+
{Utils.renderTimeAndFromStack(event)}
|
|
165
|
+
</div>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @param {ProviderEvent} stepEvent
|
|
171
|
+
*/
|
|
172
|
+
static renderStepEvent(event) {
|
|
173
|
+
if (event === null) {
|
|
174
|
+
return 'Waiting';
|
|
175
|
+
}
|
|
176
|
+
if (event instanceof Error) {
|
|
177
|
+
return Utils.renderError(event);
|
|
178
|
+
}
|
|
179
|
+
return (
|
|
180
|
+
<div>
|
|
181
|
+
<p style={{ margin: 0 }}>
|
|
182
|
+
Number: {event.data.number}<br />
|
|
183
|
+
Size: {event.data.size.toFixed(2)}m
|
|
184
|
+
</p>
|
|
185
|
+
{Utils.renderTimeAndFromStack(event)}
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static renderError(error) {
|
|
191
|
+
return (<span><strong>[{error.constructor.name}]</strong> {error.message}</span>);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static renderFromStack(providersStack) {
|
|
195
|
+
return <span style={{}}>Provider: {providersStack.join(', ')}</span>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static renderTime(timestamp) {
|
|
199
|
+
return `Time: ${timestamp.toFixed(2)} s`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
static renderTimeAndFromStack(event) {
|
|
203
|
+
return (
|
|
204
|
+
<p style={{
|
|
205
|
+
margin: 0,
|
|
206
|
+
fontSize: 'small'
|
|
207
|
+
}}>
|
|
208
|
+
{this.renderTime(event.timestamp)}<br />
|
|
209
|
+
{this.renderFromStack(event.providersStack)}
|
|
210
|
+
</p>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export default Utils;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
|
|
4
|
+
import AbsoluteAttitudeComponent from './AbsoluteAttitudeComponent';
|
|
5
|
+
import AbsolutePositionComponent from './AbsolutePositionComponent';
|
|
6
|
+
import AttitudeComponent from './AttitudeComponent';
|
|
7
|
+
import GnssWifiComponent from './GnssWifiComponent';
|
|
8
|
+
import ImuComponent from './ImuComponent';
|
|
9
|
+
import InclinationComponent from './InclinationComponent';
|
|
10
|
+
import PoseComponent from './PoseComponent';
|
|
11
|
+
import RelativeAttitudeComponent from './RelativeAttitudeComponent';
|
|
12
|
+
import StepDetectionComponent from './StepDetectionComponent';
|
|
13
|
+
|
|
14
|
+
const createReactElement = (component, container) => ReactDOM.render(
|
|
15
|
+
React.createElement(component, {}, null),
|
|
16
|
+
container
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
AbsoluteAttitudeComponent,
|
|
21
|
+
AbsolutePositionComponent,
|
|
22
|
+
AttitudeComponent,
|
|
23
|
+
ImuComponent,
|
|
24
|
+
InclinationComponent,
|
|
25
|
+
GnssWifiComponent,
|
|
26
|
+
PoseComponent,
|
|
27
|
+
RelativeAttitudeComponent,
|
|
28
|
+
StepDetectionComponent,
|
|
29
|
+
createReactElement
|
|
30
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PositioningPoseComponent from './PositioningPoseComponent';
|
|
3
|
+
import PositioningHandler from '../../src/PositioningHandler';
|
|
4
|
+
import PositioningInclinationComponent from './PositioningInclinationComponent';
|
|
5
|
+
import ProvidersLogger from '../../src/providers/ProvidersLogger';
|
|
6
|
+
|
|
7
|
+
ProvidersLogger.enabled = true;
|
|
8
|
+
|
|
9
|
+
class PositioningComponent extends React.Component {
|
|
10
|
+
|
|
11
|
+
constructor(props, context) {
|
|
12
|
+
super(props, context);
|
|
13
|
+
this.positioningHandler = new PositioningHandler();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
render() {
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div>
|
|
20
|
+
<h2>Pose</h2>
|
|
21
|
+
<div><PositioningPoseComponent positioningHandler={this.positioningHandler} /></div>
|
|
22
|
+
<h2>Inclination</h2>
|
|
23
|
+
<div><PositioningInclinationComponent positioningHandler={this.positioningHandler} /></div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default PositioningComponent;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import isEmpty from 'lodash.isempty';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import EventType from '../../src/events/EventType';
|
|
6
|
+
import Utils from './Utils';
|
|
7
|
+
import PositioningHandler from '../../src/PositioningHandler';
|
|
8
|
+
import StartStopComponent from './StartStopComponent';
|
|
9
|
+
import ProvidersLogger from '../../src/providers/ProvidersLogger';
|
|
10
|
+
|
|
11
|
+
ProvidersLogger.enabled = true;
|
|
12
|
+
|
|
13
|
+
class PositioningInclinationComponent extends React.Component {
|
|
14
|
+
|
|
15
|
+
static propTypes = { positioningHandler: PropTypes.instanceOf(PositioningHandler).isRequired };
|
|
16
|
+
|
|
17
|
+
constructor(props, context) {
|
|
18
|
+
super(props, context);
|
|
19
|
+
this.state = {
|
|
20
|
+
inclination: null,
|
|
21
|
+
errored: false
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
start() {
|
|
27
|
+
const output = this.props.positioningHandler.start(
|
|
28
|
+
[EventType.Inclination],
|
|
29
|
+
this.onEvents,
|
|
30
|
+
this.onError
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (!output) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.id = output.id;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
stop() {
|
|
42
|
+
this.props.positioningHandler.stop(this.id);
|
|
43
|
+
this.setState({
|
|
44
|
+
inclination: null,
|
|
45
|
+
errored: false
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onEvents = (events) => {
|
|
50
|
+
const newState = {};
|
|
51
|
+
events.forEach(event => {
|
|
52
|
+
if (event.dataType === EventType.Inclination) {
|
|
53
|
+
newState.inclination = event.data;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (!isEmpty(newState)) {
|
|
57
|
+
this.setState(newState);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
onError = error => {
|
|
62
|
+
this.setState({
|
|
63
|
+
errored: true,
|
|
64
|
+
inclination: error
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
render() {
|
|
69
|
+
return (
|
|
70
|
+
<div>
|
|
71
|
+
<StartStopComponent
|
|
72
|
+
onStart={() => this.start()}
|
|
73
|
+
onStop={() => this.stop()}
|
|
74
|
+
errored={this.state.errored} />
|
|
75
|
+
|
|
76
|
+
<p>{Utils.renderInclination(this.state.inclination)}</p>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default PositioningInclinationComponent;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import isEmpty from 'lodash.isempty';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import EventType from '../../src/events/EventType';
|
|
6
|
+
import NavigationConfig from './NavigationConfig';
|
|
7
|
+
import Utils from './Utils';
|
|
8
|
+
import PositioningHandler from '../../src/PositioningHandler';
|
|
9
|
+
import StartStopComponent from './StartStopComponent';
|
|
10
|
+
import MapComponent from './MapComponent';
|
|
11
|
+
import ProvidersLogger from '../../src/providers/ProvidersLogger';
|
|
12
|
+
|
|
13
|
+
ProvidersLogger.enabled = true;
|
|
14
|
+
|
|
15
|
+
class PositioningPoseComponent extends React.Component {
|
|
16
|
+
static propTypes = {positioningHandler: PropTypes.instanceOf(PositioningHandler).isRequired};
|
|
17
|
+
|
|
18
|
+
constructor(props, context) {
|
|
19
|
+
super(props, context);
|
|
20
|
+
this.state = {
|
|
21
|
+
position: null,
|
|
22
|
+
attitude: null,
|
|
23
|
+
errored: false
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
start() {
|
|
28
|
+
const output = this.props.positioningHandler.start(
|
|
29
|
+
[EventType.AbsolutePosition, EventType.AbsoluteAttitude],
|
|
30
|
+
this.onEvents,
|
|
31
|
+
this.onError,
|
|
32
|
+
{
|
|
33
|
+
waitInputPosition: true,
|
|
34
|
+
useMapMatching: true
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
if (!output) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.id = output.id;
|
|
43
|
+
|
|
44
|
+
this.props.positioningHandler.setItinerary(this.id, NavigationConfig.ITINERARY);
|
|
45
|
+
this.props.positioningHandler.setNetwork(this.id, NavigationConfig.ITINERARY);
|
|
46
|
+
this.props.positioningHandler.setPosition(this.id, NavigationConfig.INITIAL_POSITION);
|
|
47
|
+
this.props.positioningHandler.setHeading(this.id, NavigationConfig.INITIAL_HEADING);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
stop() {
|
|
51
|
+
this.props.positioningHandler.stop(this.id);
|
|
52
|
+
this.setState({
|
|
53
|
+
position: null,
|
|
54
|
+
attitude: null,
|
|
55
|
+
errored: false
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onEvents = events => {
|
|
60
|
+
const newState = {};
|
|
61
|
+
events.forEach(event => {
|
|
62
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
63
|
+
newState.position = event.data;
|
|
64
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
65
|
+
newState.attitude = event.data;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (!isEmpty(newState)) {
|
|
69
|
+
this.setState(newState);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (this.map) {
|
|
73
|
+
this.map.parseEvents(events);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
onError = error => {
|
|
78
|
+
this.setState({
|
|
79
|
+
position: error,
|
|
80
|
+
attitude: error,
|
|
81
|
+
errored: true
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
render() {
|
|
86
|
+
const attitudeRender = Utils.renderAttitude(this.state.attitude);
|
|
87
|
+
const positionRender = Utils.renderPosition(this.state.position);
|
|
88
|
+
|
|
89
|
+
const itineraryRender = Utils.renderItineraryInfo(
|
|
90
|
+
this.state.position && !(this.state.position instanceof Error)
|
|
91
|
+
? NavigationConfig.ITINERARY.getInfo(this.state.position)
|
|
92
|
+
: null
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<div>
|
|
97
|
+
<StartStopComponent
|
|
98
|
+
onStart={() => this.start()}
|
|
99
|
+
onStop={() => this.stop()}
|
|
100
|
+
errored={this.state.errored}
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<h3>Position</h3>
|
|
104
|
+
{positionRender}
|
|
105
|
+
<h3>Attitude</h3>
|
|
106
|
+
{attitudeRender}
|
|
107
|
+
<h3>Map</h3>
|
|
108
|
+
<MapComponent ref={map => (this.map = map)}
|
|
109
|
+
network={NavigationConfig.ITINERARY} />
|
|
110
|
+
<h3>ItineraryInfo</h3>
|
|
111
|
+
{itineraryRender}
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export default PositioningPoseComponent;
|
|
@@ -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 Positioning</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(GnssWifiComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
package/debug/imu.html
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 Imu</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(ImuComponent, 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 Inclination</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(InclinationComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|