speedandcurrent 1.0.1 → 1.3.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/CHANGELOG.md +19 -1
- package/correctionTable.js +26 -14
- package/index.js +220 -174
- package/package.json +3 -3
- package/public/TableRenderer.js +8 -6
- package/public/app.js +30 -20
- package/public/index.html +22 -14
- package/public/main.css +177 -0
- package/public/vectors.html +1 -1
- package/public/vectors.js +30 -50
- package/public/style.css +0 -184
- package/public/vectors.css +0 -59
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,25 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
|
|
7
|
-
## [0.1
|
|
7
|
+
## [1.0.1] - 2025-1-27
|
|
8
8
|
### Added
|
|
9
9
|
- basic functionality to estimate speed, leeway and current using Kalman filters
|
|
10
10
|
- basic functionality for a webapp that shows what is going on
|
|
11
|
+
|
|
12
|
+
## [1.1.0] - 2025-8-20
|
|
13
|
+
### Changed
|
|
14
|
+
- Path names for current. It now is self.environment.current.setTrue and self.environment.current.drift
|
|
15
|
+
### Fixed
|
|
16
|
+
- Case error in filename that prevented the webapp from displaying the correction table
|
|
17
|
+
- Corrected speed through water is now calculated when the correction table is fixed
|
|
18
|
+
|
|
19
|
+
## [1.3.0] - ntb
|
|
20
|
+
### Changed
|
|
21
|
+
- Simplified code
|
|
22
|
+
- Less CPU usage
|
|
23
|
+
### Added
|
|
24
|
+
- Option to set the source for input paths
|
|
25
|
+
- Smart heartbeat. Calculations will run right after an update of the path that has the lowest update frequency
|
|
26
|
+
- Oversampling for quick update inputs to get better variance
|
|
27
|
+
### Fixed
|
|
28
|
+
- Angles are now reported in the appropriate range, 0 to 2 * PI or -PI to PI, depending on path
|
package/correctionTable.js
CHANGED
|
@@ -9,19 +9,20 @@ class CorrectionTable extends Table2D{
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
static fromJSON(data, stability) {
|
|
12
|
-
const table = new CorrectionTable(data.row, data.col, stability);
|
|
12
|
+
const table = new CorrectionTable(data.id, data.row, data.col, stability);
|
|
13
13
|
table.table = data.table.map(row => row.map(cellData => CorrectionEstimator.fromJSON(cellData)));
|
|
14
14
|
return table;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
constructor(row, col, stability=5) {
|
|
18
|
-
super(row, col, CorrectionEstimator, CorrectionEstimator.getFilterModel(stability));
|
|
19
|
-
this.
|
|
20
|
-
this.label = "Correction Table";
|
|
17
|
+
constructor(id, row, col, stability=5) {
|
|
18
|
+
super(id, row, col, CorrectionEstimator, CorrectionEstimator.getFilterModel(stability));
|
|
19
|
+
this.lastUpdatedCell = null;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
update(speed, heel, groundSpeed, current, boatSpeed, heading) {
|
|
24
|
-
this.getCell(speed, heel)
|
|
23
|
+
const cell = this.getCell(speed, heel);
|
|
24
|
+
cell?.update(groundSpeed, current, boatSpeed, heading);
|
|
25
|
+
this.lastUpdatedCell = cell;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
getKalmanCorrection(speed, heel) {
|
|
@@ -53,15 +54,26 @@ class CorrectionTable extends Table2D{
|
|
|
53
54
|
if (totalWeightX == 0 || totalWeightY == 0) return { x: 0, y: 0 };
|
|
54
55
|
x = x / totalWeightX;
|
|
55
56
|
y = y / totalWeightY;
|
|
56
|
-
return { x, y };
|
|
57
|
+
return { x:x, y:y };
|
|
57
58
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
report() {
|
|
61
62
|
return {
|
|
63
|
+
id: this.id,
|
|
62
64
|
row: { min: this.min[0], max: this.max[0], step: this.step[0] },
|
|
63
65
|
col: { min: this.min[1], max: this.max[1], step: this.step[1] },
|
|
64
|
-
table: this.table.map(row =>
|
|
66
|
+
table: this.table.map(row =>
|
|
67
|
+
row.map(correction => {
|
|
68
|
+
const cellReport = correction.report();
|
|
69
|
+
// Mark selected if this is the last updated cell
|
|
70
|
+
cellReport.displayAttributes = {
|
|
71
|
+
selected: correction === this.lastUpdatedCell
|
|
72
|
+
};
|
|
73
|
+
return cellReport;
|
|
74
|
+
})
|
|
75
|
+
),
|
|
76
|
+
displayAttributes: this.displayAttributes
|
|
65
77
|
};
|
|
66
78
|
}
|
|
67
79
|
|
|
@@ -101,7 +113,7 @@ class CorrectionEstimator {
|
|
|
101
113
|
}
|
|
102
114
|
|
|
103
115
|
update(groundSpeed, current, boatSpeed, heading) {
|
|
104
|
-
if
|
|
116
|
+
if(groundSpeed.n < 2 || current.n < 2 || boatSpeed.n < 2) return;
|
|
105
117
|
// Rotation matrix for -theta
|
|
106
118
|
const cosTheta = Math.cos(heading);
|
|
107
119
|
const sinTheta = Math.sin(heading);
|
|
@@ -120,9 +132,9 @@ class CorrectionEstimator {
|
|
|
120
132
|
]
|
|
121
133
|
);
|
|
122
134
|
|
|
123
|
-
var groundVector = rotateValue(groundSpeed.
|
|
124
|
-
var currentVector = rotateValue(current.
|
|
125
|
-
var boatVector = boatSpeed.
|
|
135
|
+
var groundVector = rotateValue(groundSpeed.vector);
|
|
136
|
+
var currentVector = rotateValue(current.vector);
|
|
137
|
+
var boatVector = boatSpeed.vector;
|
|
126
138
|
|
|
127
139
|
const observation = [
|
|
128
140
|
-boatVector[0] + groundVector[0] - currentVector[0],
|
|
@@ -145,7 +157,7 @@ class CorrectionEstimator {
|
|
|
145
157
|
}
|
|
146
158
|
|
|
147
159
|
|
|
148
|
-
|
|
160
|
+
report() {
|
|
149
161
|
return { x: this.x, y: this.y, N: this.N };
|
|
150
162
|
}
|
|
151
163
|
|