[chronojump] Inertial position diffs fixed now



commit 662d07147ac3aa812085c0b0683c4139710088b0
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu May 21 16:35:14 2015 +0200

    Inertial position diffs fixed now

 encoder/util.R |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/encoder/util.R b/encoder/util.R
index e852d93..1d9f8c5 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -800,7 +800,8 @@ getDisplacementInertial <- function(displacement, encoderConfigurationName, diam
                position = angle * diameterMeters / 2
                position = position * 1000      #m -> mm
                #this is to make "inverted cumsum"
-               displacement = c(position[1],diff(position)) #this displacement is going to be used now
+               displacement = diff(position) #this displacement is going to be used now
+               displacement = c(displacement[1],displacement) #this is to recuperate the lost 1st value in 
the diff operation
        } else if(encoderConfigurationName == "ROTARYFRICTIONSIDEINERTIAL" ||
               encoderConfigurationName == "ROTARYFRICTIONSIDEINERTIALLATERAL"){
          displacement = displacement * diameter / diameterExt #displacement of the axis
@@ -817,7 +818,8 @@ getDisplacementInertial <- function(displacement, encoderConfigurationName, diam
          position = angle * diameterMeters / 2
          position = position * 500     #m -> mm and the rope moves twice as the body
          #this is to make "inverted cumsum"
-         displacement = c(position[1],diff(position)) #this displacement is going to be used now
+         displacement = diff(position) #this displacement is going to be used now
+         displacement = c(displacement[1],displacement) #this is to recuperate the lost 1st value in the 
diff operation
        }
        
        
@@ -879,7 +881,12 @@ getDisplacementInertialBody <- function(positionStart, displacement, draw, title
        #don't use it
        #displacementPerson = c(positionStart,diff(positionPerson))
        #better have it starting with 0 and then speed calculations... will be correct
-       displacementPerson = c(positionPerson[1],diff(positionPerson))
+       #displacementPerson = c(positionPerson[1],diff(positionPerson))
+       #displacementPerson = diff(positionPerson)
+       #displacementPerson = c(displacementPerson[1],displacementPerson) #this is to recuperate the lost 1st 
value in the diff operation
+
+       #Important: In this case, as written aboce, the first 0 should be a 0, don't touch it!
+       displacementPerson = c(0,diff(positionPerson))
 
        #write(displacementPerson,stderr())
        


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]