[chronojump] findSmoothingsEC using power instead of speed
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] findSmoothingsEC using power instead of speed
- Date: Tue, 19 May 2015 14:06:55 +0000 (UTC)
commit 9ec10b59ecccc97a80bfb8f91fc5865aea72fe32
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue May 19 16:01:17 2015 +0200
findSmoothingsEC using power instead of speed
encoder/graph.R | 37 +++++++++++++++++++++++++++++--------
encoder/util.R | 8 +++++---
2 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index bc3f07c..9f30916 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -544,12 +544,20 @@ findCurvesOld <- function(displacement, eccon, min_height, draw, title) {
return(as.data.frame(cbind(start,end,startH)))
}
-
-
+findSmoothingsECGetPower <- function(speed)
+{
+ acceleration <- getAcceleration(speed)
+ acceleration$y <- acceleration$y * 1000
+ force <- 50 * (acceleration$y + 9.81) #Do always with 50Kg right now. TODO: See if there's a need of
real mass value
+ power <- force * speed$y
+ return(power)
+}
#called on "ec" and "ce" to have a smoothingOneEC for every curve
#this smoothingOneEC has produce same speeds than smoothing "c"
findSmoothingsEC <- function(singleFile, displacement, curves, eccon, smoothingOneC)
{
+ #print(c("findSmoothingsEC: eccon smoothingOneC", eccon, smoothingOneC))
+
smoothings = NULL
n=length(curves[,1])
@@ -600,19 +608,32 @@ findSmoothingsEC <- function(singleFile, displacement, curves, eccon, smoothingO
speed <- getSpeed(concentric, smoothingOneC)
print("called")
- maxSpeedC=max(speed$y)
+ #maxSpeedC=max(speed$y)
+ powerC <- findSmoothingsECGetPower(speed)
+ maxPowerC <- max(powerC)
#find max speed at "ec" that's similar to maxSpeedC
smoothingOneEC = smoothingOneC
- for(j in seq(as.numeric(smoothingOneC),0,by=-.01)) {
+ for(j in seq(as.numeric(smoothingOneC),0,by=-.01))
+ {
print("calling speed 2")
#write("calling speed 2", stderr())
speed <- getSpeed(eccentric.concentric, j)
print("called")
+
smoothingOneEC = j
- maxSpeedEC=max(speed$y)
+
+ #don't do it base on speed because difference is very tiny
+ #do it based on power
+ #maxSpeedEC=max(speed$y)
#write(c("j",j,"maxC",round(maxSpeedC,3),"maxEC",round(maxSpeedEC,3)),stderr())
- if(maxSpeedEC >= maxSpeedC)
+ #if(maxSpeedEC >= maxSpeedC)
+ # break
+
+ powerEC <- findSmoothingsECGetPower(speed)
+ maxPowerEC <- max(powerEC)
+
+ if(maxPowerEC >= maxPowerC)
break
}
@@ -1493,13 +1514,13 @@ findInertialCurves <- function(paf) {
write("findInertialCurves",stderr())
im = paf[,findPosInPaf("Inertia", "")]
- write(im,stderr())
+ #write(im,stderr())
if(length(im) < 1)
return (FALSE)
for(i in 1:length(im)) {
- write(c("im: ", im[i]),stderr())
+ #write(c("im: ", im[i]),stderr())
if(im[i] > 0) {
return (TRUE)
}
diff --git a/encoder/util.R b/encoder/util.R
index 9dade04..e8552b0 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -367,8 +367,8 @@ reduceCurveBySpeed <- function(eccon, row, startT, startH, displacement, smoothi
#eccon="ecS" means ecSeparated. two times each curve: one for "e", one for "c"
kinematicsF <- function(displacement, massBody, massExtra, exercisePercentBodyWeight,
encoderConfigurationName,diameter,diameterExt,anglePush,angleWeight,inertiaMomentum,gearedDown,
- smoothingOneEC, smoothingOneC, g, eccon, isPropulsive) {
-
+ smoothingOneEC, smoothingOneC, g, eccon, isPropulsive)
+{
smoothing = 0
if(eccon == "c" || eccon == "e")
smoothing = smoothingOneC
@@ -376,7 +376,7 @@ kinematicsF <- function(displacement, massBody, massExtra, exercisePercentBodyWe
smoothing = smoothingOneEC
- #print(c(" smoothing:",smoothing))
+ print(c("eccon, smoothing:",eccon, smoothing))
#x vector should contain at least 4 different values
if(length(displacement) >= 4)
@@ -456,6 +456,8 @@ kinematicsF <- function(displacement, massBody, massExtra, exercisePercentBodyWe
if(inertiaMomentum > 0 && (eccon == "e" || eccon == "ec") && accel$y[1] < 0)
start <- min(which(accel$y > 0))
+ #print(c("kinematicsF start end",start,end))
+
return(list(
speedy = speed$y[start:end],
accely = accel$y[start:end],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]