[chronojump] Added debug mode for graph.R



commit 2ec3e9e11c69a3cb469cf7ddfadf23739c0dd4c8
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jul 24 13:03:51 2015 +0200

    Added debug mode for graph.R

 encoder/graph.R |   26 +++++++++++++++++++-------
 encoder/util.R  |   47 ++++++++++++++++++++++++++---------------------
 2 files changed, 45 insertions(+), 28 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 0ead52f..6d7c9df 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -1089,6 +1089,16 @@ paint <- function(displacement, eccon, xmin, xmax, yrange, knRanges, superpose,
                        axis(4, col=cols[2], lty=lty[2], line=axisLineRight, lwd=1, padj=-.5)
                        axisLineRight = axisLineRight +2
                }
+               
+               if(isInertial(encoderConfigurationName) && debug) {
+                       #print("dynamics$forceDisc")
+                       #print(dynamics$forceDisc)
+                       par(new=T)
+                       plot(dynamics$forceDisc, col="blue", xlab="", ylab="", 
xlim=c(1,length(displacement)),ylim=ylim, type="p", pch=1, axes=F);
+
+                       par(new=T)
+                       plot(dynamics$forceBody, col="blue", xlab="", ylab="", 
xlim=c(1,length(displacement)),ylim=ylim, type="p", pch=3, axes=F);
+               }
        }
 
        #mark when it's air and land
@@ -1175,6 +1185,15 @@ paint <- function(displacement, eccon, xmin, xmax, yrange, knRanges, superpose,
                else
                        plot(startX:length(power),power[startX:length(power)],type="l",
                             
xlim=c(1,length(displacement)),ylim=ylim,xlab="",ylab="",col="darkred",lty=2,lwd=3,axes=F)
+       
+
+               if(isInertial(encoderConfigurationName) && debug) {
+                       par(new=T)
+                       plot(dynamics$powerDisc, col="orangered3", xlab="", ylab="", 
xlim=c(1,length(displacement)),ylim=ylim, type="p", pch=1, axes=F);
+
+                       par(new=T)
+                       plot(dynamics$powerBody, col="orangered3", xlab="", ylab="", 
xlim=c(1,length(displacement)),ylim=ylim, type="p", pch=3, axes=F);
+               }
 
 
                meanPowerC = mean(power[min(concentric):max(concentric)])
@@ -2761,13 +2780,6 @@ doProcess <- function(options)
 
                rownames(paf)=rownames(curves)
                
-               if(debug) {
-                       #print("--------CURVES (propulsive is not calculated yet) --------------")
-                       #print(curves)
-                       #print("----------PAF---------------")
-                       #print(paf)
-               }
-
                if(op$Analysis == "powerBars") {
                        if(! singleFile) 
                                paintPowerPeakPowerBars(singleFile, op$Title, paf, 
diff --git a/encoder/util.R b/encoder/util.R
index 26321fc..47a5ae4 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -361,7 +361,6 @@ reduceCurveBySpeed <- function(eccon, row, startT, startH, displacement, smoothi
                                x.end = i
        }
 
-       #debug
        #print(speed.ext$cross[,2])
        #print(ext.cross.len)
        #print(c("time1,time2",time1,time2))
@@ -750,6 +749,11 @@ getDynamicsInertial <- function(encoderConfigurationName, displacement, diameter
 
        position.m = abs(cumsum(displacement)) / 1000 #m
        diameter.m = diameter / 100 #cm -> m
+    
+       forceDisc = 0
+       forceBody = 0
+       powerDisc = 0
+       powerBody = 0
   
   if(encoderConfigurationName == "ROTARYAXISINERTIAL" ||
        encoderConfigurationName == "ROTARYFRICTIONSIDEINERTIAL" ||
@@ -759,8 +763,12 @@ getDynamicsInertial <- function(encoderConfigurationName, displacement, diameter
     angleSpeed = speed * 2 / diameter.m
     angleAccel = accel * 2 / diameter.m
     anglePush = 90 #TODO: send from C#
-    force = abs(inertiaMomentum * angleAccel) * (2 / diameter.m) + mass * (accel + g * sin(anglePush * pi / 
180))
-    power = abs((inertiaMomentum * angleAccel) * angleSpeed) + abs(mass * (accel + g * sin(anglePush * pi / 
180)) * speed)
+
+    forceDisc = abs(inertiaMomentum * angleAccel) * (2 / diameter.m) 
+    forceBody = mass * (accel + g * sin(anglePush * pi / 180))
+    powerDisc = abs((inertiaMomentum * angleAccel) * angleSpeed)
+    powerBody = abs(mass * (accel + g * sin(anglePush * pi / 180)) * speed)
+
   } else if(encoderConfigurationName == "ROTARYAXISINERTIALMOVPULLEY" ||
               encoderConfigurationName == "ROTARYFRICTIONAXISINERTIALMOVPULLEY" ||
               encoderConfigurationName == "ROTARYFRICTIONSIDEINERTIALMOVPULLEY"){
@@ -773,8 +781,13 @@ getDynamicsInertial <- function(encoderConfigurationName, displacement, diameter
     #The configuration covers horizontal, vertical and inclinated movements
     #If the movement is vertical g*sin(alpha) = g
     #If the movement is horizontal g*sin(alpha) = 0
-    force = abs(inertiaMomentum * angleAccel) * (2 / diameter.m) + mass * (accel + g * sin(anglePush * pi / 
180))
-    power = abs((inertiaMomentum * angleAccel) * angleSpeed) + abs(mass * (accel + g * sin(anglePush * pi / 
180)) * speed)
+
+    forceDisc = abs(inertiaMomentum * angleAccel) * (2 / diameter.m)
+    forceBody = mass * (accel + g * sin(anglePush * pi / 180))
+    powerDisc = abs((inertiaMomentum * angleAccel) * angleSpeed)
+    powerBody = abs(mass * (accel + g * sin(anglePush * pi / 180)) * speed)
+
+
   } else if(encoderConfigurationName == "ROTARYAXISINERTIALLATERAL" ||
               encoderConfigurationName == "ROTARYFRICTIONAXISINERTIALLATERAL" ||
               encoderConfigurationName == "ROTARYFRICTIONSIDEINERTIALLATERAL"){
@@ -782,27 +795,19 @@ getDynamicsInertial <- function(encoderConfigurationName, displacement, diameter
     angleSpeed = speed * 2 / diameter.m
     angleAccel = accel * 2 / diameter.m
     anglePush = 0 #TODO: send from C#
-    #1.5.1
-    force = abs(inertiaMomentum * angleAccel) * (2 / diameter.m) + mass * accel
-    power = abs((inertiaMomentum * angleAccel) * angleSpeed) + abs(mass * accel * speed)
-    #1.5.2
-    #force = inertiaMomentum * angleAccel * (2 / diameter.m) + mass * accel
-    #power = abs((inertiaMomentum * angleAccel) * angleSpeed) + mass * accel * speed
     
-    #TODO: WIP    
-    forceDisc = inertiaMomentum * angleAccel * (2 / diameter.m)
+    forceDisc = abs(inertiaMomentum * angleAccel) * (2 / diameter.m)
     forceBody = mass * accel
-    #print("PRINT FORCE")
-    #xmin=9815
-    #xmax=11727
-    #print(force[xmin:xmax])
+    powerDisc = abs((inertiaMomentum * angleAccel) * angleSpeed)
+    powerBody = abs(mass * accel * speed)
 
-    #print(max(speed[xmin:xmax]))
-    #print(max(accel[xmin:xmax]))
   }
 
-       #return(list(displacement=displacement, mass=mass, force=force, power=power, forceDisc=forceDisc, 
forceBody=forceBody, accelHere = accel))
-       return(list(displacement=displacement, mass=mass, force=force, power=power))
+  force = forceDisc + forceBody
+  power = powerDisc + powerBody
+
+       #return(list(displacement=displacement, mass=mass, force=force, power=power))
+       return(list(displacement=displacement, mass=mass, force=force, power=power, forceDisc=forceDisc, 
forceBody=forceBody, powerDisc=powerDisc, powerBody=powerBody))
 }
 
 


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