ButterworthFilter.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2017, 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 2017
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #ifndef BUTTERWORTHFILTER_H
25 #define BUTTERWORTHFILTER_H
26 
27 #include "RTFilterBase.h"
28 #include <ArmarXCore/interface/observers/Filters.h>
29 
30 
31 namespace armarx::rtfilters
32 {
33 
35  {
36  public:
37  ButterworthFilter(double frequency, int sampleRate, PassType filterPassType, double resonance);
38  RTFilterBasePtr clone() const override;
39  void setInitialValue(double value);
40  // RTFilterBase interface
41  public:
42  double calculate() override;
43  double update(const IceUtil::Time& timestamp, double newValue) override;
44  protected:
45  double newestValue;
46  /// Array of input values, latest are in front
47  std::vector<double> inputHistory = std::vector<double>(2, 0.0);
48 
49  /// Array of output values, latest are in front
50  std::vector<double> outputHistory = std::vector<double>(3, 0.0);
51 
52  double resonance;
53 
54  double frequency;
55 
57 
58  ::armarx::PassType filterPassType;
59 
60  double c;
61 
62  double a1;
63 
64  double a2;
65 
66  double a3;
67 
68  double b1;
69 
70  double b2;
71  };
72 
73 }
74 #endif // BUTTERWORTHFILTER_H
armarx::rtfilters::ButterworthFilter::a2
double a2
Definition: ButterworthFilter.h:64
armarx::rtfilters::ButterworthFilter::outputHistory
std::vector< double > outputHistory
Array of output values, latest are in front.
Definition: ButterworthFilter.h:50
armarx::rtfilters::RTFilterBasePtr
std::shared_ptr< RTFilterBase > RTFilterBasePtr
Definition: RTFilterBase.h:34
armarx::rtfilters::ButterworthFilter::newestValue
double newestValue
Definition: ButterworthFilter.h:45
armarx::rtfilters::ButterworthFilter::b2
double b2
Definition: ButterworthFilter.h:70
armarx::rtfilters::ButterworthFilter::resonance
double resonance
Definition: ButterworthFilter.h:52
armarx::rtfilters::ButterworthFilter::frequency
double frequency
Definition: ButterworthFilter.h:54
armarx::rtfilters::ButterworthFilter::setInitialValue
void setInitialValue(double value)
Definition: ButterworthFilter.cpp:76
armarx::rtfilters::ButterworthFilter::sampleRate
int sampleRate
Definition: ButterworthFilter.h:56
armarx::rtfilters
Definition: AverageFilter.cpp:26
armarx::rtfilters::ButterworthFilter::calculate
double calculate() override
Definition: ButterworthFilter.cpp:89
armarx::rtfilters::ButterworthFilter::update
double update(const IceUtil::Time &timestamp, double newValue) override
Definition: ButterworthFilter.cpp:103
armarx::rtfilters::ButterworthFilter::a1
double a1
Definition: ButterworthFilter.h:62
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::rtfilters::ButterworthFilter::filterPassType
::armarx::PassType filterPassType
Definition: ButterworthFilter.h:58
armarx::rtfilters::ButterworthFilter::clone
RTFilterBasePtr clone() const override
Definition: ButterworthFilter.cpp:70
armarx::rtfilters::ButterworthFilter::c
double c
Definition: ButterworthFilter.h:60
armarx::rtfilters::ButterworthFilter::inputHistory
std::vector< double > inputHistory
Array of input values, latest are in front.
Definition: ButterworthFilter.h:47
armarx::rtfilters::ButterworthFilter::ButterworthFilter
ButterworthFilter(double frequency, int sampleRate, PassType filterPassType, double resonance)
Definition: ButterworthFilter.cpp:33
armarx::rtfilters::RTFilterBase
The RTFilterBase class is the base class for all real time capable filters.
Definition: RTFilterBase.h:40
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
RTFilterBase.h
armarx::rtfilters::ButterworthFilter
Definition: ButterworthFilter.h:34
armarx::rtfilters::ButterworthFilter::b1
double b1
Definition: ButterworthFilter.h:68
armarx::rtfilters::ButterworthFilter::a3
double a3
Definition: ButterworthFilter.h:66