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 <ArmarXCore/interface/observers/Filters.h>
28
29#include "RTFilterBase.h"
30
31namespace armarx::rtfilters
32{
33
35 {
36 public:
38 int sampleRate,
39 PassType filterPassType,
40 double resonance);
41 RTFilterBasePtr clone() const override;
42 void setInitialValue(double value);
43 // RTFilterBase interface
44 public:
45 double calculate() override;
46 double update(const IceUtil::Time& timestamp, double newValue) override;
47
48 protected:
50 /// Array of input values, latest are in front
51 std::vector<double> inputHistory = std::vector<double>(2, 0.0);
52
53 /// Array of output values, latest are in front
54 std::vector<double> outputHistory = std::vector<double>(3, 0.0);
55
56 double resonance;
57
58 double frequency;
59
61
62 ::armarx::PassType filterPassType;
63
64 double c;
65
66 double a1;
67
68 double a2;
69
70 double a3;
71
72 double b1;
73
74 double b2;
75 };
76
77} // namespace armarx::rtfilters
78#endif // BUTTERWORTHFILTER_H
std::string timestamp()
std::vector< double > inputHistory
Array of input values, latest are in front.
ButterworthFilter(double frequency, int sampleRate, PassType filterPassType, double resonance)
double update(const IceUtil::Time &timestamp, double newValue) override
std::vector< double > outputHistory
Array of output values, latest are in front.
RTFilterBasePtr clone() const override
RTFilterBase(size_t historySize)
std::shared_ptr< RTFilterBase > RTFilterBasePtr