WPILibC++  2018.4.1-20180921151738-1194-gf89274f
 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  // PIDSource interface
26  void SetPIDSourceType(PIDSourceType pidSource) override;
27  PIDSourceType GetPIDSourceType() const override;
28  double PIDGet() override = 0;
29 
36  virtual double Get() const = 0;
37 
41  virtual void Reset() = 0;
42 
43  protected:
49  double PIDGetSource();
50 
51  private:
52  std::shared_ptr<PIDSource> m_source;
53 };
54 
55 } // 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