From e1ebf10bea0e359b92a5dade551b23fbad2c9fce Mon Sep 17 00:00:00 2001 From: Hans Tool Date: Wed, 5 Jan 2022 20:57:28 +0100 Subject: [PATCH 1/6] Reading roll from navigation.attitude object As per specs navgation.attitude contains an object containing pitch, roll and yaw. navigation.attitude.roll should not exist anymore. --- calcs/leeway.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/calcs/leeway.js b/calcs/leeway.js index aff4397..337fcd6 100644 --- a/calcs/leeway.js +++ b/calcs/leeway.js @@ -5,7 +5,7 @@ module.exports = function (app, plugin) { optionKey: 'leeway', title: 'Leeway (based on heel angle and STW)', derivedFrom: [ - 'navigation.attitude.roll', + 'navigation.attitude', 'navigation.speedThroughWater' ], properties: { @@ -16,7 +16,9 @@ module.exports = function (app, plugin) { default: 12 } }, - calculator: function (roll, stw) { + calculator: function (attitude, stw) { + if (stw == 0) return // devision by zero + var roll = attitude.roll var kFactor = plugin.properties.heading.kFactor var rollDegrees = roll / Math.PI * 360 var stwKnots = stw * 1.94384 From 5b0929fa629b21bfae5679cc3f2740d0b6fd68ff Mon Sep 17 00:00:00 2001 From: David Sanner <741986+davidsanner@users.noreply.github.com> Date: Fri, 12 Nov 2021 00:22:13 -0800 Subject: [PATCH 2/6] test single value with range option Test using Mocha closeTo w/ delta --- test/test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test.js b/test/test.js index 90aa0ef..f51505c 100644 --- a/test/test.js +++ b/test/test.js @@ -46,6 +46,8 @@ describe('derived data converts', function () { let res = calc.calculator.apply(null, test.input) if (test.expected) { res.should.jsonEqual(test.expected) + } else if (test.expectedRange) { + res[0].value.should.closeTo(test.expectedRange[0].value, test.expectedRange[0].delta) } else { (typeof res).should.equal('undefined') } From 67accc2687fac9d131de0a52f829d5ae52843c06 Mon Sep 17 00:00:00 2001 From: David Sanner <741986+davidsanner@users.noreply.github.com> Date: Fri, 12 Nov 2021 00:28:24 -0800 Subject: [PATCH 3/6] Handle drift in variation Test was failing because of change in variation value (mag north drifting). Check now using expectedRange/closeTo with delta. --- calcs/magneticVariation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/calcs/magneticVariation.js b/calcs/magneticVariation.js index 19ca176..f827498 100644 --- a/calcs/magneticVariation.js +++ b/calcs/magneticVariation.js @@ -16,8 +16,8 @@ module.exports = function (app, plugin) { tests: [ { input: [{ latitude: 39.0631232, longitude: -76.4872768 }], - expected: [ - { path: 'navigation.magneticVariation', value: -0.19355701404617112 } + expectedRange: [ + { path: 'navigation.magneticVariation', value: -0.19338248112097173, delta: .05 } ] } ] From aa021bba486225e3e04b720849776c9af48b7d20 Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Sat, 29 Jan 2022 21:24:07 -0500 Subject: [PATCH 4/6] fix: magneticVariation is incorrect with null lat/long (#103) --- calcs/magneticVariation.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/calcs/magneticVariation.js b/calcs/magneticVariation.js index f827498..a2ae99e 100644 --- a/calcs/magneticVariation.js +++ b/calcs/magneticVariation.js @@ -9,6 +9,8 @@ module.exports = function (app, plugin) { derivedFrom: ['navigation.position'], defaults: [undefined, 9999], calculator: function (position) { + if (!position || !position.latitude || !position.longitude) return + let degreesVar = MagVar.get([position.latitude], [position.longitude]) let magVar = degreesVar * Math.PI / 180 return [{ path: 'navigation.magneticVariation', value: magVar }] @@ -17,8 +19,15 @@ module.exports = function (app, plugin) { { input: [{ latitude: 39.0631232, longitude: -76.4872768 }], expectedRange: [ - { path: 'navigation.magneticVariation', value: -0.19338248112097173, delta: .05 } + { + path: 'navigation.magneticVariation', + value: -0.19338248112097173, + delta: 0.05 + } ] + }, + { + input: [{ latitude: null, longitude: null }] } ] } From 54cfdfb7cecfc36a991a96e08329032f065b969b Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Sat, 29 Jan 2022 21:26:11 -0500 Subject: [PATCH 5/6] 1.29.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 762a2ef..81a4c6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "signalk-derived-data", - "version": "1.29.0", + "version": "1.29.1", "description": "Plugin that derives signalk data from other signalk data", "main": "index.js", "scripts": { From 7ea0a536f2dac8746c027ffa8ffa15dc81ca425d Mon Sep 17 00:00:00 2001 From: chris0348 <72385312+chris0348@users.noreply.github.com> Date: Sun, 30 Jan 2022 20:07:30 +0100 Subject: [PATCH 6/6] fix: VMG towards waypoint based on courseOverGround instead of headingTrue (#80) --- calcs/vmg.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/calcs/vmg.js b/calcs/vmg.js index 9de271d..a05edf5 100644 --- a/calcs/vmg.js +++ b/calcs/vmg.js @@ -3,18 +3,17 @@ module.exports = function (app) { group: 'course data', optionKey: 'vmg_Course', title: - 'Velocity Made Good to Course (based on courseGreatCircle.nextPoint.bearingTrue heading true and speedOverGround)', + 'Velocity Made Good towards next waypoint (based on courseGreatCircle.nextPoint.bearingTrue courseOverGroundTrue and speedOverGround)', derivedFrom: [ 'navigation.courseGreatCircle.nextPoint.bearingTrue', - 'navigation.headingTrue', + 'navigation.courseOverGroundTrue', 'navigation.speedOverGround' ], - calculator: function (bearingTrue, headingTrue, speedOverGround) { - var angle = Math.abs(bearingTrue - headingTrue) + calculator: function (bearingTrue, cogTrue, speedOverGround) { return [ { path: 'navigation.courseGreatCircle.nextPoint.velocityMadeGood', - value: Math.cos(bearingTrue - headingTrue) * speedOverGround + value: Math.cos(bearingTrue - cogTrue) * speedOverGround } ] }