[chronojump] improved smoothing of the variable diameter
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] improved smoothing of the variable diameter
- Date: Thu, 23 Apr 2015 16:59:58 +0000 (UTC)
commit 0f2f0362031f7ad0a2aa213ed9a19fb029520f9d
Author: Xavier Padullés <x padulles gmail com>
Date: Thu Apr 23 18:58:19 2015 +0200
improved smoothing of the variable diameter
encoder/tests/conical_diameters.R | 45 ++++++++++++++++++++++++++++++++----
1 files changed, 40 insertions(+), 5 deletions(-)
---
diff --git a/encoder/tests/conical_diameters.R b/encoder/tests/conical_diameters.R
index 21b661f..14aff87 100644
--- a/encoder/tests/conical_diameters.R
+++ b/encoder/tests/conical_diameters.R
@@ -25,10 +25,37 @@ getInertialDiametersPerTick <- function(d_vector)
# Converting the number of the loop to ticks of the encoder
d[,1] <- d[,1]*200
+ # Adding an extra point at the begining of the diameters matrix to match better the first point
+ x1 <- d[1,1]
+ y1 <- d[1,2]
+ x2 <- d[2,1]
+ y2 <- d[2,2]
+ lambda <- 200
+ x0 <- x1 - lambda
+ y0 <- y1 - lambda*(y2 - y1)/(x2 - x1)
+ p0 <- matrix(c(x0, y0), ncol=2)
+ d <- rbind(p0, d)
+
+ # Adding an extra point at the end of the diameters matrix to match better the last point
+ last <- length(d[,1])
+ x1 <- d[(last - 1),1]
+ y1 <- d[(last - 1),2]
+ x2 <- d[last,1]
+ y2 <- d[last,2]
+ lambda <- 200
+ xFinal <- x2 + lambda
+ yFinal <- y2 + lambda*(y2 - y1)/(x2 - x1)
+ pFinal <- matrix(c(xFinal, yFinal), ncol=2)
+ d <- rbind(d, pFinal)
+
+
# Linear interpolation of the radius across the lenght of the measurement of the diameters
- d.approx <- approx(x=d[,1], y=d[,2], seq(from=1, to=d[length(d[,1]),1]))
- print("Diameter in getInertialDiametersPerTick after conversion")
- print(d.approx$y)
+ #d.approx <- approx(x=d[,1], y=d[,2], seq(from=1, to=d[length(d[,1]),1]))
+ print(d)
+ d.smoothed <- smooth.spline(d, spar=0.4)
+ d.approx <- predict(d.smoothed, 0:d[length(d[,1]), 1],0)
+ #print("Diameter in getInertialDiametersPerTick after conversion")
+ print(length(d.approx$y))
return(d.approx$y)
}
#Returns the instant diameter every milisecond
@@ -50,7 +77,15 @@ getOptionsFromFile <- function(optionsFile, lines) {
}
options <- getOptionsFromFile("~/chronojump/encoder/tests/conical_diameters_Roptions.txt", 32)
-op <- assignOptions(optionsFile)
+op <- assignOptions(options)
diameter <- as.numeric(unlist(strsplit("1.5; 1.91; 2.64; 3.38; 3.83; 4.14; 4.28; 4.46; 4.54; 4.77; 4.96;
5.13; 5.3; 5.55", "\\;")))
diametersPerTick <- getInertialDiametersPerTick(diameter)
-diametersPerMs <- getInertialDiametersPerMs(displacement, diameter)
+diametersPerMs <- getInertialDiametersPerMs(displacement, diametersPerTick)
+displacementConical <- getDisplacementInertial(displacement,"ROTARYAXISINERTIAL", diametersPerMs, 6)
+positionConical <- cumsum(displacementConical)
+plot(position, t="l")
+lines(diametersPerMs*100, t="l", col="red")
+lines(positionConical, t="l", col="green")
+speedConical <- getSpeed(displacementConical, 0.7)
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]