speedandcurrent 1.5.0 → 1.6.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/index.js +35 -0
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -51,6 +51,12 @@ module.exports = function (app) {
|
|
|
51
51
|
plugin.schema = {
|
|
52
52
|
type: "object",
|
|
53
53
|
properties: {
|
|
54
|
+
sogFallback: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
title: "SOG fallback",
|
|
57
|
+
description: "Allow fallback to SOG when paddlewheel is blocked.",
|
|
58
|
+
default: true
|
|
59
|
+
},
|
|
54
60
|
startWithNewTable: {
|
|
55
61
|
type: "boolean",
|
|
56
62
|
title: "Start with new table",
|
|
@@ -148,6 +154,7 @@ module.exports = function (app) {
|
|
|
148
154
|
|
|
149
155
|
plugin.uiSchema = {
|
|
150
156
|
'ui:order': [
|
|
157
|
+
"sogFallback",
|
|
151
158
|
"estimateBoatSpeed",
|
|
152
159
|
"updateCorrectionTable",
|
|
153
160
|
"assumeCurrent",
|
|
@@ -164,6 +171,9 @@ module.exports = function (app) {
|
|
|
164
171
|
"attitudeSource",
|
|
165
172
|
"preventDuplication"
|
|
166
173
|
],
|
|
174
|
+
sogFallback: {
|
|
175
|
+
"ui:widget": "checkbox"
|
|
176
|
+
},
|
|
167
177
|
startWithNewTable: {
|
|
168
178
|
"ui:widget": "checkbox"
|
|
169
179
|
},
|
|
@@ -240,6 +250,9 @@ module.exports = function (app) {
|
|
|
240
250
|
|
|
241
251
|
|
|
242
252
|
// current
|
|
253
|
+
// send metadata for current
|
|
254
|
+
MessageHandler.setMeta(app, plugin.id, "environment.current.drift", {units: "m/s", type: "number", description: "Speed of the current"});
|
|
255
|
+
MessageHandler.setMeta(app, plugin.id, "environment.current.setTrue", { units: "rad", type: "number", description: "Direction of the current" });
|
|
243
256
|
rawCurrent = new Polar("current", "self.environment.current.drift", "self.environment.current.setTrue");
|
|
244
257
|
rawCurrent.setDisplayAttributes({ label: "current", plane: "Ground" });
|
|
245
258
|
rawCurrent.setAngleRange('0to2pi');
|
|
@@ -267,6 +280,7 @@ module.exports = function (app) {
|
|
|
267
280
|
noCurrent.ySmoother.reset(0,0);
|
|
268
281
|
PolarSmoother.send(app, plugin.id, [noCurrent]);
|
|
269
282
|
|
|
283
|
+
|
|
270
284
|
// boat speed
|
|
271
285
|
smoothedBoatSpeed = new SmoothedSpeedThroughWater(app, plugin.id, settings.boatSpeedSource, true, MovingAverageSmoother, smootherOptions, !settings.preventDuplication);
|
|
272
286
|
rawBoatSpeed = smoothedBoatSpeed.polar;
|
|
@@ -339,6 +353,18 @@ module.exports = function (app) {
|
|
|
339
353
|
smoothedBoatSpeed.onChange = () => {
|
|
340
354
|
const wellUnderway = started < new Date() - 60 * 1000;
|
|
341
355
|
const minSpeed = SI.fromKnots(settings.speedStep / 2);
|
|
356
|
+
|
|
357
|
+
if (settings.sogFallback && fallingBackToSog( minSpeed) ){
|
|
358
|
+
app.setPluginStatus("Falling back to Speed Over Ground");
|
|
359
|
+
app.debug("Falling back");
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (!wellUnderway) {
|
|
363
|
+
app.setPluginStatus("Stabilizing");
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
app.setPluginStatus("Running");
|
|
367
|
+
}
|
|
342
368
|
if (settings.estimateBoatSpeed) correct(wellUnderway);
|
|
343
369
|
if (settings.updateCorrectionTable && wellUnderway) {
|
|
344
370
|
updateTable(settings.assumeCurrent, minSpeed);
|
|
@@ -386,6 +412,15 @@ module.exports = function (app) {
|
|
|
386
412
|
});
|
|
387
413
|
};
|
|
388
414
|
|
|
415
|
+
function fallingBackToSog( minSpeed) {
|
|
416
|
+
if (!rawBoatSpeed.stale && rawBoatSpeed.magnitude > 0) return false;
|
|
417
|
+
if (rawGroundSpeed.stale || rawGroundSpeed.magnitude < minSpeed) return false;
|
|
418
|
+
// Fallback to SOG
|
|
419
|
+
correctedBoatSpeed.setVectorValue({ x: rawGroundSpeed.magnitude, y: 0 });
|
|
420
|
+
Polar.send(app, plugin.id, [correctedBoatSpeed]);
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
|
|
389
424
|
/**
|
|
390
425
|
* Estimates and applies corrections to boat speed, leeway, and current.
|
|
391
426
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "speedandcurrent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A plugin that automatically corrects boat speed and calculates current and leeway using sensor fusion.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"kalman-filter": "^2.3.0",
|
|
31
|
-
"signalkutilities": "^1.5.
|
|
31
|
+
"signalkutilities": "^1.5.1"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"index.js",
|