[chronojump] Added smoothing in getDiametersPerTick()
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Added smoothing in getDiametersPerTick()
- Date: Mon, 27 Apr 2015 17:24:06 +0000 (UTC)
commit 67797714f04c92b5b0fd21c039506a729ba3a984
Author: Xavier Padullés <x padulles gmail com>
Date: Mon Apr 27 19:10:38 2015 +0200
Added smoothing in getDiametersPerTick()
encoder/util.R | 32 +++++++++++++++++++++++++++++---
1 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/encoder/util.R b/encoder/util.R
index 1c2008d..2e25b89 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -204,7 +204,6 @@ findTakeOff <- function(forceConcentric, maxSpeedTInConcentric)
getSpeed <- function(displacement, smoothing) {
#no change affected by encoderConfiguration
-
return (smooth.spline( 1:length(displacement), displacement, spar=smoothing))
}
@@ -865,12 +864,39 @@ 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]))
+ #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)
return(d.approx$y)
}
#Returns the instant diameter every milisecond
-getInertialDiameterPerMs <- function(diameterPerTick, displacement)
+getInertialDiametersPerMs <- function(diameterPerTick, displacement)
{
return(diameterPerTick[abs(cumsum(displacement))])
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]