[chronojump] ForceSensor calculating forceResultant of full set
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor calculating forceResultant of full set
- Date: Tue, 12 Nov 2019 13:22:18 +0000 (UTC)
commit d56d74064b3b902f7d98cc2c6ea3bc69ad051d15
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Nov 12 12:25:28 2019 +0100
ForceSensor calculating forceResultant of full set
src/forceSensor.cs | 92 ++++++++++++++++++++++++++++++++++++-------
src/gui/forceSensor.cs | 30 +++++++++-----
src/gui/forceSensorAnalyze.cs | 2 +-
3 files changed, 99 insertions(+), 25 deletions(-)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 5163779b..d1dc4078 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -180,7 +180,8 @@ public class ForceSensor
//static methods
- public static double CalculeForceResultantIfNeeded (double forceRaw, CaptureOptions fsco,
ForceSensorExercise fse, double personMass)
+ //of a single point (this method will disappear)
+ public static double CalculeForceResultantIfNeeded (double forceRaw, CaptureOptions fsco,
ForceSensorExercise fse, double personMass)//, double stiffness)
{
if(! fse.ForceResultant)
return calculeForceWithCaptureOptions(forceRaw, fsco);
@@ -192,6 +193,16 @@ public class ForceSensor
//right now only code for non-elastic
double accel = 0;
+ /*
+ if(fse.Elastic)
+ {
+ double position = rawForce / stiffness;
+
+ }
+ */
+
+ //not elastic stuff ----->
+
/*
* debug info
LogB.Information("--------------");
@@ -222,6 +233,49 @@ public class ForceSensor
return force;
}
+ //of full set
+ public static List<double> CalculeForceResultantIfNeededFullSet (List<int> times, List<double> forces,
+ CaptureOptions fsco, ForceSensorExercise fse, double personMass, double stiffness)
+ {
+ if(! fse.ForceResultant)
+ return calculeForceWithCaptureOptionsFullSet(forces, fsco);
+
+ double totalMass = 0;
+ if(fse.PercentBodyWeight > 0 && personMass > 0)
+ totalMass = fse.PercentBodyWeight * personMass / 100.0;
+
+ if(fse.Elastic) {
+ } else {
+ //right now only code for non-elastic
+ double accel = 0;
+
+ for (int i = 0 ; i < forces.Count; i ++)
+ {
+ forces[i] = Math.Sqrt(
+ Math.Pow(Math.Cos(fse.AngleDefault * Math.PI / 180.0) *
(forces[i] + totalMass * accel), 2) + //Horizontal
+ Math.Pow(Math.Sin(fse.AngleDefault * Math.PI / 180.0) *
(forces[i] + totalMass * accel) + totalMass * 9.81, 2) //Vertical
+ );
+ }
+ }
+
+ return calculeForceWithCaptureOptionsFullSet(forces, fsco);
+ }
+ //TODO: do not do it like this, do it in the above methods
+ private static List<double> calculeForceWithCaptureOptionsFullSet(List<double> forceList,
CaptureOptions fsco)
+ {
+ if(fsco == CaptureOptions.NORMAL)
+ return forceList;
+
+ for(int i = 0 ; i < forceList.Count; i ++)
+ {
+ if(fsco == CaptureOptions.ABS)
+ forceList[i] = Math.Abs(forceList[i]);
+ if(fsco == CaptureOptions.INVERTED)
+ forceList[i] = -1 * forceList[i];
+ }
+ return forceList;
+ }
+
public static string GetCaptureOptionsString(CaptureOptions co)
{
if(co == ForceSensor.CaptureOptions.ABS)
@@ -1296,12 +1350,12 @@ public class ForceSensorAnalyzeInstant
private int graphHeight;
public ForceSensorAnalyzeInstant(string file, int graphWidth, int graphHeight, double start, double
end,
- ForceSensorExercise fse, double personWeight, ForceSensor.CaptureOptions fsco)
+ ForceSensorExercise fse, double personWeight, ForceSensor.CaptureOptions fsco, double
stiffness)
{
this.graphWidth = graphWidth;
this.graphHeight = graphHeight;
- readFile(file, start, end, fse, personWeight, fsco);
+ readFile(file, start, end, fse, personWeight, fsco, stiffness);
//on zoom adjust width
if(start >= 0 || end >= 0)
@@ -1315,7 +1369,8 @@ public class ForceSensorAnalyzeInstant
fscAIPoints.Redo();
}
- private void readFile(string file, double start, double end, ForceSensorExercise fse, double
personWeight, ForceSensor.CaptureOptions fsco)
+ private void readFile(string file, double start, double end, ForceSensorExercise fse,
+ double personWeight, ForceSensor.CaptureOptions fsco, double stiffness)
{
fscAIPoints = new ForceSensorCapturePoints(graphWidth, graphHeight, -1);
@@ -1328,6 +1383,9 @@ public class ForceSensorAnalyzeInstant
if(contents == null)
return;
+ List<int> times = new List<int>();
+ List<double> forces = new List<double>();
+
foreach(string str in contents)
{
if(headersRow)
@@ -1356,19 +1414,25 @@ public class ForceSensorAnalyzeInstant
timeD -= start;
}
- int time = Convert.ToInt32(timeD);
- double force = Convert.ToDouble(strFull[1]);
- force = ForceSensor.CalculeForceResultantIfNeeded (force, fsco, fse,
personWeight);
-
- fscAIPoints.Add(time, force);
- fscAIPoints.NumCaptured ++;
-
- forceSensorValues.TimeLast = time;
- forceSensorValues.ForceLast = force;
- forceSensorValues.SetMaxMinIfNeeded(force, time);
+ times.Add(Convert.ToInt32(timeD));
+ forces.Add(Convert.ToDouble(strFull[1]));
}
}
}
+ forces = ForceSensor.CalculeForceResultantIfNeededFullSet(times, forces, fsco, fse,
personWeight, stiffness);
+
+ int i = 0;
+ foreach(int time in times)
+ {
+ fscAIPoints.Add(time, forces[i]);
+ fscAIPoints.NumCaptured ++;
+
+ forceSensorValues.TimeLast = time;
+ forceSensorValues.ForceLast = forces[i];
+ forceSensorValues.SetMaxMinIfNeeded(forces[i], time);
+
+ i ++;
+ }
}
//When B checkbutton is clicked or window is resized
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index a222040c..f12c3cb2 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -1854,6 +1854,9 @@ LogB.Information(" fs R ");
//initialize
forceSensorValues = new ForceSensorValues();
+ List<int> times = new List<int>();
+ List<double> forces = new List<double>();
+
foreach(string str in contents)
{
if(headersRow)
@@ -1870,19 +1873,26 @@ LogB.Information(" fs R ");
if(Util.IsNumber(strFull[0], false) && Util.IsNumber(strFull[1], true))
{
- int time = Convert.ToInt32(strFull[0]);
- double force = Convert.ToDouble(strFull[1]);
- force = ForceSensor.CalculeForceResultantIfNeeded(force, fsco,
currentForceSensorExercise, currentPersonSession.Weight);
-
- fscPoints.Add(time, force);
- fscPoints.NumCaptured ++;
-
- forceSensorValues.TimeLast = time;
- forceSensorValues.ForceLast = force;
- forceSensorValues.SetMaxMinIfNeeded(force, time);
+ times.Add(Convert.ToInt32(strFull[0]));
+ forces.Add(Convert.ToDouble(strFull[1]));
}
}
}
+ forces = ForceSensor.CalculeForceResultantIfNeededFullSet(times, forces,
+ fsco, currentForceSensorExercise, currentPersonSession.Weight,
currentForceSensor.Stiffness);
+
+ int i = 0;
+ foreach(int time in times)
+ {
+ fscPoints.Add(time, forces[i]);
+ fscPoints.NumCaptured ++;
+
+ forceSensorValues.TimeLast = time;
+ forceSensorValues.ForceLast = forces[i];
+ forceSensorValues.SetMaxMinIfNeeded(forces[i], time);
+
+ i ++;
+ }
}
void forceSensorDoSignalGraphPlot()
{
diff --git a/src/gui/forceSensorAnalyze.cs b/src/gui/forceSensorAnalyze.cs
index 032d839c..69384ba2 100644
--- a/src/gui/forceSensorAnalyze.cs
+++ b/src/gui/forceSensorAnalyze.cs
@@ -556,7 +556,7 @@ public partial class ChronoJumpWindow
force_sensor_ai_drawingarea.Allocation.Height,
zoomA, zoomB,
currentForceSensorExercise, currentPersonSession.Weight,
- getForceSensorCaptureOptions());
+ getForceSensorCaptureOptions(), currentForceSensor.Stiffness);
/*
* position the hscales on the left to avoid loading a csv
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]