MinMaxFilter.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 Lesser General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 *
11 * ArmarX is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @package ArmarX::
20 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
21 * @date 2015
22 * @copyright http://www.gnu.org/licenses/gpl.txt
23 * GNU General Public License
24 */
25 
26 #pragma once
27 
28 #include <ArmarXCore/interface/observers/Filters.h>
30 
31 #include "DatafieldFilter.h"
32 
33 namespace armarx::filters
34 {
35 
36 
37  /**
38  * @class MaxFilter
39  * @ingroup ObserverFilters
40  * @brief The MaxFilter class provides a simple filter by calculating the
41  * average value of a window for datafields of type float, int and double.
42  */
43  class MaxFilter : public DatafieldFilter, public MaxFilterBase
44  {
45  public:
46  MaxFilter();
47 
48  // DatafieldFilterBase interface
49  public:
50  VariantBasePtr calculate(const Ice::Current& c = Ice::emptyCurrent) const override;
51 
52  /**
53  * @brief This filter supports: Int, Long, Float, Double
54  * @return List of VariantTypes
55  */
56  ParameterTypeList
57  getSupportedTypes(const Ice::Current& c = Ice::emptyCurrent) const override;
58 
59  private:
60  template <typename Type>
61  static Type
62  CalcMax(const TimeVariantBaseMap& map)
63  {
64  double curMax = std::numeric_limits<double>::min();
65  for (auto v : map)
66  {
67  VariantPtr v2 = VariantPtr::dynamicCast(v.second);
68  Type val = v2->get<Type>();
69 
70  if (val > curMax)
71  {
72  curMax = val;
73  }
74  }
75  return curMax;
76  }
77  };
78 
79 } // 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::MaxFilter::MaxFilter
MaxFilter()
Definition: MinMaxFilter.cpp:28
armarx::filters::MaxFilter::calculate
VariantBasePtr calculate(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: MinMaxFilter.cpp:33
armarx::TimeVariantBaseMap
std::deque< std::pair< long, VariantBasePtr > > TimeVariantBaseMap
Definition: DatafieldFilter.h:36
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
IceInternal::Handle<::armarx::VariantBase >
armarx::filters
Definition: AverageFilter.h:32
InvalidTypeException.h
DatafieldFilter.h
armarx::filters::MaxFilter::getSupportedTypes
ParameterTypeList getSupportedTypes(const Ice::Current &c=Ice::emptyCurrent) const override
This filter supports: Int, Long, Float, Double.
Definition: MinMaxFilter.cpp:65
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
min
T min(T t1, T t2)
Definition: gdiam.h:44
armarx::filters::MaxFilter
The MaxFilter class provides a simple filter by calculating the average value of a window for datafie...
Definition: MinMaxFilter.h:43