[chronojump] SprintEncoder. Improved detection of wrong execution.



commit c377b81205f8d670e06bb8f84e8f21ad11661536
Author: Xavier Padullés <x padulles gmail com>
Date:   Mon Feb 18 18:05:50 2019 +0100

    SprintEncoder. Improved detection of wrong execution.

 r-scripts/scripts-util.R  | 11 +++++++++++
 r-scripts/sprintEncoder.R |  5 +++++
 2 files changed, 16 insertions(+)
---
diff --git a/r-scripts/scripts-util.R b/r-scripts/scripts-util.R
index cdde2aca..05db2963 100644
--- a/r-scripts/scripts-util.R
+++ b/r-scripts/scripts-util.R
@@ -1,7 +1,18 @@
 #Function to get the interpolated x at a given y
 interpolateXAtY <- function(X, Y, desiredY){
+        if(max(Y) < desiredY){
+                print("desiredY is greater than max(Y)")
+                return(max(Y))
+        }
+                
         #find the closest sample
         nextSample = 1
+        print("X:")
+        print(X)
+        print("Y:")
+        print(Y)
+        print("desiredY:")
+        print(desiredY)
         while (Y[nextSample] < desiredY){
                 nextSample = nextSample +1
         }
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index aa1fae19..77dcb48e 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -293,6 +293,11 @@ plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics, title
 #Detecting where the sprint start and stops
 getTrimmingSamples <- function(totalTime, position, speed, accel, testLength)
 {
+        if(position[length(position)] < 5){
+                print("Sprint too short")
+                return()
+        }
+                
         #The test starts when the speed is grater than 1
         startSample = 0
         startingSample = FALSE


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