[chronojump] raceAnalyzer export instantaneous exports force and power fitted



commit ac13636c7699cfd4a0ca3d8e0422f494dc839afd
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 25 19:15:18 2021 +0200

    raceAnalyzer export instantaneous exports force and power fitted

 r-scripts/sprintEncoder.R | 51 +++++++++++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 19 deletions(-)
---
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index 2f0444d76..00dcc9ce2 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -255,8 +255,8 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
         meanSpeed = splits$meanSpeed
         meanForce = splits$meanForce
         meanPower = splits$meanPower
-        
-        return(list(Vmax = Vmax, K = K, T0 = T0,
+
+        return(list(Vmax = Vmax, K = K, T0 = T0, Ka=Ka, Vw=Vw, Mass=Mass,
                     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]),
@@ -797,27 +797,40 @@ testEncoderCJ <- function(filename, filenameInstantaneous, testLength, splitLeng
 
                if(filenameInstantaneous != "")
                {
-                       #print("sprintRawDynamics lengths:")
-                       #print(length(sprintRawDynamics$time))
-                       #print(length(sprintRawDynamics$rawPosition))
-                       #print(length(sprintRawDynamics$rawSpeed))
-                       #print(length(sprintRawDynamics$rawAccel))
-                       #print(length(sprintRawDynamics$rawForce))
-                       #print(length(sprintRawDynamics$rawPower))
-
-                       sfitted = sprintRawDynamics$Vmax * (1-exp(-sprintRawDynamics$K * 
sprintRawDynamics$time))
-                       afitted = sprintRawDynamics$Vmax * sprintRawDynamics$K * exp(-sprintRawDynamics$K * 
sprintRawDynamics$time)
-
-                       exportInstantaneous <- cbind (sprintRawDynamics$time, sprintRawDynamics$rawPosition,
-                                       c(0, sprintRawDynamics$rawSpeed), c(0, 0, 
sprintRawDynamics$rawAccel), #0s are to have same length in all variables
-                                       sprintRawDynamics$rawForce, sprintRawDynamics$rawPower,
-                                       sfitted,
-                                       afitted
+                       srd = sprintRawDynamics #to shorten formulas
+
+                       print("srd lengths:")
+                       #print(length(srd$time))
+                       #print(length(srd$rawPosition))
+                       #print(length(srd$rawSpeed))
+                       #print(length(srd$rawAccel))
+                       #print(length(srd$rawForce))
+                       #print(length(srd$rawPower))
+
+                       s.fitted = srd$Vmax * (1-exp(-srd$K * srd$time))
+                       a.fitted = srd$Vmax * srd$K * exp(-srd$K * srd$time)
+                       f.fitted = srd$Mass * a.fitted + srd$Ka * (s.fitted - srd$Vw)^2
+                       p.fitted = f.fitted * s.fitted
+
+                       print(length(s.fitted))
+                       print(length(a.fitted))
+                       print(length(f.fitted))
+                       print(length(p.fitted))
+
+                       print("srd$Mass, srd$Ka, srd$Vw:")
+                       print(srd$Mass)
+                       print(srd$Ka)
+                       print(srd$Vw)
+
+                       exportInstantaneous <- cbind (srd$time, srd$rawPosition,
+                                       c(0, srd$rawSpeed), c(0, 0, srd$rawAccel), #0s are to have same 
length in all variables
+                                       srd$rawForce, srd$rawPower,
+                                       s.fitted, a.fitted, f.fitted, p.fitted
                                        )
 
                        colnames(exportInstantaneous) = c("Time", "Position",
                                        "Speed (raw)", "Accel (raw)", "Force (raw)", "Power (raw)",
-                                       "Speed (fitted)", "Accel (fitted)")#, "Force (fitted)", "Power 
(fitted)")
+                                       "Speed (fitted)", "Accel (fitted)", "Force (fitted)", "Power 
(fitted)")
 
                        if(op$decimalCharAtExport == ".")
                                write.csv(exportInstantaneous, file = filenameInstantaneous, row.names = 
FALSE, na="")


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