[chronojump] ForceSensor dynamics smoothing
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor dynamics smoothing
- Date: Tue, 12 Nov 2019 16:45:24 +0000 (UTC)
commit 0d5bb30804fdd466372ac9748b420a67b48e1d19
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Nov 12 17:44:24 2019 +0100
ForceSensor dynamics smoothing
src/forceSensorDynamics.cs | 24 ++++++++++++++++++++++++
src/gui/forceSensorAnalyze.cs | 15 ++++++++++-----
2 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/src/forceSensorDynamics.cs b/src/forceSensorDynamics.cs
index 3d21fdca..87f14d07 100644
--- a/src/forceSensorDynamics.cs
+++ b/src/forceSensorDynamics.cs
@@ -181,11 +181,33 @@ public class ForceSensorDynamicsElastic : ForceSensorDynamics
calculeForces();
calculePowers();
}
+
+ /*
+ * take 5 values: 2 previous, current value, 2 post.
+ * with this calculated the avaerage and assigns to current
+ */
+ private List<double> smoothVariable(List<double> original_l)
+ {
+ List<double> smoothed_l = new List<double>();
+ smoothed_l.Add(0);
+ smoothed_l.Add(0);
+
+ for(int i = 2; i < position_l.Count -2; i ++)
+ smoothed_l.Add( (original_l[i-2] + original_l[i-1] + original_l[i] + original_l[i+1]
+ original_l[i+2]) / 5.0 );
+
+ smoothed_l.Add(0);
+ smoothed_l.Add(0);
+
+ return smoothed_l;
+ }
+
private void calculePositions()
{
for (int i = 0 ; i < force_l.Count; i ++)
position_l.Add(force_l[i] / stiffness);
+
+ position_l = smoothVariable(position_l);
}
private void calculeSpeeds()
@@ -202,6 +224,8 @@ public class ForceSensorDynamicsElastic : ForceSensorDynamics
speed_l.Add( (position_l[post] - position_l[pre]) / (time_l[post] - time_l[pre]) );
}
+
+ speed_l = smoothVariable(speed_l);
}
private void calculeAccels()
diff --git a/src/gui/forceSensorAnalyze.cs b/src/gui/forceSensorAnalyze.cs
index 698eed62..77b0a4ba 100644
--- a/src/gui/forceSensorAnalyze.cs
+++ b/src/gui/forceSensorAnalyze.cs
@@ -921,9 +921,14 @@ public partial class ChronoJumpWindow
allocation.Width -textWidth -10, allocation.Height/2 +
verticalPos,
layout_force_ai_text);
- //showing on elastic: position, speed, accel, power
+ //showing on elastic: position, speed, accel, power (but not on the beginning
and end)
+ //if(fsAI.CalculedElasticPSAP && (instant > 2 && instant < fsAI.GetLength()
-3))
if(fsAI.CalculedElasticPSAP)
{
+ Gdk.GC pen_temp = pen_blue_force_ai;
+ if(instant <= 2 || instant >= fsAI.GetLength() -3)
+ pen_temp = pen_red_force_ai;
+
//position
layout_force_ai_text.SetMarkup(string.Format("Position: {0:0.###} m",
Math.Round(fsAI.Position_l[instant], 3)));
@@ -931,7 +936,7 @@ public partial class ChronoJumpWindow
textHeight = 1;
layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
verticalPos += 40;
- force_sensor_ai_pixmap.DrawLayout (pen_blue_force_ai,
+ force_sensor_ai_pixmap.DrawLayout (pen_temp,
allocation.Width -textWidth -10, allocation.Height/2
+ verticalPos,
layout_force_ai_text);
@@ -942,7 +947,7 @@ public partial class ChronoJumpWindow
textHeight = 1;
layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
verticalPos += 20;
- force_sensor_ai_pixmap.DrawLayout (pen_blue_force_ai,
+ force_sensor_ai_pixmap.DrawLayout (pen_temp,
allocation.Width -textWidth -10, allocation.Height/2
+ verticalPos,
layout_force_ai_text);
@@ -953,7 +958,7 @@ public partial class ChronoJumpWindow
textHeight = 1;
verticalPos += 20;
layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
- force_sensor_ai_pixmap.DrawLayout (pen_blue_force_ai,
+ force_sensor_ai_pixmap.DrawLayout (pen_temp,
allocation.Width -textWidth -10, allocation.Height/2
+ verticalPos,
layout_force_ai_text);
@@ -964,7 +969,7 @@ public partial class ChronoJumpWindow
textHeight = 1;
verticalPos += 20;
layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
- force_sensor_ai_pixmap.DrawLayout (pen_blue_force_ai,
+ force_sensor_ai_pixmap.DrawLayout (pen_temp,
allocation.Width -textWidth -10, allocation.Height/2
+ verticalPos,
layout_force_ai_text);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]