[chronojump] Minor fix. Changing indent lines
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Minor fix. Changing indent lines
- Date: Wed, 29 Jul 2015 14:59:53 +0000 (UTC)
commit f3988972900a6f6c98f7ce3d821b270fbbc5dbf9
Author: Xavier Padullés <x padulles gmail com>
Date: Wed Jul 29 16:58:37 2015 +0200
Minor fix. Changing indent lines
encoder/tests/getDynamics2016/getDynamics.R | 134 ++++++++++++------------
encoder/tests/smooth-2015.R | 146 +++++++++++++-------------
2 files changed, 140 insertions(+), 140 deletions(-)
---
diff --git a/encoder/tests/getDynamics2016/getDynamics.R b/encoder/tests/getDynamics2016/getDynamics.R
index 55ce159..9e671ce 100644
--- a/encoder/tests/getDynamics2016/getDynamics.R
+++ b/encoder/tests/getDynamics2016/getDynamics.R
@@ -1,79 +1,79 @@
#This version uses only one formula commented in each factor. It returns the mm advanced each ms.
getMovement <- function(
- encoderSignal, #ticks per ms coming from the encoder
- inverted, # The encoder is inverted if in concentric movement the signal is negative
- #-1 (encoder inverted) or 1 (encoder NOT inverted).
- gearedDown, # speed of person divided by speed of machine. Used in machines with moving pulleys
- encoderOnMachine, # TRUE if the encoder measures directly the movement of the body. FALSE the encoder
measures the movememt of the load
- encoderType,
- diameterRope, # diameter where the rope of the machine is wrapped.
- diameterEncoder) # In encoders "LINEAR" or "ROTARYAXIS", diameter where the encoder are measuring.
- # If the encoder and the rope are attached to the same point diameterRope=diameterEncoder)
+ encoderSignal, #ticks per ms coming from the encoder
+ inverted, # The encoder is inverted if in concentric movement the signal is negative
+ #-1 (encoder inverted) or 1 (encoder NOT inverted).
+ gearedDown, # speed of person divided by speed of machine. Used in machines with moving pulleys
+ encoderOnMachine, # TRUE if the encoder measures directly the movement of the body. FALSE the
encoder measures the movememt of the load
+ encoderType,
+ diameterRope, # diameter where the rope of the machine is wrapped.
+ diameterEncoder) # In encoders "LINEAR" or "ROTARYAXIS", diameter where the encoder are measuring.
+ # If the encoder and the rope are attached to the same point diameterRope=diameterEncoder)
{
- # On LINEAR encoder movement = R * (signal/200) * (2*pi) = signal * D * pi / 200
- # We asume D / (200 / pi) = D / d ----> d= 200 / pi
-
- # It should be assignet in the interface if encoderType = "LINEAR"
- if(encoderType == "LINEAR"){
- diameterEncoder == 200 / pi
- }
- movementBody = (
- encoderSignal
- * inverted #Change the sign of the signal if is inverted (-1) and do nothing if not inverted
(1)
- * (diameterRope / diameterEncoder) #On ROTARYFRICTION or LINEAR, if the encoder is not in the same
diameter
- #as the rope this proportion gives the realmovement of the rope
- * gearedDown #If the encoder is attached to the machine movementBody is multiplied by this
factor
- ^ encoderOnMachine #If the encoder is attached to the machine (1) gearedDown is multiplied
- ) #If the encoder is attached to the the body (0) gearedDown is not used
-
- movementMachine = (
- encoderSignal
- * inverted #Change the sign of the signal if is inverted (-1) and do nothing if
not inverted (1)
- * (diameterRope / diameterEncoder) #On ROTARYFRICTION, if the encoder is not in the same diameter
- #as the rope this proportion gives the realmovement of the rope
- / gearedDown #If the encoder is attached to the body movementMachine is divided by
this factor
- ^ (1 - encoderOnMachine) #If the encoder is attached to the body (0) gearedDown is divided
- ) #If the encoder is attached to the the body (1) gearedDown is not used
-
- return(list(body = movementBody, machine = movementMachine))
+ # On LINEAR encoder movement = R * (signal/200) * (2*pi) = signal * D * pi / 200
+ # We asume D / (200 / pi) = D / d ----> d= 200 / pi
+
+ # It should be assignet in the interface if encoderType = "LINEAR"
+ if(encoderType == "LINEAR"){
+ diameterEncoder == 200 / pi
+ }
+ movementBody = (
+ encoderSignal
+ * inverted #Change the sign of the signal if is inverted (-1) and do nothing if
not inverted (1)
+ * (diameterRope / diameterEncoder) #On ROTARYFRICTION or LINEAR, if the encoder is not in
the same diameter
+ #as the rope this proportion gives the realmovement of the rope
+ * gearedDown #If the encoder is attached to the machine movementBody is multiplied
by this factor
+ ^ encoderOnMachine #If the encoder is attached to the machine (1) gearedDown is multiplied
+ ) #If the encoder is attached to the the body (0) gearedDown is not used
+
+ movementMachine = (
+ encoderSignal
+ * inverted #Change the sign of the signal if is inverted (-1) and do
nothing if not inverted (1)
+ * (diameterRope / diameterEncoder) #On ROTARYFRICTION, if the encoder is not in the same
diameter
+ #as the rope this proportion gives the realmovement of the rope
+ / gearedDown #If the encoder is attached to the body movementMachine
is divided by this factor
+ ^ (1 - encoderOnMachine) #If the encoder is attached to the body (0) gearedDown is
divided
+ ) #If the encoder is attached to the the body (1) gearedDown is
not used
+
+ return(list(body = movementBody, machine = movementMachine))
}
getDynamics <- function(
- movementBody, #movement of the body
- movementMachine, #movement of the load. mm in gravitatory. Rad in inertial
- encoderType, # "LINEAR" , "ROTARYFRICTION" or "ROTARYAXIS"
- anglePush, # Angle from the floor to the line of movement of the person
- angleWeight, # Angle from the floor to the line of movement of the resistance
- diameterRope, # Diameter of the axis
- diameterEncoder, # Diameter where Linear or RotaryFriction encoder are attached
- massBody, # mass in Kg of the person
- exerciseBodyWeight, # Percentage of the body moved in this exercise
- massLoad) # mass of the extra load
+ movementBody, #movement of the body
+ movementMachine, #movement of the load. mm in gravitatory. Rad in inertial
+ encoderType, # "LINEAR" , "ROTARYFRICTION" or "ROTARYAXIS"
+ anglePush, # Angle from the floor to the line of movement of the person
+ angleWeight, # Angle from the floor to the line of movement of the resistance
+ diameterRope, # Diameter of the axis
+ diameterEncoder, # Diameter where Linear or RotaryFriction encoder are attached
+ massBody, # mass in Kg of the person
+ exerciseBodyWeight, # Percentage of the body moved in this exercise
+ massLoad) # mass of the extra load
{
- forceMachineInertial = abs(inertiaMomentum * angleAccel) * (2 / diameter.m) #Force raveived by the inertal
machine
- forceMachineGravitatory = massExtra*(g*sin(angleWeight * pi / 180) + accelMachine) #Force received by
gravitatory machine
- forceBody = massBody * (exerciseBodyWeight / 100) * accelBody #Force received by the body
- forceBodyWeight = g * sin(anglePush * pi / 180 # Body Weight force
- powerMachineInertial = abs((inertiaMomentum * angleAccel) * angleSpeed) #Power received by the inertial
machine
- powerMachineGravitatory = forceMachineGravitatory * speedMachine #Power received by the gravitatory machine
- powerBody = abs( (massBody * accelBody + massLoad * g * sin(anglePush * pi / 180)) * speed) #Total power
received by the body
-
- force = forceMachineInertial + forceMachineGravitatory + forceTotalBody + forceBodyWeight
- power = powerMachineInertial + PowerMachineGravitatory + powerBody
-
- return(list(
- massBody = massBody,
- force = force,
- power = power,
- forceMachineInertial = forceMachineInertial,
- forceMachineGravitatory = forceMachineGravitatory,
- forceBody = forceBody,
- forceBodyWeight = forceBodyWeight,
- powerMachineInertial = powerMachineInertial,
- PowerMachineGravitatory = PowerMachineGravitatory,
- powerBody = powerBody))
+ forceMachineInertial = abs(inertiaMomentum * angleAccel) * (2 / diameter.m) #Force raveived by the
inertal machine
+ forceMachineGravitatory = massExtra*(g*sin(angleWeight * pi / 180) + accelMachine) #Force received
by gravitatory machine
+ forceBody = massBody * (exerciseBodyWeight / 100) * accelBody #Force received by the body
+ forceBodyWeight = g * sin(anglePush * pi / 180 # Body Weight force
+ powerMachineInertial = abs((inertiaMomentum * angleAccel) * angleSpeed)
#Power received by the inertial machine
+ powerMachineGravitatory = forceMachineGravitatory * speedMachine #Power
received by the gravitatory machine
+ powerBody = abs( (massBody * accelBody + massLoad * g * sin(anglePush * pi
/ 180)) * speed) #Total power received by the body
+
+ force = forceMachineInertial + forceMachineGravitatory + forceTotalBody +
forceBodyWeight
+ power = powerMachineInertial + PowerMachineGravitatory + powerBody
+
+ return(list(
+ massBody = massBody,
+ force = force,
+ power = power,
+ forceMachineInertial = forceMachineInertial,
+ forceMachineGravitatory = forceMachineGravitatory,
+ forceBody = forceBody,
+ forceBodyWeight = forceBodyWeight,
+ powerMachineInertial = powerMachineInertial,
+ PowerMachineGravitatory = PowerMachineGravitatory,
+ powerBody = powerBody))
}
################### Not necessary if the above function is
used###################################################
diff --git a/encoder/tests/smooth-2015.R b/encoder/tests/smooth-2015.R
index 2d1012e..1034958 100644
--- a/encoder/tests/smooth-2015.R
+++ b/encoder/tests/smooth-2015.R
@@ -9,93 +9,93 @@ source("../util.R")
#into points like: (0, 0) , (5, 1) , (6, 1) , (7, 0) , (8, -1) , (9, -2), (10, 0)
getPositionFromChanges <- function(curveCompressed)
{
- chunks = unlist(strsplit(curveCompressed, " "))
- points = matrix(c(0,0), ncol=2)
- x = 0
- y = 0
- for(i in 1:length(chunks))
- {
- if(grepl("\\*",chunks[i])) {
- chunk = as.numeric(unlist(strsplit(chunks[i], "\\*"))) #from "0*1072" to: 0 1072 (as integers)
- if(chunk[1] == 0){
- x = x + chunk[2]
- } else {
- for( j in 1:chunk[2]){
- y = y + chunk[1]
- point = matrix(c(x, y), ncol=2)
- points <- rbind(points, point)
- x = x + 1
+ chunks = unlist(strsplit(curveCompressed, " "))
+ points = matrix(c(0,0), ncol=2)
+ x = 0
+ y = 0
+ for(i in 1:length(chunks))
+ {
+ if(grepl("\\*",chunks[i])) {
+ chunk = as.numeric(unlist(strsplit(chunks[i], "\\*"))) #from "0*1072" to: 0 1072 (as
integers)
+ if(chunk[1] == 0){
+ x = x + chunk[2]
+ } else {
+ for( j in 1:chunk[2]){
+ y = y + chunk[1]
+ point = matrix(c(x, y), ncol=2)
+ points <- rbind(points, point)
+ x = x + 1
+ }
+ }
+ } else {
+{
+ if(chunks[i] !=0 ){
+ y = y + as.numeric(chunks[i])
+ point = matrix(c(x, y), ncol=2)
+ points <- rbind(points, point)
+ }
+}
+x = x + 1
+ }
}
- }
- } else {
- {
- if(chunks[i] !=0 ){
- y = y + as.numeric(chunks[i])
- point = matrix(c(x, y), ncol=2)
- points <- rbind(points, point)
- }
- }
- x = x + 1
- }
- }
- return (points)
+return (points)
}
uncompress <- function(curveSent)
{
- chunks = unlist(strsplit(curveSent, " "))
- ints = NULL
- for(i in 1:length(chunks))
- {
- if(grepl("\\*",chunks[i])) {
- chunk = as.numeric(unlist(strsplit(chunks[i], "\\*"))) #from "0*1072" to: 0 1072 (as integers)
- chunk = rep(chunk[1],chunk[2])
- } else {
- chunk=chunks[i]
- }
- ints = c(ints,chunk)
- }
- return (as.numeric(ints))
+ chunks = unlist(strsplit(curveSent, " "))
+ ints = NULL
+ for(i in 1:length(chunks))
+ {
+ if(grepl("\\*",chunks[i])) {
+ chunk = as.numeric(unlist(strsplit(chunks[i], "\\*"))) #from "0*1072" to: 0 1072 (as
integers)
+ chunk = rep(chunk[1],chunk[2])
+ } else {
+ chunk=chunks[i]
+ }
+ ints = c(ints,chunk)
+ }
+ return (as.numeric(ints))
}
getKinematicsFromCompressed <- function(curve, smoothing){
- positionDiscarded <- getPositionFromChanges(curve)
-
- #Adding extra points at de beggining and the end to make it flat
- pfirst <- matrix(c(-5:-1, rep(0, 5)), ncol=2)
- xlast <- positionDiscarded[nrow(positionDiscarded), 1] + 5
- ylast <- positionDiscarded[nrow(positionDiscarded), 2]
- plast <- matrix(c(seq(from=(xlast + 1), to=(xlast + 5)), rep(ylast,5)), ncol=2)
- positionDiscarded <- rbind(pfirst, positionDiscarded, plast)
-
- positionDiscardedSmoothed <- smooth.spline(positionDiscarded, spar=smoothing)
- position <- predict(positionDiscardedSmoothed, -5:positionDiscarded[nrow(positionDiscarded), 1], deriv=0)
- speed <- predict(positionDiscardedSmoothed, 0:positionDiscarded[nrow(positionDiscarded) -5 ,1], deriv=1)
- accel <- predict(positionDiscardedSmoothed, 0:positionDiscarded[nrow(positionDiscarded) -5 ,1], deriv=2)
- return(list(positionDiscarded=positionDiscarded, position=position$y[6:(length(position$y) - 5)],
speed=speed$y, accel=accel$y*1000))
+ positionDiscarded <- getPositionFromChanges(curve)
+
+ #Adding extra points at de beggining and the end to make it flat
+ pfirst <- matrix(c(-5:-1, rep(0, 5)), ncol=2)
+ xlast <- positionDiscarded[nrow(positionDiscarded), 1] + 5
+ ylast <- positionDiscarded[nrow(positionDiscarded), 2]
+ plast <- matrix(c(seq(from=(xlast + 1), to=(xlast + 5)), rep(ylast,5)), ncol=2)
+ positionDiscarded <- rbind(pfirst, positionDiscarded, plast)
+
+ positionDiscardedSmoothed <- smooth.spline(positionDiscarded, spar=smoothing)
+ position <- predict(positionDiscardedSmoothed, -5:positionDiscarded[nrow(positionDiscarded), 1],
deriv=0)
+ speed <- predict(positionDiscardedSmoothed, 0:positionDiscarded[nrow(positionDiscarded) -5 ,1],
deriv=1)
+ accel <- predict(positionDiscardedSmoothed, 0:positionDiscarded[nrow(positionDiscarded) -5 ,1],
deriv=2)
+ return(list(positionDiscarded=positionDiscarded, position=position$y[6:(length(position$y) - 5)],
speed=speed$y, accel=accel$y*1000))
}
drawKinematics <- function(kinematics){
- par(mar=c(5,4,4,8))
- plot(kinematics$position, type="l")
- par(new=TRUE)
- plot(kinematics$speed, type="l", col="green", axes=FALSE, ylab=FALSE)
- axis(4, padj=-.5, col="green")
- par(new=TRUE)
- plot(kinematics$accel, type="l", col="blue", axes=FALSE, ylab=FALSE)
- axis(4, col="blue", padj=+1)
+ par(mar=c(5,4,4,8))
+ plot(kinematics$position, type="l")
+ par(new=TRUE)
+ plot(kinematics$speed, type="l", col="green", axes=FALSE, ylab=FALSE)
+ axis(4, padj=-.5, col="green")
+ par(new=TRUE)
+ plot(kinematics$accel, type="l", col="blue", axes=FALSE, ylab=FALSE)
+ axis(4, col="blue", padj=+1)
}
getSpeedByPosition <- function(position) {
- speed = list()
- speed$y <- diff(position)
- speed$x <- 1:length(speed$y)
- return(speed)
-
- #x <- 1:length(position)
- #speed <- predict(lm(position~x), deriv=1)
-
- #return(speed)
+ speed = list()
+ speed$y <- diff(position)
+ speed$x <- 1:length(speed$y)
+ return(speed)
+
+ #x <- 1:length(position)
+ #speed <- predict(lm(position~x), deriv=1)
+
+ #return(speed)
}
#Real displacement and the resulting compressed curve
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]