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 "DatafieldFilter.h"
27 
28 #include <ArmarXCore/interface/observers/ObserverInterface.h>
29 #include <ArmarXCore/interface/observers/Filters.h>
31 
32 namespace armarx
33 {
34  template <class IceBaseClass, class DerivedClass>
35  class GenericFactory;
36 }
37 namespace armarx::filters
38 {
39 
40  /**
41  * @class MedianFilter
42  * @ingroup ObserverFilters
43  * @brief The MedianFilter class provides an implementation
44  * for a median for datafields of type float, int, long and double.
45  */
46  class MedianFilter :
47  virtual public MedianFilterBase,
48  virtual public DatafieldFilter
49  {
50  public:
51  MedianFilter(int windowSize = 11);
52 
53  // DatafieldFilterBase interface
54  public:
55  VariantBasePtr calculate(const Ice::Current& c = Ice::emptyCurrent) const override;
56 
57  /**
58  * @brief This filter supports: Int, Long, Float, Double
59  * @return List of VariantTypes
60  */
61  ParameterTypeList getSupportedTypes(const Ice::Current& c = Ice::emptyCurrent) const override;
62 
63  template <typename Type>
64  static std::vector<Type> SortVariants(const TimeVariantBaseMap& map)
65  {
66  std::vector<Type> values;
67 
68  for (auto v : map)
69  {
70  VariantPtr v2 = VariantPtr::dynamicCast(v.second);
71  values.push_back(v2->get<Type>());
72  }
73 
74  std::sort(values.begin(), values.end());
75  return values;
76  }
77 
78  };
79 
80 
81 
82 }
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:64
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:43
IceInternal::Handle<::armarx::VariantBase >
armarx::filters
Definition: AverageFilter.h:31
InvalidTypeException.h
armarx::filters::MedianFilter
The MedianFilter class provides an implementation for a median for datafields of type float,...
Definition: MedianFilter.h:46
armarx::filters::MedianFilter::getSupportedTypes
ParameterTypeList getSupportedTypes(const Ice::Current &c=Ice::emptyCurrent) const override
This filter supports: Int, Long, Float, Double.
Definition: MedianFilter.cpp:67
DatafieldFilter.h
armarx::aron::similarity::FloatSimilarity::Type
Type
The Type enum.
Definition: FloatSimilarity.h:8
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:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28