From 8f5c6c2a733812b19641789e34552afe9e601686 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sat, 19 Sep 2020 19:27:37 -0700 Subject: further work --- grapher/Models/Calculations/AccelData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'grapher/Models/Calculations/AccelData.cs') diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs index eef4d01..057a53b 100644 --- a/grapher/Models/Calculations/AccelData.cs +++ b/grapher/Models/Calculations/AccelData.cs @@ -60,8 +60,8 @@ namespace grapher.Models.Calculations public void CalculateDotsXY(int x, int y, double timeInMs) { - var outX = Math.Abs(x); - var outY = Math.Abs(y); + var outX = Math.Abs(x) / timeInMs; + var outY = Math.Abs(y) / timeInMs; (var inXVelocity, var xSensitivity, var xGain) = X.FindPointValuesFromOut(outX); EstimatedX.Velocity.Set(inXVelocity, outX); -- cgit v1.2.3 From 2a756dfb08b4f8c0870173ad4e0393cdeef33c94 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sun, 20 Sep 2020 23:16:15 -0700 Subject: Attempt to get separate x/y working --- grapher/Models/Calculations/AccelData.cs | 38 +++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'grapher/Models/Calculations/AccelData.cs') diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs index 057a53b..894774b 100644 --- a/grapher/Models/Calculations/AccelData.cs +++ b/grapher/Models/Calculations/AccelData.cs @@ -1,5 +1,6 @@ using grapher.Models.Charts; using System; +using System.Collections.Generic; namespace grapher.Models.Calculations { @@ -37,6 +38,8 @@ namespace grapher.Models.Calculations private EstimatedPoints EstimatedY { get; } + private Dictionary OutVelocityToPoints { get; } + #endregion Properties #region Methods @@ -50,10 +53,10 @@ namespace grapher.Models.Calculations public void CalculateDots(int x, int y, double timeInMs) { - var magnitude = AccelCalculator.Velocity(x, y, timeInMs); + var outVelocity = AccelCalculator.Velocity(x, y, timeInMs); - (var inCombVel, var combSens, var combGain) = Combined.FindPointValuesFromOut(magnitude); - Estimated.Velocity.Set(inCombVel, magnitude); + (var inCombVel, var combSens, var combGain) = Combined.FindPointValuesFromOut(outVelocity); + Estimated.Velocity.Set(inCombVel, outVelocity); Estimated.Sensitivity.Set(inCombVel, combSens); Estimated.Gain.Set(inCombVel, combGain); } @@ -74,6 +77,35 @@ namespace grapher.Models.Calculations EstimatedY.Gain.Set(inYVelocity, yGain); } + public void CalculateDotsCombinedDiffSens(int x, int y, double timeInMs) + { + var outVelocity = AccelCalculator.Velocity(x, y, timeInMs); + + if (OutVelocityToPoints.TryGetValue(outVelocity, out var points)) + { + EstimatedX.Sensitivity.Set(points.Item1, points.Item2); + EstimatedX.Velocity.Set(points.Item1, points.Item3); + EstimatedX.Gain.Set(points.Item1, points.Item4); + EstimatedY.Sensitivity.Set(points.Item1, points.Item5); + EstimatedY.Velocity.Set(points.Item1, points.Item6); + EstimatedY.Gain.Set(points.Item1, points.Item7); + } + else + { + var index = Combined.GetVelocityIndex(outVelocity); + var inVelocity = Combined.VelocityPoints[index]; + var xPoints = X.FindPointValuesFromOut(outVelocity); + var yPoints = Y.FindPointValuesFromOut(outVelocity); + OutVelocityToPoints.Add(outVelocity, (inVelocity, xPoints.Item1, xPoints.Item2, xPoints.Item3, yPoints.Item1, yPoints.Item2, yPoints.Item3)); + EstimatedX.Sensitivity.Set(inVelocity, xPoints.Item1); + EstimatedX.Velocity.Set(inVelocity, xPoints.Item2); + EstimatedX.Gain.Set(inVelocity, xPoints.Item3); + EstimatedY.Sensitivity.Set(inVelocity, yPoints.Item1); + EstimatedY.Velocity.Set(inVelocity, yPoints.Item2); + EstimatedY.Gain.Set(inVelocity, yPoints.Item3); + } + } + #endregion Methods } } -- cgit v1.2.3 From ba642cd8c8e63ec3778fa17ecbcd7964074aaba1 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 21 Sep 2020 00:08:19 -0700 Subject: separate x/y mostly works --- grapher/Models/Calculations/AccelData.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'grapher/Models/Calculations/AccelData.cs') diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs index 894774b..0fe7a3c 100644 --- a/grapher/Models/Calculations/AccelData.cs +++ b/grapher/Models/Calculations/AccelData.cs @@ -1,6 +1,8 @@ using grapher.Models.Charts; +using grapher.Models.Serialized; using System; using System.Collections.Generic; +using System.Linq; namespace grapher.Models.Calculations { @@ -20,6 +22,8 @@ namespace grapher.Models.Calculations Estimated = combined; EstimatedX = x; EstimatedY = y; + + OutVelocityToPoints = new Dictionary(); } #endregion Constructors @@ -49,6 +53,7 @@ namespace grapher.Models.Calculations Combined.Clear(); X.Clear(); Y.Clear(); + OutVelocityToPoints.Clear(); } public void CalculateDots(int x, int y, double timeInMs) @@ -77,9 +82,10 @@ namespace grapher.Models.Calculations EstimatedY.Gain.Set(inYVelocity, yGain); } - public void CalculateDotsCombinedDiffSens(int x, int y, double timeInMs) + public void CalculateDotsCombinedDiffSens(int x, int y, double timeInMs, DriverSettings settings) { - var outVelocity = AccelCalculator.Velocity(x, y, timeInMs); + (var xStripped, var yStripped) = AccelCalculator.StripSens(x, y, settings.sensitivity.x, settings.sensitivity.y); + var outVelocity = AccelCalculator.Velocity(xStripped, yStripped, timeInMs); if (OutVelocityToPoints.TryGetValue(outVelocity, out var points)) { @@ -93,9 +99,9 @@ namespace grapher.Models.Calculations else { var index = Combined.GetVelocityIndex(outVelocity); - var inVelocity = Combined.VelocityPoints[index]; - var xPoints = X.FindPointValuesFromOut(outVelocity); - var yPoints = Y.FindPointValuesFromOut(outVelocity); + var inVelocity = Combined.VelocityPoints.ElementAt(index).Value; + var xPoints = X.ValuesAtIndex(index); + var yPoints = Y.ValuesAtIndex(index); OutVelocityToPoints.Add(outVelocity, (inVelocity, xPoints.Item1, xPoints.Item2, xPoints.Item3, yPoints.Item1, yPoints.Item2, yPoints.Item3)); EstimatedX.Sensitivity.Set(inVelocity, xPoints.Item1); EstimatedX.Velocity.Set(inVelocity, xPoints.Item2); -- cgit v1.2.3 From 99ad8686bb039dcf82115550dbf347d8695ee1f8 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 21 Sep 2020 12:41:16 -0700 Subject: x/y diff sens works --- grapher/Models/Calculations/AccelData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grapher/Models/Calculations/AccelData.cs') diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs index 0fe7a3c..67d4f3f 100644 --- a/grapher/Models/Calculations/AccelData.cs +++ b/grapher/Models/Calculations/AccelData.cs @@ -99,7 +99,7 @@ namespace grapher.Models.Calculations else { var index = Combined.GetVelocityIndex(outVelocity); - var inVelocity = Combined.VelocityPoints.ElementAt(index).Value; + var inVelocity = Combined.VelocityPoints.ElementAt(index).Key; var xPoints = X.ValuesAtIndex(index); var yPoints = Y.ValuesAtIndex(index); OutVelocityToPoints.Add(outVelocity, (inVelocity, xPoints.Item1, xPoints.Item2, xPoints.Item3, yPoints.Item1, yPoints.Item2, yPoints.Item3)); -- cgit v1.2.3