[chronojump] Doing 699951



commit da989f44cce0a7ad0d9fff17a0ac84d1c25c2e7d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed May 15 00:34:43 2013 +0200

    Doing 699951

 encoder/graph.R           |   51 +++++++++++++++++++++++++++++++++++---------
 encoder/pyserial_pyper.py |   40 ++++++++++++++++++++---------------
 2 files changed, 63 insertions(+), 28 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 0f64906..4e4f6b4 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -78,8 +78,19 @@ findCurves <- function(rawdata, eccon, min_height, draw, title) {
                if(b$maxindex[1] < b$minindex[1]) { b$minindex = rbind(c(1,1),b$minindex) } 
                row=1; i=1; j=1
                while(max(c(i,j)) <= min(c(length(b$minindex[,1]),length(b$maxindex[,1])))) {
-                       tempStart = mean(c(b$minindex[i,1],b$minindex[i,2]))
-                       tempEnd = mean(c(b$maxindex[j,1],b$maxindex[j,2]))
+
+                       #tempStart at the mean of minindexs
+                       #tempStart = mean(c(b$minindex[i,1],b$minindex[i,2]))
+                       
+                       #tempStart at the end of minindexs
+                       tempStart = b$minindex[i,2]
+                       
+                       #end at the mean of maximum values
+                       #tempEnd = mean(c(b$maxindex[j,1],b$maxindex[j,2]))
+
+                       #end at the first maximum value
+                       tempEnd = b$maxindex[j,1]
+                       
                        height=a[tempEnd]-a[tempStart]
 #                      print(paste(height,i,j))
                        if(height >= min_height) { 
@@ -150,6 +161,14 @@ findCurves <- function(rawdata, eccon, min_height, draw, title) {
                mtext("time (s) ",side=1,adj=1,line=-1)
                mtext("height (cm) ",side=2,adj=1,line=-1)
                abline(v=b$maxindex/1000,lty=3); abline(v=b$minindex/1000,lty=3)        #ms -> s
+       
+               #plot speed     
+               speed <- smooth.spline( 1:length(rawdata), rawdata, spar=smoothingAll)
+               abline(h=0,lty=2,col="yellow")
+               lines((1:length(rawdata))/1000, speed$y*10, col="green")
+               print("SPEEEDYYYY")
+               print(max(speed$y))     
+               print(min(speed$y))     
        }
        return(as.data.frame(cbind(start,end,startH)))
 }
@@ -292,10 +311,10 @@ print("WARNING ECS\n\n\n\n\n")
 
        power <- force*speed$y
 
-       if( analysisOptions == "p" && ( eccon== "c" || eccon == "ec" ) )
-               return(list(speedy=speed$y[1:propulsiveEnd], accely=accel$y[1:propulsiveEnd], 
-                           force=force[1:propulsiveEnd], power=power[1:propulsiveEnd], mass=mass))
-       else
+       #if( analysisOptions == "p" && ( eccon== "c" || eccon == "ec" ) )
+       #       return(list(speedy=speed$y[1:propulsiveEnd], accely=accel$y[1:propulsiveEnd], 
+       #                   force=force[1:propulsiveEnd], power=power[1:propulsiveEnd], mass=mass))
+       #else
                return(list(speedy=speed$y, accely=accel$y, force=force, power=power, mass=mass))
 }
 
@@ -395,7 +414,8 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
 
                title(main=title,line=-2,outer=T)
                mtext(subtitle,side=1,adj=0,cex=.8)
-               
+       
+
                if(showAxes) {
                        axis(1)         #can be added xmin
                        axis(2)
@@ -418,6 +438,15 @@ paint <- function(rawdata, eccon, xmin, xmax, yrange, knRanges, superpose, highl
                abline(h=0,lty=3,col="black")
 
                #abline(v=seq(from=0,to=length(a),by=500),lty=3,col="gray")
+
+
+print("ROTARY")                
+print(max(yValues))
+print(max(yValues)/2)
+print(mean(which(yValues == max(yValues)/2)))
+abline(h=round(mean(which(yValues == max(yValues)/2)),0))
+abline(v=round(mean(which(yValues == max(yValues)/2)),0))
+
        }
 
        #speed
@@ -1260,10 +1289,10 @@ doProcess <- function(options) {
                n=length(curves[,1])
                quitIfNoData(n, curves, OutputData1)
 
-               for(i in 1:n) { 
-                       curves[i,1]=reduceCurveBySpeed(Eccon, i, curves[i,1], 
rawdata[curves[i,1]:curves[i,2]], 
-                                                      SmoothingOneEC, SmoothingOneC)
-               }
+               #for(i in 1:n) { 
+               #       curves[i,1]=reduceCurveBySpeed(Eccon, i, curves[i,1], 
rawdata[curves[i,1]:curves[i,2]], 
+               #                                      SmoothingOneEC, SmoothingOneC)
+               #}
                if(curvesPlot) {
                        #/10 mm -> cm
                        for(i in 1:length(curves[,1])) { 
diff --git a/encoder/pyserial_pyper.py b/encoder/pyserial_pyper.py
index 57e4843..222b6b3 100644
--- a/encoder/pyserial_pyper.py
+++ b/encoder/pyserial_pyper.py
@@ -82,9 +82,9 @@ direction_completed = -1              # 1 or -1
 #This will be useful to know the start of movement
 
 frames_pull_top1 = list()
-frames_pull_top2 = list()
+#frames_pull_top2 = list()     #unused
 frames_push_bottom1 = list()
-frames_push_bottom2 = list()
+#frames_push_bottom2 = list()  #unused
 previous_frame_change = 0
 
 lag=20
@@ -466,7 +466,7 @@ if __name__ == '__main__':
        temp = list()           #raw values
        temp_cumsum = list()    #cumulative sums of raw values
        temp_cumsum.append(0)
-       temp_speed = list()
+       #temp_speed = list()    #unused
        w_time = datetime.now().second
        #print "start read data"
        # Detecting if serial port is available and Recording the data from Chronopic.
@@ -500,10 +500,12 @@ if __name__ == '__main__':
                temp.append(signedChar_data)
                if(i>0):
                        temp_cumsum.append(temp_cumsum[i-1]+signedChar_data)
-               if(i>lag):
-                       temp_speed.append(1.0*(temp_cumsum[i]-temp_cumsum[i-lag])/lag)
-               else:
-                       temp_speed.append(0)
+               
+               #unused
+               #if(i>lag):
+               #       temp_speed.append(1.0*(temp_cumsum[i]-temp_cumsum[i-lag])/lag)
+               #else:
+               #       temp_speed.append(0)
 
                msCount = msCount +1
                if msCount == 1000 :
@@ -526,27 +528,31 @@ if __name__ == '__main__':
                                k=list(temp_cumsum[previous_frame_change:i-direction_change_period])
        
                                phase = 0
-                               speed = 0
+                               #speed = 0      #unused
        
                                if direction_now == 1:
-                                       #we are going up, we passed the ditection_change_count
+                                       #we are going up, we passed the direction_change_count
                                        #then we can record the bottom moment
-                                       #and print speed on going down
-                                       new_frame_change = previous_frame_change+k.index(min(k)) 
+                                       #and print speed on going down (Not done anymore)
+                                       new_frame_change = previous_frame_change+k.index(min(k))
+                                       print("NFC 1 1 %i" % new_frame_change) 
                                        frames_push_bottom1.append(new_frame_change)
                                        new_frame_change = 
previous_frame_change+len(k)-1-k[::-1].index(min(k))
-                                       frames_push_bottom2.append(new_frame_change)
+                                       print("NFC 1 2 %i" % new_frame_change) 
+                                       #frames_push_bottom2.append(new_frame_change)   #unused
                                        phase = " down"
-                                       if previous_frame_change != 0 and new_frame_change != 0:
-                                               speed = 
min(temp_speed[previous_frame_change:new_frame_change])
+                                       #if previous_frame_change != 0 and new_frame_change != 0:
+                                       #       speed = 
min(temp_speed[previous_frame_change:new_frame_change])
                                else:
                                        new_frame_change = previous_frame_change+k.index(max(k))
+                                       print("NFC 2 1 %i" % new_frame_change) 
                                        frames_pull_top1.append(new_frame_change)
                                        new_frame_change = 
previous_frame_change+len(k)-1-k[::-1].index(max(k))
-                                       frames_pull_top2.append(new_frame_change)
+                                       print("NFC 2 2 %i" % new_frame_change) 
+                                       #frames_pull_top2.append(new_frame_change)      unused
                                        phase = "   up"
-                                       if previous_frame_change != 0 and new_frame_change != 0:
-                                               speed = 
max(temp_speed[previous_frame_change:new_frame_change])
+                                       #if previous_frame_change != 0 and new_frame_change != 0:
+                                       #       speed = 
max(temp_speed[previous_frame_change:new_frame_change])
        
 
                                if len(frames_pull_top1)>0 and len(frames_push_bottom1)>0:


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