@wemap/positioning 1.2.2 → 2.1.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/.eslintrc.json +4 -2
- package/debug/absolute-attitude.html +16 -0
- package/debug/gnss-wifi-pdr.html +16 -0
- package/debug/gnss-wifi.html +16 -0
- package/debug/imu.html +16 -0
- package/debug/inclination.html +16 -0
- package/debug/pdr.html +16 -0
- package/debug/pose.html +16 -0
- package/debug/positioning.html +16 -0
- package/debug/relative-attitude.html +16 -0
- package/package.json +6 -4
- package/src/PositioningHandler.js +124 -0
- package/src/components/AbsoluteAttitudeComponent.jsx +104 -0
- package/src/components/GnssWifiComponent.jsx +46 -0
- package/src/components/GnssWifiPdrComponent.jsx +85 -0
- package/src/components/ImuComponent.jsx +100 -0
- package/src/components/InclinationComponent.jsx +53 -0
- package/src/components/PdrComponent.jsx +88 -0
- package/src/components/PoseComponent.jsx +74 -0
- package/src/components/PositioningComponent.jsx +26 -0
- package/src/components/PositioningInclinationComponent.jsx +76 -0
- package/src/components/PositioningPoseComponent.jsx +111 -0
- package/src/components/RelativeAttitudeComponent.jsx +82 -0
- package/src/components/StartStopComponent.jsx +50 -0
- package/src/components/Utils.js +41 -2
- package/src/components/index.js +19 -2
- package/src/errors/AskImuOnDesktopError.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/MissingGyroscopeError.js +11 -0
- package/src/errors/MissingMagnetometerError.js +9 -0
- package/src/errors/MissingSensorError.js +14 -0
- package/src/events/EventType.js +20 -0
- package/src/events/ProviderError.js +52 -0
- package/src/events/ProviderEvent.js +35 -0
- package/src/index.js +3 -4
- package/src/providers/Constants.js +5 -0
- package/src/providers/FakeAbsolutePositionProvider.js +56 -0
- package/src/providers/Provider.js +218 -0
- package/src/providers/ProviderOptions.js +28 -0
- package/src/providers/ProvidersLogger.js +3 -3
- package/src/providers/attitude/AbsoluteAttitudeProvider.js +207 -0
- package/src/providers/attitude/EkfAttitude.js +238 -0
- package/src/providers/attitude/EkfAttitude.spec.js +116 -0
- package/src/providers/attitude/RelativeAttitudeProvider.js +129 -0
- package/src/providers/others/ImuProvider.js +186 -0
- package/src/providers/others/InclinationProvider.js +107 -0
- package/src/providers/others/MapMatchingProvider.js +147 -0
- package/src/providers/pose/GnssWifiPdrProvider.js +233 -0
- package/src/providers/pose/PoseProvider.js +90 -0
- package/src/providers/pose/pdr/PdrProvider.js +352 -0
- package/src/providers/pose/pdr/helpers/HeadingUnlocker.js +41 -0
- package/src/providers/pose/pdr/helpers/HeadingUnlocker.spec.js +26 -0
- package/src/providers/pose/pdr/helpers/Smoother.js +90 -0
- package/src/providers/pose/pdr/helpers/Smoother.spec.js +424 -0
- package/src/providers/pose/pdr/helpers/ThugDetector.js +37 -0
- package/src/providers/pose/pdr/steps/StepDetection.js +7 -0
- package/src/providers/pose/pdr/steps/StepDetectionLadetto.js +67 -0
- package/src/providers/pose/pdr/steps/StepDetectionMinMaxPeaks.js +80 -0
- package/src/providers/pose/pdr/steps/StepDetectionMinMaxPeaks2.js +108 -0
- package/src/providers/position/GnssWifiProvider.js +129 -0
- package/src/providers/position/IpProvider.js +75 -0
- package/src.old/components/Utils.js +35 -0
- package/src.old/components/index.js +13 -0
- package/src.old/index.js +7 -0
- package/{src → src.old}/providers/GnssPdrLocationSource.js +1 -1
- package/src.old/providers/ProvidersLogger.js +77 -0
- package/webpack/webpack.dev.js +1 -1
- package/debug/index.html +0 -15
- package/debug/index.old.html +0 -37
- package/scripts/release-github.js +0 -216
- package/src.new/NavigationHandler.js +0 -62
- package/src.new/index.js +0 -3
- package/src.new/providers/FakeLocationSource.js +0 -39
- /package/{src → src.old}/Constants.js +0 -0
- /package/{src → src.old}/NavigationHandler.js +0 -0
- /package/{src → src.old}/Pose.js +0 -0
- /package/{src → src.old}/attitude/AttitudeHandler.js +0 -0
- /package/{src → src.old}/attitude/EkfAttitude.js +0 -0
- /package/{src → src.old}/attitude/EkfAttitude.spec.js +0 -0
- /package/{src → src.old}/components/AbsoluteAttitude.jsx +0 -0
- /package/{src → src.old}/components/Imu.jsx +0 -0
- /package/{src → src.old}/components/LocationSource.jsx +0 -0
- /package/{src → src.old}/components/Logger.jsx +0 -0
- /package/{src → src.old}/components/NavigationDebugApp.jsx +0 -0
- /package/{src → src.old}/components/Others.jsx +0 -0
- /package/{src → src.old}/components/RelativeAttitude.jsx +0 -0
- /package/{src → src.old}/providers/FixedLocationImuLocationSource.js +0 -0
- /package/{src → src.old}/providers/GnssLocationSource.js +0 -0
- /package/{src → src.old}/providers/IPLocationSource.js +0 -0
- /package/{src → src.old}/providers/LocationSource.js +0 -0
- /package/{src → src.old}/providers/PdrLocationSource.js +0 -0
- /package/{src → src.old}/providers/pdr/HeadingUnlocker.js +0 -0
- /package/{src → src.old}/providers/pdr/HeadingUnlocker.spec.js +0 -0
- /package/{src → src.old}/providers/pdr/Smoother.js +0 -0
- /package/{src → src.old}/providers/pdr/Smoother.spec.js +0 -0
- /package/{src → src.old}/providers/pdr/ThugDetector.js +0 -0
- /package/{src → src.old}/providers/steps/StepDetection.js +0 -0
- /package/{src → src.old}/providers/steps/StepDetectionLadetto.js +0 -0
- /package/{src → src.old}/providers/steps/StepDetectionMinMaxPeaks.js +0 -0
- /package/{src → src.old}/providers/steps/StepDetectionMinMaxPeaks2.js +0 -0
- /package/{src → src.old}/sensors/SensorsCompatibility.js +0 -0
- /package/{src → src.old}/sensors/SensorsCompatibility.spec.js +0 -0
- /package/{src → src.old}/sensors/SensorsLogger.js +0 -0
- /package/{src → src.old}/sensors/SensorsLoggerUtils.js +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import InclinationProvider from '../providers/others/InclinationProvider';
|
|
4
|
+
import EventType from '../events/EventType';
|
|
5
|
+
import Utils from './Utils';
|
|
6
|
+
|
|
7
|
+
class InclinationComponent extends React.Component {
|
|
8
|
+
|
|
9
|
+
constructor(props, context) {
|
|
10
|
+
super(props, context);
|
|
11
|
+
|
|
12
|
+
this.state = { inclination: null };
|
|
13
|
+
|
|
14
|
+
this.inclinationProvider = new InclinationProvider(this.onEvent, this.onError);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
this.inclinationProvider.start();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
componentWillUnmount() {
|
|
22
|
+
this.inclinationProvider.stop();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
onEvent = events => {
|
|
26
|
+
events.forEach(event => {
|
|
27
|
+
if (event.dataType === EventType.Inclination) {
|
|
28
|
+
this.setState({ inclination: event.data });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
onError = events => {
|
|
34
|
+
events.forEach(event => {
|
|
35
|
+
if (event.dataType === EventType.Inclination) {
|
|
36
|
+
this.setState({ inclination: event.error });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render() {
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div>
|
|
45
|
+
<h3>Inclination</h3>
|
|
46
|
+
<p>{Utils.renderInclination(this.state.inclination)}</p>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default InclinationComponent;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import isEmpty from 'lodash.isempty';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Itinerary, WGS84UserPosition
|
|
6
|
+
} from '@wemap/geo';
|
|
7
|
+
|
|
8
|
+
import Utils from './Utils';
|
|
9
|
+
import PdrProvider from '../providers/pose/pdr/PdrProvider';
|
|
10
|
+
import EventType from '../events/EventType';
|
|
11
|
+
|
|
12
|
+
const INITIAL_LOCATION = new WGS84UserPosition(43.6091955, 3.8841255);
|
|
13
|
+
const INITIAL_HEADING = 191.9;
|
|
14
|
+
const ITINERARY = Itinerary.fromPoints([
|
|
15
|
+
[INITIAL_LOCATION.lat, INITIAL_LOCATION.lng],
|
|
16
|
+
[43.6091883, 3.8841242],
|
|
17
|
+
[43.6091709, 3.8842382],
|
|
18
|
+
[43.6091288, 3.884226],
|
|
19
|
+
[43.6091461, 3.884112]
|
|
20
|
+
], false);
|
|
21
|
+
|
|
22
|
+
class PdrComponent extends React.Component {
|
|
23
|
+
|
|
24
|
+
constructor(props, context) {
|
|
25
|
+
super(props, context);
|
|
26
|
+
this.state = { position: null };
|
|
27
|
+
|
|
28
|
+
this.pdrProvider = new PdrProvider(this.onEvent, this.onError);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
componentDidMount() {
|
|
33
|
+
this.pdrProvider.setLocation(INITIAL_LOCATION);
|
|
34
|
+
this.pdrProvider.setHeading(INITIAL_HEADING);
|
|
35
|
+
this.pdrProvider.enableMapMatching(ITINERARY);
|
|
36
|
+
this.pdrProvider.start();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
componentWillUnmount() {
|
|
40
|
+
this.pdrProvider.stop();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onEvent = events => {
|
|
44
|
+
const newState = {};
|
|
45
|
+
events.forEach(event => {
|
|
46
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
47
|
+
newState.position = event.data;
|
|
48
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
49
|
+
newState.attitude = event.data;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (!isEmpty(newState)) {
|
|
53
|
+
this.setState(newState);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
onError = events => {
|
|
58
|
+
const newState = {};
|
|
59
|
+
events.forEach(event => {
|
|
60
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
61
|
+
newState.position = event.error;
|
|
62
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
63
|
+
newState.attitude = event.error;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
if (!isEmpty(newState)) {
|
|
67
|
+
this.setState(newState);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
render() {
|
|
72
|
+
|
|
73
|
+
const attitudeRender = Utils.renderAttitude(this.state.attitude);
|
|
74
|
+
const positionRender = Utils.renderPosition(this.state.position);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div>
|
|
78
|
+
<h3>Position</h3>
|
|
79
|
+
{positionRender}
|
|
80
|
+
<h3>Attitude</h3>
|
|
81
|
+
{attitudeRender}
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default PdrComponent;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import isEmpty from 'lodash.isempty';
|
|
3
|
+
|
|
4
|
+
import EventType from '../events/EventType';
|
|
5
|
+
import Utils from './Utils';
|
|
6
|
+
import PoseProvider from '../providers/pose/PoseProvider';
|
|
7
|
+
|
|
8
|
+
class PoseComponent extends React.Component {
|
|
9
|
+
|
|
10
|
+
constructor(props, context) {
|
|
11
|
+
super(props, context);
|
|
12
|
+
this.state = {
|
|
13
|
+
position: null,
|
|
14
|
+
attitude: null
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
this.poseProvider = new PoseProvider(this.onEvent, this.onError);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
componentDidMount() {
|
|
22
|
+
this.poseProvider.start();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
componentWillUnmount() {
|
|
26
|
+
this.poseProvider.stop();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
onEvent = events => {
|
|
30
|
+
const newState = {};
|
|
31
|
+
events.forEach(event => {
|
|
32
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
33
|
+
newState.position = event.data;
|
|
34
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
35
|
+
newState.attitude = event.data;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (!isEmpty(newState)) {
|
|
39
|
+
this.setState(newState);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
onError = events => {
|
|
44
|
+
const newState = {};
|
|
45
|
+
events.forEach(event => {
|
|
46
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
47
|
+
newState.position = event.error;
|
|
48
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
49
|
+
newState.attitude = event.error;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (!isEmpty(newState)) {
|
|
53
|
+
this.setState(newState);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
render() {
|
|
58
|
+
|
|
59
|
+
const attitudeRender = Utils.renderAttitude(this.state.attitude);
|
|
60
|
+
const positionRender = Utils.renderPosition(this.state.position);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div>
|
|
64
|
+
<h3>Position</h3>
|
|
65
|
+
{positionRender}
|
|
66
|
+
<h3>Attitude</h3>
|
|
67
|
+
{attitudeRender}
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default PoseComponent;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PositioningPoseComponent from './PositioningPoseComponent';
|
|
3
|
+
import PositioningHandler from '../PositioningHandler';
|
|
4
|
+
import PositioningInclinationComponent from './PositioningInclinationComponent';
|
|
5
|
+
|
|
6
|
+
class PositioningComponent extends React.Component {
|
|
7
|
+
|
|
8
|
+
constructor(props, context) {
|
|
9
|
+
super(props, context);
|
|
10
|
+
this.positioningHandler = new PositioningHandler();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
render() {
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div>
|
|
17
|
+
<h2>Pose</h2>
|
|
18
|
+
<div><PositioningPoseComponent positioningHandler={this.positioningHandler} /></div>
|
|
19
|
+
<h2>Inclination</h2>
|
|
20
|
+
<div><PositioningInclinationComponent positioningHandler={this.positioningHandler} /></div>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default PositioningComponent;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import isEmpty from 'lodash.isempty';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import EventType from '../events/EventType';
|
|
6
|
+
import Utils from './Utils';
|
|
7
|
+
import PositioningHandler from '../PositioningHandler';
|
|
8
|
+
import StartStopComponent from './StartStopComponent';
|
|
9
|
+
|
|
10
|
+
class PositioningInclinationComponent extends React.Component {
|
|
11
|
+
|
|
12
|
+
static propTypes = { positioningHandler: PropTypes.instanceOf(PositioningHandler).isRequired };
|
|
13
|
+
|
|
14
|
+
constructor(props, context) {
|
|
15
|
+
super(props, context);
|
|
16
|
+
this.state = {
|
|
17
|
+
inclination: null,
|
|
18
|
+
errored: false
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
start() {
|
|
24
|
+
this.id = this.props.positioningHandler.start(
|
|
25
|
+
[EventType.Inclination],
|
|
26
|
+
this.onEvents,
|
|
27
|
+
this.onErrors
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
stop() {
|
|
33
|
+
this.props.positioningHandler.stop(this.id);
|
|
34
|
+
this.setState({
|
|
35
|
+
inclination: null,
|
|
36
|
+
errored: false
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onEvents = (events) => {
|
|
41
|
+
const newState = {};
|
|
42
|
+
events.forEach(event => {
|
|
43
|
+
if (event.dataType === EventType.Inclination) {
|
|
44
|
+
newState.inclination = event.data;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (!isEmpty(newState)) {
|
|
48
|
+
this.setState(newState);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
onErrors = events => {
|
|
53
|
+
const newState = { errored: true };
|
|
54
|
+
events.forEach(event => {
|
|
55
|
+
if (event.dataType === EventType.Inclination) {
|
|
56
|
+
newState.inclination = event.error;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
this.setState(newState);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
render() {
|
|
63
|
+
return (
|
|
64
|
+
<div>
|
|
65
|
+
<StartStopComponent
|
|
66
|
+
onStart={() => this.start()}
|
|
67
|
+
onStop={() => this.stop()}
|
|
68
|
+
errored={this.state.errored} />
|
|
69
|
+
|
|
70
|
+
<p>{Utils.renderInclination(this.state.inclination)}</p>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default PositioningInclinationComponent;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import isEmpty from 'lodash.isempty';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import EventType from '../events/EventType';
|
|
6
|
+
import Utils from './Utils';
|
|
7
|
+
import PositioningHandler from '../PositioningHandler';
|
|
8
|
+
import StartStopComponent from './StartStopComponent';
|
|
9
|
+
import {
|
|
10
|
+
WGS84UserPosition, Itinerary
|
|
11
|
+
} from '@wemap/geo';
|
|
12
|
+
|
|
13
|
+
const INITIAL_LOCATION = new WGS84UserPosition(43.6091955, 3.8841255);
|
|
14
|
+
const INITIAL_HEADING = 191.9;
|
|
15
|
+
const ITINERARY = Itinerary.fromPoints([
|
|
16
|
+
[INITIAL_LOCATION.lat, INITIAL_LOCATION.lng],
|
|
17
|
+
[43.6091883, 3.8841242],
|
|
18
|
+
[43.6091709, 3.8842382],
|
|
19
|
+
[43.6091288, 3.884226],
|
|
20
|
+
[43.6091461, 3.884112]
|
|
21
|
+
], false);
|
|
22
|
+
|
|
23
|
+
class PositioningPoseComponent extends React.Component {
|
|
24
|
+
|
|
25
|
+
static propTypes = { positioningHandler: PropTypes.instanceOf(PositioningHandler).isRequired };
|
|
26
|
+
|
|
27
|
+
constructor(props, context) {
|
|
28
|
+
super(props, context);
|
|
29
|
+
this.state = {
|
|
30
|
+
position: null,
|
|
31
|
+
attitude: null,
|
|
32
|
+
errored: false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
start() {
|
|
38
|
+
this.id = this.props.positioningHandler.start(
|
|
39
|
+
[EventType.AbsolutePosition, EventType.AbsoluteAttitude],
|
|
40
|
+
this.onEvents,
|
|
41
|
+
this.onErrors,
|
|
42
|
+
{
|
|
43
|
+
waitInputPosition: true,
|
|
44
|
+
useMapMatching: true
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
this.props.positioningHandler.setPosition(this.id, INITIAL_LOCATION);
|
|
50
|
+
this.props.positioningHandler.setHeading(this.id, INITIAL_HEADING);
|
|
51
|
+
this.props.positioningHandler.setItinerary(this.id, ITINERARY);
|
|
52
|
+
}, 3000);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
stop() {
|
|
57
|
+
this.props.positioningHandler.stop(this.id);
|
|
58
|
+
this.setState({
|
|
59
|
+
position: null,
|
|
60
|
+
attitude: null,
|
|
61
|
+
errored: false
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
onEvents = (events) => {
|
|
66
|
+
const newState = {};
|
|
67
|
+
events.forEach(event => {
|
|
68
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
69
|
+
newState.position = event.data;
|
|
70
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
71
|
+
newState.attitude = event.data;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (!isEmpty(newState)) {
|
|
75
|
+
this.setState(newState);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
onErrors = events => {
|
|
80
|
+
const newState = { errored: true };
|
|
81
|
+
events.forEach(event => {
|
|
82
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
83
|
+
newState.position = event.error;
|
|
84
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
85
|
+
newState.attitude = event.error;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
this.setState(newState);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
const attitudeRender = Utils.renderAttitude(this.state.attitude);
|
|
93
|
+
const positionRender = Utils.renderPosition(this.state.position);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<div>
|
|
97
|
+
<StartStopComponent
|
|
98
|
+
onStart={() => this.start()}
|
|
99
|
+
onStop={() => this.stop()}
|
|
100
|
+
errored={this.state.errored} />
|
|
101
|
+
|
|
102
|
+
<h3>Position</h3>
|
|
103
|
+
{positionRender}
|
|
104
|
+
<h3>Attitude</h3>
|
|
105
|
+
{attitudeRender}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export default PositioningPoseComponent;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import RelativeAttitudeProvider from '../providers/attitude/RelativeAttitudeProvider';
|
|
4
|
+
import Utils from './Utils';
|
|
5
|
+
import EventType from '../events/EventType';
|
|
6
|
+
|
|
7
|
+
class RelativeAttitudeComponent extends React.Component {
|
|
8
|
+
|
|
9
|
+
constructor(props, context) {
|
|
10
|
+
super(props, context);
|
|
11
|
+
|
|
12
|
+
this.state = {
|
|
13
|
+
attitude: null,
|
|
14
|
+
deviceorientation: null
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
this.relativeAttitudeProvider = new RelativeAttitudeProvider(this.onEvent, this.onError);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
this.relativeAttitudeProvider.start();
|
|
22
|
+
window.addEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
componentWillUnmount() {
|
|
26
|
+
this.relativeAttitudeProvider.stop();
|
|
27
|
+
window.removeEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onEvent = events => {
|
|
31
|
+
events.forEach(event => {
|
|
32
|
+
if (event.dataType === EventType.RelativeAttitude) {
|
|
33
|
+
this.setState({ attitude: event.data });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
onError = events => {
|
|
39
|
+
events.forEach(event => {
|
|
40
|
+
if (event.dataType === EventType.RelativeAttitude) {
|
|
41
|
+
this.setState({ attitude: event.error });
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
onDeviceOrientationEventListener = (e) => this.setState({ deviceorientation: e });
|
|
47
|
+
|
|
48
|
+
setOffset(offset) {
|
|
49
|
+
this.relativeAttitudeProvider.setOffset(offset);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
|
|
54
|
+
let rawRender = <span>Not available</span>;
|
|
55
|
+
|
|
56
|
+
if (this.state.deviceorientation) {
|
|
57
|
+
const alpha = this.state.deviceorientation.alpha;
|
|
58
|
+
const beta = this.state.deviceorientation.beta;
|
|
59
|
+
const gamma = this.state.deviceorientation.gamma;
|
|
60
|
+
|
|
61
|
+
if (alpha && beta && gamma) {
|
|
62
|
+
rawRender = <p>alpha: {alpha.toFixed(2)}, <br />
|
|
63
|
+
beta: {beta.toFixed(2)}, <br />
|
|
64
|
+
gamma: {gamma.toFixed(2)}</p>;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const browserRender = Utils.renderAttitude(this.state.attitude);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div>
|
|
72
|
+
<h3>Raw:</h3>
|
|
73
|
+
{rawRender}
|
|
74
|
+
<h3>From browser:</h3>
|
|
75
|
+
{browserRender}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default RelativeAttitudeComponent;
|
|
82
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
componentWillUnmount() {
|
|
23
|
+
stop();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
stop() {
|
|
27
|
+
this.setState({started: false});
|
|
28
|
+
this.props.onStop();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
render() {
|
|
33
|
+
return (
|
|
34
|
+
<div>
|
|
35
|
+
<button onClick={() => this.start()}
|
|
36
|
+
disabled={(this.state.started && !this.props.errored)}>
|
|
37
|
+
Start
|
|
38
|
+
</button>
|
|
39
|
+
<button onClick={() => this.stop()}
|
|
40
|
+
disabled={!(this.state.started && !this.props.errored)}>
|
|
41
|
+
Stop
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default StartStopComponent;
|
package/src/components/Utils.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from 'react'; // eslint-disable-line no-unused-vars
|
|
2
|
+
import { rad2deg } from '@wemap/maths';
|
|
3
|
+
|
|
4
|
+
const NOT_AVAILABLE_STR = 'Not available';
|
|
2
5
|
|
|
3
6
|
class Utils {
|
|
4
7
|
|
|
@@ -8,8 +11,8 @@ class Utils {
|
|
|
8
11
|
return <p>Waiting</p>;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
if (attitude
|
|
12
|
-
return
|
|
14
|
+
if (attitude instanceof Error) {
|
|
15
|
+
return Utils.renderError(attitude);
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
const quaternion = attitude.quaternion;
|
|
@@ -30,6 +33,42 @@ class Utils {
|
|
|
30
33
|
Heading: {heading}</p>;
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
static renderPosition(position) {
|
|
37
|
+
|
|
38
|
+
if (!position) {
|
|
39
|
+
return <p>Waiting</p>;
|
|
40
|
+
}
|
|
41
|
+
if (position instanceof Error) {
|
|
42
|
+
return Utils.renderError(position);
|
|
43
|
+
}
|
|
44
|
+
return (
|
|
45
|
+
<p>
|
|
46
|
+
Latitude: {position.lat.toFixed(7)}<br />
|
|
47
|
+
Longitude: {position.lng.toFixed(7)}<br />
|
|
48
|
+
Altitude: {position.alt ? position.alt.toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
49
|
+
Bearing: {position.bearing ? position.bearing.toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
50
|
+
Accuracy: {position.accuracy ? position.accuracy.toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
51
|
+
Time: {position.time ? position.time.toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
52
|
+
Provider: {position.provider ? position.provider : NOT_AVAILABLE_STR}
|
|
53
|
+
</p>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static renderInclination(inclination) {
|
|
59
|
+
if (inclination === null) {
|
|
60
|
+
return 'Waiting';
|
|
61
|
+
}
|
|
62
|
+
if (inclination instanceof Error) {
|
|
63
|
+
return Utils.renderError(inclination);
|
|
64
|
+
}
|
|
65
|
+
return rad2deg(inclination).toFixed(2);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static renderError(error) {
|
|
69
|
+
return (<span><strong>[{error.constructor.name}]</strong> {error.message}</span>);
|
|
70
|
+
}
|
|
71
|
+
|
|
33
72
|
}
|
|
34
73
|
|
|
35
74
|
export default Utils;
|
package/src/components/index.js
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
import NavigationDebugApp from './NavigationDebugApp';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import ReactDOM from 'react-dom';
|
|
4
3
|
|
|
4
|
+
import AbsoluteAttitudeComponent from './AbsoluteAttitudeComponent';
|
|
5
|
+
import GnssWifiComponent from './GnssWifiComponent';
|
|
6
|
+
import GnssWifiPdrComponent from './GnssWifiPdrComponent';
|
|
7
|
+
import ImuComponent from './ImuComponent';
|
|
8
|
+
import InclinationComponent from './InclinationComponent';
|
|
9
|
+
import PdrComponent from './PdrComponent';
|
|
10
|
+
import PoseComponent from './PoseComponent';
|
|
11
|
+
import PositioningComponent from './PositioningComponent';
|
|
12
|
+
import RelativeAttitudeComponent from './RelativeAttitudeComponent';
|
|
13
|
+
|
|
5
14
|
const createReactElement = (component, container) => ReactDOM.render(
|
|
6
15
|
React.createElement(component, {}, null),
|
|
7
16
|
container
|
|
8
17
|
);
|
|
9
18
|
|
|
10
19
|
export {
|
|
11
|
-
|
|
20
|
+
AbsoluteAttitudeComponent,
|
|
21
|
+
ImuComponent,
|
|
22
|
+
InclinationComponent,
|
|
23
|
+
GnssWifiComponent,
|
|
24
|
+
GnssWifiPdrComponent,
|
|
25
|
+
PdrComponent,
|
|
26
|
+
PoseComponent,
|
|
27
|
+
PositioningComponent,
|
|
28
|
+
RelativeAttitudeComponent,
|
|
12
29
|
createReactElement
|
|
13
30
|
};
|