[chronojump] Fixing 699951. propulsive stuff



commit eedbc1f0733a7d853b2f07c760bef80999a481c5
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Jun 3 16:55:29 2013 +0200

    Fixing 699951. propulsive stuff

 encoder/graph.R           |   13 ++++++++-----
 encoder/pyserial_pyper.py |   40 +++++++++++++++++++++++++++-------------
 src/encoder.cs            |    9 +++++++--
 src/gui/encoder.cs        |    5 +++++
 4 files changed, 47 insertions(+), 20 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 47696cd..4fa878b 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -335,10 +335,13 @@ print("WARNING ECS\n\n\n\n\n")
 
        power <- force*speed$y
 
-       #if( analysisOptions == "p" && ( eccon== "c" || eccon == "ec" ) )
-       #       return(list(speedy=speed$y[1:propulsiveEnd], accely=accel$y[1:propulsiveEnd], 
-       #                   force=force[1:propulsiveEnd], power=power[1:propulsiveEnd], mass=mass))
-       #else
+       print("propulsiveEnd")
+       print(propulsiveEnd)
+
+       if( analysisOptions == "p" && ( eccon== "c" || eccon == "ec" ) )
+               return(list(speedy=speed$y[1:propulsiveEnd], accely=accel$y[1:propulsiveEnd], 
+                           force=force[1:propulsiveEnd], power=power[1:propulsiveEnd], mass=mass))
+       else
                return(list(speedy=speed$y, accely=accel$y, force=force, power=power, mass=mass))
 }
 
@@ -1509,7 +1512,7 @@ doProcess <- function(options) {
                        curves = curves[-discardedCurves,]
 
                rownames(paf)=rownames(curves)
-               print("--------CURVES--------------")
+               print("--------CURVES (propulsive is not calculated yet) --------------")
                print(curves)
                print("----------PAF---------------")
                print(paf)
diff --git a/encoder/pyserial_pyper.py b/encoder/pyserial_pyper.py
index d7ac9c7..0234597 100644
--- a/encoder/pyserial_pyper.py
+++ b/encoder/pyserial_pyper.py
@@ -52,18 +52,19 @@ mass = float(sys.argv[6])
 smoothingOneEC = float(sys.argv[7])
 smoothingOneC = float(sys.argv[8])
 eccon = sys.argv[9]                            #contraction "ec" or "c"
-heightHigherCondition = int(sys.argv[10])
-heightLowerCondition = int(sys.argv[11])
-meanSpeedHigherCondition = float(sys.argv[12])
-meanSpeedLowerCondition = float(sys.argv[13])
-maxSpeedHigherCondition = float(sys.argv[14])
-maxSpeedLowerCondition = float(sys.argv[15])
-powerHigherCondition = int(sys.argv[16])
-powerLowerCondition = int(sys.argv[17])
-peakPowerHigherCondition = int(sys.argv[18])
-peakPowerLowerCondition = int(sys.argv[19])
-mainVariable = sys.argv[20]
-w_serial_port = sys.argv[21]
+analysisOptions = sys.argv[10]                 #["p","none"]: propulsive or none
+heightHigherCondition = int(sys.argv[11])
+heightLowerCondition = int(sys.argv[12])
+meanSpeedHigherCondition = float(sys.argv[13])
+meanSpeedLowerCondition = float(sys.argv[14])
+maxSpeedHigherCondition = float(sys.argv[15])
+maxSpeedLowerCondition = float(sys.argv[16])
+powerHigherCondition = int(sys.argv[17])
+powerLowerCondition = int(sys.argv[18])
+peakPowerHigherCondition = int(sys.argv[19])
+peakPowerLowerCondition = int(sys.argv[20])
+mainVariable = sys.argv[21]
+w_serial_port = sys.argv[22]
 
 delete_initial_time = 20                       #delete first records because there's encoder bug
 #w_baudrate = 9600                           # Setting the baudrate of Chronopic(9600)
@@ -192,7 +193,20 @@ def calculate_all_in_r(temp, top_values, bottom_values, direction_now,
                                for i in bcross:
                                        if i < maxSpeedT:
                                                x_ini = i  #left adjust
-                       
+               
+                       #find propulsive
+                       if analysisOptions == "p":
+                               myR.run('accel <- predict( speed, deriv=1 )')
+                               myR.run('accel$y <- accel$y * 1000') #input data is in mm, conversion to m
+                               myR.run('propulsiveData <- which(accel$y <= -9.81)') 
+                               propulsiveData = myR.get('propulsiveData') 
+                               print("propulsiveData:" + str(propulsiveData) + "; end:" + str(end) + 
+                                               ";min(propulsiveData):" + str(min(propulsiveData)))
+                               propulsiveDataLength = myR.get('length(propulsiveData)') 
+                               if propulsiveDataLength > 0:
+                                       end = start + min(propulsiveData)
+
+
                        myR.assign('a',temp[start+x_ini:end])
                        print("start reduced (start+x_ini):" + str(start + x_ini) + " (x_ini:" + str(x_ini) + 
"); end:" + str(end)) 
        
diff --git a/src/encoder.cs b/src/encoder.cs
index 2689fb1..80f6bf0 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -58,7 +58,7 @@ public class EncoderParams
 
        //to encoder capture (pyserial_pyper.py)
        public EncoderParams(int time, int minHeight, int exercisePercentBodyWeight, string mass, 
-                       string smoothEccCon, string smoothCon, string eccon,
+                       string smoothEccCon, string smoothCon, string eccon, string analysisOptions,
                        double heightHigherCondition, double heightLowerCondition, 
                        double meanSpeedHigherCondition, double meanSpeedLowerCondition, 
                        double maxSpeedHigherCondition, double maxSpeedLowerCondition, 
@@ -73,6 +73,7 @@ public class EncoderParams
                this.smoothEccCon = smoothEccCon;
                this.smoothCon = smoothCon;
                this.eccon = eccon;
+               this.analysisOptions = analysisOptions;
                this.heightHigherCondition = heightHigherCondition;
                this.heightLowerCondition = heightLowerCondition;
                this.meanSpeedHigherCondition = meanSpeedHigherCondition;
@@ -88,8 +89,12 @@ public class EncoderParams
        
        public string ToString1 () 
        {
+               string analysisOptionsPrint = analysisOptions;
+               if(analysisOptionsPrint == "")
+                       analysisOptionsPrint = "none";
+
                return time.ToString() + " " + minHeight.ToString() + " " + 
exercisePercentBodyWeight.ToString() + 
-                       " " + mass.ToString() + " " + smoothEccCon + " " + smoothCon + " " + eccon +
+                       " " + mass.ToString() + " " + smoothEccCon + " " + smoothCon + " " + eccon + " " + 
analysisOptionsPrint +
                        " " + heightHigherCondition.ToString() +        " " + heightLowerCondition.ToString() 
+
                        " " + Util.ConvertToPoint(meanSpeedHigherCondition.ToString()) +        
                        " " + Util.ConvertToPoint(meanSpeedLowerCondition.ToString()) +
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index da88999..0dffdd1 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -188,6 +188,10 @@ public partial class ChronoJumpWindow
                        UtilGtk.ChronopicColors(viewport_chronopics, label_chronopics, 
label_connected_chronopics, false);
                        return;
                }
+               
+               string analysisOptions = "";
+               if(encoderPropulsive)
+                       analysisOptions = "p";
 
                double heightHigherCondition = -1;
                if(repetitiveConditionsWin.EncoderHeightHigher)         
@@ -236,6 +240,7 @@ public partial class ChronoJumpWindow
                                Util.ConvertToPoint(encoderSmoothEccCon),               //R decimal: '.'
                                Util.ConvertToPoint(encoderSmoothCon),                  //R decimal: '.'
                                findEccon(true),                                        //force ecS (ecc-conc 
separated)
+                               analysisOptions,
                                heightHigherCondition, heightLowerCondition,
                                meanSpeedHigherCondition, meanSpeedLowerCondition,
                                maxSpeedHigherCondition, maxSpeedLowerCondition,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]