@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
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
const dotenv = require('dotenv');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const git = require('simple-git/promise')('.').silent(true);
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const npm = require('npm');
|
|
6
|
-
const requestp = require('request-promise');
|
|
7
|
-
|
|
8
|
-
const config = require('../config.json');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Check GITHUB_TOKEN in .env file
|
|
12
|
-
*/
|
|
13
|
-
const result = dotenv.config();
|
|
14
|
-
if (result.error) {
|
|
15
|
-
console.error('.env does not exist. '
|
|
16
|
-
+ 'You have to create a .env file at the root directory');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const ENV = result.parsed;
|
|
20
|
-
if (!ENV.GITHUB_TOKEN) {
|
|
21
|
-
console.error('GITHUB_TOKEN does not exist in .env file. '
|
|
22
|
-
+ 'More info here: https://github.com/settings/tokens');
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Github Url and Headers
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
const GITHUB_API_URL = 'https://api.github.com';
|
|
31
|
-
const GITHUB_UPLOAD_URL = 'https://uploads.github.com';
|
|
32
|
-
|
|
33
|
-
const HEADERS = {
|
|
34
|
-
'Authorization': 'token ' + ENV.GITHUB_TOKEN,
|
|
35
|
-
'User-Agent': 'NodeJS/Release-' + config.githubRepoName
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
function checkGithubToken() {
|
|
39
|
-
|
|
40
|
-
const uri = GITHUB_API_URL;
|
|
41
|
-
const headers = HEADERS;
|
|
42
|
-
|
|
43
|
-
return requestp({
|
|
44
|
-
method: 'GET',
|
|
45
|
-
uri,
|
|
46
|
-
headers,
|
|
47
|
-
json: true
|
|
48
|
-
}).catch(e => {
|
|
49
|
-
return Promise.reject(e.message);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function createRelease(version) {
|
|
54
|
-
|
|
55
|
-
const uri = GITHUB_API_URL + '/repos/' + config.githubRepoOwner + '/'
|
|
56
|
-
+ config.githubRepoName + '/releases';
|
|
57
|
-
const headers = Object.assign({ 'Content-Type': 'application/json' }, HEADERS);
|
|
58
|
-
const inputData = {
|
|
59
|
-
'tag_name': version,
|
|
60
|
-
'target_commitish': 'master',
|
|
61
|
-
'name': version
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return requestp({
|
|
65
|
-
method: 'POST',
|
|
66
|
-
uri,
|
|
67
|
-
headers,
|
|
68
|
-
body: inputData,
|
|
69
|
-
json: true
|
|
70
|
-
}).catch(e => {
|
|
71
|
-
return Promise.reject(e.message);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
function uploadFile(releaseId, fileName, filePath) {
|
|
77
|
-
|
|
78
|
-
const stats = fs.statSync(filePath);
|
|
79
|
-
const fileSizeInBytes = stats.size;
|
|
80
|
-
|
|
81
|
-
const uri = GITHUB_UPLOAD_URL + '/repos/' + config.githubRepoOwner + '/'
|
|
82
|
-
+ config.githubRepoName + '/releases/' + releaseId
|
|
83
|
-
+ '/assets?name=' + fileName;
|
|
84
|
-
|
|
85
|
-
const headers = Object.assign({
|
|
86
|
-
'Content-Type': 'application/javascript',
|
|
87
|
-
'Content-length': fileSizeInBytes
|
|
88
|
-
}, HEADERS);
|
|
89
|
-
|
|
90
|
-
return requestp({
|
|
91
|
-
method: 'POST',
|
|
92
|
-
uri,
|
|
93
|
-
headers,
|
|
94
|
-
body: fs.createReadStream(filePath)
|
|
95
|
-
}).catch(e => {
|
|
96
|
-
return e.message;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function revertNpmVersion() {
|
|
101
|
-
return git.reset(['--hard', 'HEAD^1'])
|
|
102
|
-
.then(() => git.tag(['-d', 'v1.1.0']))
|
|
103
|
-
.catch(err => console.error(err));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const npmLoaderPromise = new Promise((resolve, reject) => {
|
|
107
|
-
npm.load(err => {
|
|
108
|
-
if (err) {
|
|
109
|
-
reject(err);
|
|
110
|
-
} else {
|
|
111
|
-
resolve();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
function main() {
|
|
118
|
-
|
|
119
|
-
const versionsList = ['minor', 'major', 'patch'];
|
|
120
|
-
|
|
121
|
-
let isVersionCreated = false;
|
|
122
|
-
const isPushed = false;
|
|
123
|
-
|
|
124
|
-
Promise.resolve()
|
|
125
|
-
// Check github token as soon as possible to avoid to revert a push
|
|
126
|
-
.then(checkGithubToken)
|
|
127
|
-
|
|
128
|
-
// Check if current branch name corresponds to "releaseBranch"
|
|
129
|
-
.then(async () => {
|
|
130
|
-
const res = await git.raw(['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
131
|
-
if (res.trim() !== config.releaseBranch) {
|
|
132
|
-
return Promise.reject('You are not on the ' + config.releaseBranch + ' branch');
|
|
133
|
-
}
|
|
134
|
-
return Promise.resolve();
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
// Check if git repo is clean before running npm version
|
|
138
|
-
.then(async () => {
|
|
139
|
-
const res = await git.raw(['status', '--porcelain']);
|
|
140
|
-
if (res) {
|
|
141
|
-
return Promise.reject('Your git working directory not clean');
|
|
142
|
-
}
|
|
143
|
-
return Promise.resolve();
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
// Update npm version with npm version argv[2]
|
|
147
|
-
.then(async () => {
|
|
148
|
-
const args = process.argv;
|
|
149
|
-
if (args.length < 3) {
|
|
150
|
-
throw new Error('version argument is missing');
|
|
151
|
-
}
|
|
152
|
-
if (!versionsList.includes(args[2])) {
|
|
153
|
-
throw new Error('version argument is unknown, it should be: ' + versionsList.join(','));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
await npmLoaderPromise;
|
|
157
|
-
return new Promise((resolve, reject) => {
|
|
158
|
-
npm.commands.version([args[2]], err => {
|
|
159
|
-
if (err) {
|
|
160
|
-
reject(err);
|
|
161
|
-
} else {
|
|
162
|
-
isVersionCreated = true;
|
|
163
|
-
resolve();
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
// Build the project in production mode
|
|
170
|
-
.then(async () => {
|
|
171
|
-
await npmLoaderPromise;
|
|
172
|
-
return new Promise((resolve, reject) => {
|
|
173
|
-
npm.commands.run(['build'], err => {
|
|
174
|
-
if (err) {
|
|
175
|
-
reject(err);
|
|
176
|
-
} else {
|
|
177
|
-
resolve();
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
// Push release to origin
|
|
184
|
-
.then(() => git.push('origin', config.releaseBranch, ['--tags']))
|
|
185
|
-
|
|
186
|
-
// Get tag name
|
|
187
|
-
.then(async () => {
|
|
188
|
-
const res = await git.raw(['describe']);
|
|
189
|
-
// TODO this condition can be improved
|
|
190
|
-
if (!res || res[0] !== 'v') {
|
|
191
|
-
return Promise.reject('Could not find tag name');
|
|
192
|
-
}
|
|
193
|
-
return Promise.resolve(res.trim());
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
// Create the release
|
|
197
|
-
.then((tagName) => createRelease(tagName))
|
|
198
|
-
|
|
199
|
-
// Upload file
|
|
200
|
-
.then(response => {
|
|
201
|
-
const filePath = path.join(config.distFolder, config.distFileName);
|
|
202
|
-
uploadFile(response.id, config.distFileName, filePath);
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
.then(() => {
|
|
206
|
-
console.log('Release finished with success');
|
|
207
|
-
})
|
|
208
|
-
.catch(e => {
|
|
209
|
-
if (isVersionCreated && !isPushed) {
|
|
210
|
-
revertNpmVersion();
|
|
211
|
-
}
|
|
212
|
-
console.error('error', e);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
main();
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash.noop';
|
|
2
|
-
|
|
3
|
-
import FakeLocationSource from './providers/FakeLocationSource';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
|
-
class NavigationHandler {
|
|
9
|
-
|
|
10
|
-
static State = {
|
|
11
|
-
STARTING: 0,
|
|
12
|
-
STARTED: 1,
|
|
13
|
-
STOPPPED: 2
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
_state = NavigationHandler.State.STOPPPED;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Constructor of NavigationHandler
|
|
20
|
-
* @param {Function} _callback callback on new pose
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
constructor(_callback) {
|
|
24
|
-
const callback = _callback || noop;
|
|
25
|
-
this.locationSource = new FakeLocationSource(pose => callback(pose));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
startIfNecessary() {
|
|
29
|
-
|
|
30
|
-
if (this._state === NavigationHandler.State.STARTING
|
|
31
|
-
|| this._state === NavigationHandler.State.STARTED) {
|
|
32
|
-
const msg = 'Navigation already started';
|
|
33
|
-
console.log(msg);
|
|
34
|
-
return Promise.resolve(msg);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this._state = NavigationHandler.State.STARTING;
|
|
38
|
-
|
|
39
|
-
const promise = this.locationSource.start();
|
|
40
|
-
promise
|
|
41
|
-
.then(() => (this._state = NavigationHandler.State.STARTED))
|
|
42
|
-
.catch(() => (this._state = NavigationHandler.State.STOPPPED));
|
|
43
|
-
|
|
44
|
-
return promise;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
stop() {
|
|
48
|
-
|
|
49
|
-
if (this._state === NavigationHandler.State.STOPPPED) {
|
|
50
|
-
const msg = 'Navigation already stopped';
|
|
51
|
-
console.log(msg);
|
|
52
|
-
return Promise.resolve(msg);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this.locationSource.stop();
|
|
56
|
-
this._state = NavigationHandler.State.STOPPPED;
|
|
57
|
-
return Promise.resolve();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default NavigationHandler;
|
package/src.new/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash.noop';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
*/
|
|
6
|
-
class FakeLocationSource {
|
|
7
|
-
|
|
8
|
-
constructor(callback) {
|
|
9
|
-
this.callback = callback || noop;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
start() {
|
|
13
|
-
this.interval = setInterval(() => {
|
|
14
|
-
this.callback({
|
|
15
|
-
location: {
|
|
16
|
-
lat: 45,
|
|
17
|
-
lng: 5,
|
|
18
|
-
alt: 0
|
|
19
|
-
},
|
|
20
|
-
attitude: {
|
|
21
|
-
quaternion: [1, 0, 0, 0]
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}, 1000);
|
|
25
|
-
|
|
26
|
-
return Promise.resolve();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
stop() {
|
|
30
|
-
if (this.interval) {
|
|
31
|
-
clearInterval(this.interval);
|
|
32
|
-
this.interval = null;
|
|
33
|
-
}
|
|
34
|
-
return Promise.resolve();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default FakeLocationSource;
|
|
File without changes
|
|
File without changes
|
/package/{src → src.old}/Pose.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|