ButterworthFilter.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 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 #pragma once
25 
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 
38 namespace armarx::filters
39 {
41  public ButterworthFilterBase,
42  public DatafieldFilter
43  {
44  template <class BaseClass, class VariantClass>
45  friend class ::armarx::GenericFactory;
46  protected:
48  public:
49 
50  ButterworthFilter(double frequency, int sampleRate, PassType passType, double resonance);
51  void setInitialValue(double value);
52  /**
53  * @brief This filter supports: Int, Long, Float, Double
54  * @return List of VariantTypes
55  */
56  ParameterTypeList getSupportedTypes(const Ice::Current& = Ice::emptyCurrent) const override;
57 
58 
59  private:
60 
61  /// Array of input values, latest are in front
62  std::vector<double> inputHistory = std::vector<double>(2, 0.0);
63 
64  /// Array of output values, latest are in front
65  std::vector<double> outputHistory = std::vector<double>(3, 0.0);
66 
67 
68 
69 
70  // DatafieldFilterBase interface
71  public:
72  void update(Ice::Long, const VariantBasePtr& value, const Ice::Current& = Ice::emptyCurrent) override;
73  void update(double newInput);
74  VariantBasePtr getValue(const Ice::Current& = Ice::emptyCurrent) const override;
75  double getRawValue() const;
76  VariantBasePtr calculate(const Ice::Current& = Ice::emptyCurrent) const override;
77 
78  void reset(double frequency, int sampleRate, PassType passType, double resonance);
79 
80  // DatafieldFilterBase interface
81  public:
82  StringFloatDictionary getProperties(const Ice::Current&) const override;
83  void setProperties(const StringFloatDictionary& values, const Ice::Current&) override;
84  };
85 
86 }
87 
88 
armarx::DatafieldFilter
The DatafieldFilter class is the base class for all filters and filter implementation should derive f...
Definition: DatafieldFilter.h:45
armarx::filters::ButterworthFilter::update
void update(Ice::Long, const VariantBasePtr &value, const Ice::Current &=Ice::emptyCurrent) override
Definition: ButterworthFilter.cpp:92
armarx::filters::ButterworthFilter::setProperties
void setProperties(const StringFloatDictionary &values, const Ice::Current &) override
Definition: ButterworthFilter.cpp:167
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
IceInternal::Handle<::armarx::VariantBase >
armarx::filters
Definition: AverageFilter.h:31
armarx::filters::ButterworthFilter::getProperties
StringFloatDictionary getProperties(const Ice::Current &) const override
Definition: ButterworthFilter.cpp:157
InvalidTypeException.h
armarx::filters::ButterworthFilter::calculate
VariantBasePtr calculate(const Ice::Current &=Ice::emptyCurrent) const override
Definition: ButterworthFilter.cpp:149
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
DatafieldFilter.h
armarx::filters::ButterworthFilter
Definition: ButterworthFilter.h:40
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
armarx::filters::ButterworthFilter::reset
void reset(double frequency, int sampleRate, PassType passType, double resonance)
Definition: ButterworthFilter.cpp:35
armarx::filters::ButterworthFilter::getValue
VariantBasePtr getValue(const Ice::Current &=Ice::emptyCurrent) const override
Definition: ButterworthFilter.cpp:136
armarx::filters::ButterworthFilter::ButterworthFilter
ButterworthFilter()
Definition: ButterworthFilter.cpp:33
armarx::filters::ButterworthFilter::setInitialValue
void setInitialValue(double value)
Definition: ButterworthFilter.cpp:70
armarx::filters::ButterworthFilter::getRawValue
double getRawValue() const
Definition: ButterworthFilter.cpp:143
armarx::filters::ButterworthFilter::getSupportedTypes
ParameterTypeList getSupportedTypes(const Ice::Current &=Ice::emptyCurrent) const override
This filter supports: Int, Long, Float, Double.
Definition: ButterworthFilter.cpp:82
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28