[chronojump] Added readme.txt about encoder R files



commit 6ef7600df57362f4a2bd3d5ea0ac9b515c06c512
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Apr 14 17:27:50 2015 +0200

    Added readme.txt about encoder R files

 encoder/graph.R    |   22 +++++++++++++++++-----
 encoder/readme.txt |   42 ++++++++++++++++++++++++++++++++++++++++++
 encoder/util.R     |    4 +++-
 src/gui/encoder.cs |    1 +
 4 files changed, 63 insertions(+), 6 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 1effd4d..274e79b 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -156,13 +156,22 @@ findCurves <- function(displacement, eccon, min_height, draw, title) {
        start=0; end=0; startH=0
        tempStart=0; tempEnd=0;
        #TODO: fer algo per si no es detecta el minindex previ al salt
-       if(eccon=="c") {
+       if(eccon=="c") 
+       {
+               #1) fix big problems with set (signal). No minindex or no maxindex
                if(length(position.ext$minindex)==0) { position.ext$minindex=cbind(1,1) }
                if(length(position.ext$maxindex)==0) { 
position.ext$maxindex=cbind(length(position),length(position)) }
-               #fixes if 1st minindex is after 1st maxindex
+
+               #2) fixes if 1st minindex is after 1st maxindex
                if(position.ext$maxindex[1] < position.ext$minindex[1]) { position.ext$minindex = 
rbind(c(1,1),position.ext$minindex) } 
-               row=1; i=1; j=1
-               while(max(c(i,j)) <= 
min(c(length(position.ext$minindex[,1]),length(position.ext$maxindex[,1])))) {
+               
+               #3 find the curves (enter the bucle)
+
+               row=1; #row means each curve
+               i=1; j=1 #i minimums; j maximums
+               while(max(c(i,j)) <= 
min(c(length(position.ext$minindex[,1]),length(position.ext$maxindex[,1])))) 
+               {
+                       #3.1) assign tempStart and tempEnd using extrema data
 
                        #tempStart at the end of minindexs
                        #tempStart = position.ext$minindex[i,2]
@@ -179,6 +188,8 @@ findCurves <- function(displacement, eccon, min_height, draw, title) {
                        #end at the first maximum value
                        #tempEnd = position.ext$maxindex[j,1]
 
+                       #3.2) get heigh. Store curve if it's enough
+
                        height=position[tempEnd]-position[tempStart]
                        if(height >= min_height) { 
                                start[row] = tempStart
@@ -188,7 +199,7 @@ findCurves <- function(displacement, eccon, min_height, draw, title) {
                                #if(eccon=="c") { break } #c only needs one result
                        } 
                        i=i+1; j=j+1
-               }
+               } #end of while
        } else { #ec, ecS, ce, ceS
                row=1; i=1; j=2
 
@@ -1964,6 +1975,7 @@ doProcess <- function(options)
                        displacement = getDisplacement(op$EncoderConfigurationName, displacement, 
op$diameter, op$diameterExt)
                }
 
+               #TODO: is this needed at all?
                if(length(displacement)==0) {
                        plot(0,0,type="n",axes=F,xlab="",ylab="")
                        text(x=0,y=0,translate("Encoder is not connected."),cex=1.5)
diff --git a/encoder/readme.txt b/encoder/readme.txt
new file mode 100644
index 0000000..c78b0f6
--- /dev/null
+++ b/encoder/readme.txt
@@ -0,0 +1,42 @@
+NOT INERTIAL
+------------
+
+(1) CAPTURE
+
+for each repetition (curve)
+- C#  src/gui/encoder/runEncoderCaptureCsharp() sends compressed displacement.
+  First checking change of direction, search the limits. Limits are supposed to be this:
+       1.- Curve starting frame:
+               a) If it's first curve from the beginning of the signal
+               b) If not, from the end of previous curve
+       2.- Curve ending frame:
+               central point at displacements == 0
+       TODO: really check if everything is working as supposed. And if this is the best method.
+- capture.R reads line by line
+- uncompres it
+- maybe displacement changes by encoderConfiguration
+- (first smoothing) reduceCurveBySpeed cuts the curve from the last and first speed=0 at each side #TODO 
maybe use just position maxs and mins (extrema)
+- kinematicsF
+
+(2) LOAD SIGNAL OR END OF CAPTURE (CUR)
+
+- graph.R doProcess singleFile == TRUE
+- reads uncompressed displacement
+- maybe displacement changes by encoderConfiguration
+- findCurves !!!! cut signal by extrema criterion
+- reduceCurveBySpeed: cut curves by speed == 0
+... process is same as in singleFile == FALSE
+
+(3) PROCESS ONE SAVED CURVE
+
+- graph.R doProcess singleFile == FALSE
+- curves are in separated files already cutted previously (this makes this data is the same than (2)
+
+CONCLUSIONS
+
+(2) and (3) are equal
+(1) sometimes is different. Check if:
+       (1) data sent by C# on capture 
+       == 
+       (3) data stored for each curve
+
diff --git a/encoder/util.R b/encoder/util.R
index 7d67363..93d3e1b 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -281,6 +281,8 @@ reduceCurveBySpeed <- function(eccon, row, startT, startH, displacement, smoothi
        #in order to reduce curve by speed, we search the cross of speed (in 0m/s)
         #before and after the peak value, but in "ec" and "ce" there are two peak values:
        #
+       #speeds:
+       #
        #ec         2
        #\         / \
        # \       /   \
@@ -307,7 +309,7 @@ reduceCurveBySpeed <- function(eccon, row, startT, startH, displacement, smoothi
        } else if(eccon=="ce") {
                time1 = min(which(speed$y == max(speed$y)))
                time2 = max(which(speed$y == min(speed$y)))
-       } else {
+       } else { #c
                speed$y=abs(speed$y)
                time1 = min(which(speed$y == max(speed$y)))
                time2 = max(which(speed$y == max(speed$y)))
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 5d237c9..ff2685d 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2259,6 +2259,7 @@ public partial class ChronoJumpWindow
                                                                (i - directionChangeCount + lastNonZero)/2    
  //endFrame
                                                                //to find endFrame, first substract 
directionChangePeriod from i
                                                                //then find the middle point between that and 
lastNonZero
+                                                               //this means that the end is in central point 
at displacements == 0
                                                                );
                
                                                if(useRDotNet) {


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