@wemap/positioning 1.2.0 → 1.2.2
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/package.json +3 -3
- package/src/attitude/AttitudeHandler.js +2 -3
- package/src/components/LocationSource.jsx +5 -5
- package/src/components/Others.jsx +2 -2
- package/src/index.js +0 -2
- package/src/providers/GnssLocationSource.js +2 -2
- package/src/providers/PdrLocationSource.js +12 -4
- package/src/providers/ProvidersLogger.js +1 -1
- package/src/providers/pdr/HeadingUnlocker.js +2 -2
- package/src/sensors/SensorsCompatibility.js +7 -5
- package/src/attitude/Attitude.js +0 -65
package/package.json
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@wemap/geo": "^0.1.
|
|
11
|
+
"@wemap/geo": "^0.1.3",
|
|
12
12
|
"@wemap/logger": "^0.1.4",
|
|
13
|
-
"@wemap/maths": "^0.1.
|
|
13
|
+
"@wemap/maths": "^0.1.2",
|
|
14
14
|
"file-saver": "^2.0.2",
|
|
15
15
|
"geomagnetism": "^0.1.0",
|
|
16
16
|
"jszip": "^3.2.2",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"test": "mocha -r esm \"src/**/*.spec.js\"",
|
|
79
79
|
"release": "node ./scripts/release-github.js"
|
|
80
80
|
},
|
|
81
|
-
"version": "1.2.
|
|
81
|
+
"version": "1.2.2"
|
|
82
82
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import geomagnetism from 'geomagnetism';
|
|
2
2
|
|
|
3
|
+
import { Attitude } from '@wemap/geo';
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
+
deg2rad, Quaternion
|
|
5
6
|
} from '@wemap/maths';
|
|
6
7
|
|
|
7
|
-
import Attitude from './Attitude';
|
|
8
8
|
import EkfAttitude from './EkfAttitude';
|
|
9
9
|
import SensorsCompatibility from '../sensors/SensorsCompatibility';
|
|
10
10
|
|
|
11
|
-
const { deg2rad } = MathUtils;
|
|
12
11
|
|
|
13
12
|
const RelativeMethod = {
|
|
14
13
|
AUTOMATIC: 0,
|
|
@@ -10,7 +10,7 @@ import 'mapbox-gl/dist/mapbox-gl.css';
|
|
|
10
10
|
import {
|
|
11
11
|
WGS84UserPosition, Itinerary, Edge
|
|
12
12
|
} from '@wemap/geo';
|
|
13
|
-
import {
|
|
13
|
+
import { deg2rad } from '@wemap/maths';
|
|
14
14
|
|
|
15
15
|
import IPLocationSource from '../providers/IPLocationSource';
|
|
16
16
|
import GnssLocationSource from '../providers/GnssLocationSource';
|
|
@@ -91,14 +91,14 @@ class LocationSource extends React.Component {
|
|
|
91
91
|
'smoother': false
|
|
92
92
|
});
|
|
93
93
|
pdr1LocationSource.setLocation(INITIAL_LOCATION);
|
|
94
|
-
pdr1LocationSource.setHeading(
|
|
94
|
+
pdr1LocationSource.setHeading(deg2rad(INITIAL_HEADING));
|
|
95
95
|
|
|
96
96
|
const pdr2LocationSource = new PdrLocationSource(fn, {
|
|
97
97
|
'stepdetectionlocker': false,
|
|
98
98
|
'smoother': false
|
|
99
99
|
});
|
|
100
100
|
pdr2LocationSource.setLocation(INITIAL_LOCATION);
|
|
101
|
-
pdr2LocationSource.setHeading(
|
|
101
|
+
pdr2LocationSource.setHeading(deg2rad(INITIAL_HEADING));
|
|
102
102
|
pdr2LocationSource.enableMapMatching(ITINERARY);
|
|
103
103
|
|
|
104
104
|
const pdr3LocationSource = new PdrLocationSource(fn, {
|
|
@@ -106,7 +106,7 @@ class LocationSource extends React.Component {
|
|
|
106
106
|
'smoother': false
|
|
107
107
|
});
|
|
108
108
|
pdr3LocationSource.setLocation(INITIAL_LOCATION);
|
|
109
|
-
pdr3LocationSource.setHeading(
|
|
109
|
+
pdr3LocationSource.setHeading(deg2rad(INITIAL_HEADING));
|
|
110
110
|
pdr3LocationSource.enableMapMatching(ITINERARY);
|
|
111
111
|
pdr3LocationSource.setItinerary(ITINERARY);
|
|
112
112
|
|
|
@@ -115,7 +115,7 @@ class LocationSource extends React.Component {
|
|
|
115
115
|
'smoother': true
|
|
116
116
|
});
|
|
117
117
|
pdr4LocationSource.setLocation(INITIAL_LOCATION);
|
|
118
|
-
pdr4LocationSource.setHeading(
|
|
118
|
+
pdr4LocationSource.setHeading(deg2rad(INITIAL_HEADING));
|
|
119
119
|
pdr4LocationSource.enableMapMatching(ITINERARY);
|
|
120
120
|
pdr4LocationSource.setItinerary(ITINERARY);
|
|
121
121
|
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { Constants as GeoConstants } from '@wemap/geo';
|
|
4
4
|
import {
|
|
5
|
-
Quaternion, Vector3,
|
|
5
|
+
Quaternion, Vector3, rad2deg
|
|
6
6
|
} from '@wemap/maths';
|
|
7
7
|
|
|
8
8
|
import AttitudeHandler from '../attitude/AttitudeHandler';
|
|
@@ -93,7 +93,7 @@ class Others extends React.Component {
|
|
|
93
93
|
} else if (inclination === -1) {
|
|
94
94
|
inclinationString += 'Not available';
|
|
95
95
|
} else {
|
|
96
|
-
inclinationString +=
|
|
96
|
+
inclinationString += rad2deg(inclination).toFixed(2);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
let stepCounterLadetto = 'StepCounter Ladetto: ';
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WGS84UserPosition } from '@wemap/geo';
|
|
2
|
-
import {
|
|
2
|
+
import { deg2rad } from '@wemap/maths';
|
|
3
3
|
|
|
4
4
|
import LocationSource from './LocationSource';
|
|
5
5
|
import AttitudeHandler from '../attitude/AttitudeHandler';
|
|
@@ -58,7 +58,7 @@ class GnssLocationSource extends LocationSource {
|
|
|
58
58
|
|
|
59
59
|
let bearing;
|
|
60
60
|
if (coords.heading) {
|
|
61
|
-
bearing =
|
|
61
|
+
bearing = deg2rad(coords.heading);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
const timestamp = SensorsLoggerUtils.unixTimestampToPerformanceNow(position.timestamp) / 1e3;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import noop from 'lodash.noop';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
Itinerary, WGS84UserPosition
|
|
4
|
+
Constants as GeoConstants, Itinerary, WGS84UserPosition
|
|
5
5
|
} from '@wemap/geo';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
rad2deg, Quaternion
|
|
8
|
+
} from '@wemap/maths';
|
|
7
9
|
|
|
8
10
|
import LocationSource from './LocationSource';
|
|
9
11
|
import AttitudeHandler from '../attitude/AttitudeHandler';
|
|
@@ -189,7 +191,7 @@ class PdrLocationSource extends LocationSource {
|
|
|
189
191
|
/**
|
|
190
192
|
* Step Detection and Step Size Detection
|
|
191
193
|
*/
|
|
192
|
-
const linearAcc =
|
|
194
|
+
const linearAcc = PdrLocationSource.computeLinearAcceleration(
|
|
193
195
|
this.pose.attitude.quaternion, acceleration);
|
|
194
196
|
const stepDetected = this.stepDetection.compute(timestamp, linearAcc, motionEvent.gyr);
|
|
195
197
|
|
|
@@ -227,7 +229,7 @@ class PdrLocationSource extends LocationSource {
|
|
|
227
229
|
*/
|
|
228
230
|
const newLocationWithoutMM = previousLocation.clone();
|
|
229
231
|
newLocationWithoutMM.move(stepSize, heading);
|
|
230
|
-
newLocationWithoutMM.bearing =
|
|
232
|
+
newLocationWithoutMM.bearing = rad2deg(heading);
|
|
231
233
|
newLocationWithoutMM.time = timestamp;
|
|
232
234
|
|
|
233
235
|
if (!this.mapMatching) {
|
|
@@ -307,6 +309,12 @@ class PdrLocationSource extends LocationSource {
|
|
|
307
309
|
this.stepDetectionLocker.setWaitingOrientation(orientation);
|
|
308
310
|
}
|
|
309
311
|
|
|
312
|
+
// Linear acceleration in ENU
|
|
313
|
+
static computeLinearAcceleration(quaternion, acc) {
|
|
314
|
+
const linearAcc = Quaternion.rotate(Quaternion.inverse(quaternion), acc);
|
|
315
|
+
linearAcc[2] -= GeoConstants.EARTH_GRAVITY;
|
|
316
|
+
return linearAcc;
|
|
317
|
+
}
|
|
310
318
|
}
|
|
311
319
|
|
|
312
320
|
export default PdrLocationSource;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import isnumber from 'lodash.isnumber';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { diffAngle } from '@wemap/maths';
|
|
4
4
|
|
|
5
5
|
const LO_ANGLE = 15 * Math.PI / 180;
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ class HeadingUnlocker {
|
|
|
29
29
|
throw new Error('HeadingUnlocker is already unlocked');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
if (Math.abs(
|
|
32
|
+
if (Math.abs(diffAngle(heading, this.waitingOrientation)) < LO_ANGLE) {
|
|
33
33
|
this.locked = false;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* global Accelerometer, Gyroscope, Magnetometer, AbsoluteOrientationSensor, RelativeOrientationSensor */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
deg2rad, rad2deg, Quaternion, Rotations
|
|
5
|
+
} from '@wemap/maths';
|
|
4
6
|
|
|
5
7
|
import SensorsLogger from './SensorsLogger';
|
|
6
8
|
|
|
@@ -405,11 +407,11 @@ class SensorsCompatibility {
|
|
|
405
407
|
}
|
|
406
408
|
|
|
407
409
|
static headingEusToEnu(_alpha, _beta, _gamma) {
|
|
408
|
-
const alpha =
|
|
409
|
-
const beta =
|
|
410
|
-
const gamma =
|
|
410
|
+
const alpha = deg2rad(_alpha);
|
|
411
|
+
const beta = deg2rad(_beta);
|
|
412
|
+
const gamma = deg2rad(_gamma);
|
|
411
413
|
|
|
412
|
-
return
|
|
414
|
+
return rad2deg(Math.atan2(
|
|
413
415
|
Math.cos(alpha) * Math.sin(gamma) + Math.cos(gamma) * Math.sin(alpha) * Math.sin(beta),
|
|
414
416
|
Math.sin(alpha) * Math.sin(gamma) - Math.cos(alpha) * Math.cos(gamma) * Math.sin(beta)));
|
|
415
417
|
}
|
package/src/attitude/Attitude.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Rotations, Utils as MathUtils, Quaternion
|
|
3
|
-
} from '@wemap/maths';
|
|
4
|
-
|
|
5
|
-
const rotxM90 = Quaternion.fromAxisAngle([1, 0, 0], -Math.PI / 2);
|
|
6
|
-
|
|
7
|
-
class Attitude {
|
|
8
|
-
|
|
9
|
-
quaternion = [1, 0, 0, 0];
|
|
10
|
-
quaternionThreeJsV = null;
|
|
11
|
-
headingV = null;
|
|
12
|
-
headingDegreesV = null;
|
|
13
|
-
eulerAnglesV = null;
|
|
14
|
-
eulerAnglesDegreesV = null;
|
|
15
|
-
|
|
16
|
-
constructor(quaternion) {
|
|
17
|
-
this.quaternion = quaternion;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get eulerAngles() {
|
|
21
|
-
if (!this.eulerAnglesV) {
|
|
22
|
-
this.eulerAnglesV = Rotations.quaternionToEulerZXY(this.quaternion);
|
|
23
|
-
}
|
|
24
|
-
return this.eulerAnglesV;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get eulerAnglesDegrees() {
|
|
28
|
-
if (!this.eulerAnglesDegreesV) {
|
|
29
|
-
this.eulerAnglesDegreesV = Rotations.quaternionToEulerZXYDegrees(this.quaternion);
|
|
30
|
-
}
|
|
31
|
-
return this.eulerAnglesDegreesV;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get heading() {
|
|
35
|
-
if (!this.headingV) {
|
|
36
|
-
this.headingV = Rotations.getHeadingFromQuaternion(this.quaternion) + MathUtils.deg2rad(window.orientation || 0);
|
|
37
|
-
}
|
|
38
|
-
return this.headingV;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get headingDegrees() {
|
|
42
|
-
if (!this.headingDegreesV) {
|
|
43
|
-
this.headingDegreesV = MathUtils.rad2deg(Rotations.getHeadingFromQuaternion(this.quaternion)) + (window.orientation || 0);
|
|
44
|
-
}
|
|
45
|
-
return this.headingDegreesV;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get quaternionThreeJs() {
|
|
49
|
-
if (!this.quaternionThreeJsV) {
|
|
50
|
-
this.quaternionThreeJsV = Quaternion.wxyz2xyzw(Quaternion.multiply(rotxM90, this.quaternion));
|
|
51
|
-
}
|
|
52
|
-
return this.quaternionThreeJsV;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
toMessage() {
|
|
56
|
-
return this.quaternion;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
static fromMessage(message) {
|
|
60
|
-
return new Attitude(message);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default Attitude;
|