RTFilterBase.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 RTFILTERBASE_H
25#define RTFILTERBASE_H
26
27#include <boost/circular_buffer.hpp>
28
29#include <IceUtil/Time.h>
30
31namespace armarx::rtfilters
32{
33 class RTFilterBase;
34 using RTFilterBasePtr = std::shared_ptr<RTFilterBase>;
35
36 /**
37 * @brief The RTFilterBase class is the base class for all real time capable filters.
38 * Real Time capable means here that no heap memory allocation is done and no mutexes are locked
39 * during the update() function. Also the runtime must be the same during each call (e.g. no random searches).
40 */
42 {
43 public:
44 RTFilterBase(size_t historySize);
45 RTFilterBase(const RTFilterBase& other) = default;
46
47 virtual ~RTFilterBase()
48 {
49 }
50
51 virtual void reset();
52 virtual double update(IceUtil::Time const& timestamp, double newValue);
53 double update(double deltaSec, double newValue);
54 virtual double calculate() = 0;
55 virtual RTFilterBasePtr clone() const = 0;
56 double getCurrentValue() const;
57
58 protected:
59 boost::circular_buffer<std::pair<IceUtil::Time, double>> dataHistory;
60 double currentValue = 0.0;
61 };
62
63 using RTFilterBasePtr = std::shared_ptr<RTFilterBase>;
64
65} // namespace armarx::rtfilters
66#endif // RTFILTERBASE_H
std::string timestamp()
The RTFilterBase class is the base class for all real time capable filters.
virtual double calculate()=0
boost::circular_buffer< std::pair< IceUtil::Time, double > > dataHistory
virtual double update(IceUtil::Time const &timestamp, double newValue)
RTFilterBase(size_t historySize)
RTFilterBase(const RTFilterBase &other)=default
virtual RTFilterBasePtr clone() const =0
std::shared_ptr< RTFilterBase > RTFilterBasePtr