[chronojump] Fixed the time shifting
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed the time shifting
- Date: Sat, 16 Jan 2021 10:37:35 +0000 (UTC)
commit e14e275f291fa79aa8677719fd6b46472ff26110
Author: Xavier Padullés <testing chronojump org>
Date: Mon Jan 11 13:52:09 2021 +0100
Fixed the time shifting
r-scripts/scripts-util.R | 4 ++--
r-scripts/sprintEncoder.R | 11 ++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/r-scripts/scripts-util.R b/r-scripts/scripts-util.R
index 36dc77db..0e5a7de7 100644
--- a/r-scripts/scripts-util.R
+++ b/r-scripts/scripts-util.R
@@ -93,7 +93,7 @@ getAreaUnderCurve <- function(x, y)
getAreaUnderCurve2 <- function(x, y)
{
- print("Calculating Area")
+ # print("Calculating Area")
# print("X:")
# print(x)
# print("Y:")
@@ -117,7 +117,7 @@ getAreaUnderCurve2 <- function(x, y)
#Calculates the mean of a curve interval
getMeanValue <- function(X, Y, startX, endX)
{
- print(paste("Calculating mean in the X range of [", startX, ",", endX, "]"))
+ # print(paste("Calculating mean in the X range of [", startX, ",", endX, "]"))
# print("x:")
# print(X)
# print("y:")
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index 2793b978..ce05d56f 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -199,8 +199,8 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
# timeBefore = speed[trimmingSamples$start] * ((time[trimmingSamples$start + 1]) /
(speed[trimmingSamples$start + 1] - speed[trimmingSamples$start]))
# time = time + timeBefore
- data = data.frame(time = c(0,time[trimmingSamples$start:trimmingSamples$end]), speed =
c(0,speed[trimmingSamples$start:trimmingSamples$end]))
- #print(data)
+ data = data.frame(time = time[trimmingSamples$start:trimmingSamples$end], speed =
speed[trimmingSamples$start:trimmingSamples$end])
+ print(data)
print("Trying nls")
regression = tryNLS(data)
@@ -232,12 +232,13 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
Vmax =summary(regression$model)$coeff[1,1]
K = summary(regression$model)$coeff[2,1]
T0 = summary(regression$model)$coeff[3,1]
- time = totalTime + T0
+ print(paste("T0:", T0))
+ time = time + T0
return(list(Vmax = Vmax, K = K, T0,
time = time, rawPosition = position, 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, endSample = trimmingSamples$end, testLength =
testLength, longEnough = longEnough, regressionDone = regression$regressionDone, timeBefore = timeBefore,
startAccel = startAccel))
+ startSample = trimmingSamples$start, endSample = trimmingSamples$end, testLength =
testLength, longEnough = longEnough, regressionDone = regression$regressionDone, timeBefore = T0, startAccel
= startAccel))
}
plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics,
@@ -668,7 +669,7 @@ tryNLS <- function(data){
# print(data)
tryCatch (
{
- model = nls(speed ~ Vmax*(1-exp(-K*(time - T0))), data,
+ model = nls(speed ~ Vmax*(1-exp(-K*(time + T0))), data,
start = list(Vmax = max(data[,"speed"]), K = 1, T0 = 0.2),
control=nls.control(warnOnly=TRUE))
# print("model:")
# print(model)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]