[chronojump] RaceAnalyzer. Fixed problem with high initial speed



commit bd6f4d30731affcf60b449e05e8f8be9a54795aa
Author: Xavier Padullés <x padulles gmail com>
Date:   Fri Mar 15 19:40:29 2019 +0100

    RaceAnalyzer. Fixed problem with high initial speed

 arduino/raceAnalyzer/raceAnalyzer.ino |  7 +++++++
 r-scripts/sprintEncoder.R             | 12 ++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/arduino/raceAnalyzer/raceAnalyzer.ino b/arduino/raceAnalyzer/raceAnalyzer.ino
index 25b3ac8d..d547c688 100644
--- a/arduino/raceAnalyzer/raceAnalyzer.ino
+++ b/arduino/raceAnalyzer/raceAnalyzer.ino
@@ -173,6 +173,13 @@ void start_capture()
   Serial.println("Starting capture...");
   totalTime = 0;
   lastSampleTime = micros();
+
+  //First sample with a low speed is mandatory to good detection of the start
+  Serial.print(0);
+  Serial.print(";");
+  Serial.print(lastSampleTime);
+  Serial.print(";");
+  Serial.println(0);
   capturing = true;
   encoderDisplacement = 0;
 }
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index c3ad294d..d0b6c2b1 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -94,8 +94,8 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
         # print(forceBody)
         # print("forceRope:")
         # print(encoderCarrera$force)
-        print("power:")
-        print(power)
+        # print("power:")
+        # print(power)
         
         #Finding when the sprint starts
         trimmingSamples = getTrimmingSamples(totalTime, position, speed, accel, testLength)
@@ -398,6 +398,14 @@ getTrimmingSamples <- function(totalTime, position, speed, accel, testLength)
         while(speed[startSample] > 0.5)
         {
                 startSample = startSample -1
+                
+                #If the sprint doesn't start at a null speed, the first sample is used
+                #In old versions of RaceAnalyzer it was possible to start with a high speed.
+                if(startSample == 0)
+                {
+                        startSample = 1
+                        break
+                }
         }
         
         #Zeroing time to the initial acceleration sample


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