[chronojump] Fixed error on encoder R findECPhases on current R versions (in previous R versions was warning)



commit c16196208dff78f1b3328f19bc77bbb58a31c76f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jun 8 12:00:21 2022 +0200

    Fixed error on encoder R findECPhases on current R versions (in previous R versions was warning)

 encoder/util.R | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/encoder/util.R b/encoder/util.R
index b89717495..f06904a95 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -585,7 +585,12 @@ kinematicsF <- function(displacement, repOp, smoothingOneEC, smoothingOneC, g, i
                        concentric = phases$concentric
        
                        #temporary fix problem of found MinSpeedEnd at right
-                       if(eccentric == 0 && isometric == 0 && concentric == 0)
+
+                       #if(eccentric == 0 && isometric == 0 && concentric == 0)
+                       #condition "if (eccentric == 0)" fails when is a vector on recent R versions, so 
check first the length
+                       if(length(eccentric) == 1 && eccentric == 0 &&
+                                       length(isometric) == 1 && isometric == 0 &&
+                                       length(concentric) == 1 && concentric == 0)
                                propulsiveEnd = length(displacement)
                        else {
                                maxSpeedT <- min(which(speed$y == max(speed$y)))
@@ -619,7 +624,7 @@ kinematicsF <- function(displacement, repOp, smoothingOneEC, smoothingOneC, g, i
        if(eccModesStartOnGround && ! isInertial(repOp$econfName) && 
           (repOp$eccon == "e" || repOp$eccon == "ec")) {
                #if eccentric is undefined, find it
-               if(eccentric == 0) {
+               if(length(eccentric == 1) && eccentric == 0) {
                        if(repOp$eccon == "e")
                                eccentric = 1:length(displacement)
                        else {  #(repOp$eccon=="ec")


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