31 using namespace filters;
37 this->offsetIndex = 0;
38 this->currentValue = Eigen::Vector3f::Zero();
39 this->currentOffset = Eigen::Vector3f::Zero();
41 this->offsetWindowSize = offsetWindowSize;
46 std::unique_lock lock(historyMutex);
48 if (dataHistory.size() == 0)
53 VariantPtr var = VariantPtr::dynamicCast(dataHistory.begin()->second);
90 float armarx::filters::MedianDerivativeFilterV3::median(std::vector<float>&
values)
96 Eigen::Vector3f armarx::filters::MedianDerivativeFilterV3::calculateMedian(
const std::vector<Eigen::Vector3f>&
data)
99 std::vector<float>
values[3];
100 for (
int i = 0; i < 3; ++i)
104 for (
const Eigen::Vector3f&
v :
data)
106 for (
int i = 0; i < 3; ++i)
112 Eigen::Vector3f result;
113 for (
int i = 0; i < 3; ++i)
115 result(i) = median(
values[i]);
127 bool offsetValid =
false;
128 if (offsetData.size() <
unsigned(offsetWindowSize))
130 offsetData.push_back(inputValue);
134 offsetData[offsetIndex] = inputValue;
135 offsetIndex = (offsetIndex + 1) % offsetWindowSize;
136 this->currentOffset = calculateMedian(offsetData);
140 if (valueData.size() <
unsigned(windowFilterSize))
142 valueData.push_back(inputValue);
146 valueData[valueIndex] = inputValue;
147 valueIndex = (valueIndex + 1) % windowFilterSize;
154 this->currentValue = calculateMedian(valueData) - currentOffset;