MedianFilter.h
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
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 #include <ArmarXCore/interface/observers/Filters.h>
27 #include <ArmarXCore/interface/observers/ObserverInterface.h>
29 
30 #include "DatafieldFilter.h"
31 
32 namespace armarx
33 {
34  template <class IceBaseClass, class DerivedClass>
35  class GenericFactory;
36 }
37 
38 namespace armarx::filters
39 {
40 
41  /**
42  * @class MedianFilter
43  * @ingroup ObserverFilters
44  * @brief The MedianFilter class provides an implementation
45  * for a median for datafields of type float, int, long and double.
46  */
47  class MedianFilter : virtual public MedianFilterBase, virtual public DatafieldFilter
48  {
49  public:
50  MedianFilter(int windowSize = 11);
51 
52  // DatafieldFilterBase interface
53  public:
54  VariantBasePtr calculate(const Ice::Current& c = Ice::emptyCurrent) const override;
55 
56  /**
57  * @brief This filter supports: Int, Long, Float, Double
58  * @return List of VariantTypes
59  */
60  ParameterTypeList
61  getSupportedTypes(const Ice::Current& c = Ice::emptyCurrent) const override;
62 
63  template <typename Type>
64  static std::vector<Type>
66  {
67  std::vector<Type> values;
68 
69  for (auto v : map)
70  {
71  VariantPtr v2 = VariantPtr::dynamicCast(v.second);
72  values.push_back(v2->get<Type>());
73  }
74 
75  std::sort(values.begin(), values.end());
76  return values;
77  }
78  };
79 
80 
81 } // namespace armarx::filters
armarx::DatafieldFilter
The DatafieldFilter class is the base class for all filters and filter implementation should derive f...
Definition: DatafieldFilter.h:45
armarx::filters::MedianFilter::MedianFilter
MedianFilter(int windowSize=11)
Definition: MedianFilter.cpp:28
armarx::filters::MedianFilter::SortVariants
static std::vector< Type > SortVariants(const TimeVariantBaseMap &map)
Definition: MedianFilter.h:65
armarx::TimeVariantBaseMap
std::deque< std::pair< long, VariantBasePtr > > TimeVariantBaseMap
Definition: DatafieldFilter.h:36
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
IceInternal::Handle<::armarx::VariantBase >
armarx::filters
Definition: AverageFilter.h:32
InvalidTypeException.h
armarx::filters::MedianFilter
The MedianFilter class provides an implementation for a median for datafields of type float,...
Definition: MedianFilter.h:47
armarx::filters::MedianFilter::getSupportedTypes
ParameterTypeList getSupportedTypes(const Ice::Current &c=Ice::emptyCurrent) const override
This filter supports: Int, Long, Float, Double.
Definition: MedianFilter.cpp:69
DatafieldFilter.h
armarx::aron::similarity::FloatSimilarity::Type
Type
The Type enum.
Definition: FloatSimilarity.h:10
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
armarx::filters::MedianFilter::calculate
VariantBasePtr calculate(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: MedianFilter.cpp:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27