WPILibC++  2019.1.1-beta-1-31-g81d10bc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Filter.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <memory>
11 
12 #include "frc/PIDSource.h"
13 
14 namespace frc {
15 
19 class Filter : public PIDSource {
20  public:
21  explicit Filter(PIDSource& source);
22  explicit Filter(std::shared_ptr<PIDSource> source);
23  virtual ~Filter() = default;
24 
25  Filter(Filter&&) = default;
26  Filter& operator=(Filter&&) = default;
27 
28  // PIDSource interface
29  void SetPIDSourceType(PIDSourceType pidSource) override;
30  PIDSourceType GetPIDSourceType() const override;
31  double PIDGet() override = 0;
32 
39  virtual double Get() const = 0;
40 
44  virtual void Reset() = 0;
45 
46  protected:
52  double PIDGetSource();
53 
54  private:
55  std::shared_ptr<PIDSource> m_source;
56 };
57 
58 } // namespace frc
void SetPIDSourceType(PIDSourceType pidSource) override
Set which parameter you are using as a process control variable.
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:20
virtual double Get() const =0
Returns the current filter estimate without also inserting new data as PIDGet() would do...
double PIDGetSource()
Calls PIDGet() of source.
virtual void Reset()=0
Reset the filter state.
Interface for filters.
Definition: Filter.h:19