[chronojump] Ugly fix of the triggers time shifting with T0



commit 4bc4a73d773750aed3ef9fc20a6f84baed8c00a0
Author: Xavier Padullés <x padulles gmail com>
Date:   Mon Mar 1 19:19:42 2021 +0100

    Ugly fix of the triggers time shifting with T0

 r-scripts/sprintEncoder.R | 20 ++++++++++++++------
 r-scripts/sprintUtil.R    |  2 ++
 2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index 7979d0cc..909918b8 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -243,7 +243,7 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
 
         print("startTime:")
         print(totalTime[trimmingSamples$start] + T0)
-        return(list(Vmax = Vmax, K = K, T0,
+        return(list(Vmax = Vmax, K = K, T0 = T0,
                     time = time, rawPosition = position + P0, rawSpeed = speed, rawAccel = accel, rawForce = 
totalForce, rawPower = power,
                     rawVmax = max(speed[trimmingSamples$start:trimmingSamples$end]), rawAmax = 
max(accel[trimmingSamples$start:trimmingSamples$end]), rawFmax = 
max(totalForce[trimmingSamples$start:trimmingSamples$end]), rawPmax = 
max(power[trimmingSamples$start:trimmingSamples$end]),
                     startSample = trimmingSamples$start, startTime = totalTime[trimmingSamples$start] + T0, 
endSample = trimmingSamples$end, testLength = testLength, longEnough = longEnough, regressionDone = 
regression$regressionDone, timeBefore = T0, startAccel = startAccel))
@@ -597,12 +597,19 @@ plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics,
         }
 
        #triggers
+        # triggersOn = triggersOn + sprintFittedDynamics$T0
+        # triggersOff = triggersOff + sprintFittedDynamics$T0
         print("triggersOn on plot:")
         print(triggersOn)
-           abline(v=triggersOn, col="green")
-           print("triggersOff plot:")
-           print(triggersOff)
-           abline(v=triggersOff, col="red")
+        #TODO: Find why the T0 have to be added twice
+        triggersOn = triggersOn + 2*sprintFittedDynamics$T0
+        print(triggersOn)
+       abline(v=triggersOn, col="green")
+       print("triggersOff plot:")
+       print(triggersOff)
+       triggersOff = triggersOff + 2*sprintFittedDynamics$T0
+       print(triggersOff)
+       abline(v=triggersOff, col="red")
 
 
         plotSize = par("usr")
@@ -718,7 +725,8 @@ testEncoderCJ <- function(filename, testLength, splitLength, mass, personHeight,
         if (sprintRawDynamics$longEnough && sprintRawDynamics$regressionDone)
         {
                 print(paste("Vmax:", sprintRawDynamics$Vmax))
-                sprintFittedDynamics = getDynamicsFromSprint(K = sprintRawDynamics$K, Vmax = 
sprintRawDynamics$Vmax, Mass = mass, T0 = 0, Temperature = tempC, Height = personHeight)
+                print(paste("T0:", sprintRawDynamics$T0))
+                sprintFittedDynamics = getDynamicsFromSprint(K = sprintRawDynamics$K, Vmax = 
sprintRawDynamics$Vmax, Mass = mass, T0 = sprintRawDynamics$T0, Temperature = tempC, Height = personHeight)
                 print(paste("K =",sprintFittedDynamics$K.fitted, "Vmax =", sprintFittedDynamics$Vmax.fitted))
                 # print("triggersOn in testEncoderCJ:")
                 # print(op$triggersOnList)
diff --git a/r-scripts/sprintUtil.R b/r-scripts/sprintUtil.R
index 1aa3a486..cdb6a6aa 100644
--- a/r-scripts/sprintUtil.R
+++ b/r-scripts/sprintUtil.R
@@ -26,6 +26,7 @@ source(paste(options[1], "/scripts-util.R", sep=""))
 #Temperature in the moment of the test and Velocity of the wind).
 getDynamicsFromSprint <- function(K, Vmax, Mass, T0 = 0, Temperature = 25, Height , Vw = 0, maxTime = 10)
 {
+        print("In getDynamicsFromEncoder()")
        # maxTime is used for the numerical calculations
         # Constants for the air friction modeling
         ro0 = 1.293
@@ -44,6 +45,7 @@ getDynamicsFromSprint <- function(K, Vmax, Mass, T0 = 0, Temperature = 25, Heigh
         sfv.rel.fitted = sfv.fitted / Mass
 
         # Getting values from the exponential model. Used for numerical calculations
+        print(paste("T0:", T0))
         time = seq(0,maxTime + T0, by = 0.01)      
         v.fitted=Vmax*(1-exp(-K*time))
         a.fitted = Vmax*K*exp(-K*time)


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