hormone v.1 for optimizing COT

Dependents:   TurtleBot_with_AHS

Fork of calculator by worasuchad haomachai

Files at this revision

API Documentation at this revision

Comitter:
worasuchad
Date:
Fri Aug 24 10:57:58 2018 +0000
Parent:
0:22ebaf70b60e
Commit message:
experiment done

Changed in this revision

calculator.cpp Show annotated file Show diff for this revision Revisions of this file
calculator.h Show annotated file Show diff for this revision Revisions of this file
diff -r 22ebaf70b60e -r b6345fbad095 calculator.cpp
--- a/calculator.cpp	Mon Aug 13 11:38:52 2018 +0000
+++ b/calculator.cpp	Fri Aug 24 10:57:58 2018 +0000
@@ -19,7 +19,7 @@
 /* RETURN VALUE : SD value                                            */ 
 /* DESCRIPTION  : -                                                   */ 
 /*--------------------------------------------------------------------*/ 
-float calculator::calculateSD(const float *sdData, int size)
+float calculator::calculateSD(const float *sdData, const int size)
 {
     float sum = 0.0, mean, standardDeviation = 0.0;
     int i;
@@ -51,7 +51,7 @@
 /* RETURN VALUE : mean value                                          */ 
 /* DESCRIPTION  : -                                                   */ 
 /*--------------------------------------------------------------------*/
-float calculator::calculateMean(const float *meanData, int size)
+float calculator::calculateMean(const float *meanData, const int size)
 {
     float sum = 0.0, mean;
     int i;
@@ -77,7 +77,7 @@
 /* RETURN VALUE : size value                                          */ 
 /* DESCRIPTION  : -                                                   */ 
 /*--------------------------------------------------------------------*/
-float calculator::calcSDVectorA(const float *arrAx, const float *arrAy, const float *arrAz, int size)
+float calculator::calcSDVectorA(const float *arrAx, const float *arrAy, const float *arrAz, const int size)
 {
     float sum = 0.0, mean = 0.0;
     float standardDeviation = 0.0;
@@ -129,7 +129,7 @@
 /* RETURN VALUE : mean value                                          */ 
 /* DESCRIPTION  : -                                                   */ 
 /*--------------------------------------------------------------------*/
-float calculator::calcG4(const float *arrRoll, const float *arrPitch, int size)
+float calculator::calcG4(const float *arrRoll, const float *arrPitch, const int sizeG4)
 {
     float sum = 0.0, mean = 0.0;
     int i; 
@@ -141,7 +141,7 @@
         return NULL;
     }
     
-    pSize = (float *)malloc(size*sizeof(float));
+    pSize = (float *)malloc(sizeG4*sizeof(float));
     /* check malloc is not return NULL */
     if( pSize == NULL )
     {
@@ -150,19 +150,19 @@
     /*--------------------------------------------------------------------*/ 
     /*                  calculate size of point                           */ 
     /*--------------------------------------------------------------------*/ 
-    for(i = 0; i < size; i++)
+    for(i = 0; i < sizeG4; i++)
     {
         *(pSize + i) = sqrt( pow(arrRoll[i],2) + pow(arrPitch[i],2) );   
     }    
     /*--------------------------------------------------------------------*/ 
     /*                  calculate mean of point size                      */ 
     /*--------------------------------------------------------------------*/
-    for(i = 0; i < size ; i++)
+    for(i = 0; i < sizeG4 ; i++)
     {
         sum += *(pSize + i);
         //pc.printf("sum = %.2f \n\r",sum);    
     }    
-    mean = sum/size;
+    mean = sum/sizeG4;
     //pc.printf("mean = %.2f \n\r",mean); 
     
     free(pSize);
diff -r 22ebaf70b60e -r b6345fbad095 calculator.h
--- a/calculator.h	Mon Aug 13 11:38:52 2018 +0000
+++ b/calculator.h	Fri Aug 24 10:57:58 2018 +0000
@@ -10,9 +10,9 @@
         int i;
     public:
         calculator();
-        float calculateSD(const float *sdData, int size);
-        float calculateMean(const float *meanData, int size);
-        float calcSDVectorA(const float *arrAx, const float *arrAy, const float *arrAz, int size);  
-        float calcG4(const float *arrRoll, const float *arrPitch, int size);
+        float calculateSD(const float *sdData, const int size);
+        float calculateMean(const float *meanData, const int size);
+        float calcSDVectorA(const float *arrAx, const float *arrAy, const float *arrAz, const int size);  
+        float calcG4(const float *arrRoll, const float *arrPitch, const int sizeG4);
 };
 #endif
\ No newline at end of file