@wemap/providers 4.0.0 → 4.0.1
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/src/AbsoluteAttitudeComponent.jsx +4 -1
- package/package.json +5 -5
- package/src/Providers.js +26 -82
- package/src/errors/AskImuOnDesktopError.js +4 -3
- package/src/errors/ContainsIgnoredProviderError.js +4 -3
- package/src/errors/GeolocationApiMissingError.js +4 -3
- package/src/errors/GeolocationPermissionDeniedError.js +4 -3
- package/src/errors/GeolocationPositionUnavailableError.js +4 -3
- package/src/errors/IpResolveServerError.js +4 -3
- package/src/errors/MissingAccelerometerError.js +3 -3
- package/src/errors/MissingArCoreError.js +4 -3
- package/src/errors/MissingGyroscopeError.js +3 -3
- package/src/errors/MissingNativeInterfaceError.js +4 -3
- package/src/errors/MissingSensorError.js +4 -3
- package/src/errors/NoProviderFoundError.js +4 -3
- package/src/events/ProvidersLoggerOld.js +35 -34
- package/src/mapmatching/MapMatchingHandler.js +15 -27
- package/src/providers/FakeProvider.spec.js +15 -15
- package/src/providers/Provider.js +2 -19
- package/src/providers/Provider.spec.js +18 -28
- package/src/providers/attitude/absolute/{AbsoluteAttitudeProvider.js → AbsoluteAttitude.js} +5 -6
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromBrowserProvider.js → AbsoluteAttitudeFromBrowser.js} +4 -4
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromRelAttProvider.js → AbsoluteAttitudeFromRelAtt.js} +6 -5
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFusedProvider.js → AbsoluteAttitudeFused.js} +3 -3
- package/src/providers/attitude/relative/{RelativeAttitudeProvider.js → RelativeAttitude.js} +4 -5
- package/src/providers/attitude/relative/{RelativeAttitudeFromBrowserProvider.js → RelativeAttitudeFromBrowser.js} +4 -4
- package/src/providers/attitude/relative/{RelativeAttitudeFromEkfProvider.js → RelativeAttitudeFromEkf.js} +7 -7
- package/src/providers/attitude/relative/{RelativeAttitudeFromInertialProvider.js → RelativeAttitudeFromInertial.js} +5 -5
- package/src/providers/imu/{AccelerometerProvider.js → Accelerometer.js} +3 -3
- package/src/providers/imu/{GyroscopeProvider.js → Gyroscope.js} +3 -3
- package/src/providers/imu/{ImuProvider.js → Imu.js} +3 -3
- package/src/providers/inclination/{InclinationProvider.js → Inclination.js} +4 -5
- package/src/providers/inclination/{InclinationFromAccProvider.js → InclinationFromAcc.js} +4 -3
- package/src/providers/inclination/{InclinationFromRelativeAttitudeProvider.js → InclinationFromRelativeAttitude.js} +4 -3
- package/src/providers/legacy/helpers/ThugDetector.js +7 -7
- package/src/providers/others/{BarcodeProvider.js → Barcode.js} +3 -3
- package/src/providers/others/{CameraNativeProvider.js → CameraNative.js} +2 -2
- package/src/providers/others/{CameraProjectionMatrixProvider.js → CameraProjectionMatrix.js} +3 -3
- package/src/providers/position/absolute/{AbsolutePositionProvider.js → AbsolutePosition.js} +11 -13
- package/src/providers/position/absolute/{AbsolutePositionFromRelProvider.js → AbsolutePositionFromRel.js} +4 -5
- package/src/providers/position/absolute/{GnssWifiProvider.js → GnssWifi.js} +9 -8
- package/src/providers/position/absolute/{IpProvider.js → Ip.js} +2 -2
- package/src/providers/position/relative/{ArCoreProvider.js → ArCore.js} +28 -30
- package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js} +5 -5
- package/src/providers/position/relative/{GeoRelativePositionFromArCoreProvider.js → GeoRelativePositionFromArCore.js} +4 -5
- package/src/providers/position/relative/{PdrProvider.js → Pdr.js} +5 -5
- package/src/providers/steps/{StepDetectionProvider.js → StepDetection.js} +6 -5
- package/src/providers/steps/StepDetectionLadetto.js +12 -13
- package/src/providers/steps/StepDetectionMinMaxPeaks.js +19 -17
- package/src/providers/steps/StepDetectionMinMaxPeaks2.js +17 -18
|
@@ -10,11 +10,6 @@ import GeolocationPermissionDeniedError from '../../../errors/GeolocationPermiss
|
|
|
10
10
|
import GeolocationPositionUnavailableError from '../../../errors/GeolocationPositionUnavailableError.js';
|
|
11
11
|
import Constants from '../../Constants.js';
|
|
12
12
|
|
|
13
|
-
const POSITION_OPTIONS = {
|
|
14
|
-
enableHighAccuracy: true,
|
|
15
|
-
timeout: Infinity,
|
|
16
|
-
maximumAge: 0
|
|
17
|
-
};
|
|
18
13
|
|
|
19
14
|
/**
|
|
20
15
|
* GnssWifiProvider is a provider based on navigator.geolocation.
|
|
@@ -22,7 +17,13 @@ const POSITION_OPTIONS = {
|
|
|
22
17
|
* by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
|
|
23
18
|
* "GnssWifi".
|
|
24
19
|
*/
|
|
25
|
-
class
|
|
20
|
+
class GnssWifi extends Provider {
|
|
21
|
+
|
|
22
|
+
static POSITION_OPTIONS = {
|
|
23
|
+
enableHighAccuracy: true,
|
|
24
|
+
timeout: Infinity,
|
|
25
|
+
maximumAge: 0
|
|
26
|
+
};
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* @override
|
|
@@ -55,7 +56,7 @@ class GnssWifiProvider extends Provider {
|
|
|
55
56
|
this.geoLocationId = navigator.geolocation.watchPosition(
|
|
56
57
|
this.onNewPosition,
|
|
57
58
|
this.onPositionError,
|
|
58
|
-
POSITION_OPTIONS
|
|
59
|
+
GnssWifi.POSITION_OPTIONS
|
|
59
60
|
);
|
|
60
61
|
|
|
61
62
|
}
|
|
@@ -122,4 +123,4 @@ class GnssWifiProvider extends Provider {
|
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
export default
|
|
126
|
+
export default new GnssWifi();
|
|
@@ -11,7 +11,7 @@ import IpResolveServerError from '../../../errors/IpResolveServerError.js';
|
|
|
11
11
|
* by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
|
|
12
12
|
* "GnssWifi".
|
|
13
13
|
*/
|
|
14
|
-
class
|
|
14
|
+
class Ip extends Provider {
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @override
|
|
@@ -63,4 +63,4 @@ class IpProvider extends Provider {
|
|
|
63
63
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export default
|
|
66
|
+
export default new Ip();
|
|
@@ -10,28 +10,26 @@ import EventType from '../../../events/EventType.js';
|
|
|
10
10
|
import MissingArCoreError from '../../../errors/MissingArCoreError.js';
|
|
11
11
|
import MissingNativeInterfaceError from '../../../errors/MissingNativeInterfaceError.js';
|
|
12
12
|
import ProviderState from '../../ProviderState.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
class ArCoreProvider extends Provider {
|
|
13
|
+
class ArCore extends Provider {
|
|
14
|
+
|
|
15
|
+
static Payload = {
|
|
16
|
+
Pose: {
|
|
17
|
+
ref: 2 ** 0,
|
|
18
|
+
size: 7
|
|
19
|
+
},
|
|
20
|
+
Barcode: {
|
|
21
|
+
ref: 2 ** 1,
|
|
22
|
+
size: 1
|
|
23
|
+
},
|
|
24
|
+
ProjMat: {
|
|
25
|
+
ref: 2 ** 2,
|
|
26
|
+
size: 16
|
|
27
|
+
},
|
|
28
|
+
ImageRef: {
|
|
29
|
+
ref: 2 ** 3,
|
|
30
|
+
size: 1
|
|
31
|
+
}
|
|
32
|
+
};
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* default relative attitude drift in rad.second-1
|
|
@@ -97,7 +95,7 @@ class ArCoreProvider extends Provider {
|
|
|
97
95
|
|
|
98
96
|
const time = TimeUtils.preciseTime() / 1e3;
|
|
99
97
|
|
|
100
|
-
if (ref & Payload.Pose.ref) {
|
|
98
|
+
if (ref & ArCore.Payload.Pose.ref) {
|
|
101
99
|
|
|
102
100
|
const attitude = new Attitude(
|
|
103
101
|
payload.slice(bufferIndex, bufferIndex + 4),
|
|
@@ -117,18 +115,18 @@ class ArCoreProvider extends Provider {
|
|
|
117
115
|
this.previousPosition = newPosition;
|
|
118
116
|
events.push(this.createEvent(EventType.RelativePosition, position));
|
|
119
117
|
|
|
120
|
-
bufferIndex += Payload.Pose.size;
|
|
118
|
+
bufferIndex += ArCore.Payload.Pose.size;
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
if (ref & Payload.Barcode.ref) {
|
|
121
|
+
if (ref & ArCore.Payload.Barcode.ref) {
|
|
124
122
|
events.push(this.createEvent(EventType.Barcode, payload[bufferIndex]));
|
|
125
|
-
bufferIndex += Payload.Barcode.size;
|
|
123
|
+
bufferIndex += ArCore.Payload.Barcode.size;
|
|
126
124
|
}
|
|
127
125
|
|
|
128
|
-
if (ref & Payload.ProjMat.ref) {
|
|
129
|
-
const projMatrix = payload.slice(bufferIndex, bufferIndex + Payload.ProjMat.size);
|
|
126
|
+
if (ref & ArCore.Payload.ProjMat.ref) {
|
|
127
|
+
const projMatrix = payload.slice(bufferIndex, bufferIndex + ArCore.Payload.ProjMat.size);
|
|
130
128
|
events.push(this.createEvent(EventType.CameraProjectionMatrix, projMatrix));
|
|
131
|
-
bufferIndex += Payload.ProjMat.size;
|
|
129
|
+
bufferIndex += ArCore.Payload.ProjMat.size;
|
|
132
130
|
}
|
|
133
131
|
|
|
134
132
|
if (events.length !== 0) {
|
|
@@ -197,4 +195,4 @@ class ArCoreProvider extends Provider {
|
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
export default
|
|
198
|
+
export default new ArCore();
|
package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js}
RENAMED
|
@@ -2,11 +2,11 @@ import { PromiseUtils } from '@wemap/utils';
|
|
|
2
2
|
|
|
3
3
|
import MetaProvider from '../../MetaProvider.js';
|
|
4
4
|
import EventType from '../../../events/EventType.js';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
} from '../../../Providers.js';
|
|
5
|
+
import GeoRelativePositionFromArCore from './GeoRelativePositionFromArCore.js';
|
|
6
|
+
import Pdr from './Pdr.js';
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
class GeoRelativePosition extends MetaProvider {
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @override
|
|
@@ -65,4 +65,4 @@ class GeoRelativePositionProvider extends MetaProvider {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export default
|
|
68
|
+
export default new GeoRelativePosition();
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { GeoRelativePosition } from '@wemap/geo';
|
|
2
2
|
|
|
3
3
|
import EventType from '../../../events/EventType.js';
|
|
4
|
+
import AbsoluteAttitude from '../../attitude/absolute/AbsoluteAttitude.js';
|
|
4
5
|
import Provider from '../../Provider.js';
|
|
5
|
-
import
|
|
6
|
-
ArCore, AbsoluteAttitude
|
|
7
|
-
} from '../../../Providers.js';
|
|
6
|
+
import ArCore from './ArCore.js';
|
|
8
7
|
|
|
9
|
-
class
|
|
8
|
+
class GeoRelativePositionFromArCore extends Provider {
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* @override
|
|
@@ -89,4 +88,4 @@ class GeoRelativePositionFromArCoreProvider extends Provider {
|
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
export default
|
|
91
|
+
export default new GeoRelativePositionFromArCore();
|
|
@@ -3,11 +3,11 @@ import { deg2rad } from '@wemap/maths';
|
|
|
3
3
|
|
|
4
4
|
import Provider from '../../Provider.js';
|
|
5
5
|
import EventType from '../../../events/EventType.js';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
} from '../../../Providers.js';
|
|
6
|
+
import StepDetection from '../../steps/StepDetection.js';
|
|
7
|
+
import AbsoluteAttitude from '../../attitude/absolute/AbsoluteAttitude.js';
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
class Pdr extends Provider {
|
|
11
11
|
|
|
12
12
|
// https://ieeexplore.ieee.org/document/7346766
|
|
13
13
|
misalignment = [1, 0, 0, 0];
|
|
@@ -128,4 +128,4 @@ class PdrProvider extends Provider {
|
|
|
128
128
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
export default
|
|
131
|
+
export default new Pdr();
|
|
@@ -2,13 +2,14 @@ import { Constants as GeoConstants } from '@wemap/geo';
|
|
|
2
2
|
import { Quaternion } from '@wemap/maths';
|
|
3
3
|
|
|
4
4
|
import EventType from '../../events/EventType.js';
|
|
5
|
+
import RelativeAttitudeFromInertial from '../attitude/relative/RelativeAttitudeFromInertial.js';
|
|
6
|
+
import Accelerometer from '../imu/Accelerometer.js';
|
|
7
|
+
import Gyroscope from '../imu/Gyroscope.js';
|
|
5
8
|
import Provider from '../Provider.js';
|
|
6
9
|
import StepDetectionMinMaxPeaks2 from './StepDetectionMinMaxPeaks2.js';
|
|
7
|
-
import {
|
|
8
|
-
Accelerometer, Gyroscope, RelativeAttitudeFromInertial
|
|
9
|
-
} from '../../Providers.js';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
class StepDetection extends Provider {
|
|
12
13
|
|
|
13
14
|
constructor() {
|
|
14
15
|
super();
|
|
@@ -103,4 +104,4 @@ class StepDetectionProvider extends Provider {
|
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
export default
|
|
107
|
+
export default new StepDetection();
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
+
class StepDetectionLadetto {
|
|
1
2
|
|
|
2
|
-
// in seconds
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// in Hz
|
|
6
|
-
const MAX_FRENQUENCY = 4;
|
|
7
|
-
const MIN_FRENQUENCY = 1;
|
|
3
|
+
// in seconds
|
|
4
|
+
static MIN_TIME_BETWEEN_STEPS = 0.4;
|
|
8
5
|
|
|
9
|
-
// in
|
|
10
|
-
|
|
6
|
+
// in Hz
|
|
7
|
+
static MAX_FRENQUENCY = 4;
|
|
8
|
+
static MIN_FRENQUENCY = 1;
|
|
11
9
|
|
|
10
|
+
// in m.s-2
|
|
11
|
+
static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD = 1;
|
|
12
12
|
|
|
13
|
-
class StepDetectionLadetto {
|
|
14
13
|
|
|
15
14
|
lastVerticalAcc = 0;
|
|
16
15
|
maxAcceleration = 0;
|
|
17
|
-
lastStepTimestamp = -MIN_TIME_BETWEEN_STEPS;
|
|
16
|
+
lastStepTimestamp = -StepDetectionLadetto.MIN_TIME_BETWEEN_STEPS;
|
|
18
17
|
|
|
19
18
|
compute(timestamp, linearAcc) {
|
|
20
19
|
|
|
@@ -29,12 +28,12 @@ class StepDetectionLadetto {
|
|
|
29
28
|
if (verticalAcc > this.maxAcceleration) {
|
|
30
29
|
this.maxAcceleration = verticalAcc;
|
|
31
30
|
}
|
|
32
|
-
} else if (this.maxAcceleration > VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD
|
|
33
|
-
&& timeInterval > MIN_TIME_BETWEEN_STEPS) {
|
|
31
|
+
} else if (this.maxAcceleration > StepDetectionLadetto.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD
|
|
32
|
+
&& timeInterval > StepDetectionLadetto.MIN_TIME_BETWEEN_STEPS) {
|
|
34
33
|
this.maxAcceleration = 0;
|
|
35
34
|
|
|
36
35
|
const diffTime = timestamp - this.lastStepTimestamp;
|
|
37
|
-
this.frequency = Math.min(Math.max((1 / diffTime), MIN_FRENQUENCY), MAX_FRENQUENCY);
|
|
36
|
+
this.frequency = Math.min(Math.max((1 / diffTime), StepDetectionLadetto.MIN_FRENQUENCY), StepDetectionLadetto.MAX_FRENQUENCY);
|
|
38
37
|
|
|
39
38
|
stepDetected = true;
|
|
40
39
|
this.lastStepTimestamp = timestamp;
|
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
|
|
2
|
-
// in seconds
|
|
3
|
-
const WINDOW_TIME = 0.3;
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
const MIN_TIME_BETWEEN_STEPS = 0.4;
|
|
3
|
+
class StepDetectionMinMaxPeaks {
|
|
7
4
|
|
|
8
|
-
// in Hz
|
|
9
|
-
const MAX_FRENQUENCY = 4;
|
|
10
|
-
const MIN_FRENQUENCY = 1;
|
|
11
5
|
|
|
12
|
-
// in
|
|
13
|
-
|
|
14
|
-
const VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD = -1;
|
|
6
|
+
// in seconds
|
|
7
|
+
static WINDOW_TIME = 0.3;
|
|
15
8
|
|
|
9
|
+
// in seconds
|
|
10
|
+
static MIN_TIME_BETWEEN_STEPS = 0.4;
|
|
11
|
+
|
|
12
|
+
// in Hz
|
|
13
|
+
static MAX_FRENQUENCY = 4;
|
|
14
|
+
static MIN_FRENQUENCY = 1;
|
|
15
|
+
|
|
16
|
+
// in m.s-2
|
|
17
|
+
static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD = 1.5;
|
|
18
|
+
static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD = -1;
|
|
16
19
|
|
|
17
|
-
class StepDetectionMinMaxPeaks {
|
|
18
20
|
|
|
19
21
|
constructor() {
|
|
20
22
|
this.slidingWindow = [];
|
|
21
23
|
|
|
22
|
-
this.lastStepTimestamp = -MIN_TIME_BETWEEN_STEPS;
|
|
24
|
+
this.lastStepTimestamp = -StepDetectionMinMaxPeaks.MIN_TIME_BETWEEN_STEPS;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
compute(timestamp, linearAcc) {
|
|
27
29
|
|
|
28
|
-
if (this.lastStepTimestamp && this.lastStepTimestamp + MIN_TIME_BETWEEN_STEPS > timestamp) {
|
|
30
|
+
if (this.lastStepTimestamp && this.lastStepTimestamp + StepDetectionMinMaxPeaks.MIN_TIME_BETWEEN_STEPS > timestamp) {
|
|
29
31
|
return false;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
let maxValue = Number.MIN_SAFE_INTEGER;
|
|
33
35
|
let minValue = Number.MAX_SAFE_INTEGER;
|
|
34
36
|
|
|
35
|
-
const windowTime = WINDOW_TIME;
|
|
37
|
+
const windowTime = StepDetectionMinMaxPeaks.WINDOW_TIME;
|
|
36
38
|
this.slidingWindow.forEach(function(item, index, object) {
|
|
37
39
|
if (item.timestamp < timestamp - windowTime) {
|
|
38
40
|
object.splice(index, 1);
|
|
@@ -47,11 +49,11 @@ class StepDetectionMinMaxPeaks {
|
|
|
47
49
|
});
|
|
48
50
|
|
|
49
51
|
|
|
50
|
-
if (maxValue > VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD
|
|
51
|
-
&& minValue < VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
|
|
52
|
+
if (maxValue > StepDetectionMinMaxPeaks.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD
|
|
53
|
+
&& minValue < StepDetectionMinMaxPeaks.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
|
|
52
54
|
|
|
53
55
|
const timeInterval = this.lastStepTimestamp ? timestamp - this.lastStepTimestamp : 1;
|
|
54
|
-
this.frequency = Math.min(Math.max((1 / timeInterval), MIN_FRENQUENCY), MAX_FRENQUENCY);
|
|
56
|
+
this.frequency = Math.min(Math.max((1 / timeInterval), StepDetectionMinMaxPeaks.MIN_FRENQUENCY), StepDetectionMinMaxPeaks.MAX_FRENQUENCY);
|
|
55
57
|
|
|
56
58
|
this.lastStepTimestamp = timestamp;
|
|
57
59
|
return true;
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
+
class StepDetectionMinMaxPeaks2 {
|
|
1
2
|
|
|
2
|
-
// in seconds
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// in seconds
|
|
6
|
-
const MIN_TIME_BETWEEN_STEPS = 0.4;
|
|
3
|
+
// in seconds
|
|
4
|
+
static WINDOW_TIME = 0.3;
|
|
7
5
|
|
|
8
|
-
// in
|
|
9
|
-
|
|
10
|
-
const MIN_FRENQUENCY = 1;
|
|
6
|
+
// in seconds
|
|
7
|
+
static MIN_TIME_BETWEEN_STEPS = 0.4;
|
|
11
8
|
|
|
12
|
-
// in
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
// in Hz
|
|
10
|
+
static MAX_FRENQUENCY = 4;
|
|
11
|
+
static MIN_FRENQUENCY = 1;
|
|
15
12
|
|
|
13
|
+
// in m.s-2
|
|
14
|
+
static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD = 0.75;
|
|
15
|
+
static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD = -0.3;
|
|
16
16
|
|
|
17
|
-
class StepDetectionMinMaxPeaks2 {
|
|
18
17
|
|
|
19
18
|
constructor() {
|
|
20
19
|
this.slidingWindow = [];
|
|
21
20
|
|
|
22
|
-
this.lastStepTimestamp = -MIN_TIME_BETWEEN_STEPS;
|
|
21
|
+
this.lastStepTimestamp = -StepDetectionMinMaxPeaks2.MIN_TIME_BETWEEN_STEPS;
|
|
23
22
|
this.previousVerticalAcc = 0;
|
|
24
23
|
this.influence = 0.2;
|
|
25
24
|
}
|
|
@@ -35,7 +34,7 @@ class StepDetectionMinMaxPeaks2 {
|
|
|
35
34
|
return false;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
if (this.lastStepTimestamp && this.lastStepTimestamp + MIN_TIME_BETWEEN_STEPS > timestamp) {
|
|
37
|
+
if (this.lastStepTimestamp && this.lastStepTimestamp + StepDetectionMinMaxPeaks2.MIN_TIME_BETWEEN_STEPS > timestamp) {
|
|
39
38
|
return false;
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -43,7 +42,7 @@ class StepDetectionMinMaxPeaks2 {
|
|
|
43
42
|
let minValue = Number.MAX_SAFE_INTEGER;
|
|
44
43
|
|
|
45
44
|
this.slidingWindow.forEach(function(item, index, object) {
|
|
46
|
-
if (item.timestamp < timestamp - WINDOW_TIME) {
|
|
45
|
+
if (item.timestamp < timestamp - StepDetectionMinMaxPeaks2.WINDOW_TIME) {
|
|
47
46
|
object.splice(index, 1);
|
|
48
47
|
} else {
|
|
49
48
|
maxValue = Math.max(item.verticalAcc, maxValue);
|
|
@@ -56,11 +55,11 @@ class StepDetectionMinMaxPeaks2 {
|
|
|
56
55
|
});
|
|
57
56
|
|
|
58
57
|
|
|
59
|
-
if (maxValue > VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD
|
|
60
|
-
&& minValue < VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
|
|
58
|
+
if (maxValue > StepDetectionMinMaxPeaks2.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD
|
|
59
|
+
&& minValue < StepDetectionMinMaxPeaks2.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
|
|
61
60
|
|
|
62
61
|
const timeInterval = this.lastStepTimestamp ? timestamp - this.lastStepTimestamp : 1;
|
|
63
|
-
this.frequency = Math.min(Math.max((1 / timeInterval), MIN_FRENQUENCY), MAX_FRENQUENCY);
|
|
62
|
+
this.frequency = Math.min(Math.max((1 / timeInterval), StepDetectionMinMaxPeaks2.MIN_FRENQUENCY), StepDetectionMinMaxPeaks2.MAX_FRENQUENCY);
|
|
64
63
|
|
|
65
64
|
this.lastStepTimestamp = timestamp;
|
|
66
65
|
return true;
|