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 <ArmarXCore/interface/observers/Filters.h>
27#include <ArmarXCore/interface/observers/ObserverInterface.h>
29
30#include "DatafieldFilter.h"
31
32namespace armarx
33{
34 template <class IceBaseClass, class DerivedClass>
35 class GenericFactory;
36}
37
38namespace armarx::filters
39{
40 class ButterworthFilter : public ButterworthFilterBase, public DatafieldFilter
41 {
42 template <class BaseClass, class VariantClass>
43 friend class ::armarx::GenericFactory;
44
45 protected:
47
48 public:
49 ButterworthFilter(double frequency, int sampleRate, PassType passType, double resonance);
50 void setInitialValue(double value);
51 /**
52 * @brief This filter supports: Int, Long, Float, Double
53 * @return List of VariantTypes
54 */
55 ParameterTypeList getSupportedTypes(const Ice::Current& = Ice::emptyCurrent) const override;
56
57
58 private:
59 /// Array of input values, latest are in front
60 std::vector<double> inputHistory = std::vector<double>(2, 0.0);
61
62 /// Array of output values, latest are in front
63 std::vector<double> outputHistory = std::vector<double>(3, 0.0);
64
65
66 // DatafieldFilterBase interface
67 public:
68 void update(Ice::Long,
69 const VariantBasePtr& value,
70 const Ice::Current& = Ice::emptyCurrent) override;
71 void update(double newInput);
72 VariantBasePtr getValue(const Ice::Current& = Ice::emptyCurrent) const override;
73 double getRawValue() const;
74 VariantBasePtr calculate(const Ice::Current& = Ice::emptyCurrent) const override;
75
76 void reset(double frequency, int sampleRate, PassType passType, double resonance);
77
78 // DatafieldFilterBase interface
79 public:
80 StringFloatDictionary getProperties(const Ice::Current&) const override;
81 void setProperties(const StringFloatDictionary& values, const Ice::Current&) override;
82 };
83
84} // namespace armarx::filters
ParameterTypeList getSupportedTypes(const Ice::Current &=Ice::emptyCurrent) const override
This filter supports: Int, Long, Float, Double.
void update(Ice::Long, const VariantBasePtr &value, const Ice::Current &=Ice::emptyCurrent) override
ButterworthFilter(double frequency, int sampleRate, PassType passType, double resonance)
VariantBasePtr getValue(const Ice::Current &=Ice::emptyCurrent) const override
void setProperties(const StringFloatDictionary &values, const Ice::Current &) override
VariantBasePtr calculate(const Ice::Current &=Ice::emptyCurrent) const override
StringFloatDictionary getProperties(const Ice::Current &) const override
void reset(double frequency, int sampleRate, PassType passType, double resonance)
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr