GaussianFilter.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX
19 * @author Mirko Waechter( mirko.waechter at kit dot edu)
20 * @date 2016
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#include "GaussianFilter.h"
25
27
28namespace armarx
29{
30 armarx::filters::GaussianFilter::GaussianFilter(int filterSizeInMs, int windowSize)
31 {
32 this->filterSizeInMs = filterSizeInMs;
33 this->windowFilterSize = windowSize;
34 }
35
38 {
39 std::unique_lock lock(historyMutex);
40
41 if (dataHistory.size() == 0)
42 {
43 return nullptr;
44 }
45
46 VariantTypeId type = dataHistory.begin()->second->getType();
47
48 if (type == VariantType::Float)
49 {
51 }
52 else if (type == VariantType::Double)
53 {
55 }
56 else if (type == VariantType::Int)
57 {
59 }
60 else if (type == VariantType::Int)
61 {
63 }
64
66 }
67
68 armarx::ParameterTypeList
70 {
71 ParameterTypeList result;
72 result.push_back(VariantType::Int);
73 result.push_back(VariantType::Long);
74 result.push_back(VariantType::Float);
75 result.push_back(VariantType::Double);
76 return result;
77 }
78
79 armarx::StringFloatDictionary
81 {
82 auto props = DatafieldFilter::getProperties();
83 props["filterSizeInMs"] = filterSizeInMs;
84 return props;
85 }
86
87 void
88 armarx::filters::GaussianFilter::setProperties(const armarx::StringFloatDictionary& newValues,
89 const Ice::Current&)
90 {
91 auto it = newValues.find("filterSizeInMs");
92 if (it != newValues.end())
93 {
94 filterSizeInMs = it->second;
95 }
97 }
98} // namespace armarx
TimeVariantBaseMap dataHistory
armarx::StringFloatDictionary getProperties(const Ice::Current &c=Ice::emptyCurrent) const override
void setProperties(const armarx::StringFloatDictionary &newValues, const Ice::Current &c=Ice::emptyCurrent) override
The Variant class is described here: Variants.
Definition Variant.h:224
void setProperties(const StringFloatDictionary &newValues, const Ice::Current &c=Ice::emptyCurrent) override
GaussianFilter(int filterSizeInMs=200, int windowSize=20)
GaussianFilter.
VariantBasePtr calculate(const Ice::Current &c=Ice::emptyCurrent) const override
StringFloatDictionary getProperties(const Ice::Current &c=Ice::emptyCurrent) const override
ParameterTypeList getSupportedTypes(const Ice::Current &c=Ice::emptyCurrent) const override
This filter supports: Int, Long, Float, Double.
Type calcGaussianFilteredValue(const TimeVariantBaseMap &map) const
const VariantTypeId Int
Definition Variant.h:917
const VariantTypeId Long
Definition Variant.h:918
const VariantTypeId Double
Definition Variant.h:920
const VariantTypeId Float
Definition Variant.h:919
This file offers overloads of toIce() and fromIce() functions for STL container types.
Ice::Int VariantTypeId
Definition Variant.h:43
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr