Skip to content

Commit

Permalink
remove average namespace and update IMU submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
vberthiaume committed Jan 7, 2025
1 parent 15d7758 commit aaf8a44
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion 3rdparty
Submodule 3rdparty updated 1 files
+1 −1 IMU_Sensor_Fusion
19 changes: 6 additions & 13 deletions include/puara/descriptors/touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,10 @@ class Touch
{
// Update the "amount of touch" for the entire touch sensor, as well as the top, middle and bottom parts.
// All normalized between 0 and 1.
touchAll = utils::average::array(discrete_touch, 0, touchSize);
touchTop = utils::average::array(discrete_touch, 0, touchSizeEdge);
touchMiddle = utils::average::array(discrete_touch, (0 + touchSizeEdge), (touchSize - touchSizeEdge));
touchBottom = utils::average::array(discrete_touch, (touchSize - touchSizeEdge), touchSize);

// for(int i = 0; i < touchSize; i++)
// std::cout << discrete_touch[i] << " ";
// std::cout << "\ntouchAll: " << touchAll;
// std::cout << "\ttouchTop: " << touchTop;
// std::cout << "\ttouchMiddle: " << touchMiddle;
// std::cout << "\ttouchBottom: " << touchBottom << std::endl;
touchAll = utils::arrayAverage(discrete_touch, 0, touchSize);
touchTop = utils::arrayAverage(discrete_touch, 0, touchSizeEdge);
touchMiddle = utils::arrayAverage(discrete_touch, (0 + touchSizeEdge), (touchSize - touchSizeEdge));
touchBottom = utils::arrayAverage(discrete_touch, (touchSize - touchSizeEdge), touchSize);

// 1D blob detection: used for brush
const auto movement = blobDetector.detect1D(discrete_touch, touchSize);
Expand Down Expand Up @@ -123,8 +116,8 @@ class Touch
}

// Calculate total brush and rub values
totalBrush = utils::average::arrayIgnoringZeroes(brushes, maxNumBlobs);
totalRub = utils::average::arrayIgnoringZeroes(rubs, maxNumBlobs);
totalBrush = utils::arrayAverageZero(brushes, maxNumBlobs);
totalRub = utils::arrayAverageZero(rubs, maxNumBlobs);
}
};
}
9 changes: 3 additions & 6 deletions include/puara/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ inline void bitShiftArrayL(int* origArray, int* shiftedArray, int arraySize, int
}
}

namespace average
{
/**
* @brief Computes the average of elements in an array over a specified range.
*
Expand All @@ -73,7 +71,7 @@ namespace average
* @return The average of the elements in the specified range as a float. Returns 0.0 if the range is invalid or empty.
*/
template <typename T>
float array(const T* array, int start, int end)
float arrayAverage(const T* array, int start, int end)
{
static_assert(
std::is_arithmetic<T>::value,
Expand All @@ -93,7 +91,7 @@ float array(const T* array, int start, int end)
* E.g., brush uses it to reduce multiBrush instances. Any value in
* the passed Array that is == 0 is ignored in the average calculation.
*/
inline double arrayIgnoringZeroes(double* Array, int ArraySize)
inline double arrayAverageZero(double* Array, int ArraySize)
{
double sum = 0;
int count = 0;
Expand All @@ -119,7 +117,7 @@ inline double arrayIgnoringZeroes(double* Array, int ArraySize)
* the passed Array that is == 0 is ignored in the average calculation.
*/
template <typename T>
inline double arrayIgnoringZeroes(T* Array, int ArraySize)
inline double arrayAverageZero(T* Array, int ArraySize)
{
static_assert(std::is_same<decltype(T::value), float>::value, "T must have a public float value member");

Expand All @@ -141,7 +139,6 @@ inline double arrayIgnoringZeroes(T* Array, int ArraySize)

return output;
}
}

namespace convert
{
Expand Down

0 comments on commit aaf8a44

Please sign in to comment.