[chronojump] encoder jumps height ok on bad executed jumps with force<0 at beginning



commit 54e5f56a5bc232ff20f708026ec936a6f3d4cab9
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue May 13 19:39:48 2014 +0200

    encoder jumps height ok on bad executed jumps with force<0 at beginning

 encoder/graph.R                |   16 +++++++++++-
 encoder/neuromuscularProfile.R |   13 ++++++++--
 encoder/util.R                 |   51 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 5 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 40cdc55..c9d158c 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -1057,7 +1057,19 @@ paint <- function(displacement, eccon, xmin, xmax, yrange, knRanges, superpose,
                if(length(which(force[concentric] <= 0)) == 0)
                        takeoff = -1
                else {
-                       takeoff = min(which(force[concentric]<=0)) + length_eccentric + length_isometric
+                       #1 get force only in concentric phase
+                       forceConcentric = force[concentric]
+                       print(c("forceConcentric",forceConcentric))
+
+                       #2 get maxSpeedT but relative to concentric, not all the ecc-con
+                       maxSpeedTInConcentric = maxSpeedT - (length_eccentric + length_isometric)
+                       
+                       takeoff = findTakeOff(forceConcentric, maxSpeedTInConcentric)
+
+                       #3 add eccentric and isometric
+                       takeoff = takeoff + length_eccentric + length_isometric
+                       print(c("takeoff",takeoff))
+                       
                        abline(v=takeoff,lty=1,col=cols[2]) 
                        mtext(text=paste(translate("land")," 
",sep=""),side=3,at=takeoff,cex=.8,adj=1,col=cols[2])
                        mtext(text=paste(" ", translate("air"), " 
",sep=""),side=3,at=takeoff,cex=.8,adj=0,col=cols[2])
@@ -1077,7 +1089,7 @@ paint <- function(displacement, eccon, xmin, xmax, yrange, knRanges, superpose,
                        }
                }
        
-               if(takeoff != -1)       
+               if(is.double(takeoff) && takeoff == -1)
                        mtext(text=paste(translate("jump height"),"=", 
                                         (position[concentric[length(concentric)]] - 
                                          position[concentric[(takeoff - length_eccentric - 
length_isometric)]])/10,
diff --git a/encoder/neuromuscularProfile.R b/encoder/neuromuscularProfile.R
index ee0881e..1e752f1 100644
--- a/encoder/neuromuscularProfile.R
+++ b/encoder/neuromuscularProfile.R
@@ -94,10 +94,13 @@ print(c("mean(e1f.force)",mean(e1f.force)))
        c.force <- mass * (c.accel$y + g)
 
        c.position = cumsum(c)
+       
        #c.takeoff = min(which(c.force <= weight))
-       c.takeoff = min(which(c.force <= 0))
+       #c.takeoff = min(which(c.force <= 0))
+       c.maxSpeedT = min(which(c.speed$y == max(c.speed$y)))
+       c.takeoff = findTakeOff(c.force, c.maxSpeedT)
+       
        c.jumpHeight = (c.position[length(c.position)] - c.position[c.takeoff]) /10
-
        print(c("jumpHeight", c.jumpHeight))
 
        #cl "land" from bottom to takeoff (force < weight)
@@ -229,7 +232,11 @@ neuromuscularProfileGetData <- function(displacement, curves, mass, smoothingC)
 
                takeoff = NULL
                #takeoff = min(which(force <= weight))
-               takeoff = min(which(force <= 0))
+               #takeoff = min(which(force <= 0))
+               maxSpeedT = min(which(speed$y == max(speed$y)))
+               takeoff = findTakeOff(force, maxSpeedT)
+               
+
                if(! is.null(takeoff)) {
                        jumpHeight = (position[length(position)] - position[takeoff]) /10
                        print(paste("Jump Height =", jumpHeight))
diff --git a/encoder/util.R b/encoder/util.R
index d396fe9..10c6664 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -74,3 +74,54 @@ extrema <- function(y, ndata = length(y), ndatam1 = ndata - 1) {
 }
 
 
+findTakeOff <- function(forceConcentric, maxSpeedTInConcentric) 
+{
+       #this can be a problem because some people does an strange countermovement at start of concentric 
movement
+       #this people moves arms down and legs go up
+       #at this moment can be a force == 0, and with this method can be detected as takeoff
+       #if this happens, takeoff will be very early and detected jump will be very high
+       #takeoff = min(which(force[concentric]<=0)) + length_eccentric + length_isometric
+
+       #then: find the force == 0 in concentric that is closer to max speed time
+
+       #------- example ------
+       #force=c(2000,1800,1600,1000,400,100,-10,-25,-5,150,400,600,200,11,-20,-60,-120,-40,5,150)
+       #maxSpeedT=17
+
+       #df=data.frame(force<0,force,abs(1:length(force)-maxSpeedT))
+       #colnames(df)=c("belowZero","force","dist")
+
+       #df2 = subset(df,subset=df$belowZero)
+       #> df2
+       #          belowZero force dist
+       #       7       TRUE   -10   10
+       #       8       TRUE   -25    9
+       #       9       TRUE    -5    8
+       #       15      TRUE   -20    2
+       #       16      TRUE   -60    1
+       #       17      TRUE  -120    0
+       #       18      TRUE   -40    1
+
+       #min(which(df2$dist == min(df2$dist)))
+       #[1] 6
+       #------- end of example ------
+
+       #1 create df dataFrame with forceData and it's distance to maxSpeedT
+       df=data.frame(forceConcentric < 0, forceConcentric, 
abs(1:length(forceConcentric)-maxSpeedTInConcentric))
+       colnames(df)=c("belowZero","force","dist")
+
+       #2 create df2 with only the rows where force is below or equal zero
+       df2 = subset(df,subset=df$belowZero)
+
+       #print("df2")
+       #print(df2)
+
+       #3 find takeoff as the df2 row with less distance to maxSpeedT
+       df2row = min(which(df2$dist == min(df2$dist)))
+       takeoff = as.integer(rownames(df2)[df2row])
+
+       #print(c("takeoff",takeoff))
+
+       return(takeoff)
+}
+


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