[chronojump] RunEncoderMinAccel (startAccel) passed and applied in R



commit 8d78cc357fc07a3543b6880a92d50bc6f99bda6d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Feb 6 12:07:06 2020 +0100

    RunEncoderMinAccel (startAccel) passed and applied in R

 r-scripts/sprintEncoder.R | 19 +++++++++++--------
 src/gui/runEncoder.cs     |  1 +
 src/runEncoder.cs         |  5 ++++-
 3 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index 227c8d4a..d56fe245 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -46,8 +46,9 @@ assignOptions <- function(options) {
                 device         = options[10],
                 title          = options[11],
                 datetime       = options[12],
-               triggersOnList  = as.numeric(unlist(strsplit(options[13], "\\;"))),
-               triggersOffList  = as.numeric(unlist(strsplit(options[14], "\\;")))
+                startAccel     = options[13],
+               triggersOnList  = as.numeric(unlist(strsplit(options[14], "\\;"))),
+               triggersOffList  = as.numeric(unlist(strsplit(options[15], "\\;")))
         ))
 }
 
@@ -57,7 +58,7 @@ op <- assignOptions(options)
 op$title = fixTitleAndOtherStrings(op$title)
 op$datetime = fixDatetime(op$datetime)
 
-getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, Height , Vw = 0, device = 
"MANUAL", startAccel = 10)
+getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, Height , Vw = 0, device = 
"MANUAL", startAccel)
 {
         print("#####Entering in getSprintFromEncoder###############")
         # Constants for the air friction modeling
@@ -238,7 +239,7 @@ plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics,
                                   plotFittedAccel = FALSE,
                                   plotFittedForce = FALSE,
                                   plotFittedPower = FALSE,
-                                  startAccel = 10,
+                                  startAccel,
                                   plotStartDetection = TRUE)
 {
         #Plotting position
@@ -532,7 +533,7 @@ plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics,
 }
 
 #Detecting where the sprint start and stops
-getTrimmingSamples <- function(totalTime, position, speed, accel, testLength, startAccel = 10)
+getTrimmingSamples <- function(totalTime, position, speed, accel, testLength, startAccel)
 {
         print("#########Entering getTrimmingSamples###########33")
         #The test starts when the acceleration is greater than startAccel m/s²
@@ -588,6 +589,7 @@ getTrimmingSamples <- function(totalTime, position, speed, accel, testLength, st
                 endSample = endSample +1
         return(list(start = startSample, end = endSample, errorInStart = !startingSample ))
 }
+
 tryNLS <- function(data){
         print("#######Entering tryNLS#########")
         tryCatch (
@@ -606,9 +608,9 @@ tryNLS <- function(data){
         )
 }
 
-testEncoderCJ <- function(filename, testLength, mass, personHeight, tempC)
+testEncoderCJ <- function(filename, testLength, mass, personHeight, tempC, startAccel)
 {
-        sprintRawDynamics = getSprintFromEncoder(filename, testLength, op$mass, op$tempC, op$personHeight, 
Vw = 0, device = op$device, startAccel = 10)
+        sprintRawDynamics = getSprintFromEncoder(filename, testLength, op$mass, op$tempC, op$personHeight, 
Vw = 0, device = op$device, startAccel)
         # print("sprintRawDynamics:")
         # print(sprintRawDynamics)
         if (sprintRawDynamics$longEnough & sprintRawDynamics$regressionDone)
@@ -631,6 +633,7 @@ testEncoderCJ <- function(filename, testLength, mass, personHeight, tempC)
                                       plotFittedAccel = FALSE,
                                       plotFittedForce = FALSE,
                                       plotFittedPower = TRUE,
+                                     startAccel,
                                       plotStartDetection = FALSE)
                 exportSprintDynamics(sprintFittedDynamics)
         } else
@@ -638,5 +641,5 @@ testEncoderCJ <- function(filename, testLength, mass, personHeight, tempC)
 }
 
 prepareGraph(op$os, pngFile, op$graphWidth, op$graphHeight)
-testEncoderCJ(op$filename, op$testLength, op$mass, op$personHeight, op$tempC)
+testEncoderCJ(op$filename, op$testLength, op$mass, op$personHeight, op$tempC, op$startAccel)
 endGraph()
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index 2041c3c8..e8a57808 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -960,6 +960,7 @@ public partial class ChronoJumpWindow
                                race_analyzer_device,
                                title,
                                dateTimeGraph,
+                               preferences.runEncoderMinAccel,
                                triggerListRunEncoder);
 
                reg.CallR(imageWidth, imageHeight);
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 60abce8f..f970756a 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -294,10 +294,11 @@ public class RunEncoderGraph
        private RunEncoder.Devices device;
        private string title;
        private string datetime;
+       private double startAccel;
        private TriggerList triggerList;
 
        public RunEncoderGraph(int testLength, double mass, double personHeight, double tempC, 
RunEncoder.Devices device,
-                       string title, string datetime, TriggerList triggerList)
+                       string title, string datetime, double startAccel, TriggerList triggerList)
        {
                this.testLength = testLength;
                this.mass = mass;
@@ -306,6 +307,7 @@ public class RunEncoderGraph
                this.device = device;
                this.title = title;
                this.datetime = datetime;
+               this.startAccel = startAccel;
                this.triggerList = triggerList;
        }
 
@@ -338,6 +340,7 @@ public class RunEncoderGraph
                        "#device\n" +                   device.ToString() + "\n" +
                        "#title\n" +                    title + "\n" +
                        "#datetime\n" +                 datetime + "\n" +
+                       "#startAccel\n" +               Util.ConvertToPoint(startAccel) + "\n" +
                        printTriggers(TriggerList.Type3.ON) + "\n" +
                        printTriggers(TriggerList.Type3.OFF);
 


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